svn-gvsig-desktop / tags / Root_v06 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / Panels / FPanelAbout.java @ 4811
History | View | Annotate | Download (7.81 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-sep-2004
|
3 |
*
|
4 |
* TODO To change the template for this generated file go to
|
5 |
* Window - Preferences - Java - Code Generation - Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
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 (at your option) 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 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig.gui.Panels; |
48 |
|
49 |
import java.awt.BorderLayout; |
50 |
import java.io.BufferedReader; |
51 |
import java.io.FileNotFoundException; |
52 |
import java.io.FileReader; |
53 |
import java.io.IOException; |
54 |
import java.net.URL; |
55 |
import java.util.StringTokenizer; |
56 |
|
57 |
import javax.swing.JButton; |
58 |
import javax.swing.JDialog; |
59 |
import javax.swing.JEditorPane; |
60 |
import javax.swing.JLabel; |
61 |
import javax.swing.JPanel; |
62 |
import javax.swing.JScrollPane; |
63 |
import javax.swing.event.HyperlinkEvent; |
64 |
|
65 |
import org.apache.log4j.Logger; |
66 |
|
67 |
import com.hardcode.gdbms.engine.instruction.Utilities; |
68 |
import com.iver.andami.PluginServices; |
69 |
import com.iver.andami.ui.mdiManager.View; |
70 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
71 |
import javax.swing.JTabbedPane; |
72 |
/**
|
73 |
* @author FJP
|
74 |
*
|
75 |
* A Window with panels showing web pages. A developer
|
76 |
* can write a web page with information about his/her plugin
|
77 |
* and call addAboutUrl to add his/her about to gvSIG's about and
|
78 |
* others.
|
79 |
*/
|
80 |
public class FPanelAbout extends JPanel implements View { |
81 |
public final static int MAJOR_VERSION_NUMBER = 0; |
82 |
public final static int MINOR_VERSION_NUMBER = 6; |
83 |
public final static int RELEASE_NUMBER = 0; |
84 |
|
85 |
private static Logger logger = Logger.getLogger(FPanelAbout.class.getName()); |
86 |
private JEditorPane jEditorPane = null; |
87 |
private JScrollPane jScrollPane = null; |
88 |
private JEditorPane jEditorPane1 = null; |
89 |
private JPanel jPanel = null; |
90 |
private JButton jButton = null; |
91 |
|
92 |
private JLabel jLblVersion = null; |
93 |
private JTabbedPane jTabbedPane = null; |
94 |
/**
|
95 |
* This is the default constructor
|
96 |
* @throws FileNotFoundException
|
97 |
*/
|
98 |
public FPanelAbout(){
|
99 |
super();
|
100 |
initialize(); |
101 |
} |
102 |
/**
|
103 |
* This method initializes this
|
104 |
*
|
105 |
* @return void
|
106 |
* @throws FileNotFoundException
|
107 |
*/
|
108 |
private void initialize(){ |
109 |
this.setLayout(new BorderLayout()); |
110 |
this.setSize(600, 450); |
111 |
this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
|
112 |
|
113 |
this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
114 |
try {
|
115 |
// Leemos el n? de versi?n y se lo pegamos a jLblVersion
|
116 |
BufferedReader fich = new BufferedReader( |
117 |
new FileReader(FPanelAbout.class.getResource("/build.number").getFile())); |
118 |
fich.readLine(); |
119 |
fich.readLine(); |
120 |
String strVer = fich.readLine();
|
121 |
StringTokenizer strTokenizer = new StringTokenizer(strVer); |
122 |
String strToken = strTokenizer.nextToken("="); |
123 |
strToken = strTokenizer.nextToken(); |
124 |
jLblVersion.setText(jLblVersion.getText() + " (" + strToken + ")"); |
125 |
fich.close(); |
126 |
} catch (Exception e) { |
127 |
e.printStackTrace(); |
128 |
} |
129 |
} |
130 |
|
131 |
/**
|
132 |
* This method initializes jScrollPane
|
133 |
*
|
134 |
* @return javax.swing.JScrollPane
|
135 |
*/
|
136 |
private JScrollPane getJScrollPane(URL url) { |
137 |
// if (jScrollPane == null) {
|
138 |
jScrollPane = new JScrollPane(); |
139 |
jScrollPane.setPreferredSize(new java.awt.Dimension(300,400)); |
140 |
jScrollPane.setViewportView(getJEditorPane(url)); |
141 |
// }
|
142 |
return jScrollPane;
|
143 |
} |
144 |
/**
|
145 |
* This method initializes jEditorPane1
|
146 |
*
|
147 |
* @return javax.swing.JEditorPane
|
148 |
*/
|
149 |
private JEditorPane getJEditorPane(URL aboutURL) { |
150 |
// if (jEditorPane == null) {
|
151 |
jEditorPane = new JEditorPane(); |
152 |
|
153 |
jEditorPane.setEditable(false);
|
154 |
jEditorPane.setContentType("text/html");
|
155 |
jEditorPane.setPreferredSize(new java.awt.Dimension(300,200)); |
156 |
|
157 |
if (aboutURL != null) { |
158 |
try {
|
159 |
jEditorPane.setPage(aboutURL); |
160 |
jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
161 |
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
162 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
163 |
{ |
164 |
JEditorPane pane = (JEditorPane) e.getSource(); |
165 |
System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate() |
166 |
BrowserControl.displayURL(e.getURL().toString()); |
167 |
// if (e instanceof HTMLFrameHyperlinkEvent) {
|
168 |
} |
169 |
|
170 |
|
171 |
} |
172 |
}); |
173 |
} catch (IOException e) { |
174 |
System.err.println("Attempted to read a bad URL: " + aboutURL); |
175 |
} |
176 |
} else {
|
177 |
System.err.println("Couldn't find file: about.html" + aboutURL.getPath()); |
178 |
} |
179 |
|
180 |
// }
|
181 |
return jEditorPane;
|
182 |
} |
183 |
/**
|
184 |
* This method initializes jPanel
|
185 |
*
|
186 |
* @return javax.swing.JPanel
|
187 |
*/
|
188 |
private JPanel getJPanel() { |
189 |
if (jPanel == null) { |
190 |
jLblVersion = new JLabel(); |
191 |
jPanel = new JPanel(); |
192 |
jPanel.setLayout(null);
|
193 |
jPanel.setPreferredSize(new java.awt.Dimension(10,50)); |
194 |
jLblVersion.setBounds(31, 20, 172, 17); |
195 |
jLblVersion.setText("Version "+MAJOR_VERSION_NUMBER+"."+MINOR_VERSION_NUMBER+"."+RELEASE_NUMBER+" "); |
196 |
jPanel.add(getJButton(), null);
|
197 |
jPanel.add(jLblVersion, null);
|
198 |
} |
199 |
return jPanel;
|
200 |
} |
201 |
/**
|
202 |
* This method initializes jButton
|
203 |
*
|
204 |
* @return javax.swing.JButton
|
205 |
*/
|
206 |
private JButton getJButton() { |
207 |
if (jButton == null) { |
208 |
jButton = new JButton(); |
209 |
jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
210 |
jButton.setText(PluginServices.getText(this,"Cerrar")); |
211 |
jButton.setBounds(266, 12, 94, 25); |
212 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
213 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
214 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
215 |
if (PluginServices.getMainFrame() != null) |
216 |
{ |
217 |
PluginServices.getMDIManager().closeView(FPanelAbout.this); |
218 |
} |
219 |
else
|
220 |
{ |
221 |
((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
222 |
} |
223 |
|
224 |
} |
225 |
}); |
226 |
} |
227 |
return jButton;
|
228 |
} |
229 |
/* (non-Javadoc)
|
230 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
231 |
*/
|
232 |
public ViewInfo getViewInfo() {
|
233 |
ViewInfo m_ViewInfo = new ViewInfo(ViewInfo.MODALDIALOG|ViewInfo.RESIZABLE);
|
234 |
m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de")); |
235 |
|
236 |
return m_ViewInfo;
|
237 |
} |
238 |
/* (non-Javadoc)
|
239 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
240 |
*/
|
241 |
public void viewActivated() { |
242 |
// TODO Auto-generated method stub
|
243 |
|
244 |
} |
245 |
public void addAboutUrl(String pluginName, URL url) |
246 |
{ |
247 |
getJTabbedPane().addTab(pluginName, getJScrollPane(url)); |
248 |
// this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
|
249 |
} |
250 |
/**
|
251 |
* This method initializes jTabbedPane
|
252 |
*
|
253 |
* @return javax.swing.JTabbedPane
|
254 |
*/
|
255 |
private JTabbedPane getJTabbedPane() { |
256 |
if (jTabbedPane == null) { |
257 |
jTabbedPane = new JTabbedPane(); |
258 |
jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50)); |
259 |
} |
260 |
return jTabbedPane;
|
261 |
} |
262 |
} // @jve:decl-index=0:visual-constraint="10,10"
|