Revision 39256

View differences:

tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/test/java/org/gvsig/daltransform/BaseFeatureStoreTransform.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.daltransform;
29

  
30
import org.gvsig.fmap.dal.DataStoreParameters;
31
import org.gvsig.fmap.dal.exception.DataException;
32
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
33
import org.gvsig.fmap.dal.feature.BaseTestFeatureStore;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
36
import org.gvsig.tools.ToolsLocator;
37
import org.gvsig.tools.persistence.PersistentState;
38

  
39
/**
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public abstract class BaseFeatureStoreTransform extends BaseTestFeatureStore {
43
	public abstract DataStoreParameters getDefaultDataStoreParameters() throws DataException;
44
		
45
	public void testInitializeStore() throws Exception {
46
		FeatureStore store = (FeatureStore) dataManager.createStore(this
47
				.getDefaultDataStoreParameters());
48
		assertNotNull(store);
49
		store.dispose();
50
	}
51
	
52
	public abstract FeatureStoreTransform getFeatureStoreTransform() throws DataException, ValidateDataParametersException;
53
	
54
	public void testTransform() throws Exception {
55
		FeatureStore store = (FeatureStore) dataManager.createStore(this
56
				.getDefaultDataStoreParameters());
57
		store.getTransforms().add(getFeatureStoreTransform());
58
		this.testSimpleIteration(store);		
59
	}
60
	
61
	public void testPersistenceTransform() throws Exception {
62
		if (ToolsLocator.getPersistenceManager() == null) {
63
			fail("Default Persistence Manager not register");
64
		}
65
		FeatureStore store = (FeatureStore) dataManager.createStore(this
66
				.getDefaultDataStoreParameters());
67
		store.getTransforms().add(getFeatureStoreTransform());
68

  
69
		testSimpleIteration(store);
70

  
71
		PersistentState state = ToolsLocator.getPersistenceManager().getState(
72
				store);
73

  
74
		FeatureStore store2 = (FeatureStore) ToolsLocator
75
				.getPersistenceManager().create(state);
76

  
77
		testSimpleIteration(store2);
78

  
79
		assertTrue(compareStores(store, store2));
80

  
81
		store.dispose();
82
		store2.dispose();
83
	}
84

  
85
	/* (non-Javadoc)
86
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#hasExplorer()
87
	 */
88
	public boolean hasExplorer() {
89
		// TODO Auto-generated method stub
90
		return false;
91
	}
92

  
93
	/* (non-Javadoc)
94
	 * @see org.gvsig.fmap.dal.feature.BaseTestFeatureStore#usesResources()
95
	 */	
96
	public boolean usesResources() {		
97
		return false;
98
	}	
99
	
100
	
101
}
102

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/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.daltransform;
29

  
30
import java.util.List;
31

  
32
import org.gvsig.daltransform.swing.DataTransformGui;
33
import org.gvsig.daltransform.swing.DataTransformWizard;
34
import org.gvsig.daltransform.swing.JDataTransformList;
35
import org.gvsig.daltransform.swing.JDialogDataTransformList;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37

  
38
/**
39
 * This singleton provides a centralized access to register
40
 * {@link DataTransformGui} that is a class to establish
41
 * a relationship between a tranformation and a user interface.
42
 * 
43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
44
 */
45
public interface DataTransformManager {
46

  
47
    /**
48
     * Register a data transformation
49
     * 
50
     * @param name
51
     *            the name used to register the transformation
52
     * @param featureTransformGui
53
     *            the class that contains the relationship between a
54
     *            transformation
55
     *            and its user interface. This class has to be an instance of
56
     *            {@link DataTransformGui}
57
     */
58
    public void registerDataTransform(String name, Class<?> dataTransformGui);
59

  
60
    /**
61
     * Register the GUI that is used to apply transformations.
62
     * 
63
     * @param dataTransformWizard
64
     *            the class that implements the GUI. This class has to be an
65
     *            instance of {@link DataTransformWizard}
66
     */
67
    public void registerDataTransformWizard(Class<?> dataTransformWizard);
68

  
69
    /**
70
     * Returns a list of the registered data transformations.
71
     * 
72
     * @return
73
     *         A list of the registered data transformations.
74
     */
75
    public List<DataTransformGui> getDataTransforms();
76

  
77
    /**
78
     * Creates a wizard that can be used to apply the transformations.
79
     * 
80
     * @return
81
     *         The wizard.
82
     */
83
    public DataTransformWizard createWizard() throws CreateWizardException;
84

  
85
    /**
86
     * It creates a wizard and selects the transformation specified
87
     * by the parameter.
88
     * 
89
     * @param transformName
90
     *            The name of the transformation to apply.
91
     * @return
92
     *         The wizard.
93
     * @throws CreateWizardException
94
     */
95
    public DataTransformWizard createWizard(String transformName)
96
        throws CreateWizardException, NotRegisteredTransformException;
97

  
98
    public JDataTransformList createJDataTransformList(FeatureStore featureStore);
99

  
100
    // public JDialogDataTransformList createJDialogDataTransformList(
101
    // FeatureStore featureStore);
102

  
103
    public JDialogDataTransformList createJDialogDataTransformList();
104

  
105
}
0 106

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/app/mainplugin/DataTransformExtension.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.daltransform.app.mainplugin;
29

  
30
import java.awt.Component;
31
import java.awt.GridBagConstraints;
32

  
33
import javax.swing.JOptionPane;
34

  
35
import org.gvsig.andami.IconThemeHelper;
36
import org.gvsig.andami.PluginServices;
37
import org.gvsig.andami.plugins.Extension;
38
import org.gvsig.andami.ui.ToolsWindowManager;
39
import org.gvsig.app.ApplicationLocator;
40
import org.gvsig.app.ApplicationManager;
41
import org.gvsig.daltransform.DataTransformLocator;
42
import org.gvsig.daltransform.DataTransformManager;
43
import org.gvsig.daltransform.swing.JDialogDataTransformList;
44
import org.gvsig.i18n.Messages;
45
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
46

  
47
/**
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
49
 */
50
public class DataTransformExtension extends Extension {
51

  
52
    /*
53
     * (non-Javadoc)
54
     * 
55
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
56
     */
57
    public void execute(String actionCommand) {
58
        ApplicationManager application = ApplicationLocator.getManager();
59
        DataTransformManager manager =
60
            DataTransformLocator.getDataTransformManager();
61

  
62
        if ("CREATE".equalsIgnoreCase(actionCommand)) {
63
            try {
64
                PluginServices.getMDIManager().addWindow(
65
                    manager.createWizard().getWindow());
66

  
67
            } catch (Exception e) {
68
                JOptionPane.showInternalMessageDialog(
69
                    (Component) PluginServices.getMDIManager(), 
70
                    Messages.getText("transform_create_wizard_exception"),
71
                    Messages.getText("feature_transform"),
72
                    JOptionPane.ERROR_MESSAGE);
73
            }
74
        } else
75
            if ("VIEW".equalsIgnoreCase(actionCommand)) {
76

  
77
                // there is no layer loaded
78
                if (application.getActiveDocument() == null) {
79
                    JOptionPane.showMessageDialog(null,
80
                        Messages.getText("not_featurestore_loaded"),
81
                        Messages.getText("view_transforms"),
82
                        JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE);
83
                    return;
84
                }
85

  
86
                JDialogDataTransformList dialog =
87
                    manager.createJDialogDataTransformList();
88

  
89
                ToolsWindowManager wm = new ToolsWindowManager();
90
                wm.showWindow(dialog, Messages.getText("view_transforms"),
91
                    WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
92
            }
93

  
94
    }
95

  
96
    /*
97
     * (non-Javadoc)
98
     * 
99
     * @see com.iver.andami.plugins.IExtension#initialize()
100
     */
101
    public void initialize() {
102
    	IconThemeHelper.registerIcon("feature-transform-tools", "feature-transform-wizard", this);
103
    }
104

  
105
    /*
106
     * (non-Javadoc)
107
     * 
108
     * @see com.iver.andami.plugins.Extension#postInitialize()
109
     */
110
    @Override
111
    public void postInitialize() {
112
        super.postInitialize();
113
    }
114

  
115
    /*
116
     * (non-Javadoc)
117
     * 
118
     * @see com.iver.andami.plugins.IExtension#isEnabled()
119
     */
120
    public boolean isEnabled() {
121
        return true;
122
    }
123

  
124
    /*
125
     * (non-Javadoc)
126
     * 
127
     * @see com.iver.andami.plugins.IExtension#isVisible()
128
     */
129
    public boolean isVisible() {
130
        return true;
131
    }
132
}
0 133

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/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.daltransform.impl;
29

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

  
39
/**
40
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
41
 */
42
public class DefaultDataTransformLibrary extends AbstractLibrary {
43
		
44
    @Override
45
    public void doRegistration() {
46
        registerAsImplementationOf(DataTransformLibrary.class);
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_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/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.daltransform.impl;
29

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

  
34
import org.slf4j.Logger;
35
import org.slf4j.LoggerFactory;
36

  
37
import org.gvsig.daltransform.CreateWizardException;
38
import org.gvsig.daltransform.DataTransformManager;
39
import org.gvsig.daltransform.NotRegisteredTransformException;
40
import org.gvsig.daltransform.swing.DataTransformGui;
41
import org.gvsig.daltransform.swing.DataTransformWizard;
42
import org.gvsig.daltransform.swing.JDataTransformList;
43
import org.gvsig.daltransform.swing.JDialogDataTransformList;
44
import org.gvsig.daltransform.swing.impl.DefaultJDataTransformList;
45
import org.gvsig.daltransform.swing.impl.DefaultJDialogDataTransformList;
46
import org.gvsig.fmap.dal.feature.FeatureStore;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.extensionpoint.ExtensionPoint;
49
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
50

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

  
76
	/*
77
	 * (non-Javadoc)
78
	 * @see org.gvsig.feature.transform.FeatureTransformManager#getFeatureTransforms()
79
	 */
80
	@SuppressWarnings("unchecked")
81
    public List<DataTransformGui> getDataTransforms() {
82
		List<DataTransformGui> transformArray = new ArrayList<DataTransformGui>();
83
		
84
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_GUI_EXTENSION_POINT);
85
		Iterator<ExtensionPoint.Extension> iterator = ep.iterator();
86
		while (iterator.hasNext()) {
87
			try {				
88
				transformArray.add((DataTransformGui)((ExtensionPoint.Extension) iterator
89
						.next()).create());				
90
			} catch (Exception e) {
91
				logger.error("Error creating a FeatureTranformationGui", e);
92
			} 
93
		}
94
		return transformArray;
95
	}
96

  
97
	/*
98
	 * (non-Javadoc)
99
	 * @see org.gvsig.app.daltransform.DataTransformManager#createWizard()
100
	 */
101
	public DataTransformWizard createWizard() throws CreateWizardException {
102
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_WIZARD_EXTENSION_POINT);
103
		try {
104
			return (DataTransformWizard)ep.create(TRANSFORM_WIZARD_NAME);			
105
		} catch (Exception e) {
106
			throw new CreateWizardException(e);
107
		}	
108
	}
109

  
110
	/* (non-Javadoc)
111
	 * @see org.gvsig.app.daltransform.DataTransformManager#registerDataTransformWizard(java.lang.String, java.lang.Class)
112
	 */
113
	public void registerDataTransformWizard(Class<?> dataTransformWizard) {
114
		if (!DataTransformWizard.class.isAssignableFrom(dataTransformWizard)) {
115
			throw new IllegalArgumentException(dataTransformWizard.getName()
116
					+ " must implement the DataTransformWizard interface");
117
		}
118
		
119
		ExtensionPoint extensionPoint = extensionPoints.add(TRANSFORM_WIZARD_EXTENSION_POINT, "");
120
		extensionPoint.append(TRANSFORM_WIZARD_NAME, "", dataTransformWizard);
121
	}
122

  
123
	/* (non-Javadoc)
124
	 * @see org.gvsig.app.daltransform.DataTransformManager#createWizard(java.lang.String)
125
	 */
126
	public DataTransformWizard createWizard(String transformName)
127
			throws CreateWizardException {
128
		ExtensionPoint ep = extensionPoints.add(TRANSFORM_GUI_EXTENSION_POINT);
129
		try {
130
			Object obj = ep.create(transformName);
131
			if (obj == null){
132
				throw new NotRegisteredTransformException(transformName);
133
			}
134
			DataTransformGui dataTransformGui = (DataTransformGui)obj;
135
			DataTransformWizard wizard = createWizard();
136
			wizard.setDataTransformGui(dataTransformGui);
137
			return wizard;
138
		} catch (Exception e) {
139
			throw new CreateWizardException(e);
140
		} 		
141
	}
142
	
143
    public JDataTransformList createJDataTransformList(FeatureStore featureStore) {
144
        return new DefaultJDataTransformList(featureStore);
145
    }
146

  
147
    public JDialogDataTransformList createJDialogDataTransformList() {
148
        return new DefaultJDialogDataTransformList();
149
    }
150

  
151
//    public JDialogDataTransformList createJDialogDataTransformList(
152
//        FeatureStore featureStore) {
153
//        return new DefaultJDialogDataTransformList(featureStore);
154
//    }
155
}
156

  
0 157

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/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.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_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/JDataTransformList.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
package org.gvsig.daltransform.swing;
23

  
24
import javax.swing.JPanel;
25
import javax.swing.event.ListSelectionListener;
26

  
27
import org.gvsig.fmap.dal.feature.FeatureStore;
28
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
29
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms;
30

  
31
/**
32
 * @author gvSIG Team
33
 * @version $Id$
34
 * 
35
 */
36
public abstract class JDataTransformList extends JPanel {
37

  
38
    private static final long serialVersionUID = -6577975265992377228L;
39

  
40
    public abstract FeatureStoreTransform getSelected();
41

  
42
    public abstract void remove(FeatureStoreTransform transform);
43

  
44
    public <ListSelectionListenerHandler> void addListSelectionListener(
45
        ListSelectionListenerHandler listSelectionListenerHandler) {
46
    }
47

  
48
    public abstract void addTransforms(FeatureStoreTransforms transforms);
49

  
50
    public abstract void removeAllTransforms();
51

  
52
    public abstract void changeStore(FeatureStore featureStore);
53

  
54
    public abstract int getTransformsCount();
55

  
56
    public abstract boolean isLastTransform(FeatureStoreTransform selected);
57

  
58
    public abstract void addListSelectionListener(
59
        ListSelectionListener actionListener);
60

  
61
    public abstract int getSelectedIndex();
62

  
63
}
0 64

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/JDialogDataTransformList.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
package org.gvsig.daltransform.swing;
23

  
24
import javax.swing.JPanel;
25

  
26
/**
27
 * @author gvSIG Team
28
 * @version $Id$
29
 * 
30
 */
31
public abstract class JDialogDataTransformList extends JPanel {
32

  
33
    private static final long serialVersionUID = -4119133113380461961L;
34

  
35
    public abstract void setDeleteButton(boolean active);
36

  
37
}
0 38

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/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.daltransform.swing.impl;
29

  
30
import jwizardcomponent.FinishAction;
31

  
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.daltransform.swing.DataTransformGui;
37
import org.gvsig.fmap.crs.CRSFactory;
38
import org.gvsig.fmap.dal.exception.DataException;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.dal.feature.FeatureStoreTransform;
41
import org.gvsig.fmap.mapcontext.MapContextLocator;
42
import org.gvsig.fmap.mapcontext.MapContextManager;
43
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
44
import org.gvsig.fmap.mapcontext.layers.FLayer;
45

  
46

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

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

  
94
}
95

  
0 96

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/DataTransformWizardContainer.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.daltransform.swing.impl;
29

  
30
import java.awt.BorderLayout;
31

  
32
import jwizardcomponent.JWizardComponents;
33
import jwizardcomponent.JWizardPanel;
34

  
35
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
36

  
37

  
38
/**
39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
40
 */
41
public class DataTransformWizardContainer extends JWizardPanel {
42
	private static final long serialVersionUID = -3410258554443619626L;
43
	private DataTransformWizardPanel wizard = null;
44
	
45
	/**
46
	 * @param wizardComponents
47
	 */
48
	public DataTransformWizardContainer(JWizardComponents wizardComponents, DataTransformWizardPanel wizard) {
49
		super(wizardComponents);	
50
		this.wizard = wizard;
51
		setLayout(new BorderLayout());
52
		setBorder(javax.swing.BorderFactory.createTitledBorder(wizard.getPanelTitle()));
53
		add(wizard.getJPanel(), BorderLayout.CENTER);
54
	}
55

  
56
	/* (non-Javadoc)
57
	 * @see jwizardcomponent.WizardPanel#back()
58
	 */
59
	@Override
60
	public void back() {
61
		wizard.lastPanel();
62
		super.back();
63
	}
64

  
65
	/* (non-Javadoc)
66
	 * @see jwizardcomponent.WizardPanel#next()
67
	 */
68
	@Override
69
	public void next() {
70
		wizard.nextPanel();
71
		super.next();
72
	}
73

  
74
	/* (non-Javadoc)
75
	 * @see jwizardcomponent.JWizardPanel#update()
76
	 */
77
	@Override
78
	public void update() {
79
		wizard.updatePanel();
80
		super.update();
81
	}
82
}
83

  
0 84

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/AbstractDataTransformWizardPanel.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.daltransform.swing.impl;
29

  
30
import javax.swing.JPanel;
31

  
32
import org.gvsig.andami.PluginServices;
33
import org.gvsig.daltransform.swing.DataTransformWizard;
34
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.slf4j.Logger;
37
import org.slf4j.LoggerFactory;
38

  
39

  
40
/**
41
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42
 */
43
public abstract class AbstractDataTransformWizardPanel extends JPanel implements DataTransformWizardPanel {
44
	/**
45
     * 
46
     */
47
    private static final long serialVersionUID = 3397225908470941630L;
48
    protected static final Logger logger = LoggerFactory.getLogger(AbstractDataTransformWizardPanel.class);
49
	private DefaultDataTransformWizard dataTransformWizard = null;
50

  
51
	/**
52
	 * @param featureStore
53
	 */
54
	public AbstractDataTransformWizardPanel() {
55
		super();
56
	}	
57
	
58
	/* (non-Javadoc)
59
	 * @see org.gvsig.app.daltransform.DataTransformWizardPanel#setDataTransformWizard(org.gvsig.app.daltransform.DataTransformWizard)
60
	 */
61
	public void setDataTransformWizard(DataTransformWizard dataTransformWizard) {
62
		this.dataTransformWizard = (DefaultDataTransformWizard)dataTransformWizard;		
63
	}
64

  
65
	/* (non-Javadoc)
66
	 * @see org.gvsig.app.daltransform.DataTransformWizard#getJPanel()
67
	 */
68
	public JPanel getJPanel() {
69
		return this;
70
	}
71

  
72
	/* (non-Javadoc)
73
	 * @see org.gvsig.app.daltransform.DataTransformWizard#getPanelTitle()
74
	 */
75
	public String getPanelTitle() {
76
		return PluginServices.getText(this, "transform_parameters");
77
	}
78

  
79
	/* (non-Javadoc)
80
	 * @see org.gvsig.app.daltransform.DataTransformWizard#isNextButtonEnabled()
81
	 */
82
	public boolean isNextButtonEnabled() {
83
		return true;
84
	}
85

  
86
	/* (non-Javadoc)
87
	 * @see org.gvsig.app.daltransform.DataTransformWizard#lastPanel()
88
	 */
89
	public void lastPanel() {
90
		// TODO Auto-generated method stub
91
		
92
	}
93

  
94
	/* (non-Javadoc)
95
	 * @see org.gvsig.app.daltransform.DataTransformWizard#nextPanel()
96
	 */
97
	public void nextPanel() {
98
		// TODO Auto-generated method stub
99
		
100
	}
101

  
102
	/* (non-Javadoc)
103
	 * @see org.gvsig.app.daltransform.DataTransformWizard#updatePanel()
104
	 */
105
	public void updatePanel() {
106
		// TODO Auto-generated method stub
107
		
108
	}
109

  
110
	/**
111
	 * @return the featureStore
112
	 */
113
	public FeatureStore getFeatureStore() {
114
		if (dataTransformWizard != null){
115
			return dataTransformWizard.getFeatureStore();
116
		}
117
		return null;
118
	}
119
	
120
	/**
121
	 * @return the dataTransformWizard
122
	 */
123
	public DefaultDataTransformWizard getDataTransformWizard() {
124
		return dataTransformWizard;
125
	}	
126
	
127
}
128

  
0 129

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/DefaultDataTransformWizard.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.daltransform.swing.impl;
29

  
30
import java.util.List;
31

  
32
import org.gvsig.andami.IconThemeHelper;
33
import org.gvsig.andami.PluginServices;
34
import org.gvsig.andami.ui.mdiManager.IWindow;
35
import org.gvsig.andami.ui.wizard.WizardAndami;
36
import org.gvsig.daltransform.swing.DataTransformGui;
37
import org.gvsig.daltransform.swing.DataTransformWizard;
38
import org.gvsig.daltransform.swing.DataTransformWizardPanel;
39
import org.gvsig.fmap.dal.feature.FeatureStore;
40
import org.gvsig.fmap.mapcontext.MapContext;
41

  
42
/**
43
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
44
 */
45
public class DefaultDataTransformWizard extends WizardAndami implements
46
    DataTransformWizard {
47

  
48
    /**
49
     * 
50
     */
51
    private static final long serialVersionUID = 8346790424453722486L;
52
    private List<DataTransformWizardPanel> transformWizardPanels = null;
53
    // The three default panels
54
    private LoadLayerWizardPanel loadLayerWizardPanel = null;
55
    private SelectDataStoreWizardPanel selectDataStoreWizardPanel = null;
56
    private SelectTransformWizardPanel selectTransformWizardPanel = null;
57
    // If the wizard has to use a concrete transformation
58
    private DataTransformGui dataTransformGui = null;
59
    private int PANELS_TO_REFRESH = 2;
60

  
61
    /**
62
     * @param wizard
63
     */
64
    public DefaultDataTransformWizard() {
65
        super(IconThemeHelper.getImageIcon("feature-transform-wizard"));
66
        loadLayerWizardPanel = new LoadLayerWizardPanel();
67
        selectDataStoreWizardPanel = new SelectDataStoreWizardPanel();
68
        selectTransformWizardPanel = new SelectTransformWizardPanel();
69
        initialize();
70
        setSize(selectTransformWizardPanel.getMaxHeight(),
71
            selectTransformWizardPanel.getMaxWidth());
72
    }
73

  
74
    private void initialize() {
75
        
76
        getWizardComponents().getFinishButton().setEnabled(false);
77
        getWizardComponents().getBackButton().setEnabled(false);
78
        
79
        getWindowInfo().setTitle(
80
            PluginServices.getText(this, "transform_wizard"));
81
        addDataTransformWizardPanel(selectTransformWizardPanel);
82
        addDataTransformWizardPanel(selectDataStoreWizardPanel);
83
        getWizardComponents().setFinishAction(
84
            new DataTransformSelectionAction(this));
85
    }
86

  
87
    /*
88
     * (non-Javadoc)
89
     * 
90
     * @see
91
     * org.gvsig.app.daltransform.gui.DataTransformWizard#setApplicable(boolean)
92
     */
93
    public void setApplicable(boolean isEnabled) {
94
        getWizardComponents().getNextButton().setEnabled(isEnabled);
95
    }
96

  
97
    /*
98
     * (non-Javadoc)
99
     * 
100
     * @see org.gvsig.app.daltransform.DataTransformWizard#getDataTransformGui()
101
     */
102
    public DataTransformGui getDataTransformGui() {
103
        if (dataTransformGui == null) {
104
            return selectTransformWizardPanel.getFeatureTransformGui();
105
        } else {
106
            return dataTransformGui;
107
        }
108
    }
109

  
110
    /*
111
     * (non-Javadoc)
112
     * 
113
     * @see
114
     * org.gvsig.app.daltransform.DataTransformWizard#setDataTransformGui(org
115
     * .gvsig.app.daltransform.DataTransformGui)
116
     */
117
    public void updateGui() {
118
        // Remove all the panels
119
        for (int i = getWizardComponents().getWizardPanelList().size() - 1; i >= PANELS_TO_REFRESH; i--) {
120
            getWizardComponents().removeWizardPanel(i);
121
        }
122
        // Add new panels
123
        transformWizardPanels = getDataTransformGui().createPanels();
124
        for (int i = 0; i < transformWizardPanels.size(); i++) {
125
            addDataTransformWizardPanel(transformWizardPanels.get(i));
126
        }
127
        addDataTransformWizardPanel(loadLayerWizardPanel);
128
    }
129

  
130
    public void addDataTransformWizardPanel(
131
        DataTransformWizardPanel dataTransformWizardPanel) {
132
        dataTransformWizardPanel.setDataTransformWizard(this);
133
        getWizardComponents().addWizardPanel(
134
            new DataTransformWizardContainer(getWizardComponents(),
135
                dataTransformWizardPanel));
136
    }
137

  
138
    /*
139
     * (non-Javadoc)
140
     * 
141
     * @see org.gvsig.app.daltransform.DataTransformWizard#getFeatureStore()
142
     */
143
    public FeatureStore getFeatureStore() {
144
        return selectDataStoreWizardPanel.getFeatureStore();
145
    }
146

  
147
    /*
148
     * (non-Javadoc)
149
     * 
150
     * @see org.gvsig.app.daltransform.DataTransformWizard#isFeatureStoreLayer()
151
     */
152
    public boolean isFeatureStoreLayer() {
153
        return selectDataStoreWizardPanel.isFeatureStoreLayer();
154
    }
155

  
156
    public boolean isLayerLoaded() {
157
        return loadLayerWizardPanel.isLayerLoaded();
158
    }
159

  
160
    public MapContext getMapContext() {
161
        return loadLayerWizardPanel.getMapContext();
162
    }
163

  
164
    /*
165
     * (non-Javadoc)
166
     * 
167
     * @see org.gvsig.app.daltransform.gui.DataTransformWizard#getWindow()
168
     */
169
    public IWindow getWindow() {
170
        return this;
171
    }
172

  
173
    /*
174
     * (non-Javadoc)
175
     * 
176
     * @see
177
     * org.gvsig.app.daltransform.gui.DataTransformWizard#setDataTransformGui
178
     * (org.gvsig.app.daltransform.gui.DataTransformGui)
179
     */
180
    public void setDataTransformGui(DataTransformGui dataTransformGui) {
181
        this.dataTransformGui = dataTransformGui;
182
        PANELS_TO_REFRESH = 1;
183
        getWizardComponents().removeWizardPanel(0);
184
        
185
        selectDataStoreWizardPanel.updatePanel();
186
    }
187
}
0 188

  
tags/v2_0_0_Build_2058/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/SelectTransformWizardPanel.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.daltransform.swing.impl;
29

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

  
33
import javax.swing.DefaultListModel;
34
import javax.swing.JList;
35
import javax.swing.JScrollPane;
36
import javax.swing.JTextArea;
37
import javax.swing.event.ListSelectionEvent;
38
import javax.swing.event.ListSelectionListener;
39

  
40
import org.gvsig.andami.PluginServices;
41
import org.gvsig.daltransform.DataTransformLocator;
42
import org.gvsig.daltransform.DataTransformManager;
43
import org.gvsig.daltransform.swing.DataTransformGui;
44

  
45

  
46
/**
47
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
48
 */
49
public class SelectTransformWizardPanel extends AbstractDataTransformWizardPanel implements ListSelectionListener{
50
	/**
51
     * 
52
     */
53
    private static final long serialVersionUID = -4191590513663444616L;
54
    private JList transformList;
55
	private JScrollPane transformScrollPane;
56
	private JScrollPane descriptionScrollPane;
57
	private JTextArea descriptionText;
58
	private int maxWidth = 315;
59
	private int maxHeight = 600;
60

  
61
	/**
62
	 * @param wizardComponents
63
	 */
64
	public SelectTransformWizardPanel() {
65
		super();	
66
		initComponents();		
67
		addTransforms();
68
		transformList.addListSelectionListener(this);		
69
	}
70

  
71
	private void initComponents() {
72
		java.awt.GridBagConstraints gridBagConstraints;
73

  
74
		transformScrollPane = new javax.swing.JScrollPane();
75
		transformList = new javax.swing.JList();
76
		descriptionScrollPane = new javax.swing.JScrollPane();
77
		descriptionText = new javax.swing.JTextArea();
78

  
79
		setLayout(new java.awt.GridBagLayout());
80

  
81
		transformScrollPane.setViewportView(transformList);
82

  
83
		transformList.setModel(new DefaultListModel());
84

  
85
		gridBagConstraints = new java.awt.GridBagConstraints();
86
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
87
		gridBagConstraints.weightx = 1.0;
88
		gridBagConstraints.weighty = 1.0;
89
		gridBagConstraints.insets = new java.awt.Insets(2, 2, 5, 2);
90
		add(transformScrollPane, gridBagConstraints);
91

  
92
		descriptionText.setColumns(20);
93
		descriptionText.setEditable(false);
94
		descriptionText.setRows(5);
95
		descriptionText.setLineWrap(true);
96
		descriptionText.setBorder(null);
97
		descriptionScrollPane.setBorder(null);
98
		descriptionScrollPane.setViewportView(descriptionText);
99

  
100
		gridBagConstraints = new java.awt.GridBagConstraints();
101
		gridBagConstraints.gridx = 0;
102
		gridBagConstraints.gridy = 1;
103
		gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
104
		gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
105
		gridBagConstraints.weightx = 1.0;
106
		gridBagConstraints.insets = new java.awt.Insets(5, 2, 2, 2);
107
		add(descriptionScrollPane, gridBagConstraints);
108
	}
109

  
110
	/**
111
	 * Adding the objects
112
	 */
113
	protected void addTransforms(){
114
		DataTransformManager featureTransformManager = 
115
			DataTransformLocator.getDataTransformManager();			
116
		List<DataTransformGui> dataTransformGui =
117
			featureTransformManager.getDataTransforms();
118
		for (int i=0 ; i<dataTransformGui.size() ; i++){
119
			((DefaultListModel)transformList.getModel()).addElement(new FeatureTransformGuiWrapper(dataTransformGui.get(i)));
120
			Dimension dimension = dataTransformGui.get(i).getMinDimension();
121
			if (dimension != null){
122
				if (dimension.getHeight() > maxHeight){
123
					maxHeight = (int)dimension.getHeight();
124
				}
125
				if (dimension.getWidth() > maxWidth){
126
					maxWidth = (int)dimension.getWidth();
127
				}
128
			}
129
		}	
130
		updatePanel();
131
	}
132

  
133
	/*
134
	 * 	(non-Javadoc)
135
	 * @see org.gvsig.app.daltransform.impl.AbstractDataTransformWizardPanel#updatePanel()
136
	 */
137
	@Override
138
	public void updatePanel() {
139
		if (transformList.getSelectedIndex() == -1){
140
			if (transformList.getModel().getSize() > 0){
141
				transformList.setSelectedIndex(0);
142
				valueChanged(null);
143
			}
144
		}else{
145
			if (transformList.getModel().getSize() == 0){
146
				getDataTransformWizard().setApplicable(false);
147
			}
148
		}
149
	}	
150

  
151
	/* (non-Javadoc)
152
	 * @see javax.swing.event.ListSelectionListener#valueChanged(javax.swing.event.ListSelectionEvent)
153
	 */
154
	public void valueChanged(ListSelectionEvent e) {
155
		Object obj = transformList.getSelectedValue();
156
		if (obj != null){
157
			descriptionText.setText(((FeatureTransformGuiWrapper)obj).getFeatureTransformGui().getDescription());
158
		}
159
	}
160

  
161
	public DataTransformGui getFeatureTransformGui(){
162
		Object obj = transformList.getSelectedValue();
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff