svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / panels / FPanelAbout.java @ 40596
History | View | Annotate | Download (6.91 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
|
25 |
package org.gvsig.app.gui.panels; |
26 |
|
27 |
import java.awt.BorderLayout; |
28 |
import java.io.FileNotFoundException; |
29 |
import java.io.IOException; |
30 |
import java.net.URL; |
31 |
|
32 |
import javax.swing.JButton; |
33 |
import javax.swing.JDialog; |
34 |
import javax.swing.JEditorPane; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JPanel; |
37 |
import javax.swing.JScrollPane; |
38 |
import javax.swing.JTabbedPane; |
39 |
import javax.swing.event.HyperlinkEvent; |
40 |
|
41 |
import org.gvsig.andami.PluginServices; |
42 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
43 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
44 |
import org.gvsig.app.extension.Version; |
45 |
import org.gvsig.utils.BrowserControl; |
46 |
import org.slf4j.Logger; |
47 |
import org.slf4j.LoggerFactory; |
48 |
|
49 |
/**
|
50 |
* @author FJP
|
51 |
*
|
52 |
* A Window with panels showing web pages. A developer
|
53 |
* can write a web page with information about his/her plugin
|
54 |
* and call addAboutUrl to add his/her about to gvSIG's about and
|
55 |
* others.
|
56 |
*
|
57 |
* @deprecated see the AboutManager
|
58 |
*/
|
59 |
public class FPanelAbout extends JPanel implements IWindow { |
60 |
private static final Logger logger = LoggerFactory |
61 |
.getLogger(FPanelAbout.class); |
62 |
|
63 |
private JEditorPane jEditorPane = null; |
64 |
private JScrollPane jScrollPane = null; |
65 |
private JEditorPane jEditorPane1 = null; |
66 |
private JPanel jPanel = null; |
67 |
private JButton jButton = null; |
68 |
|
69 |
private JLabel jLblVersion = null; |
70 |
private JLabel jLblJavaVersion = null; |
71 |
private JTabbedPane jTabbedPane = null; |
72 |
/**
|
73 |
* This is the default constructor
|
74 |
* @throws FileNotFoundException
|
75 |
*/
|
76 |
public FPanelAbout(){
|
77 |
super();
|
78 |
initialize(); |
79 |
} |
80 |
/**
|
81 |
* This method initializes this
|
82 |
*
|
83 |
* @return void
|
84 |
* @throws FileNotFoundException
|
85 |
*/
|
86 |
private void initialize(){ |
87 |
this.setLayout(new BorderLayout()); |
88 |
this.setSize(600, 450); |
89 |
this.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
|
90 |
|
91 |
this.add(getJPanel(), java.awt.BorderLayout.SOUTH);
|
92 |
} |
93 |
|
94 |
/**
|
95 |
* This method initializes jScrollPane
|
96 |
*
|
97 |
* @return javax.swing.JScrollPane
|
98 |
*/
|
99 |
private JScrollPane getJScrollPane(URL url) { |
100 |
// if (jScrollPane == null) {
|
101 |
jScrollPane = new JScrollPane(); |
102 |
jScrollPane.setPreferredSize(new java.awt.Dimension(300,400)); |
103 |
jScrollPane.setViewportView(getJEditorPane(url)); |
104 |
// }
|
105 |
return jScrollPane;
|
106 |
} |
107 |
/**
|
108 |
* This method initializes jEditorPane1
|
109 |
*
|
110 |
* @return javax.swing.JEditorPane
|
111 |
*/
|
112 |
private JEditorPane getJEditorPane(URL aboutURL) { |
113 |
// if (jEditorPane == null) {
|
114 |
jEditorPane = new JEditorPane(); |
115 |
|
116 |
jEditorPane.setEditable(false);
|
117 |
jEditorPane.setContentType("text/html");
|
118 |
jEditorPane.setPreferredSize(new java.awt.Dimension(300,200)); |
119 |
|
120 |
if (aboutURL != null) { |
121 |
try {
|
122 |
jEditorPane.setPage(aboutURL); |
123 |
jEditorPane.addHyperlinkListener(new javax.swing.event.HyperlinkListener() {
|
124 |
public void hyperlinkUpdate(javax.swing.event.HyperlinkEvent e) { |
125 |
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) |
126 |
{ |
127 |
JEditorPane pane = (JEditorPane) e.getSource(); |
128 |
System.out.println("hyperlinkUpdate()"); // TODO Auto-generated Event stub hyperlinkUpdate() |
129 |
BrowserControl.displayURL(e.getURL().toString()); |
130 |
// if (e instanceof HTMLFrameHyperlinkEvent) {
|
131 |
} |
132 |
|
133 |
|
134 |
} |
135 |
}); |
136 |
} catch (IOException e) { |
137 |
System.err.println("Attempted to read a bad URL: " + aboutURL); |
138 |
} |
139 |
} else {
|
140 |
System.err.println("Couldn't find file: about.html" + aboutURL.getPath()); |
141 |
} |
142 |
|
143 |
// }
|
144 |
return jEditorPane;
|
145 |
} |
146 |
/**
|
147 |
* This method initializes jPanel
|
148 |
*
|
149 |
* @return javax.swing.JPanel
|
150 |
*/
|
151 |
private JPanel getJPanel() { |
152 |
if (jPanel == null) { |
153 |
jLblVersion = new JLabel(); |
154 |
jLblJavaVersion = new JLabel(); |
155 |
jPanel = new JPanel(); |
156 |
jPanel.setLayout(null);
|
157 |
jPanel.setPreferredSize(new java.awt.Dimension(10,50)); |
158 |
jLblVersion.setBounds(10, 16, 205, 17); |
159 |
jLblVersion.setText("Version "+Version.longFormat());
|
160 |
jLblJavaVersion.setBounds(415, 16, 150, 17); |
161 |
jLblJavaVersion.setText("Java "+System.getProperties().get("java.version")); |
162 |
jPanel.add(getJButton(), null);
|
163 |
jPanel.add(jLblVersion, null);
|
164 |
jPanel.add(jLblJavaVersion, null);
|
165 |
} |
166 |
return jPanel;
|
167 |
} |
168 |
/**
|
169 |
* This method initializes jButton
|
170 |
*
|
171 |
* @return javax.swing.JButton
|
172 |
*/
|
173 |
private JButton getJButton() { |
174 |
if (jButton == null) { |
175 |
jButton = new JButton(); |
176 |
jButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); |
177 |
jButton.setText(PluginServices.getText(this,"Cerrar")); |
178 |
jButton.setBounds(266, 12, 94, 25); |
179 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
180 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
181 |
System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed() |
182 |
if (PluginServices.getMainFrame() != null) |
183 |
{ |
184 |
PluginServices.getMDIManager().closeWindow(FPanelAbout.this); |
185 |
} |
186 |
else
|
187 |
{ |
188 |
((JDialog) (getParent().getParent().getParent().getParent())).dispose();
|
189 |
} |
190 |
|
191 |
} |
192 |
}); |
193 |
} |
194 |
return jButton;
|
195 |
} |
196 |
/* (non-Javadoc)
|
197 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
198 |
*/
|
199 |
public WindowInfo getWindowInfo() {
|
200 |
WindowInfo m_ViewInfo = new WindowInfo(WindowInfo.MODALDIALOG|WindowInfo.RESIZABLE);
|
201 |
m_ViewInfo.setTitle(PluginServices.getText(this,"acerca_de")); |
202 |
|
203 |
return m_ViewInfo;
|
204 |
} |
205 |
/* (non-Javadoc)
|
206 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
207 |
*/
|
208 |
public void viewActivated() { |
209 |
// TODO Auto-generated method stub
|
210 |
|
211 |
} |
212 |
public void addAboutUrl(String pluginName, URL url) |
213 |
{ |
214 |
getJTabbedPane().addTab(pluginName, getJScrollPane(url)); |
215 |
// this.add(getJScrollPane(url), java.awt.BorderLayout.CENTER);
|
216 |
} |
217 |
/**
|
218 |
* This method initializes jTabbedPane
|
219 |
*
|
220 |
* @return javax.swing.JTabbedPane
|
221 |
*/
|
222 |
private JTabbedPane getJTabbedPane() { |
223 |
if (jTabbedPane == null) { |
224 |
jTabbedPane = new JTabbedPane(); |
225 |
jTabbedPane.setPreferredSize(new java.awt.Dimension(5,50)); |
226 |
} |
227 |
return jTabbedPane;
|
228 |
} |
229 |
public Object getWindowProfile() { |
230 |
return WindowInfo.DIALOG_PROFILE;
|
231 |
} |
232 |
} // @jve:decl-index=0:visual-constraint="10,10"
|