Revision 33551
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/Consola.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.coreplugin; |
|
42 |
|
|
43 |
import org.gvsig.andami.PluginServices; |
|
44 |
import org.gvsig.andami.messages.NotificationManager; |
|
45 |
import org.gvsig.andami.plugins.Extension; |
|
46 |
|
|
47 |
|
|
48 |
/** |
|
49 |
* Extensi?n que registra un frame en la aplicaci?n que recibe los eventos de |
|
50 |
* la consola de la aplicaci?n y los muestra en el frame |
|
51 |
*/ |
|
52 |
public class Consola extends Extension { |
|
53 |
static PluginServices ps; |
|
54 |
public static ConsolaFrame consolaFrame; |
|
55 |
public static NotificationDialogNew notificationDialogNew; |
|
56 |
public static NotificationDialog notificationDialog; |
|
57 |
|
|
58 |
/** |
|
59 |
* @see com.iver.mdiApp.IExtension#initialize() |
|
60 |
*/ |
|
61 |
public void initialize() { |
|
62 |
ps = PluginServices.getPluginServices(this); |
|
63 |
consolaFrame = new ConsolaFrame(); |
|
64 |
NotificationManager.addNotificationListener(consolaFrame); |
|
65 |
|
|
66 |
notificationDialogNew = new NotificationDialogNew(); |
|
67 |
NotificationManager.addNotificationListener(notificationDialogNew ); |
|
68 |
|
|
69 |
// notificationDialog= new NotificationDialog(); |
|
70 |
// NotificationManager.addNotificationListener(notificationDialog); |
|
71 |
|
|
72 |
PluginServices.getIconTheme().registerDefault( |
|
73 |
"application-console", |
|
74 |
this.getClass().getClassLoader().getResource("images/console.png") |
|
75 |
); |
|
76 |
} |
|
77 |
|
|
78 |
/* (non-Javadoc) |
|
79 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
80 |
*/ |
|
81 |
public void execute(String actionCommand) { |
|
82 |
consolaFrame.setSize(400, 325); |
|
83 |
consolaFrame.setVisible(true); |
|
84 |
PluginServices.getMDIManager().addWindow(consolaFrame); |
|
85 |
} |
|
86 |
|
|
87 |
/* (non-Javadoc) |
|
88 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
89 |
*/ |
|
90 |
public boolean isEnabled() { |
|
91 |
return true; |
|
92 |
} |
|
93 |
|
|
94 |
/* (non-Javadoc) |
|
95 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
96 |
*/ |
|
97 |
public boolean isVisible() { |
|
98 |
return true; |
|
99 |
} |
|
100 |
} |
|
0 | 101 |
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/PreferencesExtension.java | ||
---|---|---|
1 |
package org.gvsig.coreplugin; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.HashMap; |
|
5 |
import java.util.Iterator; |
|
6 |
|
|
7 |
import org.gvsig.andami.Launcher; |
|
8 |
import org.gvsig.andami.PluginServices; |
|
9 |
import org.gvsig.andami.plugins.Extension; |
|
10 |
import org.gvsig.andami.plugins.config.generate.Extensions; |
|
11 |
import org.gvsig.andami.plugins.config.generate.PluginConfig; |
|
12 |
import org.gvsig.andami.preferences.DlgPreferences; |
|
13 |
import org.gvsig.andami.preferences.IPreference; |
|
14 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
|
15 |
import org.gvsig.coreplugin.preferences.general.AppearancePage; |
|
16 |
import org.gvsig.coreplugin.preferences.general.BrowserControlPage; |
|
17 |
import org.gvsig.coreplugin.preferences.general.DirExtensionsPage; |
|
18 |
import org.gvsig.coreplugin.preferences.general.ExtensionPage; |
|
19 |
import org.gvsig.coreplugin.preferences.general.ExtensionsPage; |
|
20 |
import org.gvsig.coreplugin.preferences.general.FolderingPage; |
|
21 |
import org.gvsig.coreplugin.preferences.general.GeneralPage; |
|
22 |
import org.gvsig.coreplugin.preferences.general.LanguagePage; |
|
23 |
import org.gvsig.coreplugin.preferences.general.ScreenSettingsPage; |
|
24 |
import org.gvsig.coreplugin.preferences.general.SkinPreferences; |
|
25 |
import org.gvsig.coreplugin.preferences.network.FirewallPage; |
|
26 |
import org.gvsig.coreplugin.preferences.network.NetworkPage; |
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
29 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
30 |
|
|
31 |
|
|
32 |
/** |
|
33 |
* |
|
34 |
* <p> |
|
35 |
* Extension that provides support for visual application configuration |
|
36 |
* through a Preferences dialog where the user can specify its own settings for |
|
37 |
* general purpose aspects. |
|
38 |
* </p> |
|
39 |
* <p> |
|
40 |
* Adding new preference pages is made through ExtensionPoints by invoking |
|
41 |
* <b> |
|
42 |
* this.extensionPoints.add("AplicationPreferences","YourIPreferencesClassName", yourIPreferencesPage); |
|
43 |
* </b> |
|
44 |
* and then call <b>DlgPreferences.refreshExtensionPoints();</b> |
|
45 |
* </p> |
|
46 |
* |
|
47 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
48 |
* |
|
49 |
*/ |
|
50 |
public class PreferencesExtension extends Extension{ |
|
51 |
private ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager(); |
|
52 |
|
|
53 |
private boolean initilizedExtensions=false; |
|
54 |
|
|
55 |
public void initialize() { |
|
56 |
|
|
57 |
registerIcons(); |
|
58 |
initializeCoreExtensions(); |
|
59 |
} |
|
60 |
|
|
61 |
private void registerIcons(){ |
|
62 |
PluginServices.getIconTheme().registerDefault( |
|
63 |
"application-preferences", |
|
64 |
this.getClass().getClassLoader().getResource("images/config.png") |
|
65 |
); |
|
66 |
|
|
67 |
// AppearancePage.java |
|
68 |
PluginServices.getIconTheme().registerDefault( |
|
69 |
"aplication-preferences-appearance", |
|
70 |
this.getClass().getClassLoader().getResource("images/gnome-settings-theme.png") |
|
71 |
); |
|
72 |
|
|
73 |
// BrowserControlPage.java |
|
74 |
PluginServices.getIconTheme().registerDefault( |
|
75 |
"aplication-preferences-browsercontrol", |
|
76 |
this.getClass().getClassLoader().getResource("images/browser.png") |
|
77 |
); |
|
78 |
|
|
79 |
|
|
80 |
// DirExtensionPage.java |
|
81 |
PluginServices.getIconTheme().registerDefault( |
|
82 |
"aplication-preferences-dirextension", |
|
83 |
this.getClass().getClassLoader().getResource("images/file-manager.png") |
|
84 |
); |
|
85 |
|
|
86 |
// ExtensionPage.java |
|
87 |
PluginServices.getIconTheme().registerDefault( |
|
88 |
"aplication-preferences-extension", |
|
89 |
this.getClass().getClassLoader().getResource("images/emblem-work.png") |
|
90 |
); |
|
91 |
|
|
92 |
// ExtensionsPage.java |
|
93 |
PluginServices.getIconTheme().registerDefault( |
|
94 |
"aplication-preferences-extensions", |
|
95 |
this.getClass().getClassLoader().getResource("images/bonobo-component-browser.png") |
|
96 |
); |
|
97 |
|
|
98 |
// FolderingPage.java |
|
99 |
PluginServices.getIconTheme().registerDefault( |
|
100 |
"aplication-preferences-foldering", |
|
101 |
this.getClass().getClassLoader().getResource("images/folder.png") |
|
102 |
); |
|
103 |
|
|
104 |
// LanguagePage.java |
|
105 |
PluginServices.getIconTheme().registerDefault( |
|
106 |
"aplication-preferences-language", |
|
107 |
this.getClass().getClassLoader().getResource("images/babel.png") |
|
108 |
); |
|
109 |
|
|
110 |
// ScreenSettingsPage.java |
|
111 |
PluginServices.getIconTheme().registerDefault( |
|
112 |
"aplication-preferences-screensetting", |
|
113 |
this.getClass().getClassLoader().getResource("images/resolution.png") |
|
114 |
); |
|
115 |
// FirewallPage.java |
|
116 |
PluginServices.getIconTheme().registerDefault( |
|
117 |
"aplication-preferences-firewall", |
|
118 |
this.getClass().getClassLoader().getResource("images/shield.png") |
|
119 |
); |
|
120 |
|
|
121 |
// NetworkPage.java |
|
122 |
// |
|
123 |
PluginServices.getIconTheme().registerDefault( |
|
124 |
"aplication-preferences-network", |
|
125 |
this.getClass().getClassLoader().getResource("images/network.png") |
|
126 |
); |
|
127 |
PluginServices.getIconTheme().registerDefault( |
|
128 |
"application-console", |
|
129 |
this.getClass().getClassLoader().getResource("images/console.png") |
|
130 |
); |
|
131 |
PluginServices.getIconTheme().registerDefault( |
|
132 |
"gnome-settings-theme", |
|
133 |
this.getClass().getClassLoader().getResource("images/gnome-settings-theme.png") |
|
134 |
); |
|
135 |
PluginServices.getIconTheme().registerDefault( |
|
136 |
"browser-icon", |
|
137 |
this.getClass().getClassLoader().getResource("images/browser.png") |
|
138 |
); |
|
139 |
PluginServices.getIconTheme().registerDefault( |
|
140 |
"file-manager", |
|
141 |
this.getClass().getClassLoader().getResource("images/file-manager.png") |
|
142 |
); |
|
143 |
PluginServices.getIconTheme().registerDefault( |
|
144 |
"emblem-work", |
|
145 |
this.getClass().getClassLoader().getResource("images/emblem-work.png") |
|
146 |
); |
|
147 |
PluginServices.getIconTheme().registerDefault( |
|
148 |
"folder-icon", |
|
149 |
this.getClass().getClassLoader().getResource("images/folder.png") |
|
150 |
); |
|
151 |
PluginServices.getIconTheme().registerDefault( |
|
152 |
"kde-network-online-icon", |
|
153 |
this.getClass().getClassLoader().getResource("images/kde-network-online.png") |
|
154 |
); |
|
155 |
PluginServices.getIconTheme().registerDefault( |
|
156 |
"kde-network-offline-icon", |
|
157 |
this.getClass().getClassLoader().getResource("images/kde-network-offline.png") |
|
158 |
); |
|
159 |
|
|
160 |
|
|
161 |
|
|
162 |
} |
|
163 |
|
|
164 |
public void execute(String actionCommand) { |
|
165 |
if (!this.initilizedExtensions) { |
|
166 |
initializeExtensions(); |
|
167 |
initializeExtensionsConfig(); |
|
168 |
this.initilizedExtensions = true; |
|
169 |
} |
|
170 |
|
|
171 |
DlgPreferences dlgPreferences=PluginServices.getDlgPreferences(); |
|
172 |
dlgPreferences.refreshExtensionPoints(); |
|
173 |
PluginServices.getMDIManager().addWindow(dlgPreferences); |
|
174 |
} |
|
175 |
public boolean isEnabled() { |
|
176 |
return true; |
|
177 |
} |
|
178 |
|
|
179 |
public boolean isVisible() { |
|
180 |
return true; |
|
181 |
} |
|
182 |
|
|
183 |
private void initializeCoreExtensions() { |
|
184 |
ExtensionPoint ep = this.extensionPoints.add("AplicationPreferences", ""); |
|
185 |
ep.append("GeneralPage", "", new GeneralPage()); |
|
186 |
ep.append("NetworkPage", "", new NetworkPage()); |
|
187 |
ep.append("FirewallPage", "", new FirewallPage()); |
|
188 |
ep.append("DirExtensionsPage", "", new DirExtensionsPage()); |
|
189 |
ep.append("LanguagePage", "", new LanguagePage()); |
|
190 |
ep.append("ExtensionsPage", "", new ExtensionsPage()); |
|
191 |
ep.append("AppearancePage", "", new AppearancePage()); |
|
192 |
ep.append("FolderingPage", "", new FolderingPage()); |
|
193 |
ep.append("ScreenSettingsPage", "", new ScreenSettingsPage()); |
|
194 |
ep.append("SkinPreferences", "", new SkinPreferences()); |
|
195 |
|
|
196 |
// this.extensionPoints.add("AplicationPreferences","GeneralPage", new GeneralPage()); |
|
197 |
// this.extensionPoints.add("AplicationPreferences","NetworkPage", new NetworkPage()); |
|
198 |
// this.extensionPoints.add("AplicationPreferences","FirewallPage", new FirewallPage()); |
|
199 |
// this.extensionPoints.add("AplicationPreferences","DirExtensionsPage", new DirExtensionsPage()); |
|
200 |
// this.extensionPoints.add("AplicationPreferences","LanguagePage", new LanguagePage()); |
|
201 |
// this.extensionPoints.add("AplicationPreferences","ExtensionsPage", new ExtensionsPage()); |
|
202 |
// this.extensionPoints.add("AplicationPreferences","AppearancePage", new AppearancePage()); |
|
203 |
// this.extensionPoints.add("AplicationPreferences","FolderingPage", new FolderingPage()); |
|
204 |
// this.extensionPoints.add("AplicationPreferences","ResolutionPage", new ScreenSettingsPage()); |
|
205 |
// this.extensionPoints.add("AplicationPreferences","SkinPreferences", new SkinPreferences()); |
|
206 |
String os = System.getProperty("os.name").toLowerCase(); |
|
207 |
if (os.indexOf("linux") != -1 || os.indexOf("unix")!= -1) { |
|
208 |
ep.append("BrowserControlPage", "", new BrowserControlPage()); |
|
209 |
// this.extensionPoints.add("AplicationPreferences","BrowserControlPage", new BrowserControlPage()); |
|
210 |
} |
|
211 |
|
|
212 |
//Falta los plugin |
|
213 |
} |
|
214 |
|
|
215 |
private void initializeExtensionsConfig() { |
|
216 |
HashMap pc = Launcher.getPluginConfig(); |
|
217 |
ArrayList array = new ArrayList(); |
|
218 |
Iterator iter = pc.values().iterator(); |
|
219 |
|
|
220 |
while (iter.hasNext()) { |
|
221 |
array.add(((PluginConfig) iter.next()).getExtensions()); |
|
222 |
} |
|
223 |
ExtensionPoint ep = this.extensionPoints.add("AplicationPreferences", ""); |
|
224 |
|
|
225 |
Extensions[] exts = (Extensions[]) array.toArray(new Extensions[0]); |
|
226 |
for (int i = 0; i < exts.length; i++) { |
|
227 |
for (int j = 0; j < exts[i].getExtensionCount(); j++) { |
|
228 |
org.gvsig.andami.plugins.config.generate.Extension ext = exts[i] |
|
229 |
.getExtension(j); |
|
230 |
String sExt = ext.getClassName().toString(); |
|
231 |
// String pn = null; |
|
232 |
// pn = sExt.substring(0, sExt.lastIndexOf(".")); |
|
233 |
// dlgPrefs.addPreferencePage(new PluginsPage(pn)); |
|
234 |
// dlgPrefs.addPreferencePage(new ExtensionPage(ext)); |
|
235 |
ep.append(sExt, "", new ExtensionPage(ext)); |
|
236 |
} |
|
237 |
} |
|
238 |
} |
|
239 |
/** |
|
240 |
* |
|
241 |
*/ |
|
242 |
private void initializeExtensions() { |
|
243 |
Iterator i = Launcher.getExtensionIterator(); |
|
244 |
ExtensionPoint ep = this.extensionPoints.add("AplicationPreferences", ""); |
|
245 |
|
|
246 |
while (i.hasNext()) { |
|
247 |
Object extension = i.next(); |
|
248 |
|
|
249 |
if (extension instanceof IPreferenceExtension) { |
|
250 |
IPreferenceExtension pe=(IPreferenceExtension)extension; |
|
251 |
IPreference[] pp=pe.getPreferencesPages(); |
|
252 |
for (int j=0;j<pp.length;j++) { |
|
253 |
ep.append(pp[j].getID(), "", pp[j]); |
|
254 |
pp[j].initializeValues(); |
|
255 |
} |
|
256 |
} |
|
257 |
} |
|
258 |
} |
|
259 |
|
|
260 |
public void postInitialize() { |
|
261 |
super.postInitialize(); |
|
262 |
DlgPreferences dlgPreferences=PluginServices.getDlgPreferences(); |
|
263 |
dlgPreferences.refreshExtensionPoints(); |
|
264 |
dlgPreferences.storeValues(); |
|
265 |
} |
|
266 |
} |
|
0 | 267 |
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/NotificationDialogNew.java | ||
---|---|---|
1 |
package org.gvsig.coreplugin; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Dimension; |
|
5 |
import java.awt.FlowLayout; |
|
6 |
import java.awt.GridBagConstraints; |
|
7 |
import java.awt.GridBagLayout; |
|
8 |
import java.awt.LayoutManager; |
|
9 |
import java.awt.event.ActionEvent; |
|
10 |
import java.awt.event.ActionListener; |
|
11 |
import java.net.URL; |
|
12 |
|
|
13 |
import javax.swing.BorderFactory; |
|
14 |
import javax.swing.ImageIcon; |
|
15 |
import javax.swing.JButton; |
|
16 |
import javax.swing.JComponent; |
|
17 |
import javax.swing.JLabel; |
|
18 |
import javax.swing.JPanel; |
|
19 |
import javax.swing.JScrollPane; |
|
20 |
import javax.swing.JTextArea; |
|
21 |
import javax.swing.SwingUtilities; |
|
22 |
import javax.swing.border.Border; |
|
23 |
import javax.swing.border.TitledBorder; |
|
24 |
|
|
25 |
import org.gvsig.andami.PluginServices; |
|
26 |
import org.gvsig.andami.messages.MessageEvent; |
|
27 |
import org.gvsig.andami.messages.NotificationListener; |
|
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
29 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
|
30 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
31 |
|
|
32 |
public class NotificationDialogNew extends JPanel implements IWindow, |
|
33 |
SingletonWindow, NotificationListener { |
|
34 |
|
|
35 |
/** |
|
36 |
* |
|
37 |
*/ |
|
38 |
private static final long serialVersionUID = 4363640321917006480L; |
|
39 |
|
|
40 |
JPanelConsole console; |
|
41 |
JPanelButtons buttons; |
|
42 |
JPanelDescription description; |
|
43 |
|
|
44 |
public NotificationDialogNew() { |
|
45 |
super(); |
|
46 |
this.setLayout(new GridBagLayout()); |
|
47 |
|
|
48 |
description = new JPanelDescription(); |
|
49 |
console = new JPanelConsole(); |
|
50 |
buttons = new JPanelButtons(console); |
|
51 |
|
|
52 |
addComppnent(this, description, 0, 0, 3, 1, 1.0, 1.0, |
|
53 |
GridBagConstraints.BOTH, GridBagConstraints.CENTER); |
|
54 |
addComppnent(this, buttons, 0, 1, 3, 1, 0, 0, GridBagConstraints.NONE, |
|
55 |
GridBagConstraints.NORTHEAST); |
|
56 |
addComppnent(this, console, 0, 2, 3, 1, 1.0, 2.0, |
|
57 |
GridBagConstraints.BOTH, GridBagConstraints.CENTER); |
|
58 |
this.setVisible(true); |
|
59 |
this.hideConsole(); |
|
60 |
} |
|
61 |
|
|
62 |
void addComppnent(JPanel panel, JComponent component, int gridx, int gridy, |
|
63 |
int width, int height, double weightx, double weighty, int fill, |
|
64 |
int anchor) { |
|
65 |
GridBagConstraints constraints = new GridBagConstraints(); |
|
66 |
constraints.gridx = gridx; |
|
67 |
constraints.gridy = gridy; |
|
68 |
constraints.gridwidth = width; |
|
69 |
constraints.gridheight = height; |
|
70 |
constraints.weightx = weightx; // 1.0 se estira, 0 no. |
|
71 |
constraints.weighty = weighty; // 1.0 se estira, 0 no. |
|
72 |
constraints.fill = fill; |
|
73 |
constraints.anchor = anchor; |
|
74 |
constraints.ipadx = 2; |
|
75 |
constraints.ipady = 2; |
|
76 |
|
|
77 |
panel.add(component, constraints); |
|
78 |
component.setVisible(true); |
|
79 |
} |
|
80 |
|
|
81 |
public void setDescription(String description) { |
|
82 |
this.description.setDescription(description); |
|
83 |
} |
|
84 |
|
|
85 |
public void closeWindow() { |
|
86 |
PluginServices.getMDIManager().closeWindow(this); |
|
87 |
} |
|
88 |
|
|
89 |
public void hideConsole() { |
|
90 |
this.buttons.hideConsole(); |
|
91 |
} |
|
92 |
|
|
93 |
public void showConsole() { |
|
94 |
this.buttons.showConsole(); |
|
95 |
} |
|
96 |
|
|
97 |
class JPanelDescription extends JPanel { |
|
98 |
/** |
|
99 |
* |
|
100 |
*/ |
|
101 |
private static final long serialVersionUID = 1529755877776747074L; |
|
102 |
JTextArea description = null; |
|
103 |
JLabel image; |
|
104 |
|
|
105 |
JPanelDescription() { |
|
106 |
LayoutManager layout; |
|
107 |
Border border; |
|
108 |
|
|
109 |
layout = new GridBagLayout(); |
|
110 |
this.setLayout(layout); |
|
111 |
|
|
112 |
// border = BorderFactory.createTitledBorder("Description"); |
|
113 |
border = BorderFactory.createEmptyBorder(); |
|
114 |
this.setBorder(border); |
|
115 |
|
|
116 |
this.image = new JLabel(); |
|
117 |
URL stopurl = this.getClass().getClassLoader().getResource("images/stop.png"); |
|
118 |
this.image.setIcon(new ImageIcon(stopurl)); |
|
119 |
addComppnent(this, this.image, 0, 0, 1, 1, 0, 0, |
|
120 |
GridBagConstraints.NONE, GridBagConstraints.CENTER); |
|
121 |
|
|
122 |
this.description = new JTextArea(); |
|
123 |
this.description.setEditable(false); |
|
124 |
this.description.setOpaque(false); |
|
125 |
this.description.setText(""); |
|
126 |
JScrollPane scrollPanel = new JScrollPane(this.description); |
|
127 |
scrollPanel.setBorder(BorderFactory.createEmptyBorder()); |
|
128 |
scrollPanel.setPreferredSize(new Dimension(600, 200)); |
|
129 |
addComppnent(this, scrollPanel, 1, 0, 1, 1, 1, 1, |
|
130 |
GridBagConstraints.BOTH, GridBagConstraints.CENTER); |
|
131 |
} |
|
132 |
|
|
133 |
public String getDescription() { |
|
134 |
return this.description.getText(); |
|
135 |
} |
|
136 |
|
|
137 |
public void setDescription(String description) { |
|
138 |
this.description.setText(description); |
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
class JPanelButtons extends JPanel { |
|
143 |
/** |
|
144 |
* |
|
145 |
*/ |
|
146 |
private static final long serialVersionUID = 1529755877776747074L; |
|
147 |
JButton close = null; |
|
148 |
JButton showDetails = null; |
|
149 |
JButton hideDetails = null; |
|
150 |
JPanel console = null; |
|
151 |
|
|
152 |
JPanelButtons(JPanel console) { |
|
153 |
this.console = console; |
|
154 |
this.setLayout(new FlowLayout()); |
|
155 |
this.close = getCloseButton(); |
|
156 |
this.showDetails = getShowDetailsButton(); |
|
157 |
this.hideDetails = getHideDetailsButton(); |
|
158 |
this.add(this.close); |
|
159 |
this.add(this.showDetails); |
|
160 |
this.add(this.hideDetails); |
|
161 |
hideConsole(); |
|
162 |
} |
|
163 |
|
|
164 |
private JButton getCloseButton() { |
|
165 |
JButton button = new JButton( |
|
166 |
PluginServices.getText(this, "aceptar")); |
|
167 |
button.addActionListener(new ActionListener() { |
|
168 |
public void actionPerformed(ActionEvent e) { |
|
169 |
closeWindow(); |
|
170 |
} |
|
171 |
}); |
|
172 |
return button; |
|
173 |
} |
|
174 |
|
|
175 |
private JButton getShowDetailsButton() { |
|
176 |
JButton button = new JButton(PluginServices.getText(this, |
|
177 |
"detalles") + " >>>"); |
|
178 |
button.addActionListener(new ActionListener() { |
|
179 |
public void actionPerformed(ActionEvent e) { |
|
180 |
showConsole(); |
|
181 |
} |
|
182 |
}); |
|
183 |
return button; |
|
184 |
} |
|
185 |
|
|
186 |
private JButton getHideDetailsButton() { |
|
187 |
JButton button = new JButton(PluginServices.getText(this, |
|
188 |
"detalles") + " <<<"); |
|
189 |
button.addActionListener(new ActionListener() { |
|
190 |
public void actionPerformed(ActionEvent e) { |
|
191 |
hideConsole(); |
|
192 |
} |
|
193 |
}); |
|
194 |
return button; |
|
195 |
} |
|
196 |
|
|
197 |
public void hideConsole() { |
|
198 |
this.showDetails.setVisible(true); |
|
199 |
this.hideDetails.setVisible(false); |
|
200 |
this.console.setVisible(false); |
|
201 |
} |
|
202 |
|
|
203 |
public void showConsole() { |
|
204 |
this.showDetails.setVisible(false); |
|
205 |
this.hideDetails.setVisible(true); |
|
206 |
this.console.setVisible(true); |
|
207 |
} |
|
208 |
} |
|
209 |
|
|
210 |
class JPanelConsole extends JPanel { |
|
211 |
|
|
212 |
/** |
|
213 |
* |
|
214 |
*/ |
|
215 |
private static final long serialVersionUID = -6651900105647107644L; |
|
216 |
|
|
217 |
JPanelConsole() { |
|
218 |
BorderLayout layout = new BorderLayout(); |
|
219 |
this.setLayout(new BorderLayout()); |
|
220 |
TitledBorder border = BorderFactory.createTitledBorder("Console"); |
|
221 |
this.setBorder(border); |
|
222 |
this.setLayout(layout); |
|
223 |
this.add(Consola.consolaFrame, BorderLayout.CENTER); |
|
224 |
} |
|
225 |
} |
|
226 |
|
|
227 |
public Object getWindowModel() { |
|
228 |
return "notification-dialog"; |
|
229 |
} |
|
230 |
|
|
231 |
public WindowInfo getWindowInfo() { |
|
232 |
WindowInfo info = new WindowInfo(WindowInfo.MODELESSDIALOG |
|
233 |
| WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE); |
|
234 |
info.setTitle(PluginServices.getText(this, "Warning")); |
|
235 |
info.setHeight(this.getPreferredSize().height); |
|
236 |
info.setWidth(this.getPreferredSize().width); |
|
237 |
return info; |
|
238 |
} |
|
239 |
|
|
240 |
public Object getWindowProfile() { |
|
241 |
return WindowInfo.PROPERTIES_PROFILE; |
|
242 |
} |
|
243 |
|
|
244 |
public void errorEvent(MessageEvent e) { |
|
245 |
if (e.getMessages() != null) { |
|
246 |
for (int i = 0; i < e.getMessages().length; i++) { |
|
247 |
this.setDescription(e.getMessages()[i]); |
|
248 |
} |
|
249 |
} |
|
250 |
|
|
251 |
PluginServices.getMDIManager().restoreCursor(); |
|
252 |
if (SwingUtilities.isEventDispatchThread()) { |
|
253 |
PluginServices.getMDIManager().addCentredWindow(this); |
|
254 |
} else { |
|
255 |
final IWindow win = this; |
|
256 |
SwingUtilities.invokeLater(new Runnable() { |
|
257 |
public void run() { |
|
258 |
PluginServices.getMDIManager().addCentredWindow(win); |
|
259 |
} |
|
260 |
}); |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
public void warningEvent(MessageEvent e) { |
|
265 |
if (e.getMessages() != null) { |
|
266 |
for (int i = 0; i < e.getMessages().length; i++) { |
|
267 |
this.setDescription(e.getMessages()[i]); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
PluginServices.getMDIManager().restoreCursor(); |
|
272 |
if (SwingUtilities.isEventDispatchThread()) { |
|
273 |
PluginServices.getMDIManager().addCentredWindow(this); |
|
274 |
} else { |
|
275 |
final IWindow win = this; |
|
276 |
SwingUtilities.invokeLater(new Runnable() { |
|
277 |
public void run() { |
|
278 |
PluginServices.getMDIManager().addCentredWindow(win); |
|
279 |
} |
|
280 |
}); |
|
281 |
} |
|
282 |
} |
|
283 |
|
|
284 |
public void infoEvent(MessageEvent e) { |
|
285 |
// Do nothing, ignore info events |
|
286 |
} |
|
287 |
|
|
288 |
} |
|
0 | 289 |
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/preferences/network/FirewallPage.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.9 2006/11/21 10:59:45 fjp |
|
47 |
* Fallo proxy con usuario y contrase?a |
|
48 |
* |
|
49 |
* Revision 1.8 2006/11/20 17:29:43 fjp |
|
50 |
* Fallo proxy con usuario y contrase?a |
|
51 |
* |
|
52 |
* Revision 1.7 2006/10/18 07:55:43 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.6 2006/08/22 12:23:05 jaume |
|
56 |
* improved perfomance when saving changes |
|
57 |
* |
|
58 |
* Revision 1.5 2006/08/22 07:37:17 jaume |
|
59 |
* *** empty log message *** |
|
60 |
* |
|
61 |
* Revision 1.4 2006/08/04 11:45:12 caballero |
|
62 |
* lanzo una excepci?n cuando falla el m?todo storeValues |
|
63 |
* |
|
64 |
* Revision 1.3 2006/07/31 10:02:31 jaume |
|
65 |
* *** empty log message *** |
|
66 |
* |
|
67 |
* Revision 1.2 2006/06/13 07:43:08 fjp |
|
68 |
* Ajustes sobre los cuadros de dialogos de preferencias |
|
69 |
* |
|
70 |
* Revision 1.1 2006/06/12 16:04:28 caballero |
|
71 |
* Preferencias |
|
72 |
* |
|
73 |
* Revision 1.11 2006/06/06 10:26:31 jaume |
|
74 |
* *** empty log message *** |
|
75 |
* |
|
76 |
* Revision 1.10 2006/06/05 17:07:17 jaume |
|
77 |
* *** empty log message *** |
|
78 |
* |
|
79 |
* Revision 1.9 2006/06/05 17:00:44 jaume |
|
80 |
* *** empty log message *** |
|
81 |
* |
|
82 |
* Revision 1.8 2006/06/05 16:57:59 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* Revision 1.7 2006/06/05 14:45:06 jaume |
|
86 |
* *** empty log message *** |
|
87 |
* |
|
88 |
* Revision 1.6 2006/06/05 11:00:09 jaume |
|
89 |
* *** empty log message *** |
|
90 |
* |
|
91 |
* Revision 1.5 2006/06/05 10:39:02 jaume |
|
92 |
* *** empty log message *** |
|
93 |
* |
|
94 |
* Revision 1.4 2006/06/05 10:13:40 jaume |
|
95 |
* *** empty log message *** |
|
96 |
* |
|
97 |
* Revision 1.3 2006/06/05 10:06:08 jaume |
|
98 |
* *** empty log message *** |
|
99 |
* |
|
100 |
* Revision 1.2 2006/06/05 09:51:56 jaume |
|
101 |
* *** empty log message *** |
|
102 |
* |
|
103 |
* Revision 1.1 2006/06/02 10:50:18 jaume |
|
104 |
* *** empty log message *** |
|
105 |
* |
|
106 |
* |
|
107 |
*/ |
|
108 |
package org.gvsig.coreplugin.preferences.network; |
|
109 |
|
|
110 |
import java.awt.event.ActionEvent; |
|
111 |
import java.awt.event.ActionListener; |
|
112 |
import java.net.Authenticator; |
|
113 |
import java.net.MalformedURLException; |
|
114 |
import java.net.PasswordAuthentication; |
|
115 |
import java.net.URL; |
|
116 |
import java.util.Properties; |
|
117 |
import java.util.prefs.Preferences; |
|
118 |
|
|
119 |
import javax.swing.ImageIcon; |
|
120 |
import javax.swing.JCheckBox; |
|
121 |
import javax.swing.JPanel; |
|
122 |
import javax.swing.JPasswordField; |
|
123 |
import javax.swing.JTextField; |
|
124 |
|
|
125 |
import org.gvsig.andami.PluginServices; |
|
126 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
127 |
import org.gvsig.andami.preferences.StoreException; |
|
128 |
|
|
129 |
|
|
130 |
public class FirewallPage extends AbstractPreferencePage { |
|
131 |
|
|
132 |
// Quiz? en vez de usar un prefs cada vez deber?amos de tener una clase gvSIG.java |
|
133 |
// donde se guarden todas las preferencias, queda m?s limpio y m?s claro si se hace |
|
134 |
// un: gvSIG.getProperty("gvsig.connection") que lo de abajo. |
|
135 |
private static Preferences prefs = Preferences.userRoot().node( "gvsig.connection" ); |
|
136 |
private JCheckBox httpEnabled; |
|
137 |
private JTextField httpHost; |
|
138 |
private JTextField httpPort; |
|
139 |
private JTextField httpUser; |
|
140 |
private JPasswordField httpPass; |
|
141 |
private JTextField httpNonProxy; |
|
142 |
private JCheckBox socksEnabled; |
|
143 |
private JTextField socksHost; |
|
144 |
private JTextField socksPort; |
|
145 |
protected static String id = FirewallPage.class.getName(); |
|
146 |
private ImageIcon icon; |
|
147 |
|
|
148 |
private static final class ProxyAuth extends Authenticator { |
|
149 |
private PasswordAuthentication auth; |
|
150 |
|
|
151 |
private ProxyAuth(String user, String pass) { |
|
152 |
auth = new PasswordAuthentication(user, pass.toCharArray()); |
|
153 |
} |
|
154 |
|
|
155 |
protected PasswordAuthentication getPasswordAuthentication() { |
|
156 |
return auth; |
|
157 |
} |
|
158 |
} |
|
159 |
|
|
160 |
public FirewallPage() { |
|
161 |
super(); |
|
162 |
//icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/shield.png")); |
|
163 |
icon=PluginServices.getIconTheme().get("aplication-preferences-firewall"); |
|
164 |
setParentID(NetworkPage.id); |
|
165 |
// checkbox |
|
166 |
addComponent(httpEnabled = new JCheckBox(PluginServices.getText(this, |
|
167 |
"options.firewall.http.enabled"))); |
|
168 |
// proxy host |
|
169 |
addComponent(PluginServices.getText(this, "options.firewall.http.host") + ":", |
|
170 |
httpHost = new JTextField("", 15)); |
|
171 |
// proxy port |
|
172 |
addComponent(PluginServices.getText(this, "options.firewall.http.port") + ":", |
|
173 |
httpPort = new JTextField("", 15)); |
|
174 |
// proxy username |
|
175 |
addComponent(PluginServices.getText(this, "options.firewall.http.user") + ":", |
|
176 |
httpUser = new JTextField("", 15)); |
|
177 |
// proxy password |
|
178 |
addComponent(PluginServices.getText(this, "options.firewall.http.password") + ":", |
|
179 |
httpPass = new JPasswordField("", 15)); |
|
180 |
// no proxy for |
|
181 |
addComponent(PluginServices.getText(this, "options.firewall.http.nonProxy") + ":", |
|
182 |
httpNonProxy = new JTextField("", 15)); |
|
183 |
|
|
184 |
// checkbox |
|
185 |
addComponent(socksEnabled = new JCheckBox(PluginServices.getText(this, |
|
186 |
"options.firewall.socks.enabled"))); |
|
187 |
// proxy host |
|
188 |
addComponent(PluginServices.getText(this, "options.firewall.socks.host") + ":", |
|
189 |
socksHost = new JTextField("", 15)); |
|
190 |
// proxy port |
|
191 |
addComponent(PluginServices.getText(this, "options.firewall.socks.port") + ":", |
|
192 |
socksPort = new JTextField("", 15)); |
|
193 |
|
|
194 |
} |
|
195 |
|
|
196 |
public void initializeValues() { |
|
197 |
|
|
198 |
boolean enabled = prefs.getBoolean("firewall.http.enabled", false); |
|
199 |
httpEnabled.setSelected(enabled); |
|
200 |
httpHost.setEnabled(enabled); |
|
201 |
httpHost.setText(prefs.get("firewall.http.host","")); |
|
202 |
httpPort.setEnabled(enabled); |
|
203 |
httpPort.setText(prefs.get("firewall.http.port","")); |
|
204 |
httpUser.setEnabled(enabled); |
|
205 |
httpUser.setText(prefs.get("firewall.http.user","")); |
|
206 |
httpPass.setEnabled(enabled); |
|
207 |
httpPass.setText(prefs.get("firewall.http.password","")); |
|
208 |
httpNonProxy.setEnabled(enabled); |
|
209 |
httpNonProxy.setText(prefs.get("firewall.http.nonProxyHosts","")); |
|
210 |
|
|
211 |
|
|
212 |
httpEnabled.addActionListener(new ActionHandler()); |
|
213 |
|
|
214 |
|
|
215 |
enabled = prefs.getBoolean("firewall.socks.enabled", false); |
|
216 |
socksEnabled.setSelected(enabled); |
|
217 |
socksHost.setEnabled(enabled); |
|
218 |
socksHost.setText(prefs.get("firewall.socks.host","")); |
|
219 |
socksPort.setEnabled(enabled); |
|
220 |
socksPort.setText(prefs.get("firewall.socks.port","")); |
|
221 |
|
|
222 |
socksEnabled.addActionListener(new ActionHandler()); |
|
223 |
|
|
224 |
} |
|
225 |
|
|
226 |
public String getID() { |
|
227 |
return id; |
|
228 |
} |
|
229 |
|
|
230 |
public String getTitle() { |
|
231 |
return PluginServices.getText(this, "pref.network.firewall"); |
|
232 |
} |
|
233 |
|
|
234 |
public JPanel getPanel() { |
|
235 |
return this; |
|
236 |
} |
|
237 |
|
|
238 |
public void storeValues() throws StoreException{ |
|
239 |
Properties systemSettings = System.getProperties(); |
|
240 |
URL httpURL, socksURL; |
|
241 |
|
|
242 |
try { |
|
243 |
httpURL = new URL(createURL(httpHost.getText(), httpPort.getText())); |
|
244 |
prefs.putBoolean("firewall.http.enabled", httpEnabled.isSelected()); |
|
245 |
prefs.put("firewall.http.host", httpHost.getText()); |
|
246 |
prefs.put("firewall.http.port", httpPort.getText()); |
|
247 |
String proxyUser = httpUser.getText(); |
|
248 |
String proxyPassword = new String(httpPass.getPassword()); |
|
249 |
prefs.put("firewall.http.user", proxyUser); |
|
250 |
prefs.put("firewall.http.password", proxyPassword); |
|
251 |
prefs.put("firewall.http.nonProxyHosts", httpNonProxy.getText()); |
|
252 |
|
|
253 |
if (httpEnabled.isSelected()) { |
|
254 |
systemSettings.put("http.proxySet", "true"); |
|
255 |
systemSettings.put("http.proxyHost", httpURL.getHost()); |
|
256 |
systemSettings.put("http.proxyPort", httpURL.getPort()+""); |
|
257 |
systemSettings.put("http.proxyUserName", proxyUser); |
|
258 |
systemSettings.put("http.proxyPassword", proxyPassword); |
|
259 |
} else { |
|
260 |
systemSettings.put("http.proxySet", "false"); |
|
261 |
systemSettings.remove("http.proxyHost"); |
|
262 |
systemSettings.remove("http.proxyPort"); |
|
263 |
systemSettings.remove("http.proxyUserName"); |
|
264 |
systemSettings.remove("http.proxyPassword"); |
|
265 |
prefs.remove("firewall.http.host"); |
|
266 |
prefs.remove("firewall.http.port"); |
|
267 |
prefs.remove("firewall.http.user"); |
|
268 |
prefs.remove("firewall.http.password"); |
|
269 |
prefs.remove("firewall.http.nonProxyHosts"); |
|
270 |
|
|
271 |
} |
|
272 |
|
|
273 |
System.setProperties(systemSettings); |
|
274 |
if (proxyUser != null ) |
|
275 |
{ |
|
276 |
Authenticator.setDefault(new ProxyAuth(proxyUser, |
|
277 |
proxyPassword)); |
|
278 |
} else { |
|
279 |
Authenticator.setDefault(new ProxyAuth("", "")); |
|
280 |
} |
|
281 |
|
|
282 |
} catch (MalformedURLException e) { |
|
283 |
if (httpEnabled.isSelected()) { |
|
284 |
throw new StoreException(PluginServices.getText(this, "options.firewall.http.incorrect_host"),e); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
try { |
|
289 |
socksURL = new URL(createURL(socksHost.getText(),socksPort.getText())); |
|
290 |
|
|
291 |
prefs.putBoolean("firewall.socks.enabled", socksEnabled.isSelected()); |
|
292 |
prefs.put("firewall.socks.host", socksHost.getText()); |
|
293 |
prefs.put("firewall.socks.port", socksPort.getText()); |
|
294 |
|
|
295 |
if (socksEnabled.isSelected()) { |
|
296 |
systemSettings.put("socksProxyHost", socksURL.getHost()); |
|
297 |
systemSettings.put("socksProxyPort", socksURL.getPort()+""); |
|
298 |
} else { |
|
299 |
systemSettings.remove("socksProxyHost"); |
|
300 |
systemSettings.remove("socksProxyPort"); |
|
301 |
} |
|
302 |
|
|
303 |
System.setProperties(systemSettings); |
|
304 |
|
|
305 |
} catch (MalformedURLException e) { |
|
306 |
if (socksEnabled.isSelected()) { |
|
307 |
throw new StoreException(PluginServices.getText(this, "options.firewall.socks.incorrect_host"),e); |
|
308 |
} |
|
309 |
} |
|
310 |
} |
|
311 |
|
|
312 |
public void initializeDefaults() { |
|
313 |
httpEnabled.setSelected(false); |
|
314 |
httpHost.setText(""); |
|
315 |
httpPort.setText(""); |
|
316 |
httpUser.setText(""); |
|
317 |
httpPass.setText(""); |
|
318 |
httpNonProxy.setText(""); |
|
319 |
socksEnabled.setSelected(false); |
|
320 |
socksHost.setText(""); |
|
321 |
socksPort.setText(""); |
|
322 |
|
|
323 |
} |
|
324 |
|
|
325 |
private class ActionHandler implements ActionListener { |
|
326 |
public void actionPerformed(ActionEvent evt) { |
|
327 |
httpHost.setEnabled(httpEnabled.isSelected()); |
|
328 |
httpPort.setEnabled(httpEnabled.isSelected()); |
|
329 |
httpUser.setEnabled(httpEnabled.isSelected()); |
|
330 |
httpPass.setEnabled(httpEnabled.isSelected()); |
|
331 |
httpNonProxy.setEnabled(httpEnabled.isSelected()); |
|
332 |
socksHost.setEnabled(socksEnabled.isSelected()); |
|
333 |
socksPort.setEnabled(socksEnabled.isSelected()); |
|
334 |
} |
|
335 |
} |
|
336 |
|
|
337 |
public ImageIcon getIcon() { |
|
338 |
return icon; |
|
339 |
} |
|
340 |
|
|
341 |
public boolean isValueChanged() { |
|
342 |
return hasChanged(); |
|
343 |
} |
|
344 |
|
|
345 |
public void setChangesApplied() { |
|
346 |
setChanged(false); |
|
347 |
} |
|
348 |
|
|
349 |
private String createURL(String host, String port){ |
|
350 |
StringBuffer strUrl = new StringBuffer(); |
|
351 |
// add "http://" prefix if it wasn't included. |
|
352 |
strUrl.append(host.toLowerCase().startsWith("http://") |
|
353 |
? host.toLowerCase() : "http://"+ host.toLowerCase()); |
|
354 |
|
|
355 |
// add port |
|
356 |
strUrl.append(!port.equals("") |
|
357 |
? ":" + port : ""); |
|
358 |
return strUrl.toString(); |
|
359 |
} |
|
360 |
} |
|
0 | 361 |
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/preferences/network/NetworkPage.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
|
|
42 |
/* CVS MESSAGES: |
|
43 |
* |
|
44 |
* $Id$ |
|
45 |
* $Log$ |
|
46 |
* Revision 1.10 2007/09/19 16:16:52 jaume |
|
47 |
* removed unnecessary imports |
|
48 |
* |
|
49 |
* Revision 1.9 2006/11/20 17:29:43 fjp |
|
50 |
* Fallo proxy con usuario y contrase?a |
|
51 |
* |
|
52 |
* Revision 1.8 2006/09/12 10:11:25 jaume |
|
53 |
* *** empty log message *** |
|
54 |
* |
|
55 |
* Revision 1.7.4.1 2006/09/08 11:56:24 jaume |
|
56 |
* *** empty log message *** |
|
57 |
* |
|
58 |
* Revision 1.7 2006/08/22 12:23:05 jaume |
|
59 |
* improved perfomance when saving changes |
|
60 |
* |
|
61 |
* Revision 1.6 2006/08/22 07:37:17 jaume |
|
62 |
* *** empty log message *** |
|
63 |
* |
|
64 |
* Revision 1.5 2006/08/04 11:45:12 caballero |
|
65 |
* lanzo una excepci?n cuando falla el m?todo storeValues |
|
66 |
* |
|
67 |
* Revision 1.4 2006/07/31 10:02:31 jaume |
|
68 |
* *** empty log message *** |
|
69 |
* |
|
70 |
* Revision 1.3 2006/07/03 10:46:01 jaume |
|
71 |
* *** empty log message *** |
|
72 |
* |
|
73 |
* Revision 1.2 2006/06/13 07:43:08 fjp |
|
74 |
* Ajustes sobre los cuadros de dialogos de preferencias |
|
75 |
* |
|
76 |
* Revision 1.1 2006/06/12 16:04:28 caballero |
|
77 |
* Preferencias |
|
78 |
* |
|
79 |
* Revision 1.6 2006/06/06 10:26:31 jaume |
|
80 |
* *** empty log message *** |
|
81 |
* |
|
82 |
* Revision 1.5 2006/06/05 17:07:17 jaume |
|
83 |
* *** empty log message *** |
|
84 |
* |
|
85 |
* Revision 1.4 2006/06/05 10:06:08 jaume |
|
86 |
* *** empty log message *** |
|
87 |
* |
|
88 |
* Revision 1.3 2006/06/05 09:13:22 jaume |
|
89 |
* *** empty log message *** |
|
90 |
* |
|
91 |
* Revision 1.2 2006/06/05 08:11:38 jaume |
|
92 |
* *** empty log message *** |
|
93 |
* |
|
94 |
* Revision 1.1 2006/06/02 10:50:18 jaume |
|
95 |
* *** empty log message *** |
|
96 |
* |
|
97 |
* Revision 1.1 2006/06/01 15:54:09 jaume |
|
98 |
* added preferences extension |
|
99 |
* |
|
100 |
* |
|
101 |
*/ |
|
102 |
package org.gvsig.coreplugin.preferences.network; |
|
103 |
|
|
104 |
import java.awt.event.ActionEvent; |
|
105 |
import java.awt.event.ActionListener; |
|
106 |
import java.net.URL; |
|
107 |
|
|
108 |
import javax.swing.ImageIcon; |
|
109 |
import javax.swing.JLabel; |
|
110 |
import javax.swing.JPanel; |
|
111 |
|
|
112 |
import org.gvsig.andami.PluginServices; |
|
113 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
114 |
import org.gvsig.andami.ui.mdiFrame.JToolBarButton; |
|
115 |
|
|
116 |
|
|
117 |
/** |
|
118 |
* General network connection page. |
|
119 |
* |
|
120 |
* @author jaume dominguez faus - jaume.dominguez@iver.es |
|
121 |
* |
|
122 |
*/ |
|
123 |
public class NetworkPage extends AbstractPreferencePage { |
|
124 |
//private static Preferences prefs = Preferences.userRoot().node( "gvsig.connection" ); |
|
125 |
private ImageIcon icon; |
|
126 |
private JLabel lblNetworkStatus; |
|
127 |
private JToolBarButton btnRefresh; |
|
128 |
protected static String id; |
|
129 |
|
|
130 |
|
|
131 |
public NetworkPage() { |
|
132 |
super(); |
|
133 |
id = this.getClass().getName(); |
|
134 |
// icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/network.png")); |
|
135 |
icon=PluginServices.getIconTheme().get("aplication-preferences-network"); |
|
136 |
lblNetworkStatus = new JLabel(); |
|
137 |
lblNetworkStatus.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12)); |
|
138 |
lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection")); |
|
139 |
|
|
140 |
JPanel aux = new JPanel(); |
|
141 |
aux.add(getBtnCheckConnection()); |
|
142 |
addComponent(PluginServices.getText(this, "options.network.status") + ":", lblNetworkStatus ); |
|
143 |
addComponent("", aux); |
|
144 |
|
|
145 |
} |
|
146 |
|
|
147 |
private JToolBarButton getBtnCheckConnection() { |
|
148 |
if (btnRefresh == null) { |
|
149 |
btnRefresh = new JToolBarButton(PluginServices.getText(this, "test_now")); |
|
150 |
btnRefresh.addActionListener(new ActionListener() { |
|
151 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
152 |
refreshStatus(); |
|
153 |
}; |
|
154 |
}); |
|
155 |
} |
|
156 |
return btnRefresh; |
|
157 |
} |
|
158 |
|
|
159 |
private void refreshStatus() { |
|
160 |
boolean connected = isConnected(); |
|
161 |
ImageIcon statusIcon; |
|
162 |
String statusText; |
|
163 |
if (connected) { |
|
164 |
statusIcon = PluginServices.getIconTheme().get("kde-network-online-icon") ; |
|
165 |
statusText = PluginServices.getText(this, "online"); |
|
166 |
} else { |
|
167 |
statusIcon = PluginServices.getIconTheme().get("kde-network-offline-icon"); |
|
168 |
statusText = PluginServices.getText(this, "offline"); |
|
169 |
} |
|
170 |
lblNetworkStatus.setIcon(statusIcon); |
|
171 |
lblNetworkStatus.setText(statusText); |
|
172 |
|
|
173 |
} |
|
174 |
|
|
175 |
private boolean isConnected() { |
|
176 |
try { |
|
177 |
URL url = new URL("http://www.google.com"); |
|
178 |
url.openConnection(); |
|
179 |
url.openStream(); |
|
180 |
return true; |
|
181 |
} catch (Exception e) { |
|
182 |
return false; |
|
183 |
} |
|
184 |
|
|
185 |
} |
|
186 |
|
|
187 |
public String getID() { |
|
188 |
return id; |
|
189 |
} |
|
190 |
|
|
191 |
public String getTitle() { |
|
192 |
return PluginServices.getText(this, "pref.network"); |
|
193 |
} |
|
194 |
|
|
195 |
public JPanel getPanel() { |
|
196 |
return this; |
|
197 |
} |
|
198 |
|
|
199 |
|
|
200 |
public void initializeValues() { |
|
201 |
|
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
public void storeValues() { |
|
206 |
|
|
207 |
} |
|
208 |
|
|
209 |
public void initializeDefaults() { |
|
210 |
// nothing |
|
211 |
} |
|
212 |
|
|
213 |
class ActionHandler implements ActionListener { |
|
214 |
public void actionPerformed(ActionEvent evt) { |
|
215 |
|
|
216 |
} |
|
217 |
} |
|
218 |
|
|
219 |
public ImageIcon getIcon() { |
|
220 |
return icon; |
|
221 |
} |
|
222 |
|
|
223 |
public boolean isValueChanged() { |
|
224 |
return hasChanged(); |
|
225 |
} |
|
226 |
|
|
227 |
public void setChangesApplied() { |
|
228 |
setChanged(false); |
|
229 |
} |
|
230 |
|
|
231 |
|
|
232 |
} |
|
0 | 233 |
tags/v2_0_0_Build_2011/libraries/libCorePlugin/src/org/gvsig/coreplugin/preferences/general/LanguagePage.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib��ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.coreplugin.preferences.general; |
|
42 |
|
|
43 |
import java.awt.BorderLayout; |
|
44 |
import java.awt.event.ActionEvent; |
|
45 |
import java.awt.event.ActionListener; |
|
46 |
import java.util.Locale; |
|
47 |
|
|
48 |
import javax.swing.*; |
|
49 |
|
|
50 |
import org.gvsig.andami.Launcher; |
|
51 |
import org.gvsig.andami.PluginServices; |
|
52 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
53 |
|
|
54 |
|
|
55 |
public class LanguagePage extends AbstractPreferencePage { |
|
56 |
private static LanguageItem DEFAULT_LANGUAGE; |
|
57 |
private ImageIcon icon; |
|
58 |
|
|
59 |
private String id; |
|
60 |
|
|
61 |
private JPanel pN = null; |
|
62 |
|
|
63 |
private JPanel pC = null; |
|
64 |
|
|
65 |
private JPanel pS = null; |
|
66 |
|
|
67 |
private JPanel jPanel = null; |
|
68 |
|
|
69 |
private JComboBox cmbIdioma = null; |
|
70 |
|
|
71 |
private JLabel label = null; |
|
72 |
|
|
73 |
private int langIndex; |
|
74 |
private boolean changed = false; |
|
75 |
|
|
76 |
public LanguagePage() { |
|
77 |
super(); |
|
78 |
initialize(); |
|
79 |
id = this.getClass().getName(); |
|
80 |
setParentID(GeneralPage.class.getName()); |
|
81 |
} |
|
82 |
|
|
83 |
private void initialize() { |
|
84 |
icon=PluginServices.getIconTheme().get("aplication-preferences-language"); |
|
85 |
this.setLayout(new BorderLayout()); |
|
86 |
this.setSize(new java.awt.Dimension(386, 177)); |
|
87 |
this.add(getPN(), java.awt.BorderLayout.NORTH); |
|
88 |
this.add(getPC(), java.awt.BorderLayout.CENTER); |
|
89 |
this.add(getPS(), java.awt.BorderLayout.SOUTH); |
|
90 |
langIndex = getJComboBox().getSelectedIndex(); |
|
91 |
} |
|
92 |
|
|
93 |
public String getID() { |
|
94 |
return id; |
|
95 |
} |
|
96 |
|
|
97 |
public String getTitle() { |
|
98 |
return PluginServices.getText(this, "idioma"); |
|
99 |
} |
|
100 |
|
|
101 |
public JPanel getPanel() { |
|
102 |
return this; |
|
103 |
} |
|
104 |
|
|
105 |
public void initializeValues() { |
|
106 |
} |
|
107 |
|
|
108 |
private class LanguageItem { |
|
109 |
public Locale locale; |
|
110 |
|
|
111 |
public String description; |
|
112 |
|
|
113 |
public LanguageItem(Locale loc, String str) { |
|
114 |
locale = loc; |
|
115 |
description = str; |
|
116 |
} |
|
117 |
|
|
118 |
public String toString() { |
|
119 |
return description; |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
public void storeValues() { |
|
124 |
// Se escribe el idioma |
|
125 |
LanguageItem sel = (LanguageItem) cmbIdioma.getSelectedItem(); |
|
126 |
Launcher.getAndamiConfig().setLocaleLanguage(sel.locale.getLanguage()); |
|
127 |
Launcher.getAndamiConfig().setLocaleCountry(sel.locale.getCountry()); |
|
128 |
Launcher.getAndamiConfig().setLocaleVariant(sel.locale.getVariant()); |
|
129 |
langIndex = getJComboBox().getSelectedIndex(); |
|
130 |
|
|
131 |
} |
|
132 |
|
|
133 |
public void initializeDefaults() { |
|
134 |
getJComboBox().setSelectedItem(DEFAULT_LANGUAGE); |
|
135 |
} |
|
136 |
|
|
137 |
public ImageIcon getIcon() { |
|
138 |
return icon; |
|
139 |
} |
|
140 |
|
|
141 |
/** |
|
142 |
* This method initializes pN |
|
143 |
* |
|
144 |
* @return javax.swing.JPanel |
|
145 |
*/ |
|
146 |
private JPanel getPN() { |
|
147 |
if (pN == null) { |
|
148 |
pN = new JPanel(); |
|
149 |
} |
|
150 |
return pN; |
|
151 |
} |
|
152 |
|
|
153 |
/** |
|
154 |
* This method initializes pC |
|
155 |
* |
|
156 |
* @return javax.swing.JPanel |
|
157 |
*/ |
|
158 |
private JPanel getPC() { |
|
159 |
if (pC == null) { |
|
160 |
pC = new JPanel(); |
|
161 |
pC.add(getJPanel(), null); |
|
162 |
} |
|
163 |
return pC; |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* This method initializes pS |
|
168 |
* |
|
169 |
* @return javax.swing.JPanel |
|
170 |
*/ |
|
171 |
private JPanel getPS() { |
|
172 |
if (pS == null) { |
|
173 |
pS = new JPanel(); |
|
174 |
pS.add(getLabel(),BorderLayout.SOUTH); |
|
175 |
} |
|
176 |
return pS; |
|
177 |
} |
|
178 |
|
|
179 |
|
|
180 |
/** |
|
181 |
* This method initializes jPanel |
|
182 |
* |
|
183 |
* @return javax.swing.JPanel |
|
184 |
*/ |
|
185 |
private JPanel getJPanel() { |
|
186 |
if (jPanel == null) { |
|
187 |
jPanel = new JPanel(); |
|
188 |
jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, |
|
189 |
PluginServices.getText(this,"idioma"), |
|
190 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
|
191 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, |
Also available in: Unified diff