Revision 183

View differences:

org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.wmsclient/src/main/java/org/gvsig/raster/app/extension/wmsclient/gui/dialog/WMSPropsDialog.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.app.extension.wmsclient.gui.dialog;
24

  
25
import java.awt.Component;
26
import java.awt.Dimension;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.net.URL;
30
import java.util.HashMap;
31
import java.util.Vector;
32

  
33
import javax.swing.JButton;
34
import javax.swing.JDialog;
35
import javax.swing.JOptionPane;
36
import javax.swing.JPanel;
37
import javax.swing.tree.TreePath;
38

  
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.ui.mdiManager.IWindow;
41
import org.gvsig.andami.ui.mdiManager.WindowInfo;
42
import org.gvsig.app.gui.wizards.WizardListener;
43
import org.gvsig.app.gui.wizards.WizardListenerSupport;
44
import org.gvsig.fmap.dal.coverage.dataset.io.wms.WMSLayerNode;
45
import org.gvsig.fmap.dal.coverage.store.RasterStoreParameters;
46
import org.gvsig.fmap.dal.coverage.store.remote.RemoteRasterServiceStore;
47
import org.gvsig.fmap.mapcontext.exceptions.ConnectionErrorLayerException;
48
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException;
49
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
50
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
51
import org.gvsig.fmap.mapcontext.exceptions.NameLayerException;
52
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
53
import org.gvsig.fmap.mapcontext.exceptions.TypeLayerException;
54
import org.gvsig.fmap.mapcontext.exceptions.URLLayerException;
55
import org.gvsig.fmap.mapcontext.exceptions.UnsupportedVersionLayerException;
56
import org.gvsig.fmap.mapcontext.layers.FLayer;
57
import org.gvsig.fmap.mapcontext.layers.FLayers;
58
import org.gvsig.fmap.mapcontrol.MapControl;
59
import org.gvsig.raster.app.extension.wmsclient.gui.panel.WMSParamsPanel;
60
import org.gvsig.raster.app.extension.wmsclient.gui.wizard.LayerTreeModel;
61
import org.gvsig.raster.app.extension.wmsclient.layer.FLyrWMS;
62
import org.gvsig.raster.fmap.layers.FLyrRaster;
63

  
64

  
65
/**
66
 * The TOC WMS properties panel container.
67
 *
68
 * @author jaume - jaume.dominguez@iver.es
69
 *
70
 */
71
public class WMSPropsDialog extends JPanel implements IWindow {
72

  
73
	private static final long serialVersionUID    = 1L;
74
	JDialog                   dlg                 = null;  
75
	private JPanel            buttonsPanel        = null;
76
	private FLyrRaster        fLayer              = null;
77
	boolean                   applied             = false;;
78
	private WindowInfo        m_ViewInfo          = null;
79

  
80
	private JButton           btnApply            = null;
81
	private JButton           btnOk               = null;
82
	private JButton           btnCancel           = null;
83
	private WMSParamsPanel    wmsParamsTabbedPane;
84
    private CommandListener   m_actionListener;
85

  
86
    public WMSPropsDialog(FLayer layer) {
87
		super();
88
		if(layer instanceof FLyrRaster)
89
			initialize((FLyrRaster)layer);
90
	}
91

  
92

  
93
	private void initialize(FLyrRaster layer) {
94
		setLayout(null);
95

  
96
        setFLayer(layer);
97
        wmsParamsTabbedPane = getParamsPanel(((FLyrWMS) layer).getProperties());
98
        wmsParamsTabbedPane.addWizardListener(new WizardListener(){
99
			public void wizardStateChanged(boolean finishable) {
100
				getBtnOk().setEnabled(finishable);
101
				getBtnApply().setEnabled(finishable);
102
			}
103

  
104
			public void error(Exception e) {
105
			}
106

  
107
        })  ;
108
        wmsParamsTabbedPane.disableDisagregatedLayers();
109
        this.add(wmsParamsTabbedPane);
110
        this.add(getButtonsPanel(), null);
111

  
112
	}
113

  
114

  
115
	public void setFLayer(FLyrRaster f) {
116
		fLayer = f;
117
	}
118

  
119
	/**
120
	 * With getParamsPanel we have access to the map config TabbedPane.
121
	 * If this panel doesn't exist yet (which can occur when an existing project is
122
	 * recovered) it is been automatically constructed by connecting to the server,
123
	 * reloading the necessary data, filling up the content and setting the selected
124
	 * values that were selected when the projet was saved.
125
	 *
126
	 *
127
	 * Since a connection to the server is needed when rebuiliding the panel, this
128
	 * causes a delay for the panel's showing up or a nullPointer error if there is
129
	 * no path to the server.
130
	 *
131
	 *
132
	 * Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
133
	 * del mapa. Si este panel todav?a no existe (como puede ser cuando
134
	 * recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
135
	 * al servidor, recuperando los datos necesarios, rellenando el contenido y
136
	 * dejando seleccionados los valores que estaban seleccionados cuando se
137
	 * guarda el proyecto.
138
	 *
139
	 *
140
	 * Como para reconstruirse requiere una conexi?n con el servidor esto causa
141
	 * un retardo en la aparici?n en el toc o un error de nullPointer si no
142
	 * hay conexi?n hasta el servidor.
143
	 *
144
	 *
145
	 * @return WMSParamsPanel
146
	 */
147
	@SuppressWarnings("unchecked")
148
	public WMSParamsPanel getParamsPanel(HashMap info) {
149
	    if (info != null) {
150
	        try {
151
	        	// host
152
                URL host = (URL) info.get("host");
153
                RemoteRasterServiceStore store = (RemoteRasterServiceStore)FLyrWMS.createDataStore(host.getHost(), fLayer.getProjection());
154
    			((RasterStoreParameters)store.getParameters()).setOverrideHost(false);
155
    			store.connect(null);
156

  
157
                // name
158
	            WMSParamsPanel toc = new WMSParamsPanel();
159
	            toc.setLayerName((String)info.get("name"));
160
	            toc.setWizardData(store);
161

  
162
	            toc.setVisible(true);
163
	            toc.setListenerSupport(new WizardListenerSupport());
164

  
165
                WMSLayerNode[] selectedLayers = (WMSLayerNode[]) ((Vector) info.get("selectedLayers")).toArray(new WMSLayerNode[0]);
166
	            for (int i = 0; i < selectedLayers.length; i++) {
167
	            	toc.getJustTreeLayer().clearSelection();
168
	            	//  Se a?ade a la lista de layers seleccionados
169
	            	TreePath path = new TreePath(((LayerTreeModel)toc.getJustTreeLayer()
170
	            						.getModel()).getNodeByName(selectedLayers[i].getName()));
171
	            	toc.getJustTreeLayer().addSelectionPath(path);
172
	            	toc.addLayer();
173
                }
174

  
175
                // srs
176
                String srs = (String) info.get("srs");
177
                int index = toc.getSRSIndex( srs );
178
	            if (index != -1) {
179
					toc.getLstSRSs().setSelectedIndex(index);
180
				}
181

  
182
                // format
183
	            String format = (String) info.get("format");
184
	            index = toc.getFormatIndex(format);
185
	            if (index != -1) {
186
					toc.getLstFormats().setSelectedIndex(index);
187
				}
188

  
189
	            // transparency
190
                toc.setTransparent(((Boolean) info.get("wmsTransparency")).booleanValue());
191

  
192
                // styles
193
                Vector v = (Vector) info.get("styles");
194
                if (v != null) {
195
					toc.setStyleSelections(v);
196
				}
197

  
198
                // dimensions
199
                v = (Vector) info.get("dimensions");
200
                if (v != null) {
201
					toc.setDimensions(v);
202
				}
203

  
204
                // fixed sizes
205
                Dimension sz = (Dimension) info.get("fixedSize");
206
                if (sz != null) {
207
					toc.setFixedSize(sz);
208
				}
209
                toc.refreshInfo();
210
                applied = false;
211
	            return toc;
212
	        } catch (Exception e) {
213
	        	JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE);
214
	        }
215
	    }
216
	    return null;
217
	}
218

  
219

  
220
	public JPanel getButtonsPanel() {
221
		if (buttonsPanel == null) {
222
			m_actionListener = new CommandListener(this);
223
			buttonsPanel = new JPanel();
224
	        buttonsPanel.setBounds(5, wmsParamsTabbedPane.getHeight(), 471, 40);
225
			buttonsPanel.setLayout(null);
226
			buttonsPanel.setName("buttonPanel");
227

  
228
	        buttonsPanel.add(getBtnOk(), null);
229
	        buttonsPanel.add(getBtnApply(), null);
230
	        buttonsPanel.add(getBtnCancel(), null);
231
		}
232
		return buttonsPanel;
233
	}
234

  
235
	public JButton getBtnOk() {
236
		if (btnOk == null) {
237
	        btnOk = new JButton("ok");
238
	        btnOk.setText(PluginServices.getText(this,"ok"));
239
	        btnOk.setActionCommand("OK");
240
	        btnOk.addActionListener(m_actionListener);
241
	        btnOk.setBounds(367, 9, 90, 25);
242
		}
243
		return btnOk;
244
	}
245

  
246
	public JButton getBtnApply() {
247
		if (btnApply == null) {
248
	        btnApply = new JButton("apply");
249
	        btnApply.setText(PluginServices.getText(this,"apply"));
250
	        btnApply.setEnabled(false);
251
	        btnApply.setActionCommand("APPLY");
252
	        btnApply.addActionListener(m_actionListener);
253
	        btnApply.setBounds(267, 9, 90, 25);
254
		}
255
		return btnApply;
256
	}
257

  
258
	public JButton getBtnCancel() {
259
		if (btnCancel == null) {
260
	        btnCancel = new JButton("cancel");
261
	        btnCancel.setText(PluginServices.getText(this,"cancel"));
262
	        btnCancel.setActionCommand("CANCEL");
263
	        btnCancel.addActionListener(m_actionListener);
264
	        btnCancel.setBounds(137, 9, 90, 25);
265
		}
266
		return btnCancel;
267
	}
268

  
269
    private class CommandListener implements ActionListener {
270

  
271
        /**
272
         * Creates a new ComandosListener object.
273
         *
274
         * @param lg DOCUMENT ME!
275
         */
276
        public CommandListener(WMSPropsDialog tp) {
277
            //m_tp = tp;
278
        }
279

  
280
		/* (non-Javadoc)
281
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
282
		 */
283
		@SuppressWarnings({ "deprecation", "unchecked" })
284
		public void actionPerformed(ActionEvent e) {
285
            if (e.getActionCommand() == "CANCEL") {
286
				close();
287
			} else {
288
            	try {
289
					((FLyrWMS) fLayer).setFullExtent(wmsParamsTabbedPane.getLayersRectangle());
290
				} catch (ProjectionLayerException ex) {
291
					ex.printStackTrace();
292
			        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), ex.getMessage());
293
			        return;
294
				}
295
				((FLyrWMS) fLayer).setFormat(wmsParamsTabbedPane.getFormat());
296
                try {
297
                if (!wmsParamsTabbedPane.getDisagregatedLayers()) {
298
					((FLyrWMS) fLayer).setLayerQuery(wmsParamsTabbedPane.getLayersQuery());
299
				}
300
                ((FLyrWMS) fLayer).setInfoLayerQuery(wmsParamsTabbedPane.getQueryableLayerQuery());
301
                ((FLyrWMS) fLayer).setSRS(wmsParamsTabbedPane.getSRS());
302
                ((FLyrWMS) fLayer).setName(wmsParamsTabbedPane.getLayerName());
303
                ((FLyrWMS) fLayer).setWmsTransparency(wmsParamsTabbedPane.getTransparency());
304
                ((FLyrWMS) fLayer).setStyles(wmsParamsTabbedPane.getStyles());
305
                ((FLyrWMS) fLayer).setDimensions(wmsParamsTabbedPane.getDimensions());
306
                ((FLyrWMS) fLayer).setFixedSize(wmsParamsTabbedPane.getFixedSize());
307

  
308
            	//fLayer = wmsParamsTabbedPane.getLayer();
309
            	FLayers parent = ((FLayer)fLayer).getParentLayer();
310

  
311
                if (e.getActionCommand() == "APPLY"){
312

  
313
                	org.gvsig.app.project.documents.view.gui.DefaultViewPanel vista = (org.gvsig.app.project.documents.view.gui.DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
314
                    MapControl mapCtrl = vista.getMapControl();
315

  
316
                    if (parent != null){
317
                    	if ( wmsParamsTabbedPane.getLayer() instanceof FLayers){
318

  
319
								mapCtrl.getMapContext().getLayers().
320
								replaceLayer(parent.getName(),mergeFLayers(parent,(FLayers)wmsParamsTabbedPane.getLayer()));
321

  
322
                    	}
323
                    }
324
                    else {
325
                    	mapCtrl.getMapContext().getLayers().replaceLayer(fLayer.getName(), wmsParamsTabbedPane.getLayer());
326
                    }
327
                    //mapCtrl.getMapContext().getLayers().addLayer( fLayer );
328
                    mapCtrl.getMapContext().invalidate();
329
                    applied = true;
330
                    getBtnApply().setEnabled(!applied);
331
                }
332
                if (e.getActionCommand() == "OK") {
333
                    if (!applied) {
334

  
335
                        org.gvsig.app.project.documents.view.gui.DefaultViewPanel vista = (org.gvsig.app.project.documents.view.gui.DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow();
336
                        MapControl mapCtrl = vista.getMapControl();
337

  
338
                        if (parent != null){
339
                        	if ( wmsParamsTabbedPane.getLayer() instanceof FLayers){
340
                        		mapCtrl.getMapContext().getLayers().
341
                        		replaceLayer(parent.getName(),mergeFLayers(parent,(FLayers)wmsParamsTabbedPane.getLayer()));
342
                        	}
343
                        }
344
                        else {
345
                        	mapCtrl.getMapContext().getLayers().replaceLayer(fLayer.getName(), wmsParamsTabbedPane.getLayer());
346
                        }                        mapCtrl.getMapContext().invalidate();
347
                    }
348
                    close();
349
                }
350
                } catch (ConnectionErrorLayerException e1) {
351
    				// TODO Auto-generated catch block
352
    				e1.printStackTrace();
353
    			} catch (DriverLayerException e1) {
354
    				// TODO Auto-generated catch block
355
    				e1.printStackTrace();
356
    			} catch (LegendLayerException e1) {
357
    				// TODO Auto-generated catch block
358
    				e1.printStackTrace();
359
    			} catch (NameLayerException e1) {
360
    				// TODO Auto-generated catch block
361
    				e1.printStackTrace();
362
    			} catch (ProjectionLayerException e1) {
363
    				// TODO Auto-generated catch block
364
    				e1.printStackTrace();
365
    			} catch (TypeLayerException e1) {
366
    				// TODO Auto-generated catch block
367
    				e1.printStackTrace();
368
    			} catch (UnsupportedVersionLayerException e1) {
369
    				// TODO Auto-generated catch block
370
    				e1.printStackTrace();
371
    			} catch (URLLayerException e1) {
372
    				// TODO Auto-generated catch block
373
    				e1.printStackTrace();
374
    			} catch (LoadLayerException e1) {
375
    				// TODO Auto-generated catch block
376
    				e1.printStackTrace();
377
    			}
378
            }
379
		}
380
    }
381
    /**
382
     * Merge two FLayers in one
383
     * @param group1
384
     * @param group2
385
     * @return
386
     */
387
    private FLayers mergeFLayers(FLayers group1, FLayers group2)
388
    {
389
    	//FLayers agrupation = new FLayers(group1.getFMap(), group1.getParentLayer());
390
    	FLayer layer;
391
    	for(int i = 0; i < group2.getLayersCount(); i++)
392
    	{
393
    		layer = group2.getLayer( i );
394
    		if(group1.getLayer( layer.getName()) == null ){
395
    			group1.addLayer( layer );
396
    		}
397
    	}
398

  
399
    	return group1;
400
    }
401

  
402

  
403

  
404
	public WindowInfo getWindowInfo() {
405
		if (m_ViewInfo==null){
406
			m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
407
			m_ViewInfo.setTitle(PluginServices.getText(this,"fit_WMS_layer"));
408
	        m_ViewInfo.setWidth(wmsParamsTabbedPane.getWidth()+10);
409
	        m_ViewInfo.setHeight(wmsParamsTabbedPane.getHeight()+40);
410

  
411
		}
412
		return m_ViewInfo;
413
	}
414

  
415
	public void close() {
416
		PluginServices.getMDIManager().closeWindow(this);
417
	}
418

  
419

  
420
	public Object getWindowProfile() {
421
		return WindowInfo.DIALOG_PROFILE;
422
	}
423

  
424
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 425

  
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.wmsclient/src/main/java/org/gvsig/raster/app/extension/wmsclient/gui/panel/WebMapContextFileChooserAccessory.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.app.extension.wmsclient.gui.panel;
24

  
25
import java.awt.Dimension;
26
import java.util.List;
27

  
28
import javax.swing.JComboBox;
29
import javax.swing.JLabel;
30
import javax.swing.JPanel;
31

  
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.app.project.ProjectManager;
34
import org.gvsig.app.project.documents.Document;
35
import org.gvsig.app.project.documents.view.DefaultViewDocument;
36
import org.gvsig.app.project.documents.view.ViewManager;
37
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
38

  
39

  
40
public class WebMapContextFileChooserAccessory extends JPanel {
41
	public static int NEW_VIEW = -1;
42
	public static int CURRENT_VIEW = -1;
43
	public static int USERS_VIEW_SELECTION = -1;
44

  
45
	private JComboBox cmbMode = null;
46
	private JComboBox cmbViews = null;
47
	private JLabel lblExplain = null;
48
	private String currentView = null;
49

  
50
	public WebMapContextFileChooserAccessory(String currentViewName) {
51
		super();
52
		currentView = currentViewName;
53
		initialize();
54
	}
55

  
56
	private void initialize() {
57
		lblExplain = new JLabel();
58
		lblExplain.setBounds(25, 52, 268, 55);
59
		lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
60
		setLayout(null);
61
		setSize(315, 240);
62
		setPreferredSize(new Dimension(315, 72));
63
		this.add(getCmbViews(), null);
64
		this.add(lblExplain, null);
65
		setBorder(javax.swing.BorderFactory.createTitledBorder(
66
				  null, PluginServices.getText(this, "open_layers_as"),
67
				  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
68
				  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
69
		this.add(getCmbMode(), null);
70
	}
71

  
72
	/**
73
	 * This method initializes cmbBoxMode
74
	 *
75
	 * @return javax.swing.JComboBox
76
	 */
77
	private JComboBox getCmbMode() {
78
		if (cmbMode == null) {
79
			cmbMode = new JComboBox();
80
			cmbMode.setBounds(25, 26, 268, 20);
81
			cmbMode.removeAllItems();
82
			cmbMode.addItemListener(new java.awt.event.ItemListener() {
83
				public void itemStateChanged(java.awt.event.ItemEvent e) {
84
					cmbViews.setVisible(false);
85

  
86
					if (cmbMode.getSelectedIndex() == NEW_VIEW) {
87
						lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
88
					} else if (cmbMode.getSelectedIndex() == CURRENT_VIEW) {
89
						lblExplain.setText(PluginServices.getText(this, "html_in_the_current_view"));
90
					} else if (cmbMode.getSelectedIndex() == USERS_VIEW_SELECTION) {
91
						lblExplain.setText(PluginServices.getText(this, "html_in_other_view"));
92
						cmbViews.setVisible(true);
93
					}
94
				}
95
			});
96
			cmbMode.addItem(PluginServices.getText(this, "a_new_view"));
97
			if (currentView!=null) {
98
				cmbMode.addItem(PluginServices.getText(this, "layers_in_the_current_view")+": "+currentView);
99
				CURRENT_VIEW = cmbMode.getItemCount()-1;
100
				cmbMode.setSelectedIndex(CURRENT_VIEW);
101
			}
102
			if (getCmbViews().getItemCount()>0) {
103
				cmbMode.addItem(PluginServices.getText(this, "layers_in_other_view"));
104
				USERS_VIEW_SELECTION = cmbMode.getItemCount() -1;
105
			}
106
		}
107

  
108
		return cmbMode;
109
	}
110

  
111
	public void setCurrentView(DefaultViewPanel v) {
112
		currentView = v.getName();
113
	}
114

  
115
	public DefaultViewDocument getSelectedView() {
116
		String viewName = null;
117
		if (getCmbMode().getSelectedIndex() == NEW_VIEW)
118
			return null;
119
		else if (getCmbMode().getSelectedIndex() == CURRENT_VIEW)
120
			viewName = currentView;
121
		else if (getCmbMode().getSelectedIndex() == USERS_VIEW_SELECTION)
122
			viewName = (String) getCmbViews().getSelectedItem();
123
		return (DefaultViewDocument) ProjectManager.getInstance().getCurrentProject().getDocument(viewName, ViewManager.TYPENAME);
124
//		ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
125
//		return (ProjectView) pe.getProject().getProjectDocumentByName(viewName, ProjectViewFactory.registerName);
126
	}
127

  
128
	public int getOption() {
129
		return cmbMode.getSelectedIndex();
130
	}
131

  
132
	/**
133
	 * This method initializes cmbViews
134
	 *
135
	 * @return javax.swing.JComboBox
136
	 */
137
	private JComboBox getCmbViews() {
138
		if (cmbViews == null) {
139
			cmbViews = new JComboBox();
140
			cmbViews.setBounds(25, 114, 266, 20);
141
			List<Document> views = ProjectManager.getInstance().getCurrentProject().getDocuments( ViewManager.TYPENAME);
142
			for (Document v : views) {
143
				cmbViews.addItem(v.getName());
144
			}
145
			
146
//			ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
147
//			ArrayList views = pe.getProject().getDocumentsByType(ProjectViewFactory.registerName);
148
//			for (int i = 0; i < views.size(); i++) {
149
//				ProjectView v = (ProjectView)views.get(i);
150
//				cmbViews.addItem(v.getName());
151
//			}
152
		}
153
		return cmbViews;
154
	}
155
}  //  @jve:decl-index=0:visual-constraint="10,0"
0 156

  
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.wmsclient/src/main/java/org/gvsig/raster/app/extension/wmsclient/gui/panel/StyleTree.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.app.extension.wmsclient.gui.panel;
24

  
25
import java.awt.Color;
26
import java.awt.Component;
27
import java.util.ArrayList;
28
import java.util.Vector;
29

  
30
import javax.swing.JLabel;
31
import javax.swing.JPanel;
32
import javax.swing.JRadioButton;
33
import javax.swing.JTree;
34
import javax.swing.event.TreeModelListener;
35
import javax.swing.tree.DefaultTreeCellRenderer;
36
import javax.swing.tree.TreeModel;
37
import javax.swing.tree.TreePath;
38

  
39
import org.gvsig.fmap.dal.coverage.dataset.io.wms.WMSLayerNode;
40
import org.gvsig.fmap.dal.coverage.datastruct.RemoteStyle;
41
import org.gvsig.fmap.dal.coverage.store.remote.RemoteLayerNode;
42

  
43

  
44
/**
45
 * This class holds a visual tree that handles the selection of the styles in the
46
 * selected layers. It encapsulates any gui interface handling the mouse selection.
47
 * <p>
48
 * It has a method getStylesSelection that returns the current selection in a 
49
 * bi-dimensional string array containing the layer name and the selected style name.
50
 * </p>
51
 * <p>
52
 * Keep in mind that although it's similar to LayersTree it is not the same.
53
 * It does not use the same instances of the WMSLayerNode that LayerTreeModel
54
 * because it allows to repeat layers. So, each layer is a completely new 
55
 * WMSLayerNode containing same properties but not the same parent (which is always
56
 * the tree root) and each style is a completely new FMapStyle containing same
57
 * properties but its parent is one of the layers of the StylesTree and not one
58
 * of those of the Layers tree.
59
 * </p>
60
 * 
61
 * @author jaume dominguez faus
62
 *
63
 */
64
public class StyleTree extends JTree {
65
	public boolean showLayerNames = false;
66
    public StyleTree(){
67
        super();
68
        initialize();
69
    }
70
    
71
    private void initialize(){
72
        setToggleClickCount(1);
73
        setRowHeight(22);
74
        
75
        setCellRenderer(new DefaultTreeCellRenderer() {
76
            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
77
                if (leaf) {
78
                    JPanel leafComponent = new JPanel();
79
                    leafComponent.setBackground(Color.WHITE);
80
                    JRadioButton leafRadioButton = new JRadioButton("", ((StyleTreeModel) getModel()).isSelected((RemoteStyle) value));//selected);
81
                    leafRadioButton.setBackground(Color.WHITE);
82
                    leafComponent.add(leafRadioButton);
83
                    leafComponent.add(new JLabel(((RemoteStyle) value).getTitle()));
84
                    return leafComponent;
85
                } else {
86
                	super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
87
                	if (value instanceof WMSLayerNode) {
88
                		WMSLayerNode layer = (WMSLayerNode) value;
89
                		if (!showLayerNames) {
90
                			if (layer.getName() != null || layer.getName() == "") {
91
                				String text = layer.toString();
92
                				text = text.substring(text.indexOf(']')+2, text.length());
93
                				setText(text);
94
                			}
95
                		}
96
                	}
97
            		return this;
98
                }
99
            }});
100
        addMouseListener(new java.awt.event.MouseAdapter() { 
101
            public void mouseClicked(java.awt.event.MouseEvent e) {
102
                ((StyleTreeModel)getModel()).setSelectedLeaf(getSelectionPath());
103
                clearSelection();
104
                repaint();
105
            }
106
        });
107
    }
108
    
109
    /**
110
     * Expands this tree.
111
     *
112
     */
113
    public void expandAll(){
114
        int row = 0; 
115
        while (row < getRowCount()) {
116
          expandRow(row);
117
          row++;
118
          }
119
    }
120
    /**
121
     * Returns a Vector of Strings containing the style titles.
122
     */
123
    public Vector getStyleSelectionTitles(){
124
        if (getModel() instanceof StyleTreeModel)
125
            return ((StyleTreeModel)getModel()).getStyleSelectionTitles();
126
        else
127
            return null;
128
    }
129
    
130
    /**
131
     * Sets the selected styles in the StylesTree. The argument styleNames is
132
     * a Vector with exactly the same amount of strings than the amount of
133
     * themes (layers) contained by the tree. A blank or null string will
134
     * leave the default style for that layer, but this element <b>must exist</b>
135
     * in the array in any case.
136
     * 
137
     * @param styleNames, Vector containing the style names. 
138
     * The styles order <b>must match</b> with the layer order. 
139
     */
140
    public void initSelections(Vector styleNames){
141
    	if (styleNames!=null) {
142
    		StyleTreeModel model = (StyleTreeModel) getModel();
143
    		model.setStylesSelection(styleNames);
144
    	}
145
    }
146
	
147
}
148

  
149
class StyleTreeModel implements TreeModel {
150
	private WMSLayerNode root;
151
	private ArrayList<WMSLayerNode> layers = new ArrayList<WMSLayerNode>();
152

  
153
	public StyleTreeModel(WMSLayerNode root){
154
        this.root = root;
155
        
156
    }
157
	
158
	/**
159
	 * Will return true if this style is selected.
160
	 * @param style
161
	 * @return
162
	 */
163
	public boolean isSelected(RemoteStyle style) {
164
		return style.getParent().getSelectedStyle().equals(style);
165
	}
166

  
167
	/**
168
	 * Gets the names of the selected styles into a Vector using the same order
169
	 * as they was represented in the StylesTree.
170
	 * @return
171
	 */
172
	public Vector<String> getStyleSelectionTitles() {
173
		Vector<String> v = new Vector<String>();
174
		for (int i = 0; i < layers.size(); i++) {
175
			WMSLayerNode layer = (WMSLayerNode) layers.get(i);
176
			RemoteStyle sty = layer.getSelectedStyle();
177
			if (sty == null) 
178
				v.add("");
179
			else 
180
				v.add(sty.getTitle());
181
		}
182
		return v;
183
	}
184

  
185
	/**
186
	 * Sets the selected styles in the StylesTree. The argument styleNames is
187
	 * a Vector with exactly the same amount of strings than the amount of
188
	 * themes (layers) contained by the tree. A blank or null string will
189
	 * leave the default style for that layer, but this element <b>must exist</b>
190
	 * in the array in any case.
191
	 * 
192
	 * @param styleNames, Vector containing the style names. 
193
	 * The styles order <b>must match</b> with the layer order. 
194
	 */
195
	public void setStylesSelection(Vector styleNames) {
196
		for (int i = 0; i < layers.size(); i++) {
197
			WMSLayerNode layer = (WMSLayerNode) layers.get(i);
198
			for (int j = 0; j < layer.getStyles().size(); j++) {
199
				RemoteStyle sty = (RemoteStyle) layer.getStyles().get(j);
200
				if ( sty.getName().equals((String) styleNames.get(i))) {
201
					layer.setSelectedStyleByIndex(j);
202
				}
203
			}
204
		}
205
	}
206
	
207
	/**
208
	 * Adds a new branch to this tree. It must be a layer node.
209
	 * @param node
210
	 * @return <b>True</b>, if the added branch actually defines any style.
211
	 *         <b>False</b>, if the layer has no styles.
212
	 */
213
	@SuppressWarnings("unchecked")
214
	public boolean addLayerBranch(WMSLayerNode node) {
215
		layers.add(node);
216
		if (node.getStyles()==null || node.getStyles().size()==0){
217
			return false;
218
		}
219
		for (int i = 0; i < node.getStyles().size(); i++) {
220
			((RemoteStyle) node.getStyles().get(i)).setParent(node);
221
		}
222
		((RemoteLayerNode)getRoot()).getChildren().add(node);
223
		return true;
224
	}
225
	
226
	/**
227
     * Sets a leaf (an style) selected.
228
     * @param selectionPath to this leaf.
229
     */
230
	protected void setSelectedLeaf(TreePath selectionPath) {
231
		if (selectionPath!=null){
232
			Object[] objects = selectionPath.getPath();
233
			Object item = objects[objects.length-1];
234
			if (isLeaf(item)){
235
				RemoteStyle style = (RemoteStyle) item;
236
				RemoteLayerNode layer = style.getParent() ;
237
				for (int i = 0; i < layer.getStyles().size(); i++) {
238
					RemoteStyle sty = (RemoteStyle) layer.getStyles().get(i);
239
					if (sty.getName().equals(style.getName())) {
240
						layer.setSelectedStyleByIndex(i);
241
						return;
242
					}
243
				}
244
			}
245
		}
246
	}
247

  
248

  
249
	/*
250
	 *  (non-Javadoc)
251
	 * @see javax.swing.tree.TreeModel#getRoot()
252
	 */
253
	public Object getRoot() {
254
		if (root == null) {
255
            root = new WMSLayerNode();
256
            root.setParent(null);
257
        }
258
        return root;
259
	}
260

  
261
	/*
262
	 *  (non-Javadoc)
263
	 * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object)
264
	 */
265
	public int getChildCount(Object parent) {
266
        int count=0;
267
        
268
        if (parent == root)
269
            count = ((WMSLayerNode) parent).getChildren().size();
270
        else
271
            count = ((WMSLayerNode) parent).getStyles().size();
272
        return count;
273
    }
274

  
275
	/*
276
	 *  (non-Javadoc)
277
	 * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object)
278
	 */
279
	public boolean isLeaf(Object node) {
280
		return (node instanceof RemoteStyle);
281
	}
282

  
283
	/*
284
	 *  (non-Javadoc)
285
	 * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener)
286
	 */
287
	public void addTreeModelListener(TreeModelListener l) {
288
	}
289

  
290
	/*
291
	 *  (non-Javadoc)
292
	 * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener)
293
	 */
294
	public void removeTreeModelListener(TreeModelListener l) {
295
	}
296

  
297
	/*
298
	 *  (non-Javadoc)
299
	 * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int)
300
	 */
301
	public Object getChild(Object parent, int index) {
302
		if (parent instanceof RemoteStyle)
303
            return null;
304
        if (parent == root)
305
            return ((WMSLayerNode) parent).getChildren().get(index);
306
        
307
        return ((WMSLayerNode) parent).getStyles().get(index);
308
	}
309

  
310
	/*
311
	 *  (non-Javadoc)
312
	 * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object)
313
	 */
314
	public int getIndexOfChild(Object parent, Object child) {
315
		if (parent instanceof RemoteStyle){ 
316
            return -1;   
317
        }
318
         
319
        WMSLayerNode l = (WMSLayerNode)parent;
320
        if (l.getParent()==null){
321
            for (int i = 0; i < l.getChildren().size(); i++) {
322
                if (l.getChildren().get(i).equals(child)){
323
                   return i;
324
                }
325
            }
326
        } else {
327
            for (int i = 0; i < l.getStyles().size(); i++) {
328
                if (l.getChildren().get(i).equals(child)){
329
                    return i;
330
                }
331
            }
332
        }
333
        return -1;
334
	}
335

  
336
	/*
337
	 *  (non-Javadoc)
338
	 * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object)
339
	 */
340
	public void valueForPathChanged(TreePath path, Object newValue) {
341
	}
342
}
0 343

  
org.gvsig.raster.app/trunk/org.gvsig.raster.app/org.gvsig.raster.app.wmsclient/src/main/java/org/gvsig/raster/app/extension/wmsclient/gui/panel/WebMapContextSettingsPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.app.extension.wmsclient.gui.panel;
24

  
25
import java.awt.Component;
26
import java.awt.Dimension;
27
import java.awt.FlowLayout;
28
import java.awt.geom.Rectangle2D;
29
import java.io.File;
30
import java.util.ArrayList;
31
import java.util.prefs.Preferences;
32

  
33
import javax.swing.ButtonGroup;
34
import javax.swing.JComboBox;
35
import javax.swing.JLabel;
36
import javax.swing.JOptionPane;
37
import javax.swing.JPanel;
38
import javax.swing.JRadioButton;
39
import javax.swing.JScrollPane;
40
import javax.swing.JTextArea;
41
import javax.swing.JTextField;
42
import javax.swing.SwingConstants;
43
import javax.swing.filechooser.FileFilter;
44

  
45
import org.gvsig.andami.PluginServices;
46
import org.gvsig.andami.messages.NotificationManager;
47
import org.gvsig.andami.ui.mdiManager.SingletonWindow;
48
import org.gvsig.andami.ui.mdiManager.WindowInfo;
49
import org.gvsig.app.project.documents.view.DefaultViewDocument;
50
import org.gvsig.app.project.documents.view.ViewManager;
51
import org.gvsig.fmap.dal.exception.ReadException;
52
import org.gvsig.fmap.geom.primitive.Envelope;
53
import org.gvsig.fmap.mapcontext.MapContext;
54
import org.gvsig.gui.beans.swing.JButton;
55
import org.gvsig.gui.beans.swing.JFileChooser;
56
import org.gvsig.raster.app.extension.wmsclient.wmc.ExportWebMapContextExtension;
57
import org.gvsig.raster.app.extension.wmsclient.wmc.ImportWebMapContextExtension;
58
import org.gvsig.raster.app.extension.wmsclient.wmc.WebMapContext;
59
import org.gvsig.raster.app.extension.wmsclient.wmc.WebMapContextTags;
60

  
61
/**
62
 * A graphical form to fill up the customizable information of a destinantion
63
 * Web Map Context file.
64
 *
65
 * @author jaume dominguez faus - jaume.dominguez@iver.es
66
 *
67
 */
68
public class WebMapContextSettingsPanel extends JPanel implements SingletonWindow {
69
	public static Preferences fPrefs = Preferences.userRoot().node( "gvsig.mapcontext-settingspanel" );
70
	private JPanel simplePanel = null;
71
	private JPanel advancedPanel = null;
72
	private JPanel buttonsPanel = null;
73
	private JComboBox cmbVersion = null;
74
	private JLabel lblTitle = null;
75
	private JButton btnBrowseFileSystem = null;
76
	private JTextField txtTitle = null;
77
	private JLabel lblVersion = null;
78
	private JLabel lblId = null;
79
	private JTextField txtId = null;
80
	private JLabel lblFile = null;
81
	private JTextField txtFile = null;
82
	private JButton btnAdvanced = null;
83
	private JButton btnOk = null;
84
	private JButton btnCancel = null;
85
	private JLabel lblAbstract = null;
86
	private JLabel lblLogoURL = null;
87
	private JLabel lblDescriptionURL = null;
88
	private JTextArea txtAbstract = null;
89
	private JScrollPane scrlAbstract = null;
90
	private JTextField txtLogoURL = null;
91
	private JTextField txtDescriptionURL = null;
92
	private JPanel pnlMapSize = null;
93
	private JRadioButton rdBtnUseViewSize = null;
94
	private JRadioButton rdBtnCustomSize = null;
95
	private JLabel lblWidth = null;
96
	private JLabel lblHeight = null;
97
	private JTextField txtWidth = null;
98
	private JTextField txtHeight = null;
99
	private JPanel pnlContactInfo = null;
100
	private JTextField txtKeyWords = null;
101
	private JLabel lblKeyWords = null;
102
	private JLabel lblContactPerson = null;
103
	private JTextField txtContactPerson = null;
104
	private JLabel lblContactOrganization = null;
105
	private JTextField txtOrganization = null;
106
	private JLabel lblContactPosition = null;
107
	private JTextField txtContactPosition = null;
108
	private JLabel lblAddress = null;
109
	private JTextField txtAddress = null;
110
	private JLabel lblCity = null;
111
	private JTextField txtCity = null;
112
	private JLabel lblStateProvince = null;
113
	private JTextField txtStateOrProvince = null;
114
	private JLabel lblPostCode = null;
115
	private JTextField txtPostCode = null;
116
	private JLabel lblCountry = null;
117
	private JComboBox cmbCountries = null;
118
	private JLabel lblPhone = null;
119
	private JTextField txtTelephone = null;
120
	private JLabel lblFax = null;
121
	private JTextField txtFax = null;
122
	private JLabel lblEMail = null;
123
	private JTextField txtEMail = null;
124
	private boolean first = true;
125
	private boolean advanced = fPrefs.getBoolean("advanced-panel", false);
126
	private WindowInfo m_viewInfo;
127
	private String strAdvanced = PluginServices.getText(this, "advanced");
128
	private File targetFile;
129
	private WebMapContext wmc;
130
	private DefaultViewDocument[] exportableViews;
131
	private JLabel lblView = null;
132
	private JComboBox cmbViews = null;
133
	private String lastWidth, lastHeight;
134
	private int defaultWidth = 500;
135
	private int defaultHeight = 450;
136
	private JLabel lblExtent = null;
137
	private JRadioButton rdBtnCurrentViewExtent = null;
138
	private JRadioButton rdBtnFullExtent = null;
139
	private static String lastPath = null;
140

  
141
	protected boolean useFullExtent = fPrefs.getBoolean("use_full_extent", false);
142

  
143
	public WebMapContextSettingsPanel(DefaultViewDocument[] views) {
144
		super();
145
		exportableViews = views;
146
		initialize();
147
	}
148

  
149
	/**
150
	 * This method initializes this
151
	 *
152
	 * @return void
153
	 */
154
	private void initialize() {
155
		this.setLayout(null);
156

  
157
		switchPanels();
158
	}
159

  
160
	private void switchPanels() {
161
		this.removeAll();
162
		Dimension sz;
163
		this.add(getSimplePanel(), java.awt.BorderLayout.NORTH);
164
		if (advanced) {
165
			this.add(getAdvancedPanel(), java.awt.BorderLayout.CENTER);
166
			sz = new Dimension(535, 640);
167
			btnAdvanced.setText(strAdvanced+"  <<");
168

  
169
		} else {
170
			sz = new Dimension(535, 260);
171
			btnAdvanced.setText(strAdvanced+"  >>");
172

  
173
		}
174

  
175
		this.setSize(sz);
176

  
177

  
178
		this.add(getButtonsPanel(), java.awt.BorderLayout.SOUTH);
179
		fPrefs.putBoolean("advanced-panel", advanced);
180
		if (!first) {
181
			PluginServices.getMDIManager().changeWindowInfo(this, getWindowInfo());
182

  
183
			PluginServices.getMDIManager().closeWindow(this);
184
			PluginServices.getMDIManager().addWindow(this);
185
		}
186
		first = false;
187
	}
188

  
189
	public WindowInfo getWindowInfo() {
190

  
191
		m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE);
192
		m_viewInfo.setTitle(PluginServices.getText(this, "web_map_context_settings"));
193
		m_viewInfo.setWidth(this.getWidth()+8);
194
		m_viewInfo.setHeight(getHeight());
195
		return m_viewInfo;
196
	}
197

  
198
	/**
199
	 * This method initializes simplePanel
200
	 *
201
	 * @return javax.swing.JPanel
202
	 */
203
	private JPanel getSimplePanel() {
204
		if (simplePanel == null) {
205
			ButtonGroup group = new ButtonGroup();
206
			lblExtent = new JLabel();
207
			lblExtent.setBounds(9, 146, 79, 20);
208
			lblExtent.setHorizontalTextPosition(SwingConstants.RIGHT);
209
			lblExtent.setHorizontalAlignment(SwingConstants.RIGHT);
210
			lblExtent.setText(PluginServices.getText(this, "map_extent")+":");
211
			lblView = new JLabel();
212
			lblView.setBounds(9, 24, 79, 20);
213
			lblView.setHorizontalTextPosition(SwingConstants.RIGHT);
214
			lblView.setHorizontalAlignment(SwingConstants.RIGHT);
215
			lblView.setText(PluginServices.getText(this, ViewManager.TYPENAME)+":");
216
			lblTitle = new JLabel();
217
			lblTitle.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
218
			lblTitle.setBounds(9, 48, 79, 20);
219
			lblTitle.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
220
			lblTitle.setText(PluginServices.getText(this, "title")+":");
221
			lblId = new JLabel();
222
			lblId.setBounds(9, 72, 79, 20);
223
			lblId.setHorizontalTextPosition(SwingConstants.RIGHT);
224
			lblId.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
225
			lblId.setText(PluginServices.getText(this, "id")+":");
226
			lblVersion = new JLabel();
227
			lblVersion.setBounds(9, 120, 79, 20);
228
			lblVersion.setHorizontalTextPosition(SwingConstants.RIGHT);
229
			lblVersion.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
230
			lblVersion.setText(PluginServices.getText(this, "version")+":");
231
			lblFile = new JLabel();
232
			lblFile.setBounds(9, 96, 79, 20);
233
			lblFile.setHorizontalTextPosition(SwingConstants.RIGHT);
234
			lblFile.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
235
			lblFile.setText(PluginServices.getText(this, "file_name")+":");
236
			simplePanel = new JPanel();
237
			simplePanel.setLayout(null);
238
			simplePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
239
					  null, PluginServices.getText(this, "options"),
240
					  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
241
					  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
242
			simplePanel.setBounds(new java.awt.Rectangle(0,0,535,196));
243
			simplePanel.add(lblView, null);
244
			simplePanel.add(getCmbViews(), null);
245
			simplePanel.add(getTxtTitle(), null);
246
			simplePanel.add(lblTitle, null);
247
			simplePanel.add(getBtnBrowseFileSystem(), null);
248
			simplePanel.add(lblVersion, null);
249
			simplePanel.add(lblId, null);
250
			simplePanel.add(getTxtId(), null);
251
			simplePanel.add(lblFile, null);
252
			simplePanel.add(getTxtFile(), null);
253
			simplePanel.add(getBtnAdvanced(), null);
254
			simplePanel.add(getCmbVersion(), null);
255
			simplePanel.add(lblExtent, null);
256
			simplePanel.add(getRdBtnCurrentViewExtent(), null);
257
			simplePanel.add(getRdBtnFullExtent(), null);
258
			group.add(getRdBtnCurrentViewExtent());
259
			group.add(getRdBtnFullExtent());
260
		}
261
		return simplePanel;
262
	}
263

  
264
	/**
265
	 * This method initializes advancedPanel
266
	 *
267
	 * @return javax.swing.JPanel
268
	 */
269
	private JPanel getAdvancedPanel() {
270
		if (advancedPanel == null) {
271
			lblKeyWords = new JLabel();
272
			lblKeyWords.setBounds(10, 79, 99, 20);
273
			lblKeyWords.setHorizontalTextPosition(SwingConstants.RIGHT);
274
			lblKeyWords.setHorizontalAlignment(SwingConstants.RIGHT);
275
			lblKeyWords.setText(PluginServices.getText(this, "keywords")+":");
276
			lblDescriptionURL = new JLabel();
277
			lblDescriptionURL.setBounds(10, 104, 99, 20);
278
			lblDescriptionURL.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
279
			lblDescriptionURL.setText(PluginServices.getText(this, "description_URL")+":");
280
			lblDescriptionURL.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
281
			lblLogoURL = new JLabel();
282
			lblLogoURL.setBounds(10, 130, 99, 20);
283
			lblLogoURL.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
284
			lblLogoURL.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
285
			lblLogoURL.setText(PluginServices.getText(this, "logo_URL")+":");
286
			lblAbstract = new JLabel();
287
			lblAbstract.setText(PluginServices.getText(this, "abstract")+":");
288
			lblAbstract.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
289
			lblAbstract.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
290
			lblAbstract.setBounds(10, 27, 99, 20);
291
			advancedPanel = new JPanel();
292
			advancedPanel.setLayout(null);
293
			advancedPanel.setBounds(0, 194, 535, 386);
294
			advancedPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
295
					  null, PluginServices.getText(this, "advanced_settings"),
296
					  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
297
					  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
298
			advancedPanel.add(lblAbstract, null);
299
			advancedPanel.add(lblKeyWords, null);
300
			advancedPanel.add(lblLogoURL, null);
301
			advancedPanel.add(lblDescriptionURL, null);
302
			advancedPanel.add(getScrlAbstract(), null);
303
			advancedPanel.add(getTxtLogoURL(), null);
304
			advancedPanel.add(getTxtDescriptionURL(), null);
305
			advancedPanel.add(getPnlMapSize(), null);
306
			advancedPanel.add(getPnlContactInfo(), null);
307
			advancedPanel.add(getTxtKeyWords(), null);
308
		}
309
		return advancedPanel;
310
	}
311

  
312
	/**
313
	 * This method initializes buttonsPanel
314
	 *
315
	 * @return javax.swing.JPanel
316
	 */
317
	private JPanel getButtonsPanel() {
318
		if (buttonsPanel == null) {
319
			FlowLayout flowLayout = new FlowLayout();
320
			flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
321
			flowLayout.setVgap(1);
322
			buttonsPanel = new JPanel();
323
			buttonsPanel.setLayout(flowLayout);
324
			buttonsPanel.add(getBtnOk(), null);
325
			buttonsPanel.add(getBtnCancel(), null);
326
		}
327
		buttonsPanel.setBounds(0, this.getHeight()-60, 535, 38);
328

  
329
		return buttonsPanel;
330
	}
331

  
332
	/**
333
	 * This method initializes cmbVersion
334
	 *
335
	 * @return javax.swing.JComboBox
336
	 */
337
	private JComboBox getCmbVersion() {
338
		if (cmbVersion == null) {
339
			cmbVersion = new JComboBox();
340
			cmbVersion.setSize(89, 20);
341
			cmbVersion.setLocation(91, 120);
342
			for (int i = 0; i < WebMapContext.exportVersions.size(); i++) {
343
				cmbVersion.addItem(WebMapContext.exportVersions.get(i));
344
			}
345

  
346
		}
347
		return cmbVersion;
348
	}
349

  
350

  
351

  
352
	/**
353
	 * This method initializes btnBrowseFileSystem
354
	 *
355
	 * @return javax.swing.JButton
356
	 */
357
	private JButton getBtnBrowseFileSystem() {
358
		if (btnBrowseFileSystem == null) {
359
			btnBrowseFileSystem = new JButton();
360
			btnBrowseFileSystem.setBounds(403, 95, 120, 22);
361
			btnBrowseFileSystem.addActionListener(new java.awt.event.ActionListener() {
362

  
363
				public void actionPerformed(java.awt.event.ActionEvent e) {
364
					JFileChooser fc = new JFileChooser(ImportWebMapContextExtension.WMC_FILECHOOSER_ID, lastPath);
365
					fc.setFileFilter(new FileFilter() {
366
						public boolean accept(File f) {
367
							return f.isDirectory() || f.getAbsolutePath().toLowerCase().endsWith(WebMapContext.FILE_EXTENSION);
368
						}
369

  
370
						public String getDescription() {
371
							return PluginServices.getText(this, "ogc_mapcontext_file")+" (*.cml)";
372
						}
373
					});
374
					if (fc.showOpenDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION){
375

  
376
						String fileName = fc.getSelectedFile().getAbsolutePath();
377
						if (!fileName.toLowerCase().endsWith(WebMapContext.FILE_EXTENSION)) {
378
							fileName += WebMapContext.FILE_EXTENSION;
379
						}
380
						targetFile = new File(fileName);
381
						getTxtFile().setText(fileName);
382
						lastPath  = fileName.substring(0, fileName.lastIndexOf(File.separatorChar));
383
					}
384

  
385
					fc = null;
386
				}
387
			});
388
			btnBrowseFileSystem.setText(PluginServices.getText(this, "browse"));
389
		}
390
		return btnBrowseFileSystem;
391
	}
392

  
393
	/**
394
	 * This method initializes txtTitle
395
	 *
396
	 * @return javax.swing.JTextField
397
	 */
398
	private JTextField getTxtTitle() {
399
		if (txtTitle == null) {
400
			txtTitle = new JTextField();
401
			txtTitle.setBounds(91, 48, 432, 20);
402
			txtTitle.setName(PluginServices.getText(this, "title"));
403
		}
404
		return txtTitle;
405
	}
406

  
407
	/**
408
	 * This method initializes jTextField
409
	 *
410
	 * @return javax.swing.JTextField
411
	 */
412
	private JTextField getTxtId() {
413
		if (txtId == null) {
414
			txtId = new JTextField();
415
			txtId.setBounds(91, 72, 432, 20);
416
			txtId.setName(PluginServices.getText(this, "id"));
417
		}
418
		return txtId;
419
	}
420

  
421
	/**
422
	 * This method initializes txtFile
423
	 *
424
	 * @return javax.swing.JTextField
425
	 */
426
	private JTextField getTxtFile() {
427
		if (txtFile == null) {
428
			txtFile = new JTextField();
429
			txtFile.setBounds(91, 96, 308, 20);
430
		}
431
		return txtFile;
432
	}
433

  
434
	/**
435
	 * This method initializes btnAdvanced
436
	 *
437
	 * @return javax.swing.JButton
438
	 */
439
	private JButton getBtnAdvanced() {
440
		if (btnAdvanced == null) {
441
			btnAdvanced = new JButton();
442
//			btnAdvanced.setBounds(403, 160, 120, 25);
443
			btnAdvanced.setLocation(403, 160);
444
			btnAdvanced.addActionListener(new java.awt.event.ActionListener() {
445
				public void actionPerformed(java.awt.event.ActionEvent e) {
446
					advanced = !advanced;
447
					switchPanels();
448
				}
449
			});
450
		}
451
		return btnAdvanced;
452
	}
453

  
454
	/**
455
	 * This method initializes btnAceptar
456
	 *
457
	 * @return javax.swing.JButton
458
	 */
459
	private JButton getBtnOk() {
460
		if (btnOk == null) {
461
			btnOk = new JButton();
462
			btnOk.setText(PluginServices.getText(this, "Ok"));
463
			btnOk.addActionListener(new java.awt.event.ActionListener() {
464
				public void actionPerformed(java.awt.event.ActionEvent e) {
465
					execute("OK");
466
				}
467
			});
468
		}
469
		return btnOk;
470
	}
471

  
472
	/**
473
	 * This method initializes btnCancel
474
	 *
475
	 * @return javax.swing.JButton
476
	 */
477
	private JButton getBtnCancel() {
478
		if (btnCancel == null) {
479
			btnCancel = new JButton();
480
			btnCancel.setText(PluginServices.getText(this, "cancel"));
481
			btnCancel.addActionListener(new java.awt.event.ActionListener() {
482
				public void actionPerformed(java.awt.event.ActionEvent e) {
483
					execute("CANCEL");
484
				}
485
			});
486
		}
487
		return btnCancel;
488
	}
489

  
490
	/**
491
	 * This method initializes txtAbstract
492
	 *
493
	 * @return javax.swing.JTextArea
494
	 */
495
	private JTextArea getTxtAbstract() {
496
		if (txtAbstract == null) {
497
			txtAbstract = new JTextArea();
498
		}
499
		return txtAbstract;
500
	}
501

  
502
	/**
503
	 * This method initializes scrlAbstract
504
	 *
505
	 * @return javax.swing.JScrollPane
506
	 */
507
	private JScrollPane getScrlAbstract() {
508
		if (scrlAbstract == null) {
509
			scrlAbstract = new JScrollPane();
510
			scrlAbstract.setBounds(115, 27, 232, 48);
511
			scrlAbstract.setViewportView(getTxtAbstract());
512
		}
513
		return scrlAbstract;
514
	}
515

  
516
	/**
517
	 * This method initializes txtLogoURL
518
	 *
519
	 * @return javax.swing.JTextField
520
	 */
521
	private JTextField getTxtLogoURL() {
522
		if (txtLogoURL == null) {
523
			txtLogoURL = new JTextField();
524
			txtLogoURL.setBounds(115, 130, 407, 20);
525
		}
526
		return txtLogoURL;
527
	}
528

  
529
	/**
530
	 * This method initializes jTextField
531
	 *
532
	 * @return javax.swing.JTextField
533
	 */
534
	private JTextField getTxtDescriptionURL() {
535
		if (txtDescriptionURL == null) {
536
			txtDescriptionURL = new JTextField();
537
			txtDescriptionURL.setBounds(115, 104, 232, 20);
538
		}
539
		return txtDescriptionURL;
540
	}
541

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff