Revision 33924

View differences:

tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/DataTransformManager.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.app.daltransform;
29

  
30
import java.util.ArrayList;
31

  
32
import org.gvsig.app.daltransform.gui.DataTransformGui;
33
import org.gvsig.app.daltransform.gui.DataTransformWizard;
34

  
35
/**
36
 * This singleton provides a centralized access to register 
37
 * {@link DataTransformGui} that is a class to establish 
38
 * a relationship between a tranformation and a user interface.
39
 * 
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public interface DataTransformManager {
43
	
44
	/**
45
	 * Register a data transformation
46
	 * @param name
47
	 * the name used to register the transformation
48
	 * @param featureTransformGui
49
	 * the class that contains the relationship between a transformation
50
	 * and its user interface. This class has to be an instance of
51
	 * {@link DataTransformGui}
52
	 */
53
	public void registerDataTransform(String name, Class dataTransformGui);
54
	
55
	/**
56
	 * Register the GUI that is used to apply transformations.
57
	 * @param dataTransformWizard
58
	 * the class that implements the GUI. This class has to be an instance of
59
	 * {@link DataTransformWizard}
60
	 */
61
	public void registerDataTransformWizard(Class dataTransformWizard);
62
	
63
	/**
64
	 * Returns a list of the registered data transformations.
65
	 * @return 
66
	 * A list of the registered data transformations.
67
	 */
68
	public ArrayList<DataTransformGui> getDataTransforms();
69
	
70
	/**
71
	 * Creates a wizard that can be used to apply the transformations.
72
	 * @return 
73
	 * The wizard.
74
	 */
75
	public DataTransformWizard createWizard() throws CreateWizardException;
76
	
77
	/**
78
	 * It creates a wizard and selects the transformation specified
79
	 * by the parameter.
80
	 * @param transformName
81
	 * The name of the transformation to apply.
82
	 * @return
83
	 * The wizard.
84
	 * @throws CreateWizardException
85
	 */
86
	public DataTransformWizard createWizard(String transformName) throws CreateWizardException, NotRegisteredTransformException;
87
	
88
}
89

  
0 90

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/impl/DefaultDataTransformLibrary.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.app.daltransform.impl;
29

  
30
import org.gvsig.app.ApplicationLibrary;
31
import org.gvsig.app.daltransform.DataTransformLibrary;
32
import org.gvsig.app.daltransform.DataTransformLocator;
33
import org.gvsig.app.daltransform.DataTransformManager;
34
import org.gvsig.app.daltransform.gui.impl.DefaultDataTransformWizard;
35
import org.gvsig.fmap.dal.DALLibrary;
36
import org.gvsig.tools.library.AbstractLibrary;
37
import org.gvsig.tools.library.Library;
38
import org.gvsig.tools.library.LibraryException;
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public class DefaultDataTransformLibrary extends AbstractLibrary {
44
		
45
	public DefaultDataTransformLibrary() {
46
		super(DataTransformLibrary.class, Library.TYPE.IMPL);
47
		require(DALLibrary.class);
48
		require(ApplicationLibrary.class);
49
	}
50
	
51
	@Override
52
	protected void doInitialize() throws LibraryException {
53
        //Register the default DataTransformManager
54
        DataTransformLocator.registerDataTransformManager(DefaultDataTransformManager.class);
55
	}
56

  
57
	@Override
58
	protected void doPostInitialize() throws LibraryException {
59
		DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager();
60
		
61
		//Register the default wizard to apply transformations
62
		dataTransformManager.registerDataTransformWizard(DefaultDataTransformWizard.class);
63
	}
64
}
65

  
0 66

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/impl/DefaultDataTransformManager.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.app.daltransform.impl;
29

  
30
import java.util.ArrayList;
31
import java.util.Iterator;
32

  
33
import org.gvsig.app.daltransform.CreateWizardException;
34
import org.gvsig.app.daltransform.DataTransformManager;
35
import org.gvsig.app.daltransform.NotRegisteredTransformException;
36
import org.gvsig.app.daltransform.gui.DataTransformGui;
37
import org.gvsig.app.daltransform.gui.DataTransformWizard;
38
import org.gvsig.tools.ToolsLocator;
39
import org.gvsig.tools.extensionpoint.ExtensionPoint;
40
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44
/**
45
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
46
 */
47
public class DefaultDataTransformManager implements DataTransformManager{
48
	private static final String TRANSFORM_GUI_EXTENSION_POINT = "TransformGuiExtensionPoint";
49
	private static final String TRANSFORM_WIZARD_EXTENSION_POINT = "TransformWizardExtensionPoint";
50
	private static final String TRANSFORM_WIZARD_NAME = "Wizard";
51
	private static final Logger logger = LoggerFactory.getLogger(DefaultDataTransformManager.class);
52
	private ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
53
	
54
	/*
55
	 * (non-Javadoc)
56
	 * @see org.gvsig.feature.transform.FeatureTransformManager#registerFeatureTransform(java.lang.String, java.lang.Class)
57
	 */
58
	public void registerDataTransform(String name,
59
			Class featureTransformPage) {
60
		if (!DataTransformGui.class.isAssignableFrom(featureTransformPage)) {
61
			throw new IllegalArgumentException(featureTransformPage.getName()
62
					+ " must implement the DataTransformGui interface");
63
		}
64
		
65
		ExtensionPoint extensionPoint = extensionPoints.add(TRANSFORM_GUI_EXTENSION_POINT, "");
66
		extensionPoint.append(name, name, featureTransformPage);
67
	}
68

  
69
	/*
70
	 * (non-Javadoc)
71
	 * @see org.gvsig.feature.transform.FeatureTransformManager#getFeatureTransforms()
72
	 */
73
	public ArrayList<DataTransformGui> getDataTransforms() {
74
		ArrayList<DataTransformGui> transformArray = new ArrayList();
75
		
76
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_GUI_EXTENSION_POINT);
77
		Iterator iterator = ep.iterator();
78
		while (iterator.hasNext()) {
79
			try {				
80
				transformArray.add((DataTransformGui)((ExtensionPoint.Extension) iterator
81
						.next()).create());				
82
			} catch (Exception e) {
83
				logger.error("Error creating a FeatureTranformationGui", e);
84
			} 
85
		}
86
		return transformArray;
87
	}
88

  
89
	/*
90
	 * (non-Javadoc)
91
	 * @see org.gvsig.app.daltransform.DataTransformManager#createWizard()
92
	 */
93
	public DataTransformWizard createWizard() throws CreateWizardException {
94
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_WIZARD_EXTENSION_POINT);
95
		try {
96
			return (DataTransformWizard)ep.create(TRANSFORM_WIZARD_NAME);			
97
		} catch (Exception e) {
98
			throw new CreateWizardException(e);
99
		}	
100
	}
101

  
102
	/* (non-Javadoc)
103
	 * @see org.gvsig.app.daltransform.DataTransformManager#registerDataTransformWizard(java.lang.String, java.lang.Class)
104
	 */
105
	public void registerDataTransformWizard(Class dataTransformWizard) {
106
		if (!DataTransformWizard.class.isAssignableFrom(dataTransformWizard)) {
107
			throw new IllegalArgumentException(dataTransformWizard.getName()
108
					+ " must implement the DataTransformWizard interface");
109
		}
110
		
111
		ExtensionPoint extensionPoint = extensionPoints.add(TRANSFORM_WIZARD_EXTENSION_POINT, "");
112
		extensionPoint.append(TRANSFORM_WIZARD_NAME, "", dataTransformWizard);
113
	}
114

  
115
	/* (non-Javadoc)
116
	 * @see org.gvsig.app.daltransform.DataTransformManager#createWizard(java.lang.String)
117
	 */
118
	public DataTransformWizard createWizard(String transformName)
119
			throws CreateWizardException {
120
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_GUI_EXTENSION_POINT);
121
		try {
122
			Object obj = ep.create(transformName);
123
			if (obj == null){
124
				throw new NotRegisteredTransformException(transformName);
125
			}
126
			DataTransformGui dataTransformGui = (DataTransformGui)obj;
127
			DataTransformWizard wizard = createWizard();
128
			wizard.setDataTransformGui(dataTransformGui);
129
			return wizard;
130
		} catch (Exception e) {
131
			throw new CreateWizardException(e);
132
		} 		
133
	}
134
}
135

  
0 136

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/CreateWizardException.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.app.daltransform;
29

  
30
import org.gvsig.tools.exception.BaseException;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class CreateWizardException extends BaseException{
36
	private static final long serialVersionUID = 3062621423281216473L;
37

  
38
	/**
39
	 * @param message
40
	 * @param cause
41
	 * @param key
42
	 * @param code
43
	 */
44
	public CreateWizardException(Throwable cause) {
45
		init();
46
		initCause(cause);
47
	}
48
	
49
	private void init() {
50
		messageKey = "transform_create_wizard_exception";
51
		formatString = "Can?t create the wizard to apply transformations.";
52
	}
53

  
54
}
55

  
0 56

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/FeatureTypeCombo.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.app.daltransform.gui.components.impl;
29

  
30
import java.util.List;
31

  
32
import javax.swing.DefaultComboBoxModel;
33
import javax.swing.JComboBox;
34

  
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.feature.FeatureType;
38
import org.slf4j.Logger;
39
import org.slf4j.LoggerFactory;
40

  
41
/**
42
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
43
 */
44
public class FeatureTypeCombo extends JComboBox{
45
	protected static final Logger logger = LoggerFactory.getLogger(FeatureTypeCombo.class);
46

  
47
	public FeatureTypeCombo() {
48
		super();
49
		this.setModel(new DefaultComboBoxModel());
50
	}
51

  
52
	public void addFeatureStore(FeatureStore featureStore){
53
		removeAllItems();
54
		List<FeatureType> featureTypes;
55
		try {
56
			featureTypes = featureStore.getFeatureTypes();
57
			for (int i=0 ; i<featureTypes.size() ; i++){
58
				((DefaultComboBoxModel)getModel()).addElement(featureTypes.get(i));
59
			}
60
		} catch (DataException e) {
61
			logger.error("Error updating the panel", e);
62
		}		
63
	}
64
	
65
	public FeatureType getSelectedFeatureType(){
66
		return (FeatureType)getSelectedItem();
67
	}	
68
}
69

  
0 70

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/FeatureTypeWrapper.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.app.daltransform.gui.components.impl;
29

  
30
import org.gvsig.fmap.dal.feature.FeatureType;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class FeatureTypeWrapper {
36
	private FeatureType featureType = null;
37
	
38
	/**
39
	 * @param featureType
40
	 */
41
	public FeatureTypeWrapper(FeatureType featureType) {
42
		super();
43
		this.featureType = featureType;
44
	}
45

  
46
	/**
47
	 * @return the featureType
48
	 */
49
	public FeatureType getFeatureType() {
50
		return featureType;
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see java.lang.Object#toString()
55
	 */		
56
	public String toString() {			
57
		return featureType.toString();
58
	}		
59
}
60

  
0 61

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/FeatureTypeAttributesList.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.app.daltransform.gui.components.impl;
29

  
30
import java.util.ArrayList;
31

  
32
import javax.swing.DefaultListModel;
33
import javax.swing.JList;
34

  
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.fmap.dal.feature.FeatureType;
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public class FeatureTypeAttributesList extends JList {
44

  
45
	public FeatureTypeAttributesList() {
46
		super();	
47
		setModel(new DefaultListModel());
48
	}
49
	
50
	public void addFeatureAttrubutes(FeatureStore featureStore) throws DataException{
51
		addFeatureAttributes(featureStore.getDefaultFeatureType());
52
	}
53
	
54
	public void addFeatureAttributes(FeatureType featureType){
55
		removeAll();
56
		FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors();
57
		for (int i=0 ; i<descriptors.length ; i++){
58
			addFeatureAttributeDescriptor(descriptors[i]);						
59
		}		
60
	}
61

  
62
	public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){
63
		((DefaultListModel)getModel()).addElement(new FeatureTypeAttributeWrapper(featureAttributeDescriptor));
64
	}
65
	
66
	public ArrayList<FeatureAttributeDescriptor> getSelectedFeatureTypes(){
67
		ArrayList<FeatureAttributeDescriptor> featureTypes = new ArrayList<FeatureAttributeDescriptor>();
68
		Object[] objects = getSelectedValues();
69
		for (int i=0 ; i<objects.length ; i++){
70
			featureTypes.add(((FeatureTypeAttributeWrapper)objects[i]).getFeatureAttributeDescriptor());
71
		}
72
		return featureTypes;
73
	}
74
	
75
	public String[] getAttributesName(){
76
		Object[] objects = getSelectedValues();
77
		String[] featureTypes = new String[objects.length];
78
		for (int i=0 ; i<objects.length ; i++){
79
			featureTypes[i] = ((FeatureTypeAttributeWrapper)objects[i]).getFeatureAttributeDescriptor().getName();
80
		}
81
		return featureTypes;
82
	}
83
}
84

  
0 85

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/FeatureTypeAttributeWrapper.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.app.daltransform.gui.components.impl;
29

  
30
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
31

  
32
/**
33
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
34
 */
35
public class FeatureTypeAttributeWrapper {
36
	private FeatureAttributeDescriptor attributeDescriptor = null;
37
	
38
	/**
39
	 * @param featureType
40
	 */
41
	public FeatureTypeAttributeWrapper(FeatureAttributeDescriptor attributeDescriptor) {
42
		super();
43
		this.attributeDescriptor = attributeDescriptor;
44
	}
45

  
46
	/**
47
	 * @return the featureType
48
	 */
49
	public FeatureAttributeDescriptor getFeatureAttributeDescriptor() {
50
		return attributeDescriptor;
51
	}
52

  
53
	/* (non-Javadoc)
54
	 * @see java.lang.Object#toString()
55
	 */		
56
	public String toString() {			
57
		return attributeDescriptor.getName();
58
	}		
59
}
60

  
0 61

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/FeatureTypeAttributesCombo.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.app.daltransform.gui.components.impl;
29

  
30
import javax.swing.DefaultComboBoxModel;
31
import javax.swing.JComboBox;
32

  
33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.fmap.dal.feature.FeatureType;
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public class FeatureTypeAttributesCombo extends JComboBox {
44
	protected static final Logger logger = LoggerFactory.getLogger(FeatureTypeAttributesCombo.class);
45

  
46
	public FeatureTypeAttributesCombo() {
47
		super();
48
		this.setModel(new DefaultComboBoxModel());
49
	}
50

  
51
	public void addFeatureAttrubutes(FeatureStore featureStore) throws DataException{
52
		addFeatureAttributes(featureStore.getDefaultFeatureType());
53
	}
54
	
55
	public void addFeatureAttributes(FeatureType featureType){
56
		removeAllItems();
57
		FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors();
58
		for (int i=0 ; i<descriptors.length ; i++){
59
			addFeatureAttributeDescriptor(descriptors[i]);						
60
		}		
61
	}
62

  
63
	public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){
64
		((DefaultComboBoxModel)getModel()).addElement(new FeatureTypeAttributeWrapper(featureAttributeDescriptor));
65
	}
66
		
67
	public FeatureAttributeDescriptor getSelectedFeatureAttributeDescriptor(){
68
		return ((FeatureTypeAttributeWrapper)getSelectedItem()).getFeatureAttributeDescriptor();
69
	}	
70
}
71

  
0 72

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/components/impl/NumericFeatureTypeAttributesCombo.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.app.daltransform.gui.components.impl;
29

  
30
import org.gvsig.fmap.dal.DataTypes;
31
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
32

  
33
/**
34
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
35
 */
36
public class NumericFeatureTypeAttributesCombo extends FeatureTypeAttributesCombo{
37

  
38
	/* (non-Javadoc)
39
	 * @see org.gvsig.app.daltransform.gui.combos.FeatureTypeAttributesCombo#addFeatureAttributeDescriptor(org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor)
40
	 */
41
	public void addFeatureAttributeDescriptor(
42
			FeatureAttributeDescriptor featureAttributeDescriptor) {
43
		int type = featureAttributeDescriptor.getType();
44
		if ((type == DataTypes.DOUBLE) ||
45
				(type == DataTypes.FLOAT) ||
46
				(type == DataTypes.INT) ||
47
				(type == DataTypes.LONG)){
48
			super.addFeatureAttributeDescriptor(featureAttributeDescriptor);
49
		}
50
	}	
51
}
52

  
0 53

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/DataTransformWizard.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.app.daltransform.gui;
29

  
30
import org.gvsig.andami.ui.mdiManager.IWindow;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
33

  
34

  
35
/**
36
 * This interface has to be implemented by the transformation
37
 * wizard. It has to provide 
38
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
39
 */
40
public interface DataTransformWizard {
41
	
42
	/**
43
	 * Returns the window that has to be displayed to 
44
	 * apply transformation.
45
	 * @return
46
	 * The window to display.
47
	 */
48
	public IWindow getWindow();
49
	
50
	/**
51
	 * Returns <code>true</code> if the transformation 
52
	 * can be applied. 
53
	 * @param isApplicable
54
	 * If the transformation can be applied.
55
	 */
56
	public void setApplicable(boolean isApplicable);
57
	
58
	/**
59
	 * Returns the  {@link FeatureStore} that can is used
60
	 * to apply the transformation.
61
	 * @return
62
	 * The selected {@link FeatureStore}
63
	 */
64
	public FeatureStore getFeatureStore();
65
	
66
	/**
67
	 * Returns <code>true</code> if the selected {@link FeatureStore}
68
	 * has been selected from a layer. 
69
	 * @return
70
	 * If the selected {@link FeatureStore} has been selected
71
	 * from a layer. 
72
	 */
73
	public boolean isFeatureStoreLayer();
74
	
75
	/**
76
	 * Returns the selected {@link DataTransformGui}. It is used
77
	 * to create the {@link FeatureStoreTransform}.
78
	 * @return
79
	 * The selected {@link DataTransformGui}.
80
	 */
81
	public DataTransformGui getDataTransformGui();	
82
	
83
	/**
84
	 * Sets the value of the transformation to apply. The wizard
85
	 * uses this transformation like the selected transformation.
86
	 * @param dataTransformGui
87
	 * The transformation to apply.
88
	 */
89
	public void setDataTransformGui(DataTransformGui dataTransformGui);
90
}
91

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/DataTransformWizardPanel.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.app.daltransform.gui;
29

  
30
import javax.swing.JPanel;
31

  
32
/**
33
 * This class has to be inherited by all the classes
34
 * that appears on the transformation wizard. It contains
35
 * methods to manage the wizard.  
36
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
37
 */
38
public interface DataTransformWizardPanel {
39

  
40
	/**
41
	 * Returns a title for the panel.
42
	 * @return
43
	 * The panel title.
44
	 */
45
	public String getPanelTitle();
46

  
47
	/**
48
	 * This method is called when the next button is clicked
49
	 */
50
	public void nextPanel();
51

  
52
	/**
53
	 * This method is called when the last button is clicked
54
	 */
55
	public void lastPanel();
56
	
57
	/**
58
	 * This method is called when the panel is displayed
59
	 */
60
	public void updatePanel();
61
		
62
	/**
63
	 * Return the panel to display.
64
	 * @return
65
	 * The panel.
66
	 */
67
	public JPanel getJPanel();
68
	
69
	/**
70
	 * Sets the DataTransformWizard that contains information about
71
	 * all the wizard.
72
	 * @param dataTransformWizard
73
	 * The wizard to set.
74
	 */
75
	public void setDataTransformWizard(DataTransformWizard dataTransformWizard);
76
}
77

  
78

  
0 79

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/DataTransformGui.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.app.daltransform.gui;
29

  
30
import java.awt.Dimension;
31
import java.util.List;
32

  
33
import org.gvsig.fmap.dal.exception.DataException;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
36

  
37
/**
38
 * This interface is used to establish a relationship between 
39
 * feature transformations and their user interfaces. It creates 
40
 * the panels that are used to set the parameters that the 
41
 * transformation needs. 
42
 * 
43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
44
 */
45
public interface DataTransformGui {
46
    
47
	/**
48
	 * Creates a feature transformation from a feature store. The
49
	 * class that implements this interface can create a transformation
50
	 * using this feature store and all the parameters that the user has
51
	 * selected. All these parameters must be known by this class
52
	 * @param featureStore
53
	 * The selected feature store
54
	 * @return
55
	 * the transformation
56
	 * @throws DataException
57
	 */
58
	public FeatureStoreTransform createFeatureStoreTransform(FeatureStore featureStore) throws DataException;
59
		
60
    /**
61
     * Creates a list of panels to set the parameters used on the transformation.
62
     * @return
63
     * a set of panels with the parameters of the transformation
64
     */
65
	public List<DataTransformWizardPanel> createPanels();
66

  
67
	/**
68
	 * @return the name that is displayed in the feature transformation
69
	 * list
70
	 */
71
	public String getName();
72
	
73
	/**
74
	 * @return a description of the feature transformation
75
	 */
76
	public String getDescription();
77
	
78
	/**
79
	 * Returns the minimum size that has to be the wizard to display
80
	 * the forms.
81
	 * @return
82
	 * The minimum size for the panels. 
83
	 */
84
	public Dimension getMinDimension();
85
}
86

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/impl/SelectDataStoreWizardPanel.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.app.daltransform.gui.impl;
29

  
30
import java.util.List;
31

  
32
import javax.swing.DefaultListModel;
33
import javax.swing.JList;
34
import javax.swing.JScrollPane;
35

  
36
import org.gvsig.andami.PluginServices;
37
import org.gvsig.andami.ui.mdiManager.IWindow;
38
import org.gvsig.app.project.ProjectManager;
39
import org.gvsig.app.project.documents.Document;
40
import org.gvsig.app.project.documents.table.TableDocument;
41
import org.gvsig.app.project.documents.table.TableManager;
42
import org.gvsig.app.project.documents.view.gui.IView;
43
import org.gvsig.fmap.dal.feature.FeatureStore;
44
import org.gvsig.fmap.mapcontext.layers.FLayer;
45
import org.gvsig.fmap.mapcontext.layers.LayersIterator;
46
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
47

  
48

  
49
/**
50
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
51
 */
52
public class SelectDataStoreWizardPanel extends AbstractDataTransformWizardPanel{
53
	private static final long serialVersionUID = -1841990357325903449L;
54
	private JList dataStoreList;
55
	private JScrollPane dataStoreScrollPane;
56

  
57
	/**
58
	 * @param wizardComponents
59
	 */
60
	public SelectDataStoreWizardPanel() {
61
		super();
62
		initComponents();
63
		addDataStores();		
64
	}	
65

  
66
	private void initComponents() {
67
		java.awt.GridBagConstraints gridBagConstraints;
68

  
69
		dataStoreScrollPane = new javax.swing.JScrollPane();
70
		dataStoreList = new javax.swing.JList();
71

  
72
		setLayout(new java.awt.GridBagLayout());
73

  
74
		dataStoreScrollPane.setViewportView(dataStoreList);
75

  
76
		dataStoreList.setModel(new DefaultListModel());
77

  
78
		gridBagConstraints = new java.awt.GridBagConstraints();
79
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
80
		gridBagConstraints.weightx = 1.0;
81
		gridBagConstraints.weighty = 1.0;
82
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
83
		add(dataStoreScrollPane, gridBagConstraints);
84
	}
85

  
86
	public void removeFeatureStore(FeatureStore featureStore){
87
		DefaultListModel model =( DefaultListModel)dataStoreList.getModel();
88
		for (int i=model.getSize()-1 ; i>=0 ; i--){
89
			if (((FeatureStoreCombo)model.get(i)).getFeatureStore().equals(featureStore)){
90
				model.remove(i);
91
				break;
92
			}
93
		}		
94
	}
95

  
96
	/**
97
	 * Adding the objects
98
	 */
99
	private void addDataStores(){
100
		//Add all the tables
101
		List<Document> tables = ProjectManager.getInstance().getCurrentProject()
102
			.getDocuments(TableManager.TYPENAME);
103
		for (Document table : tables) {
104
			((DefaultListModel)dataStoreList.getModel()).addElement(					
105
					new FeatureStoreCombo(
106
							table.getName(),
107
							((TableDocument)table).getStore(),
108
							false
109
					)
110
			);
111
		}
112
		
113
//		ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
114
//		ArrayList<ProjectDocument> tables = ext.getProject().getDocumentsByType(FeatureTableDocumentFactory.registerName);
115
//		for (int i=0 ; i<tables.size() ; i++){
116
//			FeatureTableDocument table = (FeatureTableDocument)tables.get(i);
117
//			((DefaultListModel)dataStoreList.getModel()).addElement(					
118
//					new FeatureStoreCombo(table.getName(),
119
//							table.getStore(),
120
//							false));
121
//		}
122
		//Add the layers from the current view
123
		IWindow window = PluginServices.getMDIManager().getActiveWindow();
124
		if (window instanceof IView){
125
			IView view = (IView)window;
126
			LayersIterator it = new LayersIterator(
127
					view.getMapControl().getMapContext().getLayers());
128
			while(it.hasNext()){
129
				FLayer layer = it.nextLayer();
130
				if (layer instanceof FLyrVect){
131
//					try {
132
						FLyrVect layerVect = (FLyrVect)layer;
133
						FeatureStore featureStore = layerVect.getFeatureStore();
134
						boolean found = false;
135
						for (int i=0 ; i<tables.size() ; i++){
136
							TableDocument table = (TableDocument)tables.get(i);
137
							if (table.getStore().equals(featureStore)) {
138
								found = true;
139
							}							
140
						}
141
						if (!found){
142
							((DefaultListModel)dataStoreList.getModel()).addElement(
143
									new FeatureStoreCombo(layerVect.getName(),
144
											featureStore,
145
											true));
146
						}
147
//					} catch (ReadException e) {
148
//						logger.error("It is not possible to read the FeatureStore", e);
149
//					}
150
				}
151
			}
152
		}	
153
	}
154

  
155

  
156
	/**
157
	 * @return the selected feature store
158
	 */
159
	public FeatureStore getSelectedFeatureStore(){
160
		Object obj = dataStoreList.getSelectedValue();
161
		if (obj != null){
162
			return ((FeatureStoreCombo)obj).getFeatureStore();
163
		}
164
		return null;
165
	}	
166

  
167
	/* (non-Javadoc)
168
	 * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#getFeatureStore()
169
	 */
170
	@Override
171
	public FeatureStore getFeatureStore() {
172
		return getSelectedFeatureStore();
173
	}
174

  
175
	/**
176
	 * @return the selected feature store
177
	 */
178
	public boolean isSelectedFeatureStoreLoaded(){
179
		Object obj = dataStoreList.getSelectedValue();
180
		if (obj != null){
181
			return ((FeatureStoreCombo)obj).isLoaded();
182
		}
183
		return false;
184
	}
185

  
186
	/**
187
	 * Used to fill the combo
188
	 * @author jpiera
189
	 */
190
	private class FeatureStoreCombo{
191
		private FeatureStore featureStore = null;
192
		private String name = null;
193
		private boolean isLoaded = false;
194

  
195
		public FeatureStoreCombo(String name, FeatureStore featureStore, boolean isLoaded) {
196
			super();
197
			this.name = name;
198
			this.featureStore = featureStore;
199
			this.isLoaded = isLoaded;
200
		}
201

  
202
		/**
203
		 * @return the isLoaded
204
		 */
205
		public boolean isLoaded() {
206
			return isLoaded;
207
		}
208

  
209
		/**
210
		 * @return the featureStore
211
		 */
212
		public FeatureStore getFeatureStore() {
213
			return featureStore;
214
		}
215

  
216
		/* (non-Javadoc)
217
		 * @see java.lang.Object#toString()
218
		 */		
219
		public String toString() {			
220
			return name;
221
		}		
222
	}
223

  
224
	/*
225
	 * 	(non-Javadoc)
226
	 * @see org.gvsig.app.daltransform.gui.FeatureTransformWizard#getPanelTitle()
227
	 */
228
	public String getPanelTitle() {
229
		return PluginServices.getText(this, "transform_datastore_selection");
230
	}
231

  
232
	/* (non-Javadoc)
233
	 * @see org.gvsig.app.daltransform.DataTransformWizard#updatePanel()
234
	 */
235
	public void updatePanel() {
236
		if (dataStoreList.getSelectedIndex() == -1){
237
			if (dataStoreList.getModel().getSize() > 0){
238
				dataStoreList.setSelectedIndex(0);
239
				getDataTransformWizard().setApplicable(true);
240
			}else{
241
				getDataTransformWizard().setApplicable(false);
242
			}
243
		}		
244
	}
245

  
246
	/**
247
	 * @return
248
	 */
249
	public boolean isFeatureStoreLayer() {
250
		Object obj = dataStoreList.getSelectedValue();
251
		if (obj != null){
252
			return ((FeatureStoreCombo)obj).isLoaded;
253
		}
254
		return false;
255
	}
256

  
257
	/* (non-Javadoc)
258
	 * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#nextPanel()
259
	 */
260
	@Override
261
	public void nextPanel() {
262
		getDataTransformWizard().updateGui();
263
	}
264
	
265
	
266
}
267

  
0 268

  
tags/v2_0_0_Build_2020/extensions/extDalTransform/src/org/gvsig/app/daltransform/gui/impl/DataTransformSelectionAction.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.app.daltransform.gui.impl;
29

  
30
import jwizardcomponent.FinishAction;
31

  
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.app.daltransform.gui.DataTransformGui;
34
import org.gvsig.fmap.crs.CRSFactory;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
38
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
39
import org.gvsig.fmap.mapcontext.layers.FLayer;
40
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
41
import org.slf4j.Logger;
42
import org.slf4j.LoggerFactory;
43

  
44

  
45
/**
46
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
47
 */
48
public class DataTransformSelectionAction extends FinishAction{
49
	private static final Logger logger = LoggerFactory.getLogger(DataTransformSelectionAction.class);
50
	private DefaultDataTransformWizard dataTransformWizard = null;
51
	
52
	public DataTransformSelectionAction(DefaultDataTransformWizard dataTransformWizard) {
53
		super(dataTransformWizard.getWizardComponents());		
54
		this.dataTransformWizard = dataTransformWizard;
55
	}
56

  
57
	/* (non-Javadoc)
58
	 * @see jwizardcomponent.Action#performAction()
59
	 */
60
	public void performAction() {		
61
		//Gets the selected transformation
62
		DataTransformGui featureTransformGui = dataTransformWizard.getDataTransformGui();
63
			
64
		//Gets the selected FeatureStore
65
		FeatureStore featureStore = dataTransformWizard.getFeatureStore();
66
				
67
		try {			
68
			//Gets the transform
69
			FeatureStoreTransform featureStoreTransform = featureTransformGui.createFeatureStoreTransform(featureStore);
70
			
71
			//Apply the transformation
72
			featureStore.getTransforms().add(featureStoreTransform);
73
			
74
			//Create and load a new layer...
75
			if (dataTransformWizard.isLayerLoaded()){
76
				FLayer layer = LayerFactory.getInstance().createLayer(featureTransformGui.toString(),
77
						featureStore);
78
				layer.setProjection(CRSFactory.getCRS("EPSG:23030"));
79
				dataTransformWizard.getMapContext().getLayers().addLayer(layer);
80
			}
81
		} catch (DataException e) {
82
			logger.error("Error creating the transformation", e);
83
		} catch (LoadLayerException e) {
84
			logger.error("Error loading the layer", e);
85
		}
86
		//Closing the window
87
		PluginServices.getMDIManager().closeWindow(dataTransformWizard);
88
	}
89

  
90
}
91

  
0 92

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

Also available in: Unified diff