Revision 384

View differences:

org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/pom.xml
1
<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/maven-v4_0_0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <artifactId>org.gvsig.wfs.app</artifactId>
4
    <packaging>pom</packaging>
5

  
6
    <name>${project.artifactId}</name>
7
    <description>Web Feature Service support</description>
8
    <version>2.0.59</version>
9

  
10
    <parent>
11
        <groupId>org.gvsig</groupId>
12
        <artifactId>org.gvsig.desktop</artifactId>
13
        <version>2.0.193</version>
14
    </parent>
15

  
16
    <url>https://devel.gvsig.org/redmine/projects/gvsig-wfs</url>
17

  
18
    <repositories>
19
        <repository>
20
            <id>gvsig-public-http-repository</id>
21
            <name>gvSIG maven public HTTP repository</name>
22
            <url>http://devel.gvsig.org/m2repo/j2se</url>
23
            <releases>
24
                <enabled>true</enabled>
25
                <updatePolicy>daily</updatePolicy>
26
                <checksumPolicy>warn</checksumPolicy>
27
            </releases>
28
            <snapshots>
29
                <enabled>true</enabled>
30
                <updatePolicy>daily</updatePolicy>
31
                <checksumPolicy>warn</checksumPolicy>
32
            </snapshots>
33
        </repository>
34
    </repositories>
35

  
36
    <scm>
37
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59</connection>
38
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59</developerConnection>
39
        <url>scm:svn:https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59</url>
40
    </scm>
41

  
42
    <build>
43
        <plugins>
44
            <plugin>
45
                <groupId>org.apache.maven.plugins</groupId>
46
                <artifactId>maven-release-plugin</artifactId>
47
                <configuration>
48
                    <tagBase>https://devel.gvsig.org/svn/gvsig-wfs/org.gvsig.wfs.app/tags</tagBase>
49
                </configuration>
50
            </plugin>
51
        </plugins>
52
    </build>
53
   
54
    <properties>
55
        <org.gvsig.gpe.version>2.1.53</org.gvsig.gpe.version>
56
        <org.gvsig.xmlschema.version>2.0.13</org.gvsig.xmlschema.version>
57
    </properties>  
58
    
59
    <dependencyManagement>
60
        <dependencies>
61
            <!-- Childs -->
62
            <dependency>
63
                <groupId>org.gvsig</groupId>
64
                <artifactId>org.gvsig.wfs.app.mainplugin</artifactId>
65
                <version>2.0.59</version>
66
            </dependency>
67
                                 
68
            <!-- Extern libraries -->
69
            
70
            <!-- gvSIG extern libraries -->
71
            <dependency>
72
                <groupId>org.gvsig</groupId>
73
                <artifactId>org.gvsig.gpe</artifactId>
74
                <version>${org.gvsig.gpe.version}</version>
75
                <type>pom</type>
76
                <scope>import</scope>
77
            </dependency>
78
            <dependency>
79
                <groupId>org.gvsig</groupId>
80
                <artifactId>org.gvsig.xmlschema</artifactId>
81
                <version>${org.gvsig.xmlschema.version}</version>
82
                <type>pom</type>
83
                <scope>import</scope>
84
            </dependency>
85

  
86
        </dependencies>
87
    </dependencyManagement>
88

  
89
    <modules>
90
        <module>org.gvsig.wfs.app.mainplugin</module>
91
    </modules>
92

  
93
</project>
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/org.gvsig.wfs.app.mainplugin/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.wfs.app.mainplugin</include>
33
      </includes>
34
    </dependencySet>
35
  </dependencySets>
36
-->
37

  
38
</assembly>
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/wfs/gui/panels/model/WFSSelectedFeatureManager.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
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27

  
28
package org.gvsig.wfs.gui.panels.model;
29

  
30
import java.text.Collator;
31
import java.util.ArrayList;
32
import java.util.Collections;
33
import java.util.HashMap;
34
import java.util.Hashtable;
35
import java.util.Iterator;
36
import java.util.Locale;
37

  
38
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
39
import org.gvsig.remoteclient.wfs.WFSFeature;
40
import org.gvsig.remoteclient.wfs.exceptions.WFSException;
41
import org.gvsig.utils.StringComparator;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45

  
46
/**
47
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
48
 */
49
public class WFSSelectedFeatureManager {
50
	private static final Logger LOG = LoggerFactory.getLogger(WFSSelectedFeatureManager.class);
51
	
52
    private WFSServerExplorer serverExplorer = null;
53

  
54
	//To keep the array of features
55
	private Hashtable hashFeatures;
56
	private WFSSelectedFeature[] featuresList;
57
	
58
	private static HashMap featureManagers = new HashMap();
59
	
60
	public static WFSSelectedFeatureManager getInstance(WFSServerExplorer serverExplorer){
61
		if (featureManagers.containsKey(serverExplorer)){
62
			return (WFSSelectedFeatureManager)featureManagers.get(serverExplorer);
63
		}
64
		WFSSelectedFeatureManager selectedFeatureManager = new WFSSelectedFeatureManager(serverExplorer);
65
		featureManagers.put(serverExplorer, selectedFeatureManager);
66
		return selectedFeatureManager;
67
	}
68
	
69
	
70
	/**
71
	 * @param serverExplorer
72
	 */
73
	private WFSSelectedFeatureManager(WFSServerExplorer serverExplorer) {
74
		super();
75
		this.serverExplorer = serverExplorer;
76
	}
77
	
78
	public WFSSelectedFeature getFeatureInfo(String nameSpace, String layerName){
79
		if (hashFeatures == null){
80
			getLayerList();
81
		}
82
		WFSSelectedFeature selectedFeature = (WFSSelectedFeature)hashFeatures.get(layerName);
83
		try {
84
			WFSFeature feature = serverExplorer.getFeatureInfo(nameSpace, layerName);
85
			selectedFeature.setFeature(feature);
86
		} catch (WFSException e) {
87
			// The feature doesn't has fields
88
			LOG.error("Impossible to get the feature", e);
89
		}		
90
		return selectedFeature;		
91
	}
92

  
93
	public WFSSelectedFeature[] getLayerList(){
94
		if (hashFeatures == null) {
95
			hashFeatures = new Hashtable();
96
			Hashtable wfsFeatures  = serverExplorer.getFeatures();
97

  
98
			StringComparator stringComparator = new StringComparator();
99
			// Set spanish rules and with case sensitive
100
			Collator collator = Collator.getInstance(new Locale("es_ES"));		
101
			stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
102
			stringComparator.setCaseSensitive(false);
103

  
104
			ArrayList keysList = new ArrayList(wfsFeatures.keySet());
105
			Collections.sort(keysList, stringComparator);
106

  
107
			Iterator keys = keysList.iterator();
108
			featuresList = new WFSSelectedFeature[wfsFeatures.size()];
109

  
110
			for (int i=0 ; i<wfsFeatures.size() ; i++){
111
				WFSFeature feature = (WFSFeature)wfsFeatures.get(keys.next());
112
				WFSSelectedFeature selectedFeature = new WFSSelectedFeature(feature);
113
				featuresList[i] = selectedFeature;
114
				hashFeatures.put(selectedFeature.getName(), selectedFeature);
115
			}
116
		}
117
		return featuresList;
118
	}
119

  
120
	
121
}
122

  
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/wfs/gui/panels/model/WFSSelectedFeature.java
1
package org.gvsig.wfs.gui.panels.model;
2

  
3
import java.util.Vector;
4

  
5
import org.gvsig.remoteclient.utils.BoundaryBox;
6
import org.gvsig.remoteclient.wfs.WFSFeature;
7
import org.gvsig.remoteclient.wfs.WFSFeatureField;
8

  
9
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
10
 *
11
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
12
 *
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
26
 */
27
/**
28
 * This class represents one node of the layer tree of a common WFS service.
29
 *
30
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
31
 */
32
public class WFSSelectedFeature {
33

  
34
    private WFSFeature feature = null;
35
    private Vector selectedFields = new Vector();
36
    private String filter = null;
37
    private Vector srs = new Vector();
38
    private BoundaryBox latLonBbox = null;
39
    private WFSFeatureField geometryField = null;
40

  
41
    /**
42
     * @param feature
43
     */
44
    public WFSSelectedFeature(WFSFeature feature) {
45
        super();
46
        this.feature = feature;
47
    }
48

  
49
    public WFSFeature getWFSFeature() {
50
        return feature;
51
    }
52

  
53
    /**
54
     *
55
     */
56
    public String toString() {
57
        String str;
58
        if (getName() == null) {
59
            str = getTitle();
60
        } else {
61
            str = "[" + getName() + "] " + getTitle();
62
        }
63
        return str;
64
    }
65

  
66
    /**
67
     * @return Returns the _abstract.
68
     */
69
    public String getAbstract() {
70
        return feature.getAbstract();
71
    }
72

  
73
    /**
74
     * @return Returns the name.
75
     */
76
    public String getName() {
77
        return feature.getName();
78
    }
79

  
80
    /**
81
     * @return Returns the title.
82
     */
83
    public String getTitle() {
84
        return feature.getTitle();
85
    }
86

  
87
    /**
88
     * @return Returns the selectedFields.
89
     */
90
    public Vector getSelectedFields() {
91
        return selectedFields;
92
    }
93

  
94
    /**
95
     * @param selectedFields The selectedFields to set.
96
     */
97
    public void setSelectedFields(Vector selectedFields) {
98
        this.selectedFields = selectedFields;
99
    }
100

  
101
    /**
102
     * @param fields The fields to set.
103
     */
104
    public void setSelectedFields(Object[] selectedFields) {
105
        this.selectedFields.clear();
106
        for (int i = 0; i < selectedFields.length; i++) {
107
            this.selectedFields.add(selectedFields[i]);
108
        }
109
    }
110

  
111
    /**
112
     * @return Returns the srs.
113
     */
114
    public Vector getSrs() {
115
        return feature.getSrs();
116
    }
117
    
118
    /**
119
     * @return Returns the latLonBbox.
120
     */
121
    public BoundaryBox getLatLonBbox() {
122
        return feature.getLatLonBbox();
123
    }
124

  
125
    /**
126
     * @return Returns the filter.
127
     */
128
    public String getFilter() {
129
        return filter;
130
    }
131

  
132
    /**
133
     * @param filter The filter to set.
134
     */
135
    public void setFilter(String filter) {
136
        this.filter = filter;
137
    }
138

  
139
    /**
140
     * @return the nameSpace
141
     */
142
    public String getNameSpace() {
143
        if (feature.getNamespace() != null) {
144
            return feature.getNamespace().getLocation();
145
        }
146
        return null;
147
    }
148

  
149
    /**
150
     * @param feature the feature to set
151
     */
152
    public void setFeature(WFSFeature feature) {
153
        this.feature = feature;
154
    }
155

  
156
    public WFSFeatureField getGeometryField() {
157
        if (geometryField == null) {
158
            for (int i = 0; i < getWFSFeature().getFieldSize(); i++) {
159
                WFSFeatureField field = (WFSFeatureField) getWFSFeature().getFieldAt(i);
160
                if (field.isGeometry()) {
161
                    geometryField = field;
162
                }
163
            }
164
        }
165
        return geometryField;
166
    }
167

  
168
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/wfs/gui/panels/AbstractWFSPanel.java
1
package org.gvsig.wfs.gui.panels;
2

  
3
import java.awt.Dimension;
4

  
5
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
6
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
7
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
8
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager;
9
import org.slf4j.Logger;
10
import org.slf4j.LoggerFactory;
11

  
12

  
13

  
14
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
15
 *
16
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
17
 *
18
 * This program is free software; you can redistribute it and/or
19
 * modify it under the terms of the GNU General Public License
20
 * as published by the Free Software Foundation; either version 2
21
 * of the License, or (at your option) any later version.
22
 *
23
 * This program is distributed in the hope that it will be useful,
24
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
 * GNU General Public License for more details.
27
 *
28
 * You should have received a copy of the GNU General Public License
29
 * along with this program; if not, write to the Free Software
30
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
31
 *
32
 * For more information, contact:
33
 *
34
 *  Generalitat Valenciana
35
 *   Conselleria d'Infraestructures i Transport
36
 *   Av. Blasco Ib??ez, 50
37
 *   46010 VALENCIA
38
 *   SPAIN
39
 *
40
 *      +34 963862235
41
 *   gvsig@gva.es
42
 *      www.gvsig.gva.es
43
 *
44
 *    or
45
 *
46
 *   IVER T.I. S.A
47
 *   Salamanca 50
48
 *   46005 Valencia
49
 *   Spain
50
 *
51
 *   +34 963163400
52
 *   dac@iver.es
53
 */
54

  
55
/* CVS MESSAGES:
56
 *
57
 * $Id$
58
 * $Log$
59
 *
60
 */
61

  
62
/**
63
 * <p>Default panel used to create a WFS group's panel.</p>
64
 * 
65
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
66
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
67
 */
68
public abstract class AbstractWFSPanel extends AbstractPanel implements IWFSPanel {
69
	// Default dimensions of all WFS panels
70
	static final int PANEL_WIDTH = 475;
71
	static final int PANEL_HEIGHT = 365;
72
	protected static final Logger logger = LoggerFactory.getLogger(AbstractWFSPanel.class);
73

  
74
	/**
75
	 * Initializes an WFS panel.
76
	 */
77
	public AbstractWFSPanel() {
78
		super();
79
		setPreferredSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
80
	}
81

  
82
	/*
83
	 * (non-Javadoc)
84
	 * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#initialize()
85
	 */
86
	protected void initialize() {
87
		// By default all panels will be at the GUI
88
		setVisible(true);
89
	}
90

  
91
	/**
92
	 * <p>Gets the information of the wizard used to add or load panels.</p>
93
	 * 
94
	 * @return the wizard data
95
	 */
96
	public WFSServerExplorer getServerExplorer(){
97
		return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getServerExplorer();  
98
	}
99
	
100
	public WFSSelectedFeatureManager getSelectedFeatureManager(){
101
		return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getSelectedFeatureManager();
102
	}
103

  
104
	/*
105
	 * (non-Javadoc)
106
	 * @see org.gvsig.gui.beans.panelGroup.panels.AbstractPanel#setReference(java.lang.Object)
107
	 */
108
	public void setReference(Object ref) {
109
		super.setReference(ref);
110
	}	
111
 
112
	/*
113
	 * (non-Javadoc)
114
	 * @see com.iver.cit.gvsig.gui.panels.IWFSPanel#refresh(com.iver.cit.gvsig.fmap.layers.WFSLayerNode)
115
	 */
116
	public void refresh(WFSSelectedFeature layer) {
117
	}
118

  
119
	/*
120
	 * (non-Javadoc)
121
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
122
	 */
123
	public void accept() {
124
	}
125

  
126
	/*
127
	 * (non-Javadoc)
128
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply()
129
	 */
130
	public void apply() {
131
	}
132

  
133
	/*
134
	 * (non-Javadoc)
135
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel()
136
	 */
137
	public void cancel() {
138
	}
139

  
140
	/*
141
	 * (non-Javadoc)
142
	 * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected()
143
	 */
144
	public void selected() {
145
	}
146
}
org.gvsig.wfs.app/tags/org.gvsig.wfs.app-2.0.59/org.gvsig.wfs.app.mainplugin/src/main/java/org/gvsig/wfs/gui/panels/WFSParamsPanel.java
1
package org.gvsig.wfs.gui.panels;
2

  
3
import java.awt.Container;
4
import java.util.List;
5

  
6
import javax.swing.JTabbedPane;
7

  
8
import org.cresques.cts.IProjection;
9
import org.gvsig.andami.PluginServices;
10
import org.gvsig.app.gui.ILayerPanel;
11
import org.gvsig.app.gui.WizardPanel;
12
import org.gvsig.fmap.crs.CRSFactory;
13
import org.gvsig.fmap.dal.DALLocator;
14
import org.gvsig.fmap.dal.DataManager;
15
import org.gvsig.fmap.dal.DataStore;
16
import org.gvsig.fmap.dal.exception.DataException;
17
import org.gvsig.fmap.dal.exception.InitializeException;
18
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
19
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
20
import org.gvsig.fmap.dal.store.wfs.WFSStoreParameters;
21
import org.gvsig.fmap.dal.store.wfs.WFSStoreProvider;
22
import org.gvsig.fmap.geom.Geometry;
23
import org.gvsig.fmap.geom.primitive.Envelope;
24
import org.gvsig.fmap.mapcontext.MapContextLocator;
25
import org.gvsig.fmap.mapcontext.MapContextManager;
26
import org.gvsig.fmap.mapcontext.exceptions.CreateLayerException;
27
import org.gvsig.fmap.mapcontext.layers.FLayer;
28
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
29
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupException;
30
import org.gvsig.gui.beans.panelGroup.exceptions.EmptyPanelGroupGUIException;
31
import org.gvsig.gui.beans.panelGroup.exceptions.ListCouldntAddPanelException;
32
import org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader;
33
import org.gvsig.gui.beans.panelGroup.panels.AbstractPanel;
34
import org.gvsig.gui.beans.panelGroup.panels.IPanel;
35
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel;
36
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding;
37
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace;
38
import org.gvsig.tools.dynobject.DynObject;
39
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
40
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeatureManager;
41
import org.gvsig.wfs.gui.wizards.WFSWizard;
42
import org.slf4j.Logger;
43
import org.slf4j.LoggerFactory;
44

  
45

  
46
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
47
 *
48
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
49
 *
50
 * This program is free software; you can redistribute it and/or
51
 * modify it under the terms of the GNU General Public License
52
 * as published by the Free Software Foundation; either version 2
53
 * of the License, or (at your option) any later version.
54
 *
55
 * This program is distributed in the hope that it will be useful,
56
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
58
 * GNU General Public License for more details.
59
 *
60
 * You should have received a copy of the GNU General Public License
61
 * along with this program; if not, write to the Free Software
62
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
63
 *
64
 * For more information, contact:
65
 *
66
 *  Generalitat Valenciana
67
 *   Conselleria d'Infraestructures i Transport
68
 *   Av. Blasco Ib??ez, 50
69
 *   46010 VALENCIA
70
 *   SPAIN
71
 *
72
 *      +34 963862235
73
 *   gvsig@gva.es
74
 *      www.gvsig.gva.es
75
 *
76
 *    or
77
 *
78
 *   IVER T.I. S.A
79
 *   Salamanca 50
80
 *   46005 Valencia
81
 *   Spain
82
 *
83
 *   +34 963163400
84
 *   dac@iver.es
85
 */
86
/* CVS MESSAGES:
87
 *
88
 * $Id: WFSParamsPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
89
 * $Log$
90
 * Revision 1.42  2007-09-19 16:14:50  jaume
91
 * removed unnecessary imports
92
 *
93
 * Revision 1.41  2007/06/26 09:33:54  jorpiell
94
 * Information tab refreshed
95
 *
96
 * Revision 1.40  2007/04/11 12:08:55  ppiqueras
97
 * Varios cambios:
98
 * - Corregida etiqueta "Campo"
99
 * - Cambiada actualizaci?n
100
 * - Corregido bug: actualizar ?rea visible despu?s de pulsar "Aplicar" en la interfaz gr?fica.
101
 *
102
 * Revision 1.39  2007/03/15 13:33:44  ppiqueras
103
 * Corregido bug de excepci?n que se lanzaba cuando se filtraba y no se pod?a cargar la capa.
104
 *
105
 * Revision 1.38  2007/03/05 13:49:42  ppiqueras
106
 * Si una capa WFS no tiene campos (y por tanto no tiene un campo obligatorio de tipo geometr?a), que avise al usuario y no permita que se intente cargar dicha capa.
107
 *
108
 * Revision 1.37  2007/03/01 13:12:09  ppiqueras
109
 * Mejorado el filtrado por ?rea.
110
 *
111
 * Revision 1.36  2007/02/22 12:30:59  ppiqueras
112
 * - Eliminado m?todo que sobraba.
113
 * - Mejorada la relaci?n con el panel del ?rea.
114
 * - A?adido JOptionPanel de aviso que no se aplicar? ?rea porque es incorrecta.
115
 *
116
 * Revision 1.35  2007/02/20 11:31:11  ppiqueras
117
 * Eliminados comentarios que sobraban.
118
 *
119
 * Revision 1.34  2007/02/19 11:44:42  jorpiell
120
 * Aรฑadidos los filtros por รกrea
121
 *
122
 * Revision 1.33  2007/02/16 13:36:53  ppiqueras
123
 * Que el ?rea seleccionada en el panel WFSArea sea accesible una vez se va a aplicar.
124
 *
125
 * Revision 1.32  2007/02/12 11:37:00  ppiqueras
126
 * A?adidos comentarios y m?todo para refrescar el MapControl de la pesta?a del ?rea.
127
 *
128
 * Revision 1.31  2007/02/09 14:12:39  jorpiell
129
 * Soporte para WFS 1.1 y WFS-T
130
 *
131
 * Revision 1.30  2007/02/02 12:22:22  ppiqueras
132
 * Corregido alg?n bug.
133
 *
134
 * Revision 1.29  2007/01/08 09:37:39  ppiqueras
135
 * Eliminado comentario que sobraba
136
 *
137
 * Revision 1.28  2006/12/29 09:27:02  ppiqueras
138
 * Corregidos varios bugs:
139
 *
140
 * - Se ejecuta 2 veces "Aplicar" o "Aceptar" en los filtros WFS.
141
 * - Cuando se carga por primera vez una capa WFS, si se pone un
142
 * filtro incorrecto, se ignora el filtro (cargando toda la informaciรณn posible de la capa, y borrando el texto de filtrado).
143
 *
144
 * Revision 1.27  2006/12/26 09:19:40  ppiqueras
145
 * Cambiado "atttibutes" en todas las aparaciones en atributos, mรฉtodos, clases, paquetes o comentarios por "fields". (Sรณlo a aquellas que afectan a clases dentro del proyecto extWFS2).
146
 *
147
 * Revision 1.26  2006/12/20 14:22:06  ppiqueras
148
 * Aรฑadido comentario
149
 *
150
 * Revision 1.25  2006/12/15 13:59:36  ppiqueras
151
 * -Permite que se almacenen y/o recojan todos los campos y valores conocidos de la capa actual.
152
 *
153
 * -Ademรกs, control frentre a consultas de filtro errรณneas, (esto a medias aรบn).
154
 *
155
 * - Algรบn comentario mรกs.
156
 *
157
 * Revision 1.24  2006/12/12 10:24:45  ppiqueras
158
 * Nueva funcionalidad: Pulsando doble 'click' sobre una capa de un servidor, se carga (igual que antes), pero ademรกs se avanza a la siguiente pestaรฑa sin tener que pulsar el botรณn 'Siguiente'.
159
 *
160
 * Revision 1.23  2006/12/11 11:02:24  ppiqueras
161
 * Corregido bug -> que se mantenga la frase de filtrado
162
 *
163
 * Revision 1.22  2006/12/04 08:59:47  ppiqueras
164
 * Algunos bugs corregidos. A cambio hay 2 bugs relacionados que todavรญa no han sido corregidos (ver PHPCollab) (los tiene asignados Jorge).
165
 *
166
 * Revision 1.21  2006/11/28 08:05:13  jorpiell
167
 * Se escribe la query en la pesta?a del filtro
168
 *
169
 * Revision 1.20  2006/11/14 13:45:49  ppiqueras
170
 * Aรฑadida pequeรฑa funcionalidad:
171
 * Cuando se pulsa el botรณn "Aplicar", (al seleccionar un nuevo filtro), si el รกrbol de campos posee alguno seleccionado, actualiza los valores (con los nuevos), asociados a รฉste campo seleccionado.
172
 *
173
 * Revision 1.19  2006/10/27 12:10:02  ppiqueras
174
 * Nueva funcionalidad
175
 *
176
 * Revision 1.16  2006/10/23 07:37:04  jorpiell
177
 * Ya funciona el filterEncoding
178
 *
179
 * Revision 1.14  2006/10/13 13:05:32  ppiqueras
180
 * Permite el refrescado de datos del panel de filtrado sobre capa WFS.
181
 *
182
 * Revision 1.13  2006/10/10 12:55:06  jorpiell
183
 * Se ha a?adido el soporte de features complejas
184
 *
185
 * Revision 1.12  2006/10/02 09:17:48  jorpiell
186
 * A?adido el setCRS a la capa
187
 *
188
 * Revision 1.11  2006/09/29 13:02:38  ppiqueras
189
 * Filtro para WFS. De momento sรณlo interfaz grรกfica.
190
 *
191
 * Revision 1.10  2006/07/21 11:50:31  jaume
192
 * improved appearance
193
 *
194
 * Revision 1.9  2006/06/21 12:35:45  jorpiell
195
 * Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
196
 *
197
 * Revision 1.8  2006/06/15 07:50:58  jorpiell
198
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
199
 *
200
 * Revision 1.7  2006/05/25 16:22:47  jorpiell
201
 * Se limpia el panel cada vez que se conecta con un servidor distinto
202
 *
203
 * Revision 1.6  2006/05/25 16:01:43  jorpiell
204
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
205
 *
206
 * Revision 1.5  2006/05/25 10:31:06  jorpiell
207
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
208
 *
209
 * Revision 1.4  2006/05/23 08:09:39  jorpiell
210
 * Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
211
 *
212
 * Revision 1.3  2006/05/19 12:57:08  jorpiell
213
 * Modificados algunos paneles
214
 *
215
 * Revision 1.2  2006/04/20 16:38:24  jorpiell
216
 * Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
217
 *
218
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
219
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
220
 *
221
 */
222

  
223
/**
224
 * <p>Container of the WFS panels, that works as a {@linkplain TabbedPanel TabbedPanel}.</p>
225
 *
226
 * @author Pablo Piqueras Bartolom? (pablo.piqueras@iver.es)
227
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
228
 */
229
public class WFSParamsPanel extends TabbedPanel implements ILayerPanel {
230
	private static final long serialVersionUID = 150328995058481516L;
231

  
232
	private static Logger logger = LoggerFactory.getLogger(WFSParamsPanel.class);
233

  
234
	private WFSServerExplorer serverExplorer = null;
235
	private WFSSelectedFeatureManager selectedFeatureManager = null;
236

  
237
	private static final MapContextManager MAP_CONTEXT_MANAGER = MapContextLocator.getMapContextManager();
238

  
239
	// Tab positions
240
	private int infoTabPosition = -1;
241
	private int featureTabPosition = -1;
242
	private int fieldsTabPosition = -1;
243
	private int optionsTabPosition = -1;
244
	// private int filterTabPosition = -1;
245
	private int areaTabPosition = -1;
246

  
247
	// Tabs
248
	private WFSInfoPanel infoPanel = null;
249
	private WFSSelectFeaturePanel featurePanel = null;
250
	private WFSSelectFieldsPanel fieldsPanel = null;
251
	private WFSOptionsPanel optionsPanel = null;
252
	// private WFSFilterPanel filterPanel = null;
253
	private WFSAreaPanel areaPanel = null;
254

  
255
	private String cacheSelected = null;
256

  
257
	/**
258
	 * This method initializes jTabbedPane
259
	 *
260
	 * @return javax.swing.JTabbedPane
261
	 */
262
	public WFSParamsPanel(Object reference) {
263
		super(reference);
264
		initialize();
265
	}
266

  
267
	/*
268
	 * (non-Javadoc)
269
	 * @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#initialize()
270
	 */
271
	protected void initialize() {
272
		super.initialize();
273

  
274
		this.setVisible(false);
275
	}
276

  
277
	/**
278
	 * Sets the focus to the next tab of the current one.
279
	 */
280
	public void goToNextTab() {
281
		int tabIndex = getSelectedIndex();
282

  
283
		if ((tabIndex - 1) < getPanelInGUICount()) {
284
			int nextIndex = nextPageEnabled();
285

  
286
			if (nextIndex > -1)
287
				setSelectedIndex(nextIndex);
288
		}
289
	}
290

  
291
	/**
292
	 * Sets the focus to the tab previous to the current one.
293
	 */
294
	public void goToPreviousTab(){
295
		setSelectedIndex(previousEnabledPage());
296
	}
297

  
298
	/**
299
	 * @see JTabbedPane#getSelectedIndex()
300
	 */
301
	public int getSelectedIndex(){
302
		return this.getJTabbedPane().getSelectedIndex();
303
	}
304

  
305
	/**
306
	 * @see JTabbedPane#setSelectedIndex(int)
307
	 */
308
	public void setSelectedIndex(int index) {
309
		this.getJTabbedPane().setSelectedIndex(index);
310
	}
311

  
312
	/**
313
	 * This method initializes infoPanel
314
	 *
315
	 * @return the information panel
316
	 */
317
	public WFSInfoPanel getInfoPanel() {
318
		if (infoPanel != null)
319
			return infoPanel;
320

  
321
		if (infoTabPosition == -1)
322
			return null;
323

  
324
		return (infoPanel = (WFSInfoPanel) values().toArray()[infoTabPosition]);
325
	}
326

  
327
	/**
328
	 * This method initializes featurePanel
329
	 *
330
	 * @return javax.swing.JPanel
331
	 */
332
	public WFSSelectFeaturePanel getFeaturesPanel() {
333
		if (featurePanel != null)
334
			return featurePanel;
335

  
336
		if (featureTabPosition == -1)
337
			return null;
338

  
339
		return (featurePanel = (WFSSelectFeaturePanel) values().toArray()[featureTabPosition]);
340
	}
341

  
342
	/**
343
	 * This method initializes fieldsPanel
344
	 *
345
	 * @return javax.swing.JPanel
346
	 */
347
	public WFSSelectFieldsPanel getFieldsPanel() {
348
		if (fieldsPanel != null)
349
			return fieldsPanel;
350

  
351
		if (fieldsTabPosition == -1)
352
			return null;
353

  
354
		return (fieldsPanel = (WFSSelectFieldsPanel) values().toArray()[fieldsTabPosition]);
355
	}
356

  
357
	/**
358
	 * This method initializes optionsPanel
359
	 *
360
	 * @return javax.swing.JPanel
361
	 */
362
	public WFSOptionsPanel getOptionsPanel() {
363
		if (optionsPanel != null)
364
			return optionsPanel;
365

  
366
		if (optionsTabPosition == -1)
367
			return null;
368

  
369
		return (optionsPanel = (WFSOptionsPanel) values().toArray()[optionsTabPosition]);
370
	}
371

  
372
	/**
373
	 * This method initializes filterPanel
374
	 *
375
	 * @return javax.swing.JPanel
376
	 */
377

  
378
	/*
379
	public WFSFilterPanel getFilterPanel(){
380
		if (filterPanel != null)
381
			return filterPanel;
382

  
383
		if (filterTabPosition == -1)
384
			return null;
385

  
386
		return (filterPanel = (WFSFilterPanel) values().toArray()[filterTabPosition]);
387
	}
388
	*/
389

  
390
	/**
391
	 * This method initializes areaPanel
392
	 *
393
	 * @return javax.swing.JPanel
394
	 */
395
	public WFSAreaPanel getAreaPanel() {
396
		if (areaPanel != null)
397
			return areaPanel;
398

  
399
		if (areaTabPosition == -1)
400
			return null;
401

  
402
		return (areaPanel = (WFSAreaPanel) values().toArray()[areaTabPosition]);
403
	}
404

  
405
	/**
406
	 * Verifies that the selected parameters are enough to request
407
	 * the coverage to the server.
408
	 *
409
	 * @return boolean <code>true</code> if its correctly configured;
410
	 * otherwise returns <code>false</code>
411
	 */
412
	public boolean isCorretlyConfigured() {
413

  
414
	    if (featurePanel == null) {
415
	        return false;
416
	    }
417

  
418
	    int n_sel = featurePanel.getSelectedFeaturesCount();
419
	    return (n_sel > 0);
420
	}
421

  
422
	/**
423
	 * Enable or disable the default tabs
424
	 */
425
	public void enableDefaultTabs(boolean isEnabled) {
426
		if (fieldsTabPosition != -1)
427
			setEnabledAt(fieldsTabPosition, isEnabled);
428

  
429
		/*
430
		if (filterTabPosition != -1)
431
			setEnabledAt(filterTabPosition, isEnabled);
432
			*/
433

  
434
		if (areaTabPosition != -1)
435
			setEnabledAt(areaTabPosition, isEnabled);
436
	}
437

  
438
	/*
439
	 * (non-Javadoc)
440
	 * @see org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel#loadPanel(org.gvsig.gui.beans.panelGroup.panels.IPanel)
441
	 */
442
	protected void loadPanel(IPanel panel) {
443
		super.loadPanel(panel);
444

  
445
		if (((AbstractPanel)panel).getClass() ==  WFSInfoPanel.class) {
446
			infoTabPosition = getPanelInGUICount() - 1;
447
			return;
448
		}
449

  
450
		if (((AbstractPanel)panel).getClass() ==  WFSSelectFeaturePanel.class) {
451
			featureTabPosition = getPanelInGUICount() - 1;
452
			return;
453
		}
454

  
455
		if (((AbstractPanel)panel).getClass() ==  WFSSelectFieldsPanel.class) {
456
			fieldsTabPosition = getPanelInGUICount() - 1;
457
			return;
458
		}
459

  
460
		if (((AbstractPanel)panel).getClass() ==  WFSOptionsPanel.class) {
461
			optionsTabPosition = getPanelInGUICount() - 1;
462
			return;
463
		}
464

  
465
		/*
466
		if (((AbstractPanel)panel).getClass() ==  WFSFilterPanel.class) {
467
			filterTabPosition = getPanelInGUICount() - 1;
468
			return;
469
		}
470
		*/
471

  
472
		if (((AbstractPanel)panel).getClass() ==  WFSAreaPanel.class) {
473
			areaTabPosition = getPanelInGUICount() - 1;
474
			return;
475
		}
476
	}
477

  
478
	/**
479
	 * Refresh all the panels with the WFS capabilities information.
480
	 */
481
	public void refreshCapabilitiesInfo(){
482
		WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature();
483
		if (selectedFeature != null) {
484
			selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields());
485
		} else {
486
			getFeaturesPanel().refresh(null);
487
		}
488
		serverExplorer.setUserName(getOptionsPanel().getUserName());
489
		serverExplorer.setMaxFeatures(getOptionsPanel().getBuffer());
490
		serverExplorer.setTimeOut(getOptionsPanel().getTimeout());
491

  
492
		getInfoPanel().refresh(selectedFeature);
493
	}
494

  
495
	/**
496
	 * Gets the information used to add or load a WFS layer.
497
	 *
498
	 * @return information used to add or load a WFS layer
499
	 */
500
	public WFSServerExplorer getServerExplorer() {
501
		return serverExplorer;
502
	}
503

  
504
	/**
505
	 * Sets the information used to add or load a WFS layer.
506
	 *
507
	 * @param wizardData information used to add or load a WFS layer
508
	 */
509
	public void setServerExplorer(WFSServerExplorer serverExplorer) {
510
		this.serverExplorer = serverExplorer;
511
		this.selectedFeatureManager =
512
			WFSSelectedFeatureManager.getInstance(serverExplorer);
513
	}
514

  
515
	/**
516
	 * Returns the next enabled tab's index, or -1 if there isn't any.
517
	 *
518
	 * @return The index or -1 if there is no one.
519
	 */
520
	public int nextPageEnabled() {
521
		int currentPage = getSelectedIndex();
522
		int nPages = getPanelInGUICount();
523

  
524
		if (currentPage == nPages)
525
			return -1;
526

  
527
		for (int i = currentPage + 1; i < nPages; i++){
528
			if (getJTabbedPane().isEnabledAt(i)){
529
				return i;
530
			}
531
		}
532

  
533
		return -1;
534
	}
535

  
536
	/**
537
	 * Returns the index of the current tab.
538
	 *
539
	 * @return index of the current tab
540
	 */
541
	public int currentPage() {
542
		return getSelectedIndex();
543
	}
544

  
545
	/**
546
	 * Returns the index of the previous enabled tab.
547
	 *
548
	 * @return The index, or -1 if there is no one.
549
	 */
550
	public int previousEnabledPage() {
551
		int currentPage = getSelectedIndex();
552

  
553
		if (currentPage == 0)
554
			return -1;
555

  
556
		for (int i = currentPage - 1; i > -1; i--) {
557
			if (isEnabledAt(i)) {
558
				return i;
559
			}
560
		}
561

  
562
		return -1;
563
	}
564

  
565
	/*
566
	 *  (non-Javadoc)
567
	 * @see com.iver.cit.gvsig.gui.WizardPanel#initWizard()
568
	 */
569
	public void initWizard() {
570

  
571
	}
572

  
573
	/*
574
	 *  (non-Javadoc)
575
	 * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
576
	 */
577
	public void execute() {
578

  
579
	}
580

  
581
	/*
582
	 *  (non-Javadoc)
583
	 * @see com.iver.cit.gvsig.gui.ILayerPanel#getLayer()
584
	 */
585
	public FLayer getLayer() {
586
	    try {
587
	        FLayer layer = (FLyrVect) createLayer();
588
	        logger.warn("El flujo de la apliaci?n tal vez no deber?a haber pasado por aqu?.");
589
	        return layer;
590
	    } catch (CreateLayerException e) {
591
	        // do nothing
592
	    }
593
	    return null;
594
	}
595

  
596
	public FLayer createLayer() throws CreateLayerException {
597
		try {
598
		    FLyrVect layerAux =
599
		        (FLyrVect)MAP_CONTEXT_MANAGER.createLayer(getFeaturesPanel().getLayerName(), getDataStoreParameters());
600

  
601
			if((cacheSelected != null) && (!this.cacheSelected.equals(PluginServices.getText(this, "none")))){
602
				layerAux.getFeatureStore().createCache(cacheSelected, getParameters(cacheSelected));
603
			}
604
			return layerAux;
605
		} catch (Exception e) {
606
			logger.warn("Can't create layer.",e);
607
			throw new CreateLayerException(getFeaturesPanel().getLayerName(), e);
608
		}
609

  
610
	}
611

  
612

  
613
	 protected DynObject getParameters(String nameCacheProvider) throws DataException {
614
		 DataManager dataManager = DALLocator.getDataManager();
615
		 return dataManager.createCacheParameters(nameCacheProvider);
616
	 }
617

  
618
	public WFSStoreParameters getDataStoreParameters() throws InitializeException, ProviderNotRegisteredException{
619
		DataManager dataManager = DALLocator.getDataManager();
620
		WFSStoreParameters parameters = (WFSStoreParameters) dataManager
621
		.createStoreParameters(WFSStoreProvider.NAME);
622
		refreshDataStoreParameters(parameters);
623
		return parameters;
624
	}
625

  
626
	private void refreshDataStoreParameters(WFSStoreParameters parameters){
627
		WFSSelectedFeature selectedFeature = getSelectedFeature();
628
		parameters.setUrl(serverExplorer.getUrl());
629
		parameters.setFeatureType(selectedFeature.getNameSpace(),
630
				selectedFeature.getName());
631
		parameters.setFields(getFieldsPanel().getSelectedFieldsAsString());
632
		parameters.setUser(getOptionsPanel().getUserName());
633
		parameters.setPassword(getOptionsPanel().getPassword());
634
		parameters.setMaxFeatures(getOptionsPanel().getBuffer());
635
		parameters.setTimeOut(getOptionsPanel().getTimeout());
636

  
637
		boolean useAxisOrderYX = getOptionsPanel().getUseAxisOrderYX();
638
		parameters.setUseAxisOrderYX(useAxisOrderYX);
639

  
640
		// MapServer no funciona con filtros por intersecci?n de pol?gonos
641

  
642
//		parameters.setFilterByAreaGeometry(getAreaPanel().getArea());
643
		Geometry area = getAreaPanel().getArea();
644
		if (area != null) {
645

  
646
			Envelope envelope = area.getEnvelope();
647
			parameters.setFilterByAreaEnvelope(envelope);
648
		}
649
		parameters.setFilterByAreaCrs(getAreaPanel().getSrs());
650

  
651
		XMLNameSpace ns = selectedFeature.getWFSFeature().getNamespace();
652
		if (ns != null) {
653
	        String ns_pre = ns.getPrefix();
654
	        parameters.setDynValue(
655
	            WFSStoreParameters.DYNFIELDNAME_NAMESPACEPREFIX, ns_pre);
656
		}
657
		// serverExplorer.getServerExplorerProviderServices();
658

  
659
		parameters.setVersion(getOptionsPanel().getVersion());
660

  
661
		parameters.setFilterByAreaOperation(FilterEncoding.GEOMETRIC_OPERATOR_CONTAINS); //(int)AbstractFilter.GEOMETRY_INTERSECTS);
662
		parameters.setFilterByAreaAttribute(selectedFeature.getGeometryField().getName());
663
		parameters.setCrs(getOptionsPanel().getSRS());
664

  
665
		// parameters.setFilterEncodingByAttribute(getFilterPanel().getQuery());
666
	}
667

  
668
    /**
669
     * Sets the forms from a
670
     */
671
    public void setDataStore(DataStore dataStore){
672
        WFSStoreParameters storeParameters =
673
            (WFSStoreParameters)dataStore.getParameters();
674
        WFSSelectedFeature selectedFeature =
675
            selectedFeatureManager.getFeatureInfo(storeParameters.getFeatureNamespace(),
676
                storeParameters.getFeatureType());
677
        getFeaturesPanel().setSelectedFeature(selectedFeature);
678
        getFieldsPanel().setSelectedFields(storeParameters.getFields());
679
        getOptionsPanel().setUserName(storeParameters.getUser());
680
        getOptionsPanel().setPassword(storeParameters.getPassword());
681
        getOptionsPanel().setBuffer(storeParameters.getMaxFeatures());
682
        getOptionsPanel().setTimeOut(storeParameters.getTimeOut());
683
        getAreaPanel().setArea(storeParameters.getFilterByAreaGeometry());
684
        getAreaPanel().setSrs(storeParameters.getFilterByAreaCrs());
685

  
686
        getOptionsPanel().setSRS(storeParameters.getCrs());
687
        getOptionsPanel().setVersion(storeParameters.getVersion());
688

  
689
        // getFilterPanel().setFilterExpressionIntoInterface(storeParameters.getFilterEncodingByAttribute());
690

  
691
        //The filter panel needs to store to update the attributes list
692
        // getFilterPanel().setDataStore(dataStore);
693
    }
694

  
695
    /**
696
     * Gets the node of the layer selected as a feature, with the selected fields and the filter defined.
697
     *
698
     * @return gets the node of the layer selected as a feature, with the selected fields and the filter defined
699
     */
700
    private WFSSelectedFeature getSelectedFeature(){
701
        WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature();
702
        selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields());
703
        // selectedFeature.setFilter(getFilterPanel().getQuery());
704
        return selectedFeature;
705
    }
706

  
707
	/**
708
	 * @see WFSWizard#doClickOnNextButton()
709
	 */
710
	public void doClickOnNextButton() {
711
		Object obj = this.getParent();
712

  
713
		if (obj == null)
714
			return;
715

  
716
		// When we start to connect to a server -> the interface is the dialog WFSWizard
717
		if (obj instanceof WFSWizard)
718
			((WFSWizard)this.getParent()).doClickOnNextButton();
719
		else {
720
			// When we are modifying a loaded layer -> the interface is the dialog WFSPropsDialog
721
			this.advanceCurrentTab();
722
		}
723
	}
724

  
725
	/**
726
	 * Selects the next tab
727
	 */
728
	public void advanceCurrentTab() {
729
		int currentTabIndex = this.getJTabbedPane().getSelectedIndex();
730

  
731
		// Ensure we can select next tab
732
		if ((currentTabIndex != -1) && (currentTabIndex < (values().size() -1)))
733
			setSelectedIndex(currentTabIndex + 1);
734
	}
735

  
736
	/**
737
	 * Refreshes the data of the inner <code>WFSSelectFeaturePanel</code>.
738
	 */
739
	public void refreshWFSSelectFeaturePanel() {
740
		WFSSelectFeaturePanel panel = getFeaturesPanel();
741

  
742
		if (panel != null) {
743
			panel.refresh(null);
744
		}
745
	}
746

  
747
	/**
748
	 * @return the selected projection
749
	 */
750
	public IProjection getSelectedFeatureProjection(){
751
		WFSSelectedFeature selectedFeature = getSelectedFeature();
752
		if (selectedFeature.getSrs().size() > 0){
753
			String crs = (String)selectedFeature.getSrs().get(0);
754
			crs = getSRS(crs);
755
			IProjection projection = CRSFactory.getCRS(crs);
756
			if (projection != null){
757
				return projection;
758
			}
759
		}
760
		return null;
761
	}
762

  
763
	/**
764
	 * Removing the URN prefix
765
	 * @param srs
766
	 * @return
767
	 */
768
	private String getSRS(String srs){
769
		if (srs == null){
770
			return null;
771
		}
772
		if (srs.startsWith("urn:x-ogc:def:crs:")){
773
			String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length());
774
			if (srs.indexOf("EPSG") > 0){
775
				if (newString.indexOf("EPSG") < 0){
776
					newString = "EPSG:" + newString;
777
				}
778
			}
779
			return newString;
780
		}
781
		if (srs.toLowerCase().startsWith("crs:")){
782
			return srs.substring(4, srs.length());
783
		}
784
		return srs;
785
	}
786

  
787
	/**
788
	 * Refresh all the panels every time that a different layer is selected. The info panel is refreshed every time the user
789
	 * makes a click on it.
790
	 *
791
	 * @param selectedFeature the selected layer
792
	 */
793
	public void refresh(WFSSelectedFeature selectedFeature, List vers_list){
794
		boolean hasFields = false;
795

  
796
		if (selectedFeature!=null){
797
			//Update the layer information
798
			selectedFeature = selectedFeatureManager.getFeatureInfo(selectedFeature.getNameSpace(),
799
					selectedFeature.getName());
800

  
801
			// If there is no fields -> disable not necessary tabs
802
			if (selectedFeature.getWFSFeature().getFieldSize() == 0) {
803
				setApplicable(false);
804
				hasFields = false;
805
			}else{
806
				getFieldsPanel().refresh(selectedFeature);
807
				getOptionsPanel().refresh(selectedFeature);
808
                getOptionsPanel().refreshVersions(vers_list);
809
				// getFilterPanel().refresh(selectedFeature);
810
				getAreaPanel().refresh(selectedFeature);
811
				hasFields = true;
812
			}
813
		}
814

  
815
		enableDefaultTabs(hasFields);
816
	}
817

  
818
	/**
819
	 * Changes the <i>enable</i> status of the "<i>apply</i>" button
820
	 *
821
	 * @param isApplicable the <i>enable</i> status of the "<i>apply</i>" button
822
	 */
823
	public void setApplicable(boolean isApplicable){
824
		setEnabledApplyButton(isApplicable);
825
	}
826

  
827
	/*
828
	 * (non-Javadoc)
829
	 * @see org.gvsig.gui.beans.buttonspanel.IButtonsPanel#setEnabledApplyButton(boolean)
830
	 */
831
	public void setEnabledApplyButton(boolean b) {
832
		super.setEnabledApplyButton(b);
833

  
834
		Container parent = getParent();
835

  
836
		if ((parent != null) && (parent instanceof WizardPanel))
837
			((WizardPanel)parent).callStateChanged(b);
838
	}
839

  
840
	/*
841
	 * (non-Javadoc)
842
	 * @see org.gvsig.gui.beans.panelGroup.AbstractPanelGroup#loadPanels(org.gvsig.gui.beans.panelGroup.loaders.IPanelGroupLoader)
843
	 */
844
	public void loadPanels(IPanelGroupLoader loader) throws ListCouldntAddPanelException, EmptyPanelGroupException, EmptyPanelGroupGUIException {
845
		// This code will be executed when is creating the dialog of properties
846
		if (getReference() != null) {
847
			FLyrVect lyr = (FLyrVect) getReference();
848

  
849
			DataManager dataManager = DALLocator.getDataManager();
850
			//Create the datastore parameters and fill them
851
			WFSStoreParameters parameters;
852
			try {
853
				parameters = (WFSStoreParameters) dataManager
854
				.createStoreParameters(WFSStoreProvider.NAME);
855
				parameters.setUrl(serverExplorer.getUrl());
856
				parameters.setVersion(serverExplorer.getVersion());
857
				//parameters.setFeatureType(namespacePrefix, namespace, featureType);
858

  
859
				//dataSource.setDriver(lyr.getWfsDriver());
860

  
861
				//setServerExplorer(dataSource);
862

  
863
				super.loadPanels(loader);
864

  
865
				//				HashMap<String, Object> info = lyr.getProperties();
866
				//				setSelectedFeature((WFSLayerNode)info.get("wfsLayerNode"));
867
				//				setStatus((WFSStatus)info.get("status"));
868
				//				setLayerName(lyr.getName());
869
				//				setVisible(true);
870
				//				refreshInfo();
871
			} catch (InitializeException e) {
872
				// TODO Auto-generated catch block
873
				e.printStackTrace();
874
			} catch (ProviderNotRegisteredException e) {
875
				// TODO Auto-generated catch block
876
				e.printStackTrace();
877
			}
878
			return;
879
		}
880

  
881
		// This will executed when is adding a new WFS layer:
882
		super.loadPanels(loader);
883
	}
884

  
885
	///// BEGIN: METHODS FOR INITIALIZE THIS PANEL AS A COMPONENT OF A PROPERTIES DIALOG /////
886

  
887

  
888
	/**
889
	 * @see WFSSelectFeaturePanel#setLayerName(String)
890
	 */
891
	public void setLayerName(String name) {
892
		getFeaturesPanel().setLayerName(name);
893
	}
894

  
895
	/**
896
	 * Updates the information stored at the wizard's data and <i>info</i> panel.
897
	 */
898
	public void refreshInfo(){
899
		WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature();
900

  
901
		if (selectedFeature != null) {
902
			selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields());
903
		}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff