svn-gvsig-desktop / branches / piloto3d / libraries / libCorePlugin / src / com / iver / core / preferences / network / NetworkPage.java @ 9588
History | View | Annotate | Download (5.54 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 | 9588 | jcampos | * Revision 1.7.2.3 2007-01-08 13:39:07 jcampos
|
47 | * Syncronize with V10
|
||
48 | 9522 | sbayarri | *
|
49 | * Revision 1.7.4.2 2006/11/15 00:08:23 jjdelcerro
|
||
50 | * *** empty log message ***
|
||
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 | 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 | package com.iver.core.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 com.iver.andami.PluginServices; |
||
113 | import com.iver.andami.preferences.AbstractPreferencePage; |
||
114 | 6152 | jaume | import com.iver.andami.ui.mdiFrame.JToolBarButton; |
115 | 5792 | caballero | |
116 | /**
|
||
117 | * General network connection page.
|
||
118 | *
|
||
119 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
120 | *
|
||
121 | */
|
||
122 | public class NetworkPage extends AbstractPreferencePage { |
||
123 | 6805 | jaume | //private static Preferences prefs = Preferences.userRoot().node( "gvsig.connection" );
|
124 | 5792 | caballero | private ImageIcon icon; |
125 | private JLabel lblNetworkStatus; |
||
126 | 6152 | jaume | private JToolBarButton btnRefresh;
|
127 | 5792 | caballero | protected static String id; |
128 | |||
129 | public NetworkPage() {
|
||
130 | super();
|
||
131 | id = this.getClass().getName();
|
||
132 | icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/network.png")); |
||
133 | 6575 | jaume | lblNetworkStatus = new JLabel(); |
134 | lblNetworkStatus.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12)); |
||
135 | lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection")); |
||
136 | |||
137 | JPanel aux = new JPanel(); |
||
138 | aux.add(getBtnCheckConnection()); |
||
139 | 9522 | sbayarri | addComponent(PluginServices.getText(this, "options.network.status") + ":", lblNetworkStatus ); |
140 | addComponent("", aux);
|
||
141 | |||
142 | 5792 | caballero | } |
143 | |||
144 | 6152 | jaume | private JToolBarButton getBtnCheckConnection() {
|
145 | 5792 | caballero | if (btnRefresh == null) { |
146 | 6152 | jaume | btnRefresh = new JToolBarButton(PluginServices.getText(this, "test_now")); |
147 | 5792 | caballero | btnRefresh.addActionListener(new ActionListener() { |
148 | public void actionPerformed(java.awt.event.ActionEvent e) { |
||
149 | refreshStatus(); |
||
150 | }; |
||
151 | }); |
||
152 | } |
||
153 | return btnRefresh;
|
||
154 | } |
||
155 | |||
156 | private void refreshStatus() { |
||
157 | boolean connected = isConnected();
|
||
158 | ImageIcon statusIcon;
|
||
159 | String statusText;
|
||
160 | if (connected) {
|
||
161 | statusIcon = new ImageIcon(this.getClass().getClassLoader().getResource("images/kde-network-online.png")) ; |
||
162 | statusText = PluginServices.getText(this, "online"); |
||
163 | } else {
|
||
164 | statusIcon = new ImageIcon(this.getClass().getClassLoader().getResource("images/kde-network-offline.png")); |
||
165 | statusText = PluginServices.getText(this, "offline"); |
||
166 | } |
||
167 | lblNetworkStatus.setIcon(statusIcon); |
||
168 | lblNetworkStatus.setText(statusText); |
||
169 | |||
170 | } |
||
171 | |||
172 | private boolean isConnected() { |
||
173 | try {
|
||
174 | URL url = new URL("http://www.google.com"); |
||
175 | url.openConnection(); |
||
176 | url.openStream(); |
||
177 | return true; |
||
178 | } catch (Exception e) { |
||
179 | return false; |
||
180 | } |
||
181 | |||
182 | } |
||
183 | |||
184 | public String getID() { |
||
185 | return id;
|
||
186 | } |
||
187 | |||
188 | public String getTitle() { |
||
189 | return PluginServices.getText(this, "pref.network"); |
||
190 | } |
||
191 | |||
192 | public JPanel getPanel() { |
||
193 | return this; |
||
194 | } |
||
195 | |||
196 | |||
197 | public void initializeValues() { |
||
198 | 6575 | jaume | |
199 | |||
200 | 5792 | caballero | } |
201 | |||
202 | 6662 | caballero | public void storeValues() { |
203 | 6810 | jaume | |
204 | 5792 | caballero | } |
205 | |||
206 | public void initializeDefaults() { |
||
207 | 6575 | jaume | // nothing
|
208 | } |
||
209 | 5792 | caballero | |
210 | class ActionHandler implements ActionListener { |
||
211 | public void actionPerformed(ActionEvent evt) { |
||
212 | |||
213 | } |
||
214 | } |
||
215 | |||
216 | public ImageIcon getIcon() { |
||
217 | return icon;
|
||
218 | } |
||
219 | |||
220 | 6805 | jaume | public boolean isValueChanged() { |
221 | return hasChanged();
|
||
222 | } |
||
223 | 6575 | jaume | |
224 | 6810 | jaume | public void setChangesApplied() { |
225 | setChanged(false);
|
||
226 | } |
||
227 | 6805 | jaume | |
228 | 6810 | jaume | |
229 | 5792 | caballero | } |