root / branches / v2_0_0_prep / libraries / libCorePlugin / src / org / gvsig / coreplugin / preferences / network / NetworkPage.java @ 38564
History | View | Annotate | Download (5.58 KB)
1 | 5792 | caballero | /* 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 | 14808 | jmvivo | * Revision 1.10 2007/09/19 16:16:52 jaume
|
47 | 13881 | jaume | * removed unnecessary imports
|
48 | *
|
||
49 | * Revision 1.9 2006/11/20 17:29:43 fjp
|
||
50 | 8884 | fjp | * Fallo proxy con usuario y contrase?a
|
51 | *
|
||
52 | * Revision 1.8 2006/09/12 10:11:25 jaume
|
||
53 | 7204 | jaume | * *** 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 | 6810 | jaume | * improved perfomance when saving changes
|
60 | *
|
||
61 | * Revision 1.6 2006/08/22 07:37:17 jaume
|
||
62 | 6805 | jaume | * *** empty log message ***
|
63 | *
|
||
64 | * Revision 1.5 2006/08/04 11:45:12 caballero
|
||
65 | 6662 | caballero | * lanzo una excepci?n cuando falla el m?todo storeValues
|
66 | *
|
||
67 | * Revision 1.4 2006/07/31 10:02:31 jaume
|
||
68 | 6152 | jaume | * *** empty log message ***
|
69 | *
|
||
70 | 6575 | jaume | * Revision 1.3 2006/07/03 10:46:01 jaume
|
71 | * *** empty log message ***
|
||
72 | *
|
||
73 | 6152 | jaume | * Revision 1.2 2006/06/13 07:43:08 fjp
|
74 | 5804 | fjp | * Ajustes sobre los cuadros de dialogos de preferencias
|
75 | *
|
||
76 | * Revision 1.1 2006/06/12 16:04:28 caballero
|
||
77 | 5792 | caballero | * 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 | 29630 | jpiera | package org.gvsig.coreplugin.preferences.network; |
103 | 5792 | caballero | |
104 | 38215 | cordinyana | import java.awt.Font; |
105 | 5792 | caballero | import java.awt.event.ActionEvent; |
106 | import java.awt.event.ActionListener; |
||
107 | import java.net.URL; |
||
108 | |||
109 | import javax.swing.ImageIcon; |
||
110 | import javax.swing.JLabel; |
||
111 | import javax.swing.JPanel; |
||
112 | |||
113 | 29630 | jpiera | import org.gvsig.andami.PluginServices; |
114 | import org.gvsig.andami.preferences.AbstractPreferencePage; |
||
115 | import org.gvsig.andami.ui.mdiFrame.JToolBarButton; |
||
116 | 5792 | caballero | |
117 | 29630 | jpiera | |
118 | 5792 | caballero | /**
|
119 | * General network connection page.
|
||
120 | *
|
||
121 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
122 | *
|
||
123 | */
|
||
124 | public class NetworkPage extends AbstractPreferencePage { |
||
125 | 6805 | jaume | //private static Preferences prefs = Preferences.userRoot().node( "gvsig.connection" );
|
126 | 5792 | caballero | private ImageIcon icon; |
127 | private JLabel lblNetworkStatus; |
||
128 | 6152 | jaume | private JToolBarButton btnRefresh;
|
129 | 5792 | caballero | protected static String id; |
130 | |||
131 | 14808 | jmvivo | |
132 | 5792 | caballero | public NetworkPage() {
|
133 | super();
|
||
134 | id = this.getClass().getName();
|
||
135 | 14808 | jmvivo | // icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/network.png"));
|
136 | 38564 | jjdelcerro | icon=PluginServices.getIconTheme().get("edit-setup-network");
|
137 | 6575 | jaume | lblNetworkStatus = new JLabel(); |
138 | 38215 | cordinyana | lblNetworkStatus.setFont(lblNetworkStatus.getFont().deriveFont(Font.BOLD));
|
139 | 6575 | jaume | lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection")); |
140 | JPanel aux = new JPanel(); |
||
141 | aux.add(getBtnCheckConnection()); |
||
142 | 7204 | jaume | addComponent(PluginServices.getText(this, "options.network.status") + ":", lblNetworkStatus ); |
143 | addComponent("", aux);
|
||
144 | |||
145 | 5792 | caballero | } |
146 | |||
147 | 6152 | jaume | private JToolBarButton getBtnCheckConnection() {
|
148 | 5792 | caballero | if (btnRefresh == null) { |
149 | 6152 | jaume | btnRefresh = new JToolBarButton(PluginServices.getText(this, "test_now")); |
150 | 5792 | caballero | 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 | 15635 | jmvivo | statusIcon = PluginServices.getIconTheme().get("kde-network-online-icon") ;
|
165 | 5792 | caballero | statusText = PluginServices.getText(this, "online"); |
166 | } else {
|
||
167 | 15635 | jmvivo | statusIcon = PluginServices.getIconTheme().get("kde-network-offline-icon");
|
168 | 5792 | caballero | 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 | 6575 | jaume | |
202 | |||
203 | 5792 | caballero | } |
204 | |||
205 | 6662 | caballero | public void storeValues() { |
206 | 6810 | jaume | |
207 | 5792 | caballero | } |
208 | |||
209 | public void initializeDefaults() { |
||
210 | 6575 | jaume | // nothing
|
211 | } |
||
212 | 5792 | caballero | |
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 | 6805 | jaume | public boolean isValueChanged() { |
224 | return hasChanged();
|
||
225 | } |
||
226 | 6575 | jaume | |
227 | 6810 | jaume | public void setChangesApplied() { |
228 | setChanged(false);
|
||
229 | } |
||
230 | 6805 | jaume | |
231 | 6810 | jaume | |
232 | 5792 | caballero | } |