Statistics
| Revision:

root / branches / piloto3d / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / view / info / gui / HTMLInfoToolPanel.java @ 9529

History | View | Annotate | Download (1.84 KB)

1 7304 caballero
package com.iver.cit.gvsig.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 7415 azabala
import javax.swing.text.html.HTMLEditorKit;
11 7304 caballero
12
import com.iver.cit.gvsig.gui.panels.BrowserControl;
13
14
/**
15
 * JPanel to show the feature information return in HTML code
16
 * @author laura
17
 *
18
 */
19
public class HTMLInfoToolPanel extends JPanel implements IInfoToolPanel{
20
21
        private boolean initialized = false;
22
        private JEditorPane editor = null;
23
        private JScrollPane scrollPane = null;
24
25
        public HTMLInfoToolPanel() throws HeadlessException {
26
                super();
27
        }
28
29
        private void init() {
30
                if (this.initialized ) return;
31
32
                this.setAutoscrolls(true);
33
                this.setLocation(0,0);
34
35
                scrollPane = new JScrollPane();
36
                scrollPane.setAutoscrolls(true);
37
38
                editor = new JEditorPane();
39
                editor.setContentType("text/html");
40
                editor.setAutoscrolls(true);
41
                editor.setEditable(false);
42
                editor.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
43
                  public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
44
                   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
45
                   {
46
                           BrowserControl.displayURL(e.getURL().toString());
47
                   }
48
                  }
49
                });
50
51 7415 azabala
//azabala                this.add(editor);
52
53
54 7304 caballero
                this.setSize(new Dimension(640, 400));
55
                editor.setSize(new Dimension(640, 400));
56 7415 azabala
57
58
                editor.setEditorKit(new HTMLEditorKit());
59
        scrollPane.setViewportView(editor);
60
//azabalA
61
                this.add(scrollPane);
62
63
//azabala                scrollPane.setLocation(0,0);
64 7304 caballero
        }
65
66
        public void show(String text)
67
        {
68
                this.init();
69
                this.setVisible(true);
70
                editor.setText(text.replaceFirst("Content-Type","Content-Typex"));
71
        }
72
73
        public void refreshSize() {
74
                // TODO Auto-generated method stub
75
76
        }
77
}