Revision 9048

View differences:

branches/v10/libraries/libRemoteServices/src/org/gvsig/remoteClient/RemoteClient.java
5 5

  
6 6
/**
7 7
 * <p></p>
8
 * 
8
 *
9 9
 */
10 10
public abstract class RemoteClient {
11 11

  
12 12
/**
13 13
 * <p>Represents ...</p>
14
 * 
14
 *
15 15
 */
16 16
    protected String hostName;
17 17

  
18 18
/**
19 19
 * <p>Represents ...</p>
20
 * 
20
 *
21 21
 */
22 22
    protected int port;
23 23

  
24 24
/**
25 25
 * <p>Represents ...</p>
26
 * 
26
 *
27 27
 */
28 28
    protected String serviceName;
29 29

  
30 30
/**
31 31
 * <p>Represents ...</p>
32
 * 
32
 *
33 33
 */
34 34
    private String type;
35 35

  
36 36
/**
37 37
 * <p>Represents ...</p>
38
 * 
38
 *
39 39
 */
40 40
    private String subtype;
41 41

  
42 42
/**
43 43
 * <p>Represents ...</p>
44
 * 
45
 * 
46
 * @return 
44
 *
45
 *
46
 * @return
47 47
 */
48
    public String getHost() {        
48
    public String getHost() {
49 49
        return hostName;
50
    } 
50
    }
51 51

  
52 52
/**
53 53
 * <p>Represents ...</p>
54
 * 
55
 * 
56
 * @param _hostName 
54
 *
55
 *
56
 * @param _hostName
57 57
 */
58
    public void setHost(String _hostName) {        
58
    public void setHost(String _hostName) {
59 59
        hostName = _hostName;
60
    } 
60
    }
61 61

  
62 62
/**
63 63
 * <p>Represents ...</p>
64
 * 
65
 * 
66
 * @return 
64
 *
65
 *
66
 * @return
67 67
 */
68
    public int getPort() {        
68
    public int getPort() {
69 69
        // your code here
70 70
        return port;
71
    } 
71
    }
72 72

  
73 73
/**
74 74
 * <p>Does ...</p>
75
 * 
76
 * 
77
 * @param _port 
75
 *
76
 *
77
 * @param _port
78 78
 */
79
    public void setPort(int _port) {        
79
    public void setPort(int _port) {
80 80
        port = _port;
81
    } 
81
    }
82 82

  
83 83
/**
84 84
 * <p>Does ...</p>
85
 * 
86
 * 
87
 * @return 
85
 *
86
 *
87
 * @return
88 88
 */
89
    public String getServiceName() {        
89
    public String getServiceName() {
90 90
        // your code here
91 91
        return serviceName;
92
    } 
92
    }
93 93

  
94 94
/**
95 95
 * <p>Does ...</p>
96
 * 
97
 * 
98
 * @param _serviceName 
96
 *
97
 *
98
 * @param _serviceName
99 99
 */
100
    public void setServiceName(String _serviceName) {        
100
    public void setServiceName(String _serviceName) {
101 101
        serviceName = _serviceName;
102
    } 
102
    }
103 103

  
104 104
/**
105 105
 * <p>Does ...</p>
106
 * 
106
 *
107 107
 */
108
    public abstract boolean connect(ICancellable cancel);
108
    public abstract boolean connect(boolean override, ICancellable cancel);
109 109

  
110 110
/**
111 111
 * <p>Does ...</p>
112
 * 
112
 *
113 113
 */
114 114
    public abstract void close();
115 115

  
116 116
/**
117 117
 * <p>Represents ...</p>
118
 * 
119
 * 
120
 * @return 
118
 *
119
 *
120
 * @return
121 121
 */
122
    public String getType() {        
122
    public String getType() {
123 123
        return type;
124
    } 
124
    }
125 125

  
126 126
/**
127 127
 * <p>Represents ...</p>
128
 * 
129
 * 
130
 * @param _type 
128
 *
129
 *
130
 * @param _type
131 131
 */
132
    public void setType(String _type) {        
132
    public void setType(String _type) {
133 133
        type = _type;
134
    } 
134
    }
135 135

  
136 136
/**
137 137
 * <p>Represents ...</p>
138
 * 
139
 * 
140
 * @return 
138
 *
139
 *
140
 * @return
141 141
 */
142
    public String getSubtype() {        
142
    public String getSubtype() {
143 143
        return subtype;
144
    } 
144
    }
145 145

  
146 146
/**
147 147
 * <p>Represents ...</p>
148
 * 
149
 * 
150
 * @param _subtype 
148
 *
149
 *
150
 * @param _subtype
151 151
 */
152
    public void setSubtype(String _subtype) {        
152
    public void setSubtype(String _subtype) {
153 153
        subtype = _subtype;
154
    } 
154
    }
155 155
 }
branches/v10/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/WCSClient.java
86 86
    }
87 87

  
88 88
    /**
89
     * <p>Checks the connection to de remote WMS and requests its capabilities.</p>
89
     * @param override
90 90
     *
91 91
     */
92
    public boolean connect(ICancellable cancel)
92
    public boolean connect(boolean override, ICancellable cancel)
93 93
    {
94 94
        try {
95 95
            if (handler == null) {
......
101 101
                    return false;
102 102
                }
103 103
            }
104
            getCapabilities(null, cancel);
104
            getCapabilities(null, override, cancel);
105 105

  
106
            describeCoverage(null, cancel); //TODO falta posar el onlineresource del describe coverage
106
            describeCoverage(null, override, cancel); //TODO falta posar el onlineresource del describe coverage
107 107
            return true;
108 108

  
109 109
        } catch (Exception e) {
......
115 115
    /**
116 116
     * Sends a GetCapabilities request using the properties contained by
117 117
     * the status. If status is null, then it uses the default configuration.
118
     * @param override
118 119
     * @param WCSStatus, containing the status properties
119 120
     */
120
    private void getCapabilities(WCSStatus status, ICancellable cancel) {
121
        handler.getCapabilities(status, cancel);
121
    private void getCapabilities(WCSStatus status, boolean override, ICancellable cancel) {
122
        handler.getCapabilities(status, override, cancel);
122 123
    }
123 124

  
124 125
    /**
125 126
     * Sends a DescribeCoverage request using the properties contained by
126 127
     * the status.
128
     * @param override, if true the cache is ignored
127 129
     * @param WCSStatus, containing the status properties
128 130
     */
129
    private void describeCoverage(WCSStatus status, ICancellable cancel) {
130
        handler.describeCoverage(status, cancel);
131
    private void describeCoverage(WCSStatus status, boolean override, ICancellable cancel) {
132
        handler.describeCoverage(status, override, cancel);
131 133
        // check it was response or if we need to perform a specific DescribeCoverage for each coverage
132 134
        Hashtable layers = handler.getLayers();
133 135
        Iterator it = layers.keySet().iterator();
......
137 139
        		if (status == null)
138 140
        			status = new WCSStatus();
139 141
        		status.setCoveraName( ((CoverageOfferingBrief) obj).getName());
140
        		handler.describeCoverage(status, cancel);
142
        		handler.describeCoverage(status, override, cancel);
141 143
        	}
142 144
        }
143 145

  
branches/v10/libraries/libRemoteServices/src/org/gvsig/remoteClient/wcs/WCSProtocolHandler.java
83 83
     * the response will be parse to extract the data needed by the
84 84
     * WCS client.
85 85
     * </p>
86
     * @param override, if true the cache is ignored
86 87
     */
87
    public void getCapabilities(WCSStatus status, ICancellable cancel) {
88
    public void getCapabilities(WCSStatus status, boolean override, ICancellable cancel) {
88 89
           URL request = null;
89 90
            try {
90 91
                request = new URL(buildCapabilitiesRequest(status));
......
93 94
                e.printStackTrace();
94 95
            }
95 96
            try {
97
            	if (override)
98
    				Utilities.removeURL(request);
96 99
            	File f =  Utilities.downloadFile(request,"wcs_capabilities.xml", cancel);
97 100
            	if (f!=null)
98 101
            		parseCapabilities(f);
......
155 158
    /**
156 159
     * Send a DescribeCoverage request using the settings passed in the status argument.
157 160
     * If status is null, then default settings are used.
161
     * @param override
158 162
     * @return String
159 163
     */
160
    public void describeCoverage(WCSStatus status, ICancellable cancel) {
164
    public void describeCoverage(WCSStatus status, boolean override, ICancellable cancel) {
161 165
        URL request = null;
162 166
        try {
163 167
            request = new URL(buildDescribeCoverageRequest(status));
......
166 170
            e.printStackTrace();
167 171
        }
168 172
        try {
173
        	if (override)
174
				Utilities.removeURL(request);
169 175
        	File f = Utilities.downloadFile(request, "wcs_describeCoverage.xml", cancel);
170 176
        	if (f!=null)
171 177
        		parseDescribeCoverage(f);
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/fmap/drivers/wcs/FMapWCSDriver.java
79 79
	private Hashtable coverages;
80 80
	private WCSLayer[] layerList;
81 81

  
82
	
83 82

  
83

  
84 84
	/**
85 85
	 * Obtains the host name.
86 86
	 *
......
264 264
	 * request (not a coverage-specific DescribeCoverage request) to read the
265 265
	 * necessary data for building further GetCoverage requests.
266 266
	 * </p>
267
	 * @param override
267 268
	 * @throws IOException, DriverException.
268 269
	 */
269
	public boolean connect(ICancellable cancel) throws IOException, DriverException {
270
	public boolean connect(boolean override, ICancellable cancel) throws IOException, DriverException {
271
		coverages = null;
270 272
		setHost(client.getHost());
271
		return client.connect(cancel);
273
		return client.connect(override, cancel);
272 274
	}
273 275

  
274 276
	/**
......
363 365
			throw new WCSException(e.getMessage());
364 366
		}
365 367
	}
366

  
367
	/**
368
     * Creates a new instance of a WCSClient.
369
     * @param host
370
     * @throws IOException
371
     * @throws ConnectException
372
     */
373
	public void createClient(URL host) throws ConnectException, IOException{
374
		client = new WCSClient(host.toString());
375
	}
376 368
}
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/fmap/layers/FLyrWCS.java
170 170
		}
171 171

  
172 172
		try{
173
			if (!drv.connect(null)){
173
			if (!drv.connect(false, null)){
174 174
				throw new DriverIOException("Can't connect to host '" + host + "'.");
175 175
			}
176 176
		}catch(Exception e){
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/gui/wcs/WCSWizard.java
44 44
import java.awt.geom.Rectangle2D;
45 45
import java.net.MalformedURLException;
46 46
import java.net.URL;
47
import java.util.prefs.Preferences;
47 48

  
48 49
import javax.swing.DefaultComboBoxModel;
50
import javax.swing.JCheckBox;
49 51
import javax.swing.JLabel;
50 52
import javax.swing.JPanel;
51 53
import javax.swing.JScrollPane;
......
88 90
	private WCSParamsPanel wcsParamsPanel = null;
89 91
	private WCSWizardData dataSource = null;
90 92
	private JPanel pnlName;
93
	private static Preferences fPrefs = Preferences.userRoot().node( "gvsig.wcs-wizard" );
94
	private boolean refreshing = fPrefs.getBoolean("refresh_capabilities", false);
95
	private JCheckBox chkCaching;
91 96

  
92 97
	/**
93 98
	 * This is the default constructor
......
158 163
		try {
159 164
			String host = cmbHost.getModel().getSelectedItem().toString();
160 165

  
161
			dataSource.setHost(new URL(host));
166
			dataSource.setHost(new URL(host), refreshing);
162 167

  
163 168
			addHost(host);
164 169
			getLblTitle().setText(dataSource.getTitle());
......
358 363

  
359 364
		return txtAbstract;
360 365
	}
366
	/**
367
	 * This method initializes chkCaching
368
	 *
369
	 * @return javax.swing.JCheckBox
370
	 */
371
	private JCheckBox getChkCaching() {
372
		if (chkCaching == null) {
373
			chkCaching = new JCheckBox();
374
			chkCaching.setBounds(7, 51, 349, 20);
375
			chkCaching.setText(PluginServices.getText(this, "refresh_capabilities"));
376
			chkCaching.setToolTipText(PluginServices.getText(this, "refresh_capabilities_tooltip"));
377
			chkCaching.setSelected(refreshing);
378
			chkCaching.addItemListener(new java.awt.event.ItemListener() {
379
				public void itemStateChanged(java.awt.event.ItemEvent e) {
380
					refreshing = chkCaching.isSelected();
381
				}
382
			});
383
			chkCaching.addActionListener(new java.awt.event.ActionListener() {
384
				public void actionPerformed(java.awt.event.ActionEvent e) {
385
					fPrefs.putBoolean("refresh_capabilities", chkCaching.isSelected());
386
				}
387
			});
361 388

  
389
		}
390
		return chkCaching;
391
	}
392

  
362 393
	/**
363 394
	 * This method initializes panelPage1
364 395
	 *
......
373 404
			panelPage1.setBounds(15, 5, 480, 427);
374 405
			panelPage1.add(getJPanel1(), null);
375 406
			panelPage1.add(getJPanel(), null);
407
			jPanel1.add(getChkCaching(), null);
376 408
		}
377 409

  
378 410
		return panelPage1;
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/gui/wcs/WCSWizardData.java
73 73
	private WCSLayer[] coverageList;
74 74

  
75 75

  
76
    public void setHost(URL host) throws DriverException{
76
    public void setHost(URL host, boolean override) throws DriverException{
77 77
        try {
78 78
        	wcs = FMapWCSDriverFactory.getFMapDriverForURL(host);
79 79

  
80 80
			//wcs.createClient(host);
81 81

  
82 82
        // Send getCapabilities and describe coverage request;
83
		if (!wcs.connect(null))
84
            throw new DriverException(PluginServices.getText(this, "wcs_cant_connect") + host.toString());
83
        	if (!wcs.connect(override, null))
84
        		throw new DriverException(PluginServices.getText(this, "wcs_cant_connect") + host.toString());
85 85
        } catch (ConnectException e) {
86 86
        	JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"wcs_server_timeout"));
87 87
			return;
branches/v10/extensions/extWCS/src/com/iver/cit/gvsig/gui/dialog/WCSPropsDialog.java
65 65

  
66 66
/**
67 67
 *  The TOC WCS properties panel container.
68
 *  
68
 *
69 69
 * @author jaume - jaume.dominguez@iver.es
70 70
 *
71 71
 */
......
76 76
	private FLayer fLayer = null;
77 77
	boolean applied;
78 78
	private WindowInfo m_ViewInfo = null;
79
	
79

  
80 80
	private JButton btnApply = null;
81 81
	private JButton btnOk = null;
82 82
	private JButton btnCancel = null;
......
85 85

  
86 86
    /**
87 87
     * Creates a new instance of WCSPropsDialog
88
     * @param layer, 
88
     * @param layer,
89 89
     */
90 90
    public WCSPropsDialog(FLyrWCS layer) {
91 91
		super();
92 92
		initialize(layer);
93 93
	}
94
    
95
    
94

  
95

  
96 96
	private void initialize(FLyrWCS layer) {
97 97
		setBounds(0,0,500,333);
98 98
        setLayout(null);
......
108 108

  
109 109
			public void error(Exception e) {
110 110
			}
111
        	
112
        })  ; 
113
        
111

  
112
        })  ;
113

  
114 114
        this.add(wcsParamsTabbedPane);
115
		this.add(getButtonsPanel(), null);        
115
		this.add(getButtonsPanel(), null);
116 116
	}
117
	
118 117

  
118

  
119 119
	public void setFLayer(FLayer f) {
120 120
		fLayer = f;
121 121
	}
......
126 126
	 * recovered) it is been automatically constructed by connecting to the server,
127 127
	 * reloading the necessary data, filling up the content and setting the selected
128 128
	 * values that were selected when the projet was saved.
129
	 * 
129
	 *
130 130
	 * Since a connection to the server is needed when rebuiliding the panel, this
131 131
	 * causes a delay for the panel's showing up or a nullPointer error if there is
132 132
	 * no path to the server.
133
	 * 
134
	 * 
133
	 *
134
	 *
135 135
	 * Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
136 136
	 * de la cobertura. Si este panel todav?a no existe (como puede ser cuando
137 137
	 * recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
138 138
	 * al servidor, recuperando los datos necesarios, rellenando el contenido y
139 139
	 * dejando seleccionados los valores que estaban seleccionados cuando se
140 140
	 * guard? el proyecto.
141
	 * 
141
	 *
142 142
	 * Como para reconstruirse requiere una conexi?n con el servidor esto causa
143 143
	 * un retardo en la aparici?n en el toc o un error de nullPointer si no
144 144
	 * hay conexi?n hasta el servidor.
145
	 * 
145
	 *
146 146
	 * @return WCSParamsPanel
147 147
	 */
148 148
	public WCSParamsPanel getParamsPanel(Hashtable info) {
149 149
		try {
150
			
150

  
151 151
			URL host = (URL) info.get("host");
152 152
			WCSWizardData dataSource = new WCSWizardData();
153
			dataSource.setHost(host);
154
			
153
			dataSource.setHost(host, false);
154

  
155 155
			WCSParamsPanel toc = new WCSParamsPanel();
156 156
			toc.setVisible(true);
157 157
			toc.setListenerSupport(new WizardListenerSupport());
158
			
158

  
159 159
			toc.setDataSource(dataSource);
160
			
160

  
161 161
			toc.getLstCoverages().setListData(dataSource.getCoverageList());
162
			
162

  
163 163
			String coverageName = (String) info.get("name");
164 164
			int index = toc.getCoverageIndex( coverageName );
165 165
			if (index != -1)
166 166
				toc.getLstCoverages().setSelectedIndex(index);
167
			
167

  
168 168
			toc.refreshData();
169
			
169

  
170 170
			index = toc.getSRSIndex((String) info.get("crs") );
171 171
			if (index != -1)
172 172
				toc.getLstCRSs().setSelectedIndex(index);
......
180 180
			if (!parameter.equals("")){
181 181
				String[] s = parameter.split("=");
182 182
				String pName = s[0];
183
				
183

  
184 184
				String regexDouble = "-?[0-9]+(\\.[0-9]+)?";
185 185
				String regexInterval = regexDouble+"/"+regexDouble;
186 186
				String regexIntervalList = regexInterval+"(,"+regexInterval+")*";
......
188 188
					// Single Interval
189 189
					toc.getJScrollPane5().setVisible(false);
190 190
					toc.getSingleParamValuesList().setEnabled(false);
191
					
192
				
191

  
192

  
193 193
				} else if (s[1].matches(regexIntervalList)){
194 194
					// Multiple Interval
195
					
195

  
196 196
				} else {
197 197
					// Single values
198 198
					toc.getJScrollPane5().setVisible(true);
199 199
					toc.getSingleParamValuesList().setEnabled(true);
200
					
200

  
201 201
					String[] pVals = s[1].split(",");
202
					index = toc.getParamIndex(pName); 
202
					index = toc.getParamIndex(pName);
203 203
					toc.getCmbParam().setSelectedIndex(index);
204 204
					//toc.refreshParamValues( coverageName );
205 205
					int[] indexes = new int[pVals.length];
206 206
					for (int i = 0; i < pVals.length; i++) {
207 207
						indexes[i] = toc.getValueIndex(pVals[i]);
208 208
					}
209
					
209

  
210 210
					toc.getSingleParamValuesList().setSelectedIndices(indexes);
211 211
				}
212
			}	
212
			}
213 213
			toc.refreshInfo();
214 214
			return toc;
215 215
		} catch (DriverException soe) {
......
219 219
		}
220 220
		return null;
221 221
	}
222
	
222

  
223 223
	public JPanel getButtonsPanel() {
224 224
		if (buttonsPanel == null) {
225 225
			m_actionListener = new ComandosListener(this);
226 226
			buttonsPanel = new JPanel();
227 227
	        buttonsPanel.setBounds(5, wcsParamsTabbedPane.getHeight(), 471, 40);
228
			buttonsPanel.setLayout(null);     
228
			buttonsPanel.setLayout(null);
229 229
			buttonsPanel.setName("buttonPanel");
230
			
230

  
231 231
	        buttonsPanel.add(getBtnOk(), null);
232 232
	        buttonsPanel.add(getBtnApply(), null);
233 233
	        buttonsPanel.add(getBtnCancel(), null);
234 234
		}
235 235
		return buttonsPanel;
236 236
	}
237
	
237

  
238 238
	public JButton getBtnOk() {
239 239
		if (btnOk == null) {
240 240
	        btnOk = new JButton("Ok");
......
245 245
		}
246 246
		return btnOk;
247 247
	}
248
	
248

  
249 249
	public JButton getBtnApply() {
250 250
		if (btnApply == null) {
251 251
	        btnApply = new JButton("Apply");
......
257 257
		}
258 258
		return btnApply;
259 259
	}
260
	
260

  
261 261
	public JButton getBtnCancel() {
262 262
		if (btnCancel == null) {
263 263
	        btnCancel = new JButton("Cancel");
......
268 268
		}
269 269
		return btnCancel;
270 270
	}
271
	
271

  
272 272
    private class ComandosListener implements ActionListener {
273 273
        private WCSPropsDialog m_tp;
274 274

  
......
289 289
				close();
290 290
			} else {
291 291
				applied = false;
292
				
292

  
293 293
            	((FLyrWCS) fLayer).setCoverageName(wcsParamsTabbedPane.getCurrentCoverageName());
294 294
            	((FLyrWCS) fLayer).setName(wcsParamsTabbedPane.getCoverageName());
295 295
            	((FLyrWCS) fLayer).setSRS(wcsParamsTabbedPane.getSRS());
......
297 297
            	((FLyrWCS) fLayer).setFullExtent(wcsParamsTabbedPane.getExtent());
298 298
            	((FLyrWCS) fLayer).setTime(wcsParamsTabbedPane.getTime());
299 299
            	((FLyrWCS) fLayer).setParameter(wcsParamsTabbedPane.getParameterString());
300
            	
300

  
301 301
            	if (e.getActionCommand() == "APPLY") {
302 302
            		com.iver.cit.gvsig.project.documents.view.gui.View vista = (com.iver.cit.gvsig.project.documents.view.gui.View) PluginServices.getMDIManager().getActiveWindow();
303 303
            		MapControl mapCtrl = vista.getMapControl();
......
305 305
            		applied = true;
306 306
            		getBtnApply().setEnabled(!applied);
307 307
            	}
308
            	
308

  
309 309
            	if (e.getActionCommand() == "OK") {
310 310
            		if (!applied) {
311 311
            			com.iver.cit.gvsig.project.documents.view.gui.View vista = (com.iver.cit.gvsig.project.documents.view.gui.View) PluginServices.getMDIManager().getActiveWindow();
......
317 317
             }
318 318
		}
319 319
    }
320
    
320

  
321 321
	public WindowInfo getWindowInfo() {
322 322
		if (m_ViewInfo==null){
323 323
			m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
......
327 327
		}
328 328
		return m_ViewInfo;
329 329
	}
330
	
330

  
331 331
	public void viewActivated() {
332 332
	}
333 333

  
......
340 340
			dlg.setBounds(bnds);
341 341
			dlg.setSize(getSize());
342 342
			dlg.getContentPane().add(this);
343
			dlg.setModal(true);			
343
			dlg.setModal(true);
344 344
			dlg.pack();
345 345
			dlg.show();
346 346
		} else
347 347
			PluginServices.getMDIManager().addWindow(this);
348 348
	}
349
	
349

  
350 350
	public void close() {
351
		PluginServices.getMDIManager().closeWindow(this);		
351
		PluginServices.getMDIManager().closeWindow(this);
352 352
	}
353 353

  
354 354
}

Also available in: Unified diff