Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Dialogs / HTMLInfoToolPanel.java @ 6117

History | View | Annotate | Download (1.55 KB)

1
package com.iver.cit.gvsig.gui.Dialogs;
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

    
11
import com.iver.cit.gvsig.gui.panels.BrowserControl;
12

    
13
/**
14
 * JPanel to show the feature information return in HTML code
15
 * @author laura
16
 *
17
 */
18
public class HTMLInfoToolPanel extends JPanel implements IInfoToolPanel{
19
                
20
        private boolean initialized = false;
21
        private JEditorPane editor = null;
22
        private JScrollPane scrollPane = null;
23

    
24
        public HTMLInfoToolPanel() throws HeadlessException {
25
                super();
26
        }
27
        
28
        private void init() {
29
                if (this.initialized ) return;
30
                                
31
                this.setAutoscrolls(true);
32
                this.setLocation(0,0);
33

    
34
                scrollPane = new JScrollPane();                
35
                scrollPane.setAutoscrolls(true);
36
                                
37
                editor = new JEditorPane();
38
                editor.setContentType("text/html");
39
                editor.setAutoscrolls(true);
40
                editor.setEditable(false);
41
                editor.addHyperlinkListener(new javax.swing.event.HyperlinkListener() { 
42
                  public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) {
43
                   if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
44
                   {
45
                           BrowserControl.displayURL(e.getURL().toString());
46
                   }
47
                  }
48
                });
49
                
50
                this.add(editor);
51
                this.setSize(new Dimension(640, 400));
52
                editor.setSize(new Dimension(640, 400));
53
                scrollPane.setLocation(0,0);
54
        }
55
        
56
        public void show(String text) 
57
        {
58
                this.init();
59
                this.setVisible(true);        
60
                editor.setText(text.replaceFirst("Content-Type","Content-Typex"));                
61
        }
62
}