svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / view / info / gui / HTMLInfoToolPanel.java @ 40558
History | View | Annotate | Download (2.84 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.project.documents.view.info.gui; |
25 |
|
26 |
import java.awt.Dimension; |
27 |
import java.awt.HeadlessException; |
28 |
|
29 |
import javax.swing.JEditorPane; |
30 |
import javax.swing.JPanel; |
31 |
import javax.swing.JScrollPane; |
32 |
import javax.swing.event.HyperlinkEvent; |
33 |
import javax.swing.text.html.HTMLEditorKit; |
34 |
|
35 |
import org.gvsig.utils.BrowserControl; |
36 |
|
37 |
|
38 |
/**
|
39 |
* JPanel to show the feature information return in HTML code
|
40 |
* @author laura
|
41 |
*
|
42 |
*/
|
43 |
public class HTMLInfoToolPanel extends JPanel implements IInfoToolPanel{ |
44 |
|
45 |
private boolean initialized = false; |
46 |
private JEditorPane editor = null; |
47 |
private JScrollPane scrollPane = null; |
48 |
|
49 |
public HTMLInfoToolPanel() throws HeadlessException { |
50 |
super();
|
51 |
} |
52 |
|
53 |
private void init() { |
54 |
if (this.initialized ) return; |
55 |
|
56 |
this.setAutoscrolls(true); |
57 |
this.setLocation(0,0); |
58 |
|
59 |
scrollPane = new JScrollPane(); |
60 |
scrollPane.setAutoscrolls(true);
|
61 |
|
62 |
editor = new JEditorPane(); |
63 |
editor.setContentType("text/html");
|
64 |
editor.setAutoscrolls(true);
|
65 |
editor.setEditable(false);
|
66 |
editor.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
67 |
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
68 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
69 |
{ |
70 |
BrowserControl.displayURL(e.getURL().toString()); |
71 |
} |
72 |
} |
73 |
}); |
74 |
|
75 |
//azabala this.add(editor);
|
76 |
|
77 |
|
78 |
this.setSize(new Dimension(640, 400)); |
79 |
editor.setSize(new Dimension(640, 400)); |
80 |
|
81 |
|
82 |
editor.setEditorKit(new HTMLEditorKit()); |
83 |
scrollPane.setViewportView(editor); |
84 |
//azabalA
|
85 |
this.add(scrollPane);
|
86 |
|
87 |
//azabala scrollPane.setLocation(0,0);
|
88 |
} |
89 |
|
90 |
public void show(String text) |
91 |
{ |
92 |
this.init();
|
93 |
this.setVisible(true); |
94 |
editor.setText(text.replaceFirst("Content-Type","Content-Typex")); |
95 |
} |
96 |
|
97 |
public void refreshSize() { |
98 |
// TODO Auto-generated method stub
|
99 |
|
100 |
} |
101 |
|
102 |
public void show(XMLItem item) { |
103 |
// TODO Auto-generated method stub
|
104 |
|
105 |
} |
106 |
} |