root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / panels / FPanelAbout.java @ 6117
History | View | Annotate | Download (7.79 KB)
1 | 6117 | jaume | /*
|
---|---|---|---|
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 = 1; |
||
82 | public final static int MINOR_VERSION_NUMBER = 0; |
||
83 | public final static int RELEASE_NUMBER = 0; |
||
84 | private static Logger logger = Logger.getLogger(FPanelAbout.class.getName()); |
||
85 | private JEditorPane jEditorPane = null; |
||
86 | private JScrollPane jScrollPane = null; |
||
87 | private JEditorPane jEditorPane1 = null; |
||
88 | private JPanel jPanel = null; |
||
89 | private JButton jButton = null; |
||
90 | |||
91 | private JLabel jLblVersion = null; |
||
92 | private JTabbedPane jTabbedPane = null; |
||
93 | /**
|
||
94 | * This is the default constructor
|
||
95 | * @throws FileNotFoundException
|
||
96 | */
|
||
97 | public FPanelAbout(){
|
||
98 | super();
|
||
99 | initialize(); |
||
100 | } |
||
101 | /**
|
||
102 | * This method initializes this
|
||
103 | *
|
||
104 | * @return void
|
||
105 | * @throws FileNotFoundException
|
||
106 | */
|
||
107 | private void initialize(){ |
||
108 | this.setLayout(new BorderLayout()); |
||
109 | this.setSize(600, 450); |
||
110 | this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
|
||
111 | |||
112 | this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
||
113 | try {
|
||
114 | // Leemos el n? de versi?n y se lo pegamos a jLblVersion
|
||
115 | BufferedReader fich = new BufferedReader( |
||
116 | new FileReader(FPanelAbout.class.getResource("/build.number").getFile())); |
||
117 | fich.readLine(); |
||
118 | fich.readLine(); |
||
119 | String strVer = fich.readLine();
|
||
120 | StringTokenizer strTokenizer = new StringTokenizer(strVer); |
||
121 | String strToken = strTokenizer.nextToken("="); |
||
122 | strToken = strTokenizer.nextToken(); |
||
123 | jLblVersion.setText(jLblVersion.getText() + " (" + strToken + ")"); |
||
124 | fich.close(); |
||
125 | } catch (Exception e) { |
||
126 | e.printStackTrace(); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | /**
|
||
131 | * This method initializes jScrollPane
|
||
132 | *
|
||
133 | * @return javax.swing.JScrollPane
|
||
134 | */
|
||
135 | private JScrollPane getJScrollPane(URL url) { |
||
136 | // if (jScrollPane == null) {
|
||
137 | jScrollPane = new JScrollPane(); |
||
138 | jScrollPane.setPreferredSize(new java.awt.Dimension(300,400)); |
||
139 | jScrollPane.setViewportView(getJEditorPane(url)); |
||
140 | // }
|
||
141 | return jScrollPane;
|
||
142 | } |
||
143 | /**
|
||
144 | * This method initializes jEditorPane1
|
||
145 | *
|
||
146 | * @return javax.swing.JEditorPane
|
||
147 | */
|
||
148 | private JEditorPane getJEditorPane(URL aboutURL) { |
||
149 | // if (jEditorPane == null) {
|
||
150 | jEditorPane = new JEditorPane(); |
||
151 | |||
152 | jEditorPane.setEditable(false);
|
||
153 | jEditorPane.setContentType("text/html");
|
||
154 | jEditorPane.setPreferredSize(new java.awt.Dimension(300,200)); |
||
155 | |||
156 | if (aboutURL != null) { |
||
157 | try {
|
||
158 | jEditorPane.setPage(aboutURL); |
||
159 | jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
||
160 | public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
||
161 | if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
||
162 | { |
||
163 | JEditorPane pane = (JEditorPane) e.getSource(); |
||
164 | System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate() |
||
165 | BrowserControl.displayURL(e.getURL().toString()); |
||
166 | // if (e instanceof HTMLFrameHyperlinkEvent) {
|
||
167 | } |
||
168 | |||
169 | |||
170 | } |
||
171 | }); |
||
172 | } catch (IOException e) { |
||
173 | System.err.println("Attempted to read a bad URL: " + aboutURL); |
||
174 | } |
||
175 | } else {
|
||
176 | System.err.println("Couldn't find file: about.html" + aboutURL.getPath()); |
||
177 | } |
||
178 | |||
179 | // }
|
||
180 | return jEditorPane;
|
||
181 | } |
||
182 | /**
|
||
183 | * This method initializes jPanel
|
||
184 | *
|
||
185 | * @return javax.swing.JPanel
|
||
186 | */
|
||
187 | private JPanel getJPanel() { |
||
188 | if (jPanel == null) { |
||
189 | jLblVersion = new JLabel(); |
||
190 | jPanel = new JPanel(); |
||
191 | jPanel.setLayout(null);
|
||
192 | jPanel.setPreferredSize(new java.awt.Dimension(10,50)); |
||
193 | jLblVersion.setBounds(31, 20, 172, 17); |
||
194 | jLblVersion.setText("Version "+MAJOR_VERSION_NUMBER+"."+MINOR_VERSION_NUMBER+" "); |
||
195 | jPanel.add(getJButton(), null);
|
||
196 | jPanel.add(jLblVersion, null);
|
||
197 | } |
||
198 | return jPanel;
|
||
199 | } |
||
200 | /**
|
||
201 | * This method initializes jButton
|
||
202 | *
|
||
203 | * @return javax.swing.JButton
|
||
204 | */
|
||
205 | private JButton getJButton() { |
||
206 | if (jButton == null) { |
||
207 | jButton = new JButton(); |
||
208 | jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
||
209 | jButton.setText(PluginServices.getText(this,"Cerrar")); |
||
210 | jButton.setBounds(266, 12, 94, 25); |
||
211 | jButton.addActionListener(new java.awt.event.ActionListener() {
|
||
212 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
213 | System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
||
214 | if (PluginServices.getMainFrame() != null) |
||
215 | { |
||
216 | PluginServices.getMDIManager().closeView(FPanelAbout.this); |
||
217 | } |
||
218 | else
|
||
219 | { |
||
220 | ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
||
221 | } |
||
222 | |||
223 | } |
||
224 | }); |
||
225 | } |
||
226 | return jButton;
|
||
227 | } |
||
228 | /* (non-Javadoc)
|
||
229 | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
||
230 | */
|
||
231 | public ViewInfo getViewInfo() {
|
||
232 | ViewInfo m_ViewInfo = new ViewInfo(ViewInfo.MODALDIALOG|ViewInfo.RESIZABLE);
|
||
233 | m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de")); |
||
234 | |||
235 | return m_ViewInfo;
|
||
236 | } |
||
237 | /* (non-Javadoc)
|
||
238 | * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
||
239 | */
|
||
240 | public void viewActivated() { |
||
241 | // TODO Auto-generated method stub
|
||
242 | |||
243 | } |
||
244 | public void addAboutUrl(String pluginName, URL url) |
||
245 | { |
||
246 | getJTabbedPane().addTab(pluginName, getJScrollPane(url)); |
||
247 | // this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
|
||
248 | } |
||
249 | /**
|
||
250 | * This method initializes jTabbedPane
|
||
251 | *
|
||
252 | * @return javax.swing.JTabbedPane
|
||
253 | */
|
||
254 | private JTabbedPane getJTabbedPane() { |
||
255 | if (jTabbedPane == null) { |
||
256 | jTabbedPane = new JTabbedPane(); |
||
257 | jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50)); |
||
258 | } |
||
259 | return jTabbedPane;
|
||
260 | } |
||
261 | } // @jve:decl-index=0:visual-constraint="10,10" |