root / trunk / build / distribution / IzPack / src / lib / com / izforge / izpack / panels / HTMLInfoPanel.java @ 21757
History | View | Annotate | Download (4.21 KB)
1 |
/*
|
---|---|
2 |
* $Id: HTMLInfoPanel.java 5819 2006-06-14 07:29:09Z cesar $
|
3 |
* IzPack
|
4 |
* Copyright (C) 2001-2004 Julien Ponge
|
5 |
*
|
6 |
* File : HTMLInfoPanel.java
|
7 |
* Description : A panel to show some HTML information.
|
8 |
* Author's email : julien@izforge.com
|
9 |
* Author's Website : http://www.izforge.com
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
24 |
*/
|
25 |
package com.izforge.izpack.panels; |
26 |
|
27 |
import java.awt.GridBagConstraints; |
28 |
import java.awt.GridBagLayout; |
29 |
import java.awt.Insets; |
30 |
import java.net.URL; |
31 |
|
32 |
import javax.swing.JEditorPane; |
33 |
import javax.swing.JLabel; |
34 |
import javax.swing.JScrollPane; |
35 |
import javax.swing.event.HyperlinkEvent; |
36 |
import javax.swing.event.HyperlinkListener; |
37 |
|
38 |
import com.izforge.izpack.gui.LabelFactory; |
39 |
import com.izforge.izpack.installer.InstallData; |
40 |
import com.izforge.izpack.installer.InstallerFrame; |
41 |
import com.izforge.izpack.installer.IzPanel; |
42 |
import com.izforge.izpack.installer.ResourceManager; |
43 |
|
44 |
/**
|
45 |
* The HTML info panel.
|
46 |
*
|
47 |
* @author Julien Ponge
|
48 |
*/
|
49 |
public class HTMLInfoPanel extends IzPanel implements HyperlinkListener |
50 |
{ |
51 |
/** The layout. */
|
52 |
private GridBagLayout layout; |
53 |
|
54 |
/** The layout constraints. */
|
55 |
private GridBagConstraints gbConstraints; |
56 |
|
57 |
/** The info label. */
|
58 |
private JLabel infoLabel; |
59 |
|
60 |
/** The text area. */
|
61 |
private JEditorPane textArea; |
62 |
|
63 |
/**
|
64 |
* The constructor.
|
65 |
*
|
66 |
* @param parent The parent.
|
67 |
* @param idata The installation data.
|
68 |
*/
|
69 |
public HTMLInfoPanel(InstallerFrame parent, InstallData idata)
|
70 |
{ |
71 |
super(parent, idata);
|
72 |
|
73 |
// We initialize our layout
|
74 |
layout = new GridBagLayout(); |
75 |
gbConstraints = new GridBagConstraints(); |
76 |
setLayout(layout); |
77 |
|
78 |
// We add the components
|
79 |
|
80 |
infoLabel = |
81 |
LabelFactory.create( |
82 |
parent.langpack.getString("InfoPanel.info"),
|
83 |
parent.icons.getImageIcon("edit"),
|
84 |
JLabel.TRAILING);
|
85 |
parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.0); |
86 |
gbConstraints.insets = new Insets(5, 5, 5, 5); |
87 |
gbConstraints.fill = GridBagConstraints.NONE;
|
88 |
gbConstraints.anchor = GridBagConstraints.SOUTHWEST;
|
89 |
layout.addLayoutComponent(infoLabel, gbConstraints); |
90 |
add(infoLabel); |
91 |
|
92 |
try
|
93 |
{ |
94 |
textArea = new JEditorPane(); |
95 |
textArea.setEditable(false);
|
96 |
textArea.addHyperlinkListener(this);
|
97 |
JScrollPane scroller = new JScrollPane(textArea); |
98 |
textArea.setPage(loadInfo()); |
99 |
parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 1.0); |
100 |
gbConstraints.anchor = GridBagConstraints.CENTER;
|
101 |
gbConstraints.fill = GridBagConstraints.BOTH;
|
102 |
layout.addLayoutComponent(scroller, gbConstraints); |
103 |
add(scroller); |
104 |
} catch (Exception err) |
105 |
{ |
106 |
err.printStackTrace(); |
107 |
} |
108 |
} |
109 |
|
110 |
/**
|
111 |
* Loads the info.
|
112 |
*
|
113 |
* @return The info URL.
|
114 |
*/
|
115 |
private URL loadInfo() |
116 |
{ |
117 |
String resNamePrifix = "HTMLInfoPanel.info"; |
118 |
try
|
119 |
{ |
120 |
return ResourceManager.getInstance().getURL(resNamePrifix);
|
121 |
} catch (Exception ex) |
122 |
{ |
123 |
ex.printStackTrace(); |
124 |
} |
125 |
return null; |
126 |
} |
127 |
|
128 |
/**
|
129 |
* Indicates wether the panel has been validated or not.
|
130 |
*
|
131 |
* @return Always true.
|
132 |
*/
|
133 |
public boolean isValidated() |
134 |
{ |
135 |
return true; |
136 |
} |
137 |
|
138 |
/**
|
139 |
* Hyperlink events handler.
|
140 |
*
|
141 |
* @param e The event.
|
142 |
*/
|
143 |
public void hyperlinkUpdate(HyperlinkEvent e) |
144 |
{ |
145 |
try
|
146 |
{ |
147 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
148 |
textArea.setPage(e.getURL()); |
149 |
} catch (Exception err) |
150 |
{ |
151 |
} |
152 |
} |
153 |
} |