Revision 1460

View differences:

org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Mon Jun 25 09:21:14 CEST 2012
3
buildNumber=2
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
    <modelVersion>4.0.0</modelVersion>
6
    <artifactId>org.gvsig.raster.wms.app</artifactId>
7
    <packaging>pom</packaging>
8
    <version>2.0.0-SNAPSHOT</version>
9
    <name>org.gvsig.raster.wms.app</name>
10
    <description>WMS application</description>
11
    <parent>
12
        <groupId>org.gvsig</groupId>
13
        <artifactId>org.gvsig.maven.base.extension.pom</artifactId>
14
        <version>1.0.8-SNAPSHOT</version>
15
    </parent>
16

  
17
    <scm>
18
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.app</connection>
19
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-raster/org.gvsig.raster.wms/trunk/org.gvsig.raster.wms//org.gvsig.raster.wms.app</developerConnection>
20
        <url>https://devel.gvsig.org/redmine/projects/gvsig-raster/repository/show/org.gvsig.raster.wms/trunk/org.gvsig.raster.wms</url>
21
    </scm>
22

  
23
    <developers>
24
        <developer>
25
            <id>nbrodin</id>
26
            <name>Nacho Brodin</name>
27
            <email>nachobrodin@gmail.com</email>
28
            <roles>
29
                <role>Architect</role>
30
                <role>Developer</role>
31
            </roles>
32
        </developer>
33
    </developers>
34
    <repositories>
35
        <repository>
36
            <id>gvsig-public-http-repository</id>
37
            <name>gvSIG maven public HTTP repository</name>
38
            <url>http://devel.gvsig.org/m2repo/j2se</url>
39
            <releases>
40
                <enabled>true</enabled>
41
                <updatePolicy>daily</updatePolicy>
42
                <checksumPolicy>warn</checksumPolicy>
43
            </releases>
44
            <snapshots>
45
                <enabled>true</enabled>
46
                <updatePolicy>daily</updatePolicy>
47
                <checksumPolicy>warn</checksumPolicy>
48
            </snapshots>
49
        </repository>
50
    </repositories>
51
    <dependencyManagement>
52
        <dependencies>
53
            <dependency>
54
                <groupId>org.gvsig</groupId>
55
                <artifactId>org.gvsig.core.maven.dependencies</artifactId>
56
                <type>pom</type>
57
                <version>2.0.1-SNAPSHOT</version>
58
                <scope>import</scope>
59
            </dependency>
60
        </dependencies>
61
    </dependencyManagement>
62
    <dependencies>
63
        <dependency>
64
            <groupId>org.gvsig</groupId>
65
            <artifactId>org.gvsig.andami</artifactId>
66
            <scope>compile</scope>
67
        </dependency>
68
        <dependency>
69
            <groupId>org.gvsig</groupId>
70
            <artifactId>org.gvsig.i18n</artifactId>
71
            <scope>compile</scope>
72
        </dependency>
73
        <dependency>
74
            <groupId>org.gvsig</groupId>
75
            <artifactId>org.gvsig.tools.lib</artifactId>
76
            <scope>compile</scope>
77
        </dependency>
78
        <dependency>
79
            <groupId>org.slf4j</groupId>
80
            <artifactId>slf4j-api</artifactId>
81
            <scope>compile</scope>
82
        </dependency>
83
        <dependency>
84
            <groupId>org.slf4j</groupId>
85
            <artifactId>slf4j-log4j12</artifactId>
86
            <scope>runtime</scope>
87
        </dependency>
88
    </dependencies>
89
    <modules>
90
        <module>org.gvsig.raster.wms.app.wmsclient</module>
91
    </modules>
92
    <properties>
93
    	<package.info.state>testing</package.info.state>
94
    </properties>
95
</project>
0 96

  
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5
	<modelVersion>4.0.0</modelVersion>
6
	<artifactId>org.gvsig.raster.wms.app.wmsclient</artifactId>
7
	<packaging>jar</packaging>
8
	<name>Formats: WMS support</name>
9
	<parent>
10
		<groupId>org.gvsig</groupId>
11
		<artifactId>org.gvsig.raster.wms.app</artifactId>
12
		<version>2.0.0-SNAPSHOT</version>
13
	</parent>
14
	<description>Web Map Service support</description>
15
	<dependencies>
16
		<dependency>
17
			<groupId>org.gvsig</groupId>
18
			<artifactId>org.gvsig.raster.swing.api</artifactId>
19
			<version>2.0.0-SNAPSHOT</version>
20
            <scope>compile</scope>
21
		</dependency>
22
		<dependency>
23
			<groupId>org.gvsig</groupId>
24
			<artifactId>org.gvsig.raster.swing.impl</artifactId>
25
			<version>2.0.0-SNAPSHOT</version>
26
            <scope>runtime</scope>
27
		</dependency>
28
		<dependency>
29
			<groupId>org.gvsig</groupId>
30
			<artifactId>org.gvsig.raster.tools.app.basic</artifactId>
31
			<version>2.0.0-SNAPSHOT</version>
32
            <scope>compile</scope>
33
		</dependency>
34
		<dependency>
35
			<groupId>org.gvsig</groupId>
36
			<artifactId>org.gvsig.raster.wms.io</artifactId>
37
			<version>2.0.0-SNAPSHOT</version>
38
            <scope>compile</scope>
39
		</dependency>
40
		<dependency>
41
			<groupId>org.gvsig</groupId>
42
			<artifactId>org.gvsig.remoteclient</artifactId>
43
			<scope>compile</scope>
44
		</dependency>
45
		<dependency>
46
			<groupId>org.gvsig</groupId>
47
			<artifactId>org.gvsig.app</artifactId>
48
			<version>2.0-SNAPSHOT</version>
49
            <scope>compile</scope>
50
		</dependency>
51
		<dependency>
52
			<groupId>org.gvsig</groupId>
53
			<artifactId>org.gvsig.raster.lib.api</artifactId>
54
			<version>2.0.0-SNAPSHOT</version>
55
            <scope>compile</scope>
56
		</dependency>
57
		<dependency>
58
			<groupId>org.gvsig</groupId>
59
			<artifactId>org.gvsig.raster.fmap</artifactId>
60
			<version>2.0.0-SNAPSHOT</version>
61
            <scope>compile</scope>
62
		</dependency>
63
        <dependency>
64
            <groupId>org.gvsig</groupId>
65
            <artifactId>org.gvsig.fmap.geometry</artifactId>
66
            <scope>compile</scope>
67
        </dependency>
68
        <dependency>
69
            <groupId>org.gvsig</groupId>
70
            <artifactId>org.gvsig.fmap.dal</artifactId>
71
            <scope>compile</scope>
72
        </dependency>
73
        <dependency>
74
            <groupId>org.gvsig</groupId>
75
            <artifactId>org.gvsig.fmap.dal</artifactId>
76
            <classifier>spi</classifier>
77
            <scope>compile</scope>
78
        </dependency>
79
        <dependency>
80
            <groupId>org.gvsig</groupId>
81
            <artifactId>org.gvsig.fmap.mapcontext</artifactId>
82
            <scope>compile</scope>
83
        </dependency>
84
        <dependency>
85
            <groupId>org.gvsig</groupId>
86
            <artifactId>org.gvsig.fmap.control</artifactId>
87
            <scope>compile</scope>
88
        </dependency>
89
        <dependency>
90
            <groupId>org.gvsig</groupId>
91
            <artifactId>org.gvsig.utils</artifactId>
92
            <scope>compile</scope>
93
        </dependency>
94
        <dependency>
95
            <groupId>org.gvsig</groupId>
96
            <artifactId>org.gvsig.ui</artifactId>
97
            <scope>compile</scope>
98
        </dependency>
99
        <dependency>
100
            <groupId>org.gvsig</groupId>
101
            <artifactId>org.gvsig.symbology.lib.api</artifactId>
102
            <scope>compile</scope>
103
        </dependency>
104
        <!--<dependency>
105
            <groupId>org.gvsig</groupId>
106
            <artifactId>org.gvsig.symbology.lib.impl</artifactId>
107
            <scope>compile</scope>
108
        </dependency>-->
109
        <dependency>
110
            <groupId>org.gvsig</groupId>
111
            <artifactId>org.gvsig.projection</artifactId>
112
            <scope>compile</scope>
113
        </dependency>
114
        <dependency>
115
            <groupId>org.gvsig</groupId>
116
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
117
            <scope>compile</scope>
118
        </dependency>
119
        <dependency>
120
            <groupId>org.gvsig</groupId>
121
            <artifactId>org.gvsig.compat</artifactId>
122
            <scope>compile</scope>
123
        </dependency>
124
        <dependency>
125
			<groupId>org.gvsig</groupId>
126
			<artifactId>org.gvsig.raster.cache.lib.api</artifactId>
127
			<version>2.0.0-SNAPSHOT</version>
128
            <scope>compile</scope>
129
		</dependency>
130
	</dependencies>
131
	<profiles>
132
		<profile>
133
			<id>create-installer</id>
134
			<build>
135
				<plugins>
136
					<plugin>
137
						<groupId>org.gvsig</groupId>
138
						<artifactId>org.gvsig.installer.maven</artifactId>
139
						<configuration>
140
							<javaVM>j1_5</javaVM>
141
						</configuration>
142
					</plugin>
143
				</plugins>
144
			</build>
145
			<properties>
146
				<!--  gvSIG installation folder -->
147
    			<gvsig.install.dir>${basedir}/../../build/product</gvsig.install.dir>
148
    		</properties>
149
		</profile>
150
		<profile>
151
			<id>gvsig-install</id>
152
			<activation>
153
				<activeByDefault>true</activeByDefault>
154
			</activation>
155
			<properties>
156
				<!--
157
					Default gvSIG installation folder relative to the current workspace-->
158
				
159
				<gvsig.install.dir>${basedir}/../../build/product</gvsig.install.dir>
160
		        <package.info.dependencies>required: org.gvsig.raster.tilecache.app -ge 2, required: org.gvsig.raster.tools.app.basic -ge 2</package.info.dependencies>
161
		        <package.info.baseDownloadURL>http://devel.gvsig.org/download/projects/Raster/pool/org.gvsig.raster.wms.app.wmsclient</package.info.baseDownloadURL>
162
		        <package.info.categories>OGC,Remote Services,Raster</package.info.categories>
163
			</properties>
164
		</profile>
165
	</profiles>
166
</project>
0 167

  
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/distribution/distribution.xml
1
<assembly>
2
	<id>distribution</id>
3
	<formats>
4
		<format>dir</format>
5
	</formats>
6
	<fileSets>
7
		<!-- Estructure for the extension -->
8
		<fileSet>
9
			<directory>src/main/resources</directory>
10
			<outputDirectory>${extension.install.dir.name}
11
			</outputDirectory>
12
		</fileSet>
13
	</fileSets>
14
	<files>
15
	   <file>
16
          <source>package.info</source>
17
          <outputDirectory>${extension.install.dir.name}</outputDirectory>
18
       </file>
19
    </files>
20
	<dependencySets>
21
		<dependencySet>
22
			<outputDirectory>${extension.install.dir.name}/${library-dir}
23
			</outputDirectory>
24
			<includes>
25
				<include>org.gvsig:org.gvsig.raster.wms.app.wmsclient:jar</include>
26
				<include>org.gvsig:org.gvsig.raster.wms.io:jar</include>
27
				<include>org.gvsig:org.gvsig.remoteclient</include>
28
			</includes>
29
		</dependencySet>
30
	</dependencySets>
31
</assembly>
0 32

  
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Feb 07 16:39:00 CET 2013
3
buildNumber=29
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/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.Component;
26
import java.awt.Dimension;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.util.HashMap;
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.RemoteServiceException;
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.tools.app.basic.RasterToolsUtil;
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.WMSLayerNode;
65
import org.gvsig.raster.wms.io.WMSServerExplorer;
66
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
68

  
69

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

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

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

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

  
99

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

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

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

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

  
119
	}
120

  
121

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

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

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

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

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

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

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

  
216
                // styles
217
                Vector v = (Vector) info.get("styles");
218
                if (v != null && v.size() > 0) {
219
					toc.setStyleSelections(v);
220
				}
221

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

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

  
243

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

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

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

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

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

  
293
    private class CommandListener implements ActionListener {
294

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

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

  
333
            	//fLayer = wmsParamsTabbedPane.getLayer();
334
            	FLayers parent = ((FLayer)fLayer).getParentLayer();
335

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

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

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

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

  
422
    	return group1;
423
    }
424

  
425

  
426

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

  
434
		}
435
		return m_ViewInfo;
436
	}
437

  
438
	public void close() {
439
		PluginServices.getMDIManager().closeWindow(this);
440
	}
441

  
442

  
443
	public Object getWindowProfile() {
444
		return WindowInfo.DIALOG_PROFILE;
445
	}
446

  
447
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 448

  
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/gui/panel/LayerList.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

  
28
import javax.swing.DefaultListCellRenderer;
29
import javax.swing.JList;
30

  
31
import org.gvsig.gui.beans.controls.dnd.JDnDList;
32
import org.gvsig.raster.wms.io.WMSLayerNode;
33

  
34

  
35
/**
36
 * Class implementing a JList component adapted to the WMSLayerNode
37
 * needs (use it as a JList with drag'n'drop capabilities).
38
 * 
39
 * @author jaume dominguez faus - jaume.dominguez@iver.es
40
 *
41
 */
42
public class LayerList extends JDnDList {
43
	public boolean showLayerNames = false;
44
	private int count = 0; 
45
	public LayerList() {
46
		super();
47
		setCellRenderer(new MyRenderer());
48
	}
49
	
50
	private class MyRenderer extends DefaultListCellRenderer {
51
		public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
52
			super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
53
			if (value instanceof WMSLayerNode){
54
				WMSLayerNode layer = (WMSLayerNode) value;
55
                
56
                if (!showLayerNames) {
57
                	if (layer.getName() != null || layer.getName() == "") {
58
                		String text = layer.toString();
59
                		text = text.substring(text.indexOf(']')+2, text.length());
60
                		setText(text);
61
                	}
62
                }
63
                
64
                Dimension sz  = getPreferredSize();
65
                sz.setSize((sz.getWidth()+50) - (50*count), sz.getHeight());
66
                setPreferredSize(sz);
67
                count++;
68
            }  
69
			return this;
70
		}
71
	}
72
}
0 73

  
org.gvsig.raster.wms/tags/buildNumber_29/org.gvsig.raster.wms/org.gvsig.raster.wms.app/org.gvsig.raster.wms.app.wmsclient/src/main/java/org/gvsig/raster/wms/app/wmsclient/gui/panel/WMSParamsPanel.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.event.FocusAdapter;
28
import java.awt.event.FocusEvent;
29
import java.awt.event.FocusListener;
30
import java.awt.event.MouseAdapter;
31
import java.awt.event.MouseEvent;
32
import java.awt.geom.Rectangle2D;
33
import java.lang.reflect.InvocationTargetException;
34
import java.util.AbstractCollection;
35
import java.util.ArrayList;
36
import java.util.Hashtable;
37
import java.util.TreeSet;
38
import java.util.Vector;
39
import java.util.prefs.Preferences;
40

  
41
import javax.swing.JButton;
42
import javax.swing.JCheckBox;
43
import javax.swing.JList;
44
import javax.swing.JOptionPane;
45
import javax.swing.JPanel;
46
import javax.swing.JScrollPane;
47
import javax.swing.JTabbedPane;
48
import javax.swing.JTextField;
49
import javax.swing.tree.TreePath;
50

  
51
import org.cresques.cts.ICoordTrans;
52
import org.cresques.cts.IProjection;
53
import org.gvsig.andami.IconThemeHelper;
54
import org.gvsig.andami.PluginServices;
55
import org.gvsig.andami.messages.NotificationManager;
56
import org.gvsig.app.gui.WizardPanel;
57
import org.gvsig.app.gui.wizards.FormatListModel;
58
import org.gvsig.app.gui.wizards.WizardListenerSupport;
59
import org.gvsig.fmap.crs.CRSFactory;
60
import org.gvsig.fmap.dal.DALLocator;
61
import org.gvsig.fmap.dal.DataManager;
62
import org.gvsig.fmap.dal.DataParameters;
63
import org.gvsig.fmap.dal.DataStoreParameters;
64
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
65
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters;
66
import org.gvsig.fmap.dal.exception.InitializeException;
67
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
68
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
69
import org.gvsig.fmap.mapcontext.exceptions.ProjectionLayerException;
70
import org.gvsig.fmap.mapcontext.layers.FLayer;
71
import org.gvsig.fmap.mapcontext.layers.FLayers;
72
import org.gvsig.gui.beans.Messages;
73
import org.gvsig.gui.beans.controls.dnd.JDnDListModel;
74
import org.gvsig.gui.beans.listeners.BeanListener;
75
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.LayerTreeModel;
76
import org.gvsig.raster.wms.app.wmsclient.gui.wizard.SRSListModel;
77
import org.gvsig.raster.wms.app.wmsclient.layer.FLyrWMS;
78
import org.gvsig.raster.wms.io.RemoteWMSStyle;
79
import org.gvsig.raster.wms.io.WMSDataParameters;
80
import org.gvsig.raster.wms.io.WMSLayerNode;
81
import org.gvsig.raster.wms.io.WMSServerExplorer;
82
import org.gvsig.raster.wms.io.time.RemoteTimeDimension;
83
import org.slf4j.Logger;
84
import org.slf4j.LoggerFactory;
85

  
86

  
87
/**
88
 * This class implements the map option panel.
89
 *
90
 * It includes a set of Listeners that implement some control rules which
91
 * refresh the component values that depends on those selected in the other
92
 * components to avoid to choose an invalid set of options. It also includes a
93
 * method (isCorrectlyConfigured()) that checks if the current set of values is
94
 * enough to correctly launch a GetMap request.
95
 *
96
 * The information is obtained from a WMSWizardDataSource object.
97
 *
98
 *
99
 * Esta clase implementa el panel de opciones disponibles sobre el mapa
100
 *
101
 * Incluye una serie de Listeners que implementan unas reglas de control que
102
 * refrescan los valores de componentes cuyos valores dependen de aqu๏ฟฝllos
103
 * seleccionados en otros componentes para evitar que se escoja una combinaci๏ฟฝn
104
 * de opciones err๏ฟฝnea as๏ฟฝ como una funci๏ฟฝn (isCorrectlyConfigured()) que
105
 * comprueba si la combinaci๏ฟฝn escogida actualmente es suficiente para lanzar
106
 * una operaci๏ฟฝn GetMap correctamente.
107
 *
108
 * La informaci๏ฟฝn obtiene a partir de un objeto WMSWizardDataSource.
109
 *
110
 * @author jaume - jaume dominguez faus
111
 *
112
 */
113
@SuppressWarnings("unchecked")
114
public class WMSParamsPanel extends WizardPanel {
115
	private static final long       serialVersionUID       = 1L;
116
	private JScrollPane             jScrollPane1           = null;
117
	private JScrollPane             jScrollPane2           = null;
118
	private JScrollPane             jScrollPane3           = null;
119
	private JScrollPane             jScrollPane5           = null;
120
	private JButton                 btnAdd                 = null;
121
	private JButton                 btnDel                 = null;
122
	private JScrollPane             jScrollPane6           = null;
123
	private JPanel                  jPanel2                = null;
124
	private JPanel                  tabFormats             = null;
125
	private JPanel                  jPanel4                = null;
126
	private JTextField              jTxtNomCapa            = null;
127
	private LayerList               lstSelectedLayers      = null;
128
	private ArrayList<TreePath>     selectedPaths          = new ArrayList<TreePath>();
129
	private JList                   lstSRSs                = null;
130
	private JList                   lstInfoFormats         = null;
131
	private LayerTree               treeLayers             = null;
132
	private JList                   lstFormats             = null;
133
	private WizardListenerSupport   listenerSupport;
134
	private JTabbedPane             jTabbedPane            = null;
135
	private JPanel                  tabLayers              = null;
136
	private JPanel                  jPanel1                = null;
137
	private JPanel                  jPanel5                = null;
138
	private JPanel                  jPanel6                = null;
139
	private StylesPanel             tabStyle               = null;
140
	private JCheckBox               chkTransparency        = null;
141
	private InfoPanel               tabInfo                = null;
142
	private DimensionPanel          tabDimensions          = null;
143
	private int                     dimensionTabIndex;
144
	private int                     stylesTabIndex;
145
	private String                  oldSRS                 = null;
146
	private AbstractCollection      oldDimensions          = null;
147
	private Dimension               sizeFixed;
148
	private JCheckBox               chkExtendedNames       = null;
149
	private JButton                 btnUp                  = null;
150
	private JButton                 btnDown                = null;
151
	protected WMSServerExplorer     explorer               = null;
152
	private boolean                 updating               = fPrefs.getBoolean("refresh_capabilities", false);
153
	public static Preferences       fPrefs                 = Preferences.userRoot().node("gvsig.wms-wizard");
154
	private Logger                  log                    = LoggerFactory.getLogger(WMSParamsPanel.class);
155
	private JCheckBox               chkDisagregate         = null;
156
	private boolean                 lastCached;
157
	private String                  groupName              = "WMS Group";
158

  
159
	public WMSParamsPanel() {
160
		super();
161
		initialize();
162
	}
163

  
164
	// TODO: crear nuevo constructor para a?adir los panels que quieras...
165
	public WMSParamsPanel(WMSServerExplorer data) {
166
		super();
167
		setWizardData(data);
168
		this.setLayout(null);
169
		this.setVisible(false);
170
		this.setBounds(0, 0, 510, 427);
171
		if (jTabbedPane == null) {
172
			jTabbedPane = new JTabbedPane();
173
			jTabbedPane.setBounds(4, 4, 502, 415);
174
			StylesPanel sp = getTabStyle();
175
			DimensionPanel dp = getTabDimensions();
176

  
177
			jTabbedPane.addTab(PluginServices.getText(this, "capas"), null,
178
					getTabLayers(), null);
179
			jTabbedPane.addTab(PluginServices.getText(this, "estilos"), null,
180
					sp, null);
181
			stylesTabIndex = jTabbedPane.getTabCount() - 1;
182
			jTabbedPane.addTab(PluginServices.getText(this, "dimensiones"),
183
					null, dp, null);
184
			dimensionTabIndex = jTabbedPane.getTabCount() - 1;
185
			jTabbedPane.addTab(PluginServices.getText(this, "formatos"), null,
186
					getTabFormats(), null);
187
			jTabbedPane.setEnabledAt(dimensionTabIndex, false);
188
			jTabbedPane.setEnabledAt(stylesTabIndex, false);
189
		}
190
		this.add(jTabbedPane, null);
191

  
192
		setListenerSupport(new WizardListenerSupport());
193
	}
194

  
195
	/**
196
	 * This method initializes panelPage2
197
	 *
198
	 * @return Panel
199
	 */
200
	private void initialize() {
201
		this.setLayout(null);
202
		this.setVisible(false);
203
		this.setBounds(0, 0, 510, 427);
204
		this.add(getJTabbedPane(), null);
205
	}
206
	
207
	public boolean isUpdatingCache() {
208
		return updating;
209
	}
210

  
211
	public void setUpdatingCache(boolean updating) {
212
		this.updating = updating;
213
	}
214

  
215
	/**
216
	 * This method initializes jPanel2
217
	 *
218
	 * @return Panel
219
	 */
220
	private JPanel getJPanel2() {
221
		if (jPanel2 == null) {
222
			jPanel2 = new JPanel();
223
			jPanel2.setLayout(null);
224
			jPanel2.setBounds(5, 59, 485, 328);
225
			jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(
226
					null, PluginServices.getText(this, "select_layers"),
227
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
228
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
229
					null));
230
			jPanel2.add(getChkExtendedNames(), null);
231

  
232
			jPanel2.add(getJScrollPane1(), null);
233
			jPanel2.add(getBtnDel(), null);
234
			jPanel2.add(getBtnAdd(), null);
235
			jPanel2.add(getJScrollPane5(), null);
236
			jPanel2.add(getBtnUp(), null);
237
			jPanel2.add(getBtnDown(), null);
238
			jPanel2.add(getChkDisagregate(), null);
239
		}
240

  
241
		return jPanel2;
242
	}
243

  
244
	/**
245
	 * This method initializes jPanel4
246
	 *
247
	 * @return Panel
248
	 */
249
	private JPanel getJPanel4() {
250
		if (jPanel4 == null) {
251
			jPanel4 = new JPanel();
252
			jPanel4.setLayout(null);
253
			jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(
254
					null, PluginServices.getText(this, "layer_name"),
255
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
256
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
257
					null));
258
			jPanel4.setBounds(5, 8, 485, 49);
259
			jPanel4.add(getJTxtNomCapa(), null);
260
		}
261

  
262
		return jPanel4;
263
	}
264

  
265
	/**
266
	 * This method initializes jPanel3
267
	 *
268
	 * @return Panel
269
	 */
270
	private JPanel getTabFormats() {
271
		if (tabFormats == null) {
272
			tabFormats = new JPanel();
273
			tabFormats.setLayout(null);
274
			tabFormats.add(getJPanel1(), null);
275
			tabFormats.add(getJPanel5(), null);
276
			tabFormats.add(getJPanel6(), null);
277
		}
278

  
279
		return tabFormats;
280
	}
281

  
282
	/**
283
	 * This method initializes jScrollPane1
284
	 *
285
	 * @return ScrollPane
286
	 */
287
	private JScrollPane getJScrollPane1() {
288
		if (jScrollPane1 == null) {
289
			jScrollPane1 = new JScrollPane();
290
			jScrollPane1.setBounds(11, 22, 460, 123);
291
			jScrollPane1.setViewportView(getTreeLayers());
292
			jScrollPane1.setPreferredSize(new java.awt.Dimension(205, 75));
293
		}
294

  
295
		return jScrollPane1;
296
	}
297

  
298
	/**
299
	 * This method initializes btnDel
300
	 *
301
	 * @return Button
302
	 */
303
	private JButton getBtnDel() {
304
		if (btnDel == null) {
305
			btnDel = new JButton();
306
			// btnDel.setPreferredSize(new java.awt.Dimension(23, 23));
307
			btnDel.setText(PluginServices.getText(this, "remove"));
308
			btnDel.setMargin(new java.awt.Insets(2, 0, 2, 0));
309
			btnDel.setBounds(339, 300, 101, 20);
310
			btnDel.setEnabled(false);
311
			btnDel.addActionListener(new java.awt.event.ActionListener() {
312
				public void actionPerformed(java.awt.event.ActionEvent e) {
313
					delLayer();
314
				}
315
			});
316
		}
317
		return btnDel;
318
	}
319

  
320
	/**
321
	 * This method initializes btnAdd
322
	 *
323
	 * @return Button
324
	 */
325
	private JButton getBtnAdd() {
326
		if (btnAdd == null) {
327
			btnAdd = new JButton();
328
			// btnAdd.setPreferredSize(new java.awt.Dimension(23, 23));
329
			btnAdd.setText(PluginServices.getText(this, "add"));
330
			btnAdd.setMargin(new java.awt.Insets(2, 0, 2, 0));
331
			btnAdd.setBounds(236, 300, 101, 20);
332
			btnAdd.setEnabled(false);
333
			btnAdd.addActionListener(new java.awt.event.ActionListener() {
334
				public void actionPerformed(java.awt.event.ActionEvent e) {
335
					addLayer();
336
				}
337
			});
338
		}
339
		return btnAdd;
340
	}
341

  
342
	/**
343
	 * This method initializes jScrollPane5
344
	 *
345
	 * @return ScrollPane
346
	 */
347
	private JScrollPane getJScrollPane5() {
348
		if (jScrollPane5 == null) {
349
			jScrollPane5 = new JScrollPane();
350
			jScrollPane5.setBounds(11, 155, 422, 120);
351
			jScrollPane5.setViewportView(getLstSelectedLayers());
352
			jScrollPane5.setPreferredSize(new java.awt.Dimension(205, 75));
353
		}
354

  
355
		return jScrollPane5;
356
	}
357

  
358
	/**
359
	 * This method initializes jTextField
360
	 *
361
	 * @return TextField
362
	 */
363
	private JTextField getJTxtNomCapa() {
364
		if (jTxtNomCapa == null) {
365
			jTxtNomCapa = new JTextField();
366
			jTxtNomCapa.setBounds(10, 19, 460, 20);
367
			jTxtNomCapa.setText(PluginServices.getText(this, "WMSLayer"));
368
			jTxtNomCapa.addKeyListener(new java.awt.event.KeyAdapter() {
369
				public void keyTyped(java.awt.event.KeyEvent e) {
370
					fireWizardComplete(isCorrectlyConfigured());
371
				}
372
			});
373
		}
374

  
375
		return jTxtNomCapa;
376
	}
377
	
378
	/**
379
	 * This method initializes jPanel1
380
	 *
381
	 * @return Panel
382
	 */
383
	private JPanel getJPanel1() {
384
		if (jPanel1 == null) {
385
			jPanel1 = new JPanel();
386
			jPanel1.setLayout(null);
387
			jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(
388
					null, PluginServices.getText(this, "select_formats"),
389
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
390
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
391
					null));
392
			jPanel1.setBounds(5, 10, 485, 140);
393
			jPanel1.add(getJScrollPane6(), null);
394
			jPanel1.add(getChkTransparency(), null);
395
		}
396
		return jPanel1;
397
	}
398

  
399
	/**
400
	 * This method initializes jPanel5
401
	 *
402
	 * @return Panel
403
	 */
404
	private JPanel getJPanel5() {
405
		if (jPanel5 == null) {
406
			jPanel5 = new JPanel();
407
			jPanel5.setLayout(null);
408
			jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(
409
					null, PluginServices.getText(this, "seleccionar_srs"),
410
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
411
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
412
					null));
413
			jPanel5.setBounds(5, 150, 485, 140);
414
			jPanel5.add(getJScrollPane2(), null);
415
		}
416
		return jPanel5;
417
	}
418
	
419
	/**
420
	 * This method initializes jPanel6
421
	 *
422
	 * @return Panel
423
	 */
424
	private JPanel getJPanel6() {
425
		if (jPanel6 == null) {
426
			jPanel6 = new JPanel();
427
			jPanel6.setLayout(null);
428
			jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(
429
					null, PluginServices.getText(this, "seleccionar_infobypoint_format"),
430
					javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
431
					javax.swing.border.TitledBorder.DEFAULT_POSITION, null,
432
					null));
433
			jPanel6.setBounds(5, 295, 485, 78);
434
			jPanel6.add(getJScrollPane3(), null);
435
		}
436
		return jPanel6;
437
	}
438

  
439
	/**
440
	 * This method initializes jScrollPane6
441
	 *
442
	 * @return ScrollPane
443
	 */
444
	private JScrollPane getJScrollPane6() {
445
		if (jScrollPane6 == null) {
446
			jScrollPane6 = new JScrollPane();
447
			jScrollPane6.setBounds(5, 23, 470, 110);
448
			jScrollPane6.setViewportView(getLstFormats());
449
			jScrollPane6.setPreferredSize(new java.awt.Dimension(250, 180));
450
		}
451

  
452
		return jScrollPane6;
453
	}
454

  
455
	/**
456
	 * This method initializes jScrollPane2
457
	 *
458
	 * @return ScrollPane
459
	 */
460
	private JScrollPane getJScrollPane2() {
461
		if (jScrollPane2 == null) {
462
			jScrollPane2 = new JScrollPane();
463
			jScrollPane2.setBounds(5, 23, 470, 110);
464
			jScrollPane2.setViewportView(getLstSRSs());
465
			jScrollPane2.setPreferredSize(new java.awt.Dimension(250, 180));
466
		}
467

  
468
		return jScrollPane2;
469
	}
470
	
471
	/**
472
	 * This method initializes jScrollPane3
473
	 *
474
	 * @return ScrollPane
475
	 */
476
	private JScrollPane getJScrollPane3() {
477
		if (jScrollPane3 == null) {
478
			jScrollPane3 = new JScrollPane();
479
			jScrollPane3.setBounds(5, 23, 470, 45);
480
			jScrollPane3.setViewportView(getLstInfoFormats());
481
			jScrollPane3.setPreferredSize(new java.awt.Dimension(250, 120));
482
		}
483

  
484
		return jScrollPane3;
485
	}
486

  
487
	/**
488
	 * Gets the available layers in WMS maintaining the tree structure
489
	 *
490
	 * @return
491
	 */
492
	public LayerTree getLayerStructure() {
493
		return treeLayers;
494
	}
495

  
496
	/**
497
	 * This method initializes treeLayers
498
	 *
499
	 * @return Tree
500
	 */
501
	private LayerTree getTreeLayers() {
502
		if (treeLayers == null) {
503
			treeLayers = new LayerTree();
504
			treeLayers.setRootVisible(true);
505
			treeLayers.addMouseListener(new java.awt.event.MouseAdapter() {
506
				public void mouseClicked(java.awt.event.MouseEvent e) {
507
					if (e.getClickCount() == 2) {
508
						addLayer();
509
					}
510
				}
511
			});
512
			treeLayers
513
					.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
514
						public void valueChanged(
515
								javax.swing.event.TreeSelectionEvent e) {
516

  
517
							boolean isGetMapable = false; 
518
							TreePath[] selecciones = getTreeLayers()
519
									.getSelectionPaths();
520
							if (selecciones != null) {
521
								for (int i = 0; i < selecciones.length
522
										&& !isGetMapable; i++) {
523
									WMSLayerNode layer = ((WMSLayerNode) selecciones[i]
524
											.getLastPathComponent());
525
									isGetMapable = layer.getChildren().size() == 0
526
											|| layer.getName() != null;
527
								}
528

  
529
							}
530
							getBtnAdd().setEnabled(isGetMapable);
531
							fireWizardComplete(isCorrectlyConfigured());
532
						}
533
					});
534
		}
535

  
536
		return treeLayers;
537
	}
538

  
539
	/**
540
	 * This method checks for the options selected within the configuration
541
	 * dialog are correct and enough to perform a GetMap request.
542
	 *
543
	 * @return true if you're done, false if not.
544
	 */
545
	public boolean isCorrectlyConfigured() {
546

  
547
		boolean b;
548
		this.repaint();
549
		boolean infoFormatOk = ((getLstInfoFormats().getModel().getSize()!= 0 && 
550
								getLstInfoFormats().getSelectedIndex() != -1) || 
551
								getLstInfoFormats().getModel().getSize() == 0);
552
		if ((getLstSRSs().getSelectedIndex() != -1)
553
				&& (getLstFormats().getSelectedIndex() != -1)
554
				&& infoFormatOk
555
				&& (getLstSelectedLayers().getModel().getSize() > 0)) {
556
			b = true;
557
		} else {
558
			b = false;
559
		}
560

  
561
		// Enable or disable del button.
562
		int[] selectedIndices = getLstSelectedLayers().getSelectedIndices();
563

  
564
		getBtnDel().setEnabled(selectedIndices != null && selectedIndices.length > 0);
565

  
566
		return b;
567
	}
568

  
569
	public WMSLayerNode[] selectedLayersToArray() {
570
		JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers.getModel());
571
		ArrayList elements = modelo.getElements();
572
		WMSLayerNode[] layers = (WMSLayerNode[]) elements
573
				.toArray(new WMSLayerNode[0]);
574
		return layers;
575
	}
576

  
577
	/**
578
	 * DOCUMENT ME!
579
	 */
580
	private void delLayer() {
581
		int[] indices = lstSelectedLayers.getSelectedIndices();
582

  
583
		try {
584
			ArrayList removeList = new ArrayList();
585
			WMSLayerNode[] infos = selectedLayersToArray();
586
			JDnDListModel modelo = ((JDnDListModel) lstSelectedLayers
587
					.getModel());
588
			for (int i = 0; i < indices.length; i++) {
589
				removeList.add(infos[indices[i]]);
590
			}
591
			modelo.delIndices(indices);
592
			lstSelectedLayers.clearSelection();
593
			fireWizardComplete(isCorrectlyConfigured());
594

  
595
			// delete from selectedPaths as well
596
			WMSLayerNode elemento = null;
597
			WMSLayerNode last = null;
598
			TreePath path = null;
599
			for (int i = removeList.size() - 1; i >= 0; i--) {
600
				elemento = (WMSLayerNode) removeList.get(i);
601
				for (int j = 0; j < selectedPaths.size(); j++) {
602
					path = (TreePath) selectedPaths.get(j);
603
					last = (WMSLayerNode) path.getLastPathComponent();
604
					if (last.getTitle().compareTo(elemento.getTitle()) == 0) {
605
						selectedPaths.remove(path);
606
					}
607
				}
608
			}
609

  
610
			refreshData();
611
			refreshInfo();
612
		} catch (ArrayIndexOutOfBoundsException ex) {
613
			// if you reach this, please, tell me how you did it.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff