Revision 39031
tags/v2_0_0_Build_2056/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_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/DataTransformLocator.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.locator.AbstractLocator; |
|
31 |
import org.gvsig.tools.locator.Locator; |
|
32 |
import org.gvsig.tools.locator.LocatorException; |
|
33 |
|
|
34 |
/** |
|
35 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
36 |
*/ |
|
37 |
public class DataTransformLocator extends AbstractLocator { |
|
38 |
private static final String LOCATOR_NAME = "DataTransformLocator"; |
|
39 |
/** |
|
40 |
* GPEManager name used by the locator to access the instance |
|
41 |
*/ |
|
42 |
public static final String DATA_TRANSFORM_MANAGER_NAME = "DataTransformManager"; |
|
43 |
private static final String DATA_TRANSFORM_MANAGER_DESCRIPTION = "DataTransformManager of gvSIG"; |
|
44 |
|
|
45 |
/** |
|
46 |
* Unique instance. |
|
47 |
*/ |
|
48 |
private static final DataTransformLocator instance = new DataTransformLocator(); |
|
49 |
|
|
50 |
/* (non-Javadoc) |
|
51 |
* @see org.gvsig.tools.locator.Locator#getLocatorName() |
|
52 |
*/ |
|
53 |
public String getLocatorName() { |
|
54 |
return LOCATOR_NAME; |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Return a reference to {@link DataTransformManager}. |
|
59 |
* |
|
60 |
* @return a reference to DataTransformManager |
|
61 |
* @throws LocatorException |
|
62 |
* if there is no access to the class or the class cannot be |
|
63 |
* instantiated |
|
64 |
* @see Locator#get(String) |
|
65 |
*/ |
|
66 |
public static DataTransformManager getDataTransformManager() throws LocatorException { |
|
67 |
return (DataTransformManager) getInstance().get(DATA_TRANSFORM_MANAGER_NAME); |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* Return the singleton instance. |
|
72 |
* |
|
73 |
* @return the singleton instance |
|
74 |
*/ |
|
75 |
public static DataTransformLocator getInstance() { |
|
76 |
return instance; |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Registers the Class implementing the {@link DataTransformManager} interface. |
|
81 |
* |
|
82 |
* @param clazz |
|
83 |
* implementing the DataTransformManager interface |
|
84 |
*/ |
|
85 |
public static void registerDataTransformManager(Class<?> clazz) { |
|
86 |
getInstance().register(DATA_TRANSFORM_MANAGER_NAME, |
|
87 |
DATA_TRANSFORM_MANAGER_DESCRIPTION, |
|
88 |
clazz); |
|
89 |
} |
|
90 |
} |
|
0 | 91 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/NotRegisteredTransformException.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 NotRegisteredTransformException extends BaseException{ |
|
36 |
private static final long serialVersionUID = 6104956845700384855L; |
|
37 |
private String name = null; |
|
38 |
|
|
39 |
/** |
|
40 |
* @param message |
|
41 |
* @param cause |
|
42 |
* @param key |
|
43 |
* @param code |
|
44 |
*/ |
|
45 |
public NotRegisteredTransformException(String name) { |
|
46 |
init(); |
|
47 |
this.name = name; |
|
48 |
} |
|
49 |
|
|
50 |
private void init() { |
|
51 |
messageKey = "transform_not_registered"; |
|
52 |
formatString = "Can?t create the wizard because there is not a " + |
|
53 |
"registered transform whit the name " + name + "."; |
|
54 |
} |
|
55 |
|
|
56 |
} |
|
57 |
|
|
58 |
|
|
59 |
|
|
0 | 60 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/DataTransformLibrary.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.Locale; |
|
31 |
|
|
32 |
import org.gvsig.app.ApplicationLibrary; |
|
33 |
import org.gvsig.fmap.dal.DALLibrary; |
|
34 |
import org.gvsig.i18n.Messages; |
|
35 |
import org.gvsig.tools.library.AbstractLibrary; |
|
36 |
import org.gvsig.tools.library.LibraryException; |
|
37 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
38 |
|
|
39 |
/** |
|
40 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
41 |
*/ |
|
42 |
public class DataTransformLibrary extends AbstractLibrary { |
|
43 |
|
|
44 |
@Override |
|
45 |
public void doRegistration() { |
|
46 |
registerAsAPI(DataTransformLibrary.class); |
|
47 |
require(DALLibrary.class); |
|
48 |
require(ApplicationLibrary.class); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doInitialize() throws LibraryException { |
|
53 |
if (!Messages.hasLocales()) { |
|
54 |
Messages.addLocale(Locale.getDefault()); |
|
55 |
} |
|
56 |
Messages.addResourceFamily("org.gvsig.daltransform.i18n.text", |
|
57 |
DataTransformLibrary.class.getClassLoader(), |
|
58 |
DataTransformLibrary.class.getClass().getName()); |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
protected void doPostInitialize() throws LibraryException { |
|
63 |
// Validate there is any implementation registered. |
|
64 |
DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager(); |
|
65 |
if (dataTransformManager == null) { |
|
66 |
throw new ReferenceNotRegisteredException( |
|
67 |
DataTransformLocator.DATA_TRANSFORM_MANAGER_NAME, DataTransformLocator.getInstance()); |
|
68 |
} |
|
69 |
} |
|
70 |
} |
|
71 |
|
|
72 |
|
|
73 |
|
|
0 | 74 |
tags/v2_0_0_Build_2056/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_2056/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_2056/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_2056/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_2056/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_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
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 |
/** |
|
46 |
* |
|
47 |
*/ |
|
48 |
private static final long serialVersionUID = -3457322116557877761L; |
|
49 |
|
|
50 |
public FeatureTypeAttributesList() { |
|
51 |
super(); |
|
52 |
setModel(new DefaultListModel()); |
|
53 |
} |
|
54 |
|
|
55 |
public void addFeatureAttrubutes(FeatureStore featureStore) throws DataException{ |
|
56 |
addFeatureAttributes(featureStore.getDefaultFeatureType()); |
|
57 |
} |
|
58 |
|
|
59 |
public void addFeatureAttributes(FeatureType featureType){ |
|
60 |
removeAll(); |
|
61 |
FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors(); |
|
62 |
for (int i=0 ; i<descriptors.length ; i++){ |
|
63 |
addFeatureAttributeDescriptor(descriptors[i]); |
|
64 |
} |
|
65 |
} |
|
66 |
|
|
67 |
public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){ |
|
68 |
((DefaultListModel)getModel()).addElement(new FeatureTypeAttributeWrapper(featureAttributeDescriptor)); |
|
69 |
} |
|
70 |
|
|
71 |
public ArrayList<FeatureAttributeDescriptor> getSelectedFeatureTypes(){ |
|
72 |
ArrayList<FeatureAttributeDescriptor> featureTypes = new ArrayList<FeatureAttributeDescriptor>(); |
|
73 |
Object[] objects = getSelectedValues(); |
|
74 |
for (int i=0 ; i<objects.length ; i++){ |
|
75 |
featureTypes.add(((FeatureTypeAttributeWrapper)objects[i]).getFeatureAttributeDescriptor()); |
|
76 |
} |
|
77 |
return featureTypes; |
|
78 |
} |
|
79 |
|
|
80 |
public String[] getAttributesName(){ |
|
81 |
Object[] objects = getSelectedValues(); |
|
82 |
String[] featureTypes = new String[objects.length]; |
|
83 |
for (int i=0 ; i<objects.length ; i++){ |
|
84 |
featureTypes[i] = ((FeatureTypeAttributeWrapper)objects[i]).getFeatureAttributeDescriptor().getName(); |
|
85 |
} |
|
86 |
return featureTypes; |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
0 | 90 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
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_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
29 |
|
|
30 |
import java.util.ArrayList; |
|
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.FeatureAttributeDescriptor; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
39 |
import org.slf4j.Logger; |
|
40 |
import org.slf4j.LoggerFactory; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
44 |
*/ |
|
45 |
public class FeatureTypeAttributesCombo extends JComboBox { |
|
46 |
/** |
|
47 |
* |
|
48 |
*/ |
|
49 |
private static final long serialVersionUID = -8843843810490892699L; |
|
50 |
protected static final Logger logger = LoggerFactory.getLogger(FeatureTypeAttributesCombo.class); |
|
51 |
|
|
52 |
public FeatureTypeAttributesCombo() { |
|
53 |
super(); |
|
54 |
this.setModel(new DefaultComboBoxModel()); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Removes all items then adds atts |
|
59 |
* |
|
60 |
* @param featureStore |
|
61 |
* @return the number of items added (equals total item count) |
|
62 |
* |
|
63 |
* @throws DataException |
|
64 |
*/ |
|
65 |
public int addFeatureAttrubutes(FeatureStore featureStore) throws DataException{ |
|
66 |
return addFeatureAttributes(featureStore.getDefaultFeatureType()); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Removes all items then adds atts |
|
71 |
* |
|
72 |
* @param featureType |
|
73 |
* @return the number of items added (equals total item count) |
|
74 |
*/ |
|
75 |
public int addFeatureAttributes(FeatureType featureType){ |
|
76 |
removeAllItems(); |
|
77 |
FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors(); |
|
78 |
for (int i=0 ; i<descriptors.length ; i++){ |
|
79 |
addFeatureAttributeDescriptor(descriptors[i]); |
|
80 |
} |
|
81 |
return descriptors.length; |
|
82 |
} |
|
83 |
|
|
84 |
|
|
85 |
/** |
|
86 |
* Removes all items then adds atts whose type is |
|
87 |
* contained by list |
|
88 |
* |
|
89 |
* @param featureType |
|
90 |
* @param type |
|
91 |
* @return the number of items added (equals total item count) |
|
92 |
*/ |
|
93 |
public int addFeatureAttributes( |
|
94 |
FeatureType featureType, |
|
95 |
ArrayList<Integer> types){ |
|
96 |
|
|
97 |
removeAllItems(); |
|
98 |
|
|
99 |
int count = 0; |
|
100 |
FeatureAttributeDescriptor[] descriptors = featureType.getAttributeDescriptors(); |
|
101 |
for (int i=0 ; i<descriptors.length ; i++){ |
|
102 |
if (isIn(descriptors[i].getType(), types)) { |
|
103 |
addFeatureAttributeDescriptor(descriptors[i]); |
|
104 |
count++; |
|
105 |
} |
|
106 |
} |
|
107 |
return count; |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* @param type |
|
112 |
* @param types |
|
113 |
* @return |
|
114 |
*/ |
|
115 |
private boolean isIn(int t, ArrayList<Integer> list) { |
|
116 |
|
|
117 |
int len = list.size(); |
|
118 |
for (int i=0; i<len; i++) { |
|
119 |
if (list.get(i).intValue() == t) { |
|
120 |
return true; |
|
121 |
} |
|
122 |
} |
|
123 |
return false; |
|
124 |
} |
|
125 |
|
|
126 |
public void addFeatureAttributeDescriptor(FeatureAttributeDescriptor featureAttributeDescriptor){ |
|
127 |
((DefaultComboBoxModel)getModel()).addElement(new FeatureTypeAttributeWrapper(featureAttributeDescriptor)); |
|
128 |
} |
|
129 |
|
|
130 |
public FeatureAttributeDescriptor getSelectedFeatureAttributeDescriptor(){ |
|
131 |
return ((FeatureTypeAttributeWrapper)getSelectedItem()).getFeatureAttributeDescriptor(); |
|
132 |
} |
|
133 |
|
|
134 |
|
|
135 |
} |
|
136 |
|
|
0 | 137 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
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 |
/** |
|
39 |
* |
|
40 |
*/ |
|
41 |
private static final long serialVersionUID = -1694488470656611290L; |
|
42 |
|
|
43 |
/* (non-Javadoc) |
|
44 |
* @see org.gvsig.app.daltransform.gui.combos.FeatureTypeAttributesCombo#addFeatureAttributeDescriptor(org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor) |
|
45 |
*/ |
|
46 |
public void addFeatureAttributeDescriptor( |
|
47 |
FeatureAttributeDescriptor featureAttributeDescriptor) { |
|
48 |
int type = featureAttributeDescriptor.getType(); |
|
49 |
if ((type == DataTypes.DOUBLE) || |
|
50 |
(type == DataTypes.FLOAT) || |
|
51 |
(type == DataTypes.INT) || |
|
52 |
(type == DataTypes.LONG)){ |
|
53 |
super.addFeatureAttributeDescriptor(featureAttributeDescriptor); |
|
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
0 | 58 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
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 |
/** |
|
46 |
* |
|
47 |
*/ |
|
48 |
private static final long serialVersionUID = -3689986732982756932L; |
|
49 |
protected static final Logger logger = LoggerFactory.getLogger(FeatureTypeCombo.class); |
|
50 |
|
|
51 |
public FeatureTypeCombo() { |
|
52 |
super(); |
|
53 |
this.setModel(new DefaultComboBoxModel()); |
|
54 |
} |
|
55 |
|
|
56 |
@SuppressWarnings("unchecked") |
|
57 |
public void addFeatureStore(FeatureStore featureStore){ |
|
58 |
removeAllItems(); |
|
59 |
List<FeatureType> featureTypes; |
|
60 |
try { |
|
61 |
featureTypes = featureStore.getFeatureTypes(); |
|
62 |
for (int i=0 ; i<featureTypes.size() ; i++){ |
|
63 |
((DefaultComboBoxModel)getModel()).addElement(featureTypes.get(i)); |
|
64 |
} |
|
65 |
} catch (DataException e) { |
|
66 |
logger.error("Error updating the panel", e); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
public FeatureType getSelectedFeatureType(){ |
|
71 |
return (FeatureType)getSelectedItem(); |
|
72 |
} |
|
73 |
} |
|
74 |
|
|
0 | 75 |
tags/v2_0_0_Build_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/components/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.daltransform.swing.impl.components; |
|
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_2056/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/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): |
Also available in: Unified diff