root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / info / gui / HTMLInfoToolPanel.java @ 30350
History | View | Annotate | Download (1.9 KB)
1 |
package org.gvsig.app.project.documents.view.info.gui; |
---|---|
2 |
|
3 |
import java.awt.Dimension; |
4 |
import java.awt.HeadlessException; |
5 |
|
6 |
import javax.swing.JEditorPane; |
7 |
import javax.swing.JPanel; |
8 |
import javax.swing.JScrollPane; |
9 |
import javax.swing.event.HyperlinkEvent; |
10 |
import javax.swing.text.html.HTMLEditorKit; |
11 |
|
12 |
import org.gvsig.utils.BrowserControl; |
13 |
|
14 |
|
15 |
/**
|
16 |
* JPanel to show the feature information return in HTML code
|
17 |
* @author laura
|
18 |
*
|
19 |
*/
|
20 |
public class HTMLInfoToolPanel extends JPanel implements IInfoToolPanel{ |
21 |
|
22 |
private boolean initialized = false; |
23 |
private JEditorPane editor = null; |
24 |
private JScrollPane scrollPane = null; |
25 |
|
26 |
public HTMLInfoToolPanel() throws HeadlessException { |
27 |
super();
|
28 |
} |
29 |
|
30 |
private void init() { |
31 |
if (this.initialized ) return; |
32 |
|
33 |
this.setAutoscrolls(true); |
34 |
this.setLocation(0,0); |
35 |
|
36 |
scrollPane = new JScrollPane(); |
37 |
scrollPane.setAutoscrolls(true);
|
38 |
|
39 |
editor = new JEditorPane(); |
40 |
editor.setContentType("text/html");
|
41 |
editor.setAutoscrolls(true);
|
42 |
editor.setEditable(false);
|
43 |
editor.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
44 |
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
45 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
46 |
{ |
47 |
BrowserControl.displayURL(e.getURL().toString()); |
48 |
} |
49 |
} |
50 |
}); |
51 |
|
52 |
//azabala this.add(editor);
|
53 |
|
54 |
|
55 |
this.setSize(new Dimension(640, 400)); |
56 |
editor.setSize(new Dimension(640, 400)); |
57 |
|
58 |
|
59 |
editor.setEditorKit(new HTMLEditorKit()); |
60 |
scrollPane.setViewportView(editor); |
61 |
//azabalA
|
62 |
this.add(scrollPane);
|
63 |
|
64 |
//azabala scrollPane.setLocation(0,0);
|
65 |
} |
66 |
|
67 |
public void show(String text) |
68 |
{ |
69 |
this.init();
|
70 |
this.setVisible(true); |
71 |
editor.setText(text.replaceFirst("Content-Type","Content-Typex")); |
72 |
} |
73 |
|
74 |
public void refreshSize() { |
75 |
// TODO Auto-generated method stub
|
76 |
|
77 |
} |
78 |
|
79 |
public void show(XMLItem item) { |
80 |
// TODO Auto-generated method stub
|
81 |
|
82 |
} |
83 |
} |