Revision 15517

View differences:

org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.raster.wms</artifactId>
5
	<packaging>pom</packaging>
6
	<version>2.2.159</version>
7
	<name>${project.artifactId}</name>
8
	<description>wms client</description>
9
	<inceptionYear>2011</inceptionYear>
10
	
11
	<parent>
12
      <groupId>org.gvsig</groupId>
13
      <artifactId>org.gvsig.desktop</artifactId>
14
      <version>2.0.342</version>
15
  </parent>
16

  
17
        <properties>
18
            <!-- El plugin versions:use-latest-versions falla con scope import -->
19
            <!-- asi que toca usar el versions:update-properties que si que funciona -->
20
            <org.gvsig.raster.version>2.2.173</org.gvsig.raster.version>
21
        </properties>
22
    
23
    <repositories>
24
        <repository>
25
            <id>gvsig-public-http-repository</id>
26
            <name>gvSIG maven public HTTP repository</name>
27
            <url>http://devel.gvsig.org/m2repo/j2se</url>
28
            <releases>
29
                <enabled>true</enabled>
30
                <updatePolicy>daily</updatePolicy>
31
                <checksumPolicy>warn</checksumPolicy>
32
            </releases>
33
            <snapshots>
34
                <enabled>true</enabled>
35
                <updatePolicy>daily</updatePolicy>
36
                <checksumPolicy>warn</checksumPolicy>
37
            </snapshots>
38
        </repository>
39
    </repositories>
40
    
41
    <scm>
42
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159</connection>
43
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159</developerConnection>
44
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159</url>
45
    </scm>
46
    
47
    <build>
48
        <plugins>
49
            <plugin>
50
                <groupId>org.apache.maven.plugins</groupId>
51
                <artifactId>maven-release-plugin</artifactId>
52
                <configuration>
53
                    <tagBase>https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wms/tags/</tagBase>
54
                    <goals>deploy</goals>
55
                </configuration>
56
            </plugin>
57
        </plugins>
58
    </build>
59
    
60
    <dependencyManagement>
61
        <dependencies>
62
            <dependency>
63
                <groupId>org.gvsig</groupId>
64
                <artifactId>org.gvsig.raster</artifactId>
65
                <version>${org.gvsig.raster.version}</version>
66
                <type>pom</type>
67
                <scope>import</scope>
68
            </dependency>
69

  
70
			<dependency>
71
				<groupId>org.gvsig</groupId>
72
				<artifactId>org.gvsig.raster.wms.io</artifactId>
73
				<version>2.2.159</version>
74
			</dependency>
75
			<dependency>
76
				<groupId>org.gvsig</groupId>
77
				<artifactId>org.gvsig.raster.wms.remoteclient</artifactId>
78
				<version>2.2.159</version>
79
			</dependency>
80
			<dependency>
81
				<groupId>org.gvsig</groupId>
82
				<artifactId>org.gvsig.raster.wms.app.wmsclient</artifactId>
83
				<version>2.2.159</version>
84
			</dependency>
85

  
86
        </dependencies>
87
    </dependencyManagement>
88

  
89
    <modules>
90
        <module>org.gvsig.raster.wms.remoteclient</module>
91
        <module>org.gvsig.raster.wms.io</module>
92
        <module>org.gvsig.raster.wms.app.wmsclient</module>
93
    </modules>
94
</project>
95

  
0 96

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/org.gvsig.raster.wms.app.wmsclient/buildNumber.properties
1
#Tue Nov 16 20:27:56 CET 2021
2
buildNumber=214
0 3

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/org.gvsig.raster.wms.app.wmsclient/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
    <id>gvsig-plugin-package</id>
3
    <formats>
4
        <format>zip</format>
5
    </formats>
6
    <baseDirectory>${project.artifactId}</baseDirectory>
7
    <includeBaseDirectory>true</includeBaseDirectory>
8
    <files>
9
        <file>
10
            <source>target/${project.artifactId}-${project.version}.jar</source>
11
            <outputDirectory>lib</outputDirectory>
12
        </file>
13
        <file>
14
            <source>target/package.info</source>
15
        </file>
16
    </files>
17

  
18
    <fileSets>
19
        <fileSet>
20
            <directory>src/main/resources-plugin</directory>
21
            <outputDirectory>.</outputDirectory>
22
        </fileSet>
23
    </fileSets>
24

  
25

  
26
    <dependencySets>
27
        <dependencySet>
28
            <useProjectArtifact>false</useProjectArtifact>
29
            <useTransitiveDependencies>false</useTransitiveDependencies>
30
            <outputDirectory>lib</outputDirectory>
31
            <includes> 
32
                <include>org.gvsig:org.gvsig.raster.wms.remoteclient:jar</include>
33
                <include>org.gvsig:org.gvsig.raster.wms.io:jar</include>
34
            </includes>
35
        </dependencySet>
36
    </dependencySets>
37
</assembly>
0 38

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/WMSClientExtension.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.wms.app.wmsclient;
24

  
25
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.app.extension.AddLayer;
28
import org.gvsig.raster.wms.app.wmsclient.gui.toc.WMSPropsTocMenuEntry;
29
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.WMSWizard;
30
import org.gvsig.raster.wms.app.wmsclient.layer.DynObjectSetWMSInfo;
31
import org.gvsig.raster.wms.app.wmsclient.layer.FLyrWMS;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.extensionpoint.ExtensionPoint;
34

  
35

  
36
/**
37
 * Extension for adding WMS support to gvSIG.
38
 *
39
 * @author jaume dominguez faus - jaume.dominguez@iver.es
40
 */
41
public class WMSClientExtension extends Extension {
42

  
43
    public void initialize() {
44
    	
45
    	// Adds an entry to the TOC's floating menu to those layers defined in this extension
46
		ExtensionPoint exPoint = ToolsLocator.getExtensionPointManager().add(
47
				"View_TocActions");
48

  
49
		exPoint.append("WMSProperties", "", new WMSPropsTocMenuEntry());
50

  
51
        // Adds a new tab to the "add layer" wizard for WMS layer creation
52
    	AddLayer.addWizard(WMSWizard.class);
53

  
54
    	ToolsLocator.getExtensionPointManager().add("CatalogLayers").append(
55
				"OGC:WMS", "", FLyrWMS.class);
56
    	initilizeIcons();
57
    	DynObjectSetWMSInfo.registerDynClass();
58
    }
59
    
60
	public void postInitialize() {
61
		FLyrWMS.registerPersistent();
62
	}
63

  
64
    public void execute(String actionCommand) {
65
    	// no commands, no code.
66
    }
67

  
68
    public boolean isEnabled() {
69
    	// may return whatever
70
        return false;
71
    }
72

  
73
    public boolean isVisible() {
74
    	// may return whatever
75
        return false;
76
    }
77

  
78
    void initilizeIcons(){
79
		IconThemeHelper.registerIcon(null, "aplication-preferences-uparrow", this);
80
		IconThemeHelper.registerIcon(null, "aplication-preferences-downarrow", this);
81
		IconThemeHelper.registerIcon(null, "icon-layer-wms", this);
82
    }
83
}
0 84

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/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.wms.app.wmsclient.gui.dialog;
24

  
25
import java.awt.Dimension;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.util.HashMap;
29
import java.util.List;
30
import java.util.Vector;
31

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

  
38
import org.gvsig.andami.PluginServices;
39
import org.gvsig.andami.ui.mdiManager.IWindow;
40
import org.gvsig.andami.ui.mdiManager.WindowInfo;
41
import org.gvsig.app.gui.wizards.WizardListener;
42
import org.gvsig.app.gui.wizards.WizardListenerSupport;
43
import org.gvsig.fmap.dal.coverage.exception.ConnectException;
44
import org.gvsig.fmap.dal.exception.InitializeException;
45
import org.gvsig.fmap.mapcontext.MapContext;
46
import org.gvsig.fmap.mapcontext.exceptions.ConnectionErrorLayerException;
47
import org.gvsig.fmap.mapcontext.exceptions.DriverLayerException;
48
import org.gvsig.fmap.mapcontext.exceptions.LegendLayerException;
49
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
50
import org.gvsig.fmap.mapcontext.exceptions.NameLayerException;
51
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
52
import org.gvsig.fmap.mapcontext.exceptions.TypeLayerException;
53
import org.gvsig.fmap.mapcontext.exceptions.URLLayerException;
54
import org.gvsig.fmap.mapcontext.exceptions.UnsupportedVersionLayerException;
55
import org.gvsig.fmap.mapcontext.layers.FLayer;
56
import org.gvsig.fmap.mapcontext.layers.FLayers;
57
import org.gvsig.fmap.mapcontrol.MapControl;
58
import org.gvsig.raster.fmap.layers.FLyrRaster;
59
import org.gvsig.raster.swing.RasterSwingLibrary;
60
import org.gvsig.raster.util.CancelTaskImpl;
61
import org.gvsig.raster.wms.app.wmsclient.gui.panel.WMSParamsPanel;
62
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.LayerTreeModel;
63
import org.gvsig.raster.wms.app.wmsclient.layer.FLyrWMS;
64
import org.gvsig.raster.wms.io.RemoteWMSStyle;
65
import org.gvsig.raster.wms.io.WMSLayerNode;
66
import org.gvsig.raster.wms.io.WMSServerExplorer;
67
import org.slf4j.Logger;
68
import org.slf4j.LoggerFactory;
69

  
70

  
71
/**
72
 * The TOC WMS properties panel container.
73
 *
74
 * @author jaume - 
75
 *
76
 */
77
public class WMSPropsDialog extends JPanel implements IWindow {
78

  
79
	private static final long         serialVersionUID    = 1L;
80
	private Logger                   logger              = LoggerFactory.getLogger(WMSPropsDialog.class);
81
	JDialog                           dlg                 = null;  
82
	private JPanel                    buttonsPanel        = null;
83
	private FLyrRaster                fLayer              = null;
84
	boolean                           applied             = false;;
85
	private WindowInfo                m_ViewInfo          = null;
86

  
87
	private JButton                   btnApply            = null;
88
	private JButton                   btnOk               = null;
89
	private JButton                   btnCancel           = null;
90
	private WMSParamsPanel            wmsParamsTabbedPane;
91
    private CommandListener           m_actionListener;
92
    private WMSServerExplorer         explorer            = null;
93

  
94
    public WMSPropsDialog(FLayer layer) {
95
		super();
96
		if(layer instanceof FLyrRaster)
97
			initialize((FLyrRaster)layer);
98
	}
99

  
100

  
101
	private void initialize(FLyrRaster layer) {
102
		setLayout(null);
103

  
104
        setFLayer(layer);
105
        wmsParamsTabbedPane = getParamsPanel(((FLyrWMS) layer).getProperties());
106
        wmsParamsTabbedPane.addWizardListener(new WizardListener(){
107
			public void wizardStateChanged(boolean finishable) {
108
				getBtnOk().setEnabled(finishable);
109
				getBtnApply().setEnabled(finishable);
110
			}
111

  
112
			public void error(Exception e) {
113
			}
114

  
115
        })  ;
116
        wmsParamsTabbedPane.disableDisagregatedLayers();
117
        this.add(wmsParamsTabbedPane);
118
        this.add(getButtonsPanel(), null);
119

  
120
	}
121

  
122

  
123
	public void setFLayer(FLyrRaster f) {
124
		fLayer = f;
125
	}
126

  
127
	/**
128
	 * With getParamsPanel we have access to the map config TabbedPane.
129
	 * If this panel doesn't exist yet (which can occur when an existing project is
130
	 * recovered) it is been automatically constructed by connecting to the server,
131
	 * reloading the necessary data, filling up the content and setting the selected
132
	 * values that were selected when the projet was saved.
133
	 *
134
	 *
135
	 * Since a connection to the server is needed when rebuiliding the panel, this
136
	 * causes a delay for the panel's showing up or a nullPointer error if there is
137
	 * no path to the server.
138
	 *
139
	 *
140
	 * Con getParamsPanel tenemos acceso a juego de pesta?as de configuraci?n
141
	 * del mapa. Si este panel todav?a no existe (como puede ser cuando
142
	 * recuperamos un proyecto guardado) ?ste se crea autom?ticamente conectando
143
	 * al servidor, recuperando los datos necesarios, rellenando el contenido y
144
	 * dejando seleccionados los valores que estaban seleccionados cuando se
145
	 * guarda el proyecto.
146
	 *
147
	 *
148
	 * Como para reconstruirse requiere una conexi?n con el servidor esto causa
149
	 * un retardo en la aparici?n en el toc o un error de nullPointer si no
150
	 * hay conexi?n hasta el servidor.
151
	 *
152
	 *
153
	 * @return WMSParamsPanel
154
	 */
155
	@SuppressWarnings({ "unchecked" })
156
	public WMSParamsPanel getParamsPanel(HashMap info) {
157
	    if (info != null) {
158
	    	try {
159
	    		if(explorer == null) {
160
					explorer = ((FLyrWMS)fLayer).getExplorer();
161
					
162
					try {
163
			    		explorer.connect(new CancelTaskImpl(), true);
164
					} catch (ConnectException e) {
165
						RasterSwingLibrary.messageBoxError("The connection cannot be established", this, e);
166
						return null;
167
					} 
168
	    		}
169
	    	} catch (Exception e) {
170
	    		explorer = null;
171
	    		JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE);
172
	    	}
173
	    	try {
174
	        	
175
                // name
176
	            WMSParamsPanel toc = new WMSParamsPanel();
177
	            toc.setLayerName((String)info.get("name"));
178
	            toc.setWizardData(explorer);
179

  
180
	            toc.setVisible(true);
181
	            toc.setListenerSupport(new WizardListenerSupport());
182

  
183
	            WMSLayerNode[] selectedLayers = (WMSLayerNode[]) ((Vector) info.get("selectedLayers")).toArray(new WMSLayerNode[0]);
184
	            for (int i = 0; i < selectedLayers.length; i++) {
185
	            	toc.getJustTreeLayer().clearSelection();
186
	            	//  Se a?ade a la lista de layers seleccionados
187
	            	TreePath path = new TreePath(((LayerTreeModel)toc.getJustTreeLayer()
188
	            						.getModel()).getNodeByName(selectedLayers[i].getName()));
189
	            	toc.getJustTreeLayer().addSelectionPath(path);
190
	            	toc.addLayer();
191
                }
192

  
193
                // srs
194
                String srs = (String) info.get("srs");
195
                int index = toc.getSRSIndex( srs );
196
	            if (index != -1) {
197
					toc.getLstSRSs().setSelectedIndex(index);
198
				}
199

  
200
                // format
201
	            String format = (String) info.get("format");
202
	            index = toc.getFormatIndex(format);
203
	            if (index != -1) {
204
					toc.getLstFormats().setSelectedIndex(index);
205
				}
206
	            
207
	            //info format
208
	            String infoFormat = (String) info.get("infoformat");
209
	            index = toc.getInfoFormatIndex(infoFormat);
210
	            if (index != -1) {
211
					toc.getLstInfoFormats().setSelectedIndex(index);
212
				}
213

  
214
	            // transparency
215
                toc.setTransparent(((Boolean) info.get("wmsTransparency")).booleanValue());
216

  
217
                // styles
218
                List<RemoteWMSStyle> l = (List<RemoteWMSStyle>) info.get("styles");
219
                if (l != null && l.size() > 0) {
220
					toc.setStyleSelections(l);
221
				}
222

  
223
                // dimensions
224
                Vector v = (Vector) info.get("dimensions");
225
                if (v != null) {
226
					toc.setDimensions(v);
227
				}
228

  
229
                // fixed sizes
230
                Dimension sz = (Dimension) info.get("fixedSize");
231
                if (sz != null) {
232
					toc.setFixedSize(sz);
233
				}
234
                toc.refreshInfo();
235
                applied = false;
236
	            return toc;
237
	        } catch (Exception e) {
238
	        	JOptionPane.showMessageDialog(null, "error_comunicacion_servidor", "Error", JOptionPane.ERROR_MESSAGE);
239
	        }
240
	    }
241
	    return null;
242
	}
243

  
244

  
245
	public JPanel getButtonsPanel() {
246
		if (buttonsPanel == null) {
247
			m_actionListener = new CommandListener(this);
248
			buttonsPanel = new JPanel();
249
	        buttonsPanel.setBounds(5, wmsParamsTabbedPane.getHeight(), 471, 40);
250
			buttonsPanel.setLayout(null);
251
			buttonsPanel.setName("buttonPanel");
252

  
253
	        buttonsPanel.add(getBtnOk(), null);
254
	        buttonsPanel.add(getBtnApply(), null);
255
	        buttonsPanel.add(getBtnCancel(), null);
256
		}
257
		return buttonsPanel;
258
	}
259

  
260
	public JButton getBtnOk() {
261
		if (btnOk == null) {
262
	        btnOk = new JButton("ok");
263
	        btnOk.setText(PluginServices.getText(this,"ok"));
264
	        btnOk.setActionCommand("OK");
265
	        btnOk.addActionListener(m_actionListener);
266
	        btnOk.setBounds(367, 9, 90, 25);
267
		}
268
		return btnOk;
269
	}
270

  
271
	public JButton getBtnApply() {
272
		if (btnApply == null) {
273
	        btnApply = new JButton("apply");
274
	        btnApply.setText(PluginServices.getText(this,"apply"));
275
	        btnApply.setEnabled(false);
276
	        btnApply.setActionCommand("APPLY");
277
	        btnApply.addActionListener(m_actionListener);
278
	        btnApply.setBounds(267, 9, 90, 25);
279
		}
280
		return btnApply;
281
	}
282

  
283
	public JButton getBtnCancel() {
284
		if (btnCancel == null) {
285
	        btnCancel = new JButton("cancel");
286
	        btnCancel.setText(PluginServices.getText(this,"cancel"));
287
	        btnCancel.setActionCommand("CANCEL");
288
	        btnCancel.addActionListener(m_actionListener);
289
	        btnCancel.setBounds(137, 9, 90, 25);
290
		}
291
		return btnCancel;
292
	}
293

  
294
    private class CommandListener implements ActionListener {
295

  
296
        /**
297
         * Creates a new ComandosListener object.
298
         *
299
         * @param lg DOCUMENT ME!
300
         */
301
        public CommandListener(WMSPropsDialog tp) {
302
            //m_tp = tp;
303
        }
304

  
305
		@SuppressWarnings({ "unchecked" })
306
		public void actionPerformed(ActionEvent e) {
307
            if (e.getActionCommand() == "CANCEL") {
308
				close();
309
			} else {
310
            	/*try {
311
					((FLyrWMS) fLayer).setFullExtent(wmsParamsTabbedPane.getLayersRectangle());
312
				} catch (ProjectionLayerException ex) {
313
					ex.printStackTrace();
314
			        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), ex.getMessage());
315
			        return;
316
				}*/
317
				((FLyrWMS) fLayer).getParameters().setFormat(wmsParamsTabbedPane.getFormat());
318
				((FLyrWMS) fLayer).getParameters().setInfoFormat(wmsParamsTabbedPane.getInfoFormat());
319
                try {
320
                if (!wmsParamsTabbedPane.getDisagregatedLayers()) {
321
					((FLyrWMS) fLayer).getParameters().setLayerQuery(wmsParamsTabbedPane.getLayersQuery());
322
				}
323
                ((FLyrWMS) fLayer).getParameters().setInfoLayerQuery(wmsParamsTabbedPane.getQueryableLayerQuery());
324
                ((FLyrWMS) fLayer).getParameters().setSRS(wmsParamsTabbedPane.getSRS());
325
                ((FLyrWMS) fLayer).getParameters().setName(wmsParamsTabbedPane.getLayerName());
326
                ((FLyrWMS) fLayer).getParameters().setWmsTransparency(wmsParamsTabbedPane.getTransparency());
327
                ((FLyrWMS) fLayer).getParameters().setStyles(wmsParamsTabbedPane.getStyles());
328
                ((FLyrWMS) fLayer).getParameters().setDimensions(wmsParamsTabbedPane.getDimensions());
329
                ((FLyrWMS) fLayer).getParameters().setFixedSize(wmsParamsTabbedPane.getFixedSize());
330

  
331
            	//fLayer = wmsParamsTabbedPane.getLayer();
332
            	FLayers parent = ((FLayer)fLayer).getParentLayer();
333

  
334
                if (e.getActionCommand() == "APPLY"){
335
                	MapControl mapCtrl = null;
336
                	
337
                	IWindow[] w = PluginServices.getMDIManager().getAllWindows();
338
                	for (int i = 0; i < w.length; i++) {
339
						if (w[i] instanceof org.gvsig.app.project.documents.view.gui.AbstractViewPanel) {
340
							MapContext mapContext = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl().getMapContext();
341
							if(mapContext == fLayer.getMapContext())
342
								mapCtrl = ((org.gvsig.app.project.documents.view.gui.AbstractViewPanel)w[i]).getMapControl();
343
						}
344
					} 
345

  
346
                    if (parent != null) {
347
                    	if ( wmsParamsTabbedPane.getLayer() instanceof FLayers){
348
							mapCtrl.getMapContext().getLayers().
349
							replaceLayer(parent.getName(),mergeFLayers(parent,(FLayers)wmsParamsTabbedPane.getLayer()));
350
                    	}
351
                    }
352
                    else {
353
                    	mapCtrl.getMapContext().getLayers().replaceLayer(fLayer.getName(), wmsParamsTabbedPane.getLayer());
354
                    }
355
                    //mapCtrl.getMapContext().getLayers().addLayer( fLayer );
356
                    mapCtrl.getMapContext().invalidate();
357
                    applied = true;
358
                    getBtnApply().setEnabled(!applied);
359
                }
360
                if (e.getActionCommand() == "OK") {
361
                    if (!applied) {
362

  
363
                        org.gvsig.app.project.documents.view.gui.AbstractViewPanel vista = (org.gvsig.app.project.documents.view.gui.AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow();
364
                        MapControl mapCtrl = vista.getMapControl();
365

  
366
                        if (parent != null){
367
                        	if ( wmsParamsTabbedPane.getLayer() instanceof FLayers){
368
                        		mapCtrl.getMapContext().getLayers().
369
                        		replaceLayer(parent.getName(),mergeFLayers(parent,(FLayers)wmsParamsTabbedPane.getLayer()));
370
                        	}
371
                        }
372
                        else {
373
                        	mapCtrl.getMapContext().getLayers().replaceLayer(fLayer.getName(), wmsParamsTabbedPane.getLayer());
374
                        }                        mapCtrl.getMapContext().invalidate();
375
                    }
376
                    close();
377
                }
378
                } catch (ConnectionErrorLayerException e1) {
379
                	logger.info("", e1);
380
    			} catch (DriverLayerException e1) {
381
    				logger.info("", e1);
382
    			} catch (LegendLayerException e1) {
383
    				logger.info("", e1);
384
    			} catch (NameLayerException e1) {
385
    				logger.info("", e1);
386
    			} catch (ProjectionLayerException e1) {
387
    				logger.info("", e1);
388
    			} catch (TypeLayerException e1) {
389
    				logger.info("", e1);
390
    			} catch (UnsupportedVersionLayerException e1) {
391
    				logger.info("", e1);
392
    			} catch (URLLayerException e1) {
393
    				logger.info("", e1);
394
    			} catch (LoadLayerException e1) {
395
    				logger.info("", e1);
396
    			} catch (InitializeException e1) {
397
					logger.info("", e1);
398
				}
399
            }
400
		}
401
    }
402
    /**
403
     * Merge two FLayers in one
404
     * @param group1
405
     * @param group2
406
     * @return
407
     */
408
    private FLayers mergeFLayers(FLayers group1, FLayers group2)
409
    {
410
    	//FLayers agrupation = new FLayers(group1.getFMap(), group1.getParentLayer());
411
    	FLayer layer;
412
    	for(int i = 0; i < group2.getLayersCount(); i++)
413
    	{
414
    		layer = group2.getLayer( i );
415
    		if(group1.getLayer( layer.getName()) == null ){
416
    			group1.addLayer( layer );
417
    		}
418
    	}
419

  
420
    	return group1;
421
    }
422

  
423

  
424

  
425
	public WindowInfo getWindowInfo() {
426
		if (m_ViewInfo==null){
427
			m_ViewInfo=new WindowInfo(WindowInfo.MODALDIALOG);
428
			m_ViewInfo.setTitle(PluginServices.getText(this,"fit_WMS_layer"));
429
	        m_ViewInfo.setWidth(wmsParamsTabbedPane.getWidth()+10);
430
	        m_ViewInfo.setHeight(wmsParamsTabbedPane.getHeight()+40);
431

  
432
		}
433
		return m_ViewInfo;
434
	}
435

  
436
	public void close() {
437
		PluginServices.getMDIManager().closeWindow(this);
438
	}
439

  
440

  
441
	public Object getWindowProfile() {
442
		return WindowInfo.DIALOG_PROFILE;
443
	}
444

  
445
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 446

  
org.gvsig.raster.wms/tags/org.gvsig.raster.wms-2.2.159/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/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.wms.app.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.JButton;
35
import javax.swing.JComboBox;
36
import javax.swing.JLabel;
37
import javax.swing.JOptionPane;
38
import javax.swing.JPanel;
39
import javax.swing.JRadioButton;
40
import javax.swing.JScrollPane;
41
import javax.swing.JTextArea;
42
import javax.swing.JTextField;
43
import javax.swing.SwingConstants;
44
import javax.swing.filechooser.FileFilter;
45

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

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

  
143
	protected boolean useFullExtent = fPrefs.getBoolean("use_full_extent", false);
144

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

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

  
159
		switchPanels();
160
	}
161

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

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

  
175
		}
176

  
177
		this.setSize(sz);
178

  
179

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

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

  
191
	public WindowInfo getWindowInfo() {
192

  
193
		m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE);
194
		m_viewInfo.setTitle(Messages.getText("web_map_context_settings"));
195
		m_viewInfo.setWidth(this.getWidth()+8);
196
		m_viewInfo.setHeight(getHeight());
197
		return m_viewInfo;
198
	}
199

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

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

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

  
331
		return buttonsPanel;
332
	}
333

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

  
348
		}
349
		return cmbVersion;
350
	}
351

  
352

  
353

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

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

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

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

  
387
					fc = null;
388
				}
389
			});
390
			btnBrowseFileSystem.setText(Messages.getText("browse"));
391
		}
392
		return btnBrowseFileSystem;
393
	}
394

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

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

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

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

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

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

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

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

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

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

  
544
	/**
545
	 * This method initializes pnlMapSize
546
	 *
547
	 * @return javax.swing.JPanel
548
	 */
549
	private JPanel getPnlMapSize() {
550
		if (pnlMapSize == null) {
551
			ButtonGroup group = new ButtonGroup();
552
			lblHeight = new JLabel();
553
			lblHeight.setText(Messages.getText("height"));
554
			lblHeight.setBounds(11, 79, 52, 20);
555
			lblHeight.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
556
			lblHeight.setEnabled(false);
557
			lblHeight.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
558
			lblWidth = new JLabel();
559
			lblWidth.setText(Messages.getText("width"));
560
			lblWidth.setBounds(11, 56, 52, 20);
561
			lblWidth.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
562
			lblWidth.setEnabled(false);
563
			lblWidth.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
564
			pnlMapSize = new JPanel();
565
			pnlMapSize.setLayout(null);
566
			pnlMapSize.setBounds(351, 19, 179, 108);
567
			pnlMapSize.setBorder(javax.swing.BorderFactory.createTitledBorder(
568
					  null, Messages.getText("map_size_in_pixels"),
569
					  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
570
					  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
571
			pnlMapSize.add(getRdBtnUseViewSize(), null);
572
			pnlMapSize.add(getRdBtnCustomSize(), null);
573
			pnlMapSize.add(lblWidth, null);
574
			pnlMapSize.add(lblHeight, null);
575
			pnlMapSize.add(getTxtWidth(), null);
576
			pnlMapSize.add(getTxtHeight(), null);
577
			group.add(getRdBtnUseViewSize());
578
			group.add(getRdBtnCustomSize());
579

  
580
		}
581
		return pnlMapSize;
582
	}
583

  
584
	/**
585
	 * This method initializes rdBtnUseViewSize
586
	 *
587
	 * @return javax.swing.JRadioButton
588
	 */
589
	private JRadioButton getRdBtnUseViewSize() {
590
		if (rdBtnUseViewSize == null) {
591
			rdBtnUseViewSize = new JRadioButton();
592
			rdBtnUseViewSize.setBounds(8, 16, 142, 20);
593
			rdBtnUseViewSize.setText(Messages.getText("use_view_size"));
594
			rdBtnUseViewSize.addItemListener(new java.awt.event.ItemListener() {
595
				public void itemStateChanged(java.awt.event.ItemEvent e) {
596
					boolean b = !getRdBtnUseViewSize().isSelected();
597

  
598
					getTxtWidth().setEnabled(b);
599
					getTxtHeight().setEnabled(b);
600
				}
601
			});
602
			rdBtnUseViewSize.setSelected(true);
603
		}
604
		return rdBtnUseViewSize;
605
	}
606

  
607
	/**
608
	 * This method initializes jRadioButton
609
	 *
610
	 * @return javax.swing.JRadioButton
611
	 */
612
	private JRadioButton getRdBtnCustomSize() {
613
		if (rdBtnCustomSize == null) {
614
			rdBtnCustomSize = new JRadioButton();
615
			rdBtnCustomSize.setBounds(8, 34, 142, 20);
616
			rdBtnCustomSize.setText(Messages.getText("use_custom_size"));
617
		}
618
		return rdBtnCustomSize;
619
	}
620

  
621
	/**
622
	 * This method initializes txtWidth
623
	 *
624
	 * @return javax.swing.JTextField
625
	 */
626
	private JTextField getTxtWidth() {
627
		if (txtWidth == null) {
628
			txtWidth = new JTextField();
629
			txtWidth.setBounds(66, 56, 105, 20);
630
			txtWidth.setEnabled(false);
631
			txtWidth.addKeyListener(new java.awt.event.KeyAdapter() {
632
				public void keyTyped(java.awt.event.KeyEvent e) {
633
					try {
634
						String text = getTxtWidth().getText();
635
						Integer.parseInt(text);
636
						lastWidth = text;
637
					} catch (Exception ex) {
638
						getTxtWidth().setText(lastWidth);
639
					}
640
				}
641
			});
642
			Dimension sz = exportableViews[getCmbViews()
643
				                            .getSelectedIndex()]
644
				                            .getMapContext()
645
				                            .getViewPort()
646
				                            .getImageSize();
647
			lastWidth = (sz != null)? (int) sz.getWidth()+"": defaultWidth+"";
648

  
649
			txtWidth.setText(lastWidth);
650
		}
651
		return txtWidth;
652
	}
653

  
654
	/**
655
	 * This method initializes jTextField
656
	 *
657
	 * @return javax.swing.JTextField
658
	 */
659
	private JTextField getTxtHeight() {
660
		if (txtHeight == null) {
661
			txtHeight = new JTextField();
662
			txtHeight.setBounds(66, 79, 105, 20);
663
			txtHeight.setEnabled(false);
664
			txtHeight.addKeyListener(new java.awt.event.KeyAdapter() {
665
				public void keyTyped(java.awt.event.KeyEvent e) {
666
					try {
667
						String text = getTxtHeight().getText();
668
						Integer.parseInt(text);
669
						lastHeight = text;
670
					} catch (Exception ex) {
671
						getTxtHeight().setText(lastHeight);
672
					}
673
				}
674
			});
675
			Dimension sz = exportableViews[getCmbViews()
676
				                            .getSelectedIndex()]
677
				                            .getMapContext()
678
				                            .getViewPort()
679
				                            .getImageSize();
680
			lastHeight = (sz != null)? (int) sz.getHeight()+"": defaultHeight+"";
681
			txtHeight.setText(lastHeight);
682
		}
683
		return txtHeight;
684
	}
685

  
686
	/**
687
	 * This method initializes pnlContactInfo
688
	 *
689
	 * @return javax.swing.JPanel
690
	 */
691
	private JPanel getPnlContactInfo() {
692
		if (pnlContactInfo == null) {
693
			lblEMail = new JLabel();
694
			lblEMail.setBounds(7, 193, 98, 20);
695
			lblEMail.setHorizontalTextPosition(SwingConstants.RIGHT);
696
			lblEMail.setHorizontalAlignment(SwingConstants.RIGHT);
697
			lblEMail.setText(Messages.getText("e-mail")+":");
698
			lblFax = new JLabel();
699
			lblFax.setBounds(274, 168, 57, 20);
700
			lblFax.setHorizontalTextPosition(SwingConstants.RIGHT);
701
			lblFax.setHorizontalAlignment(SwingConstants.RIGHT);
702
			lblFax.setText(Messages.getText("fax")+":");
703
			lblPostCode = new JLabel();
704
			lblPostCode.setBounds(7, 143, 98, 20);
705
			lblPostCode.setHorizontalTextPosition(SwingConstants.RIGHT);
706
			lblPostCode.setHorizontalAlignment(SwingConstants.RIGHT);
707
			lblPostCode.setText(Messages.getText("postcode")+":");
708
			lblPhone = new JLabel();
709
			lblPhone.setBounds(7, 168, 98, 20);
710
			lblPhone.setHorizontalTextPosition(SwingConstants.RIGHT);
711
			lblPhone.setHorizontalAlignment(SwingConstants.RIGHT);
712
			lblPhone.setText(Messages.getText("telephone")+":");
713
			lblCountry = new JLabel();
714
			lblCountry.setBounds(274, 143, 57, 20);
715
			lblCountry.setText(Messages.getText("country")+":");
716
			lblCountry.setHorizontalTextPosition(SwingConstants.RIGHT);
717
			lblCountry.setHorizontalAlignment(SwingConstants.RIGHT);
718
			lblStateProvince = new JLabel();
719
			lblStateProvince.setBounds(252, 119, 111, 20);
720
			lblStateProvince.setText(Messages.getText("state_or_province")+":");
721
			lblStateProvince.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
722
			lblStateProvince.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
723

  
724
			lblCity = new JLabel();
725
			lblCity.setBounds(7, 119, 98, 20);
726
			lblCity.setText(Messages.getText("city")+":");
727
			lblCity.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
728
			lblCity.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
729
			lblContactPosition = new JLabel();
730
			lblContactPosition.setBounds(6, 69, 99, 20);
731
			lblContactPosition.setHorizontalTextPosition(SwingConstants.RIGHT);
732
			lblContactPosition.setHorizontalAlignment(SwingConstants.RIGHT);
733
			lblContactPosition.setText(Messages.getText("contact_position"));
734
			lblContactOrganization = new JLabel();
735
			lblContactOrganization.setBounds(6, 44, 99, 20);
736
			lblContactOrganization.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
737
			lblContactOrganization.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
738
			lblContactOrganization.setText(Messages.getText("contact_organization")+":");
739
			lblAddress = new JLabel();
740
			lblAddress.setBounds(6, 94, 99, 20);
741
			lblAddress.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
742
			lblAddress.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
743
			lblAddress.setText(Messages.getText("address"));
744

  
745
			lblContactPerson = new JLabel();
746
			lblContactPerson.setText(Messages.getText("contact_person")+":");
747
			lblContactPerson.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
748
			lblContactPerson.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
749
			lblContactPerson.setBounds(6, 19, 99, 20);
750
			pnlContactInfo = new JPanel();
751
			pnlContactInfo.setLayout(null);
752
			pnlContactInfo.setBorder(javax.swing.BorderFactory.createTitledBorder(
753
					  null, Messages.getText("contact_info"),
754
					  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
755
					  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
756
			pnlContactInfo.setLocation(4, 158);
757
			pnlContactInfo.setSize(527, 223);
758
			pnlContactInfo.add(lblContactPerson, null);
759
			pnlContactInfo.add(getTxtContactPerson(), null);
760
			pnlContactInfo.add(lblContactOrganization, null);
761
			pnlContactInfo.add(getTxtOrganization(), null);
762
			pnlContactInfo.add(lblContactPosition, null);
763
			pnlContactInfo.add(getTxtContactPosition(), null);
764
			pnlContactInfo.add(lblAddress, null);
765
			pnlContactInfo.add(getTxtAddress(), null);
766
			pnlContactInfo.add(lblCity, null);
767
			pnlContactInfo.add(getTxtCity(), null);
768
			pnlContactInfo.add(lblStateProvince, null);
769
			pnlContactInfo.add(getCmbCountries(), null);
770
			pnlContactInfo.add(getTxtStateOrProvince(), null);
771
			pnlContactInfo.add(lblPostCode, null);
772
			pnlContactInfo.add(getTxtPostCode(), null);
773
			pnlContactInfo.add(lblCountry, null);
774
			pnlContactInfo.add(lblPhone, null);
775
			pnlContactInfo.add(getTxtTelephone(), null);
776
			pnlContactInfo.add(lblFax, null);
777
			pnlContactInfo.add(getTxtFax(), null);
778
			pnlContactInfo.add(lblEMail, null);
779
			pnlContactInfo.add(getTxtEMail(), null);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff