Revision 37474
tags/v2_0_0_Build_2042/extensions/org.gvsig.daltransform.app.mainplugin/distribution/distribution.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>distribution</id> |
|
3 |
<formats> |
|
4 |
<format>dir</format> |
|
5 |
</formats> |
|
6 |
<fileSets> |
|
7 |
<fileSet> |
|
8 |
<directory>src/main/resources</directory> |
|
9 |
<outputDirectory>${extension.install.dir.name} |
|
10 |
</outputDirectory> |
|
11 |
</fileSet> |
|
12 |
</fileSets> |
|
13 |
|
|
14 |
<files> |
|
15 |
<file> |
|
16 |
<source>package.info</source> |
|
17 |
<outputDirectory>${extension.install.dir.name} |
|
18 |
</outputDirectory> |
|
19 |
</file> |
|
20 |
</files> |
|
21 |
|
|
22 |
<dependencySets> |
|
23 |
<dependencySet> |
|
24 |
<outputDirectory>${extension.install.dir.name}/${library-dir} |
|
25 |
</outputDirectory> |
|
26 |
<includes> |
|
27 |
<include>org.gvsig:org.gvsig.daltransform.app.mainplugin</include> |
|
28 |
</includes> |
|
29 |
</dependencySet> |
|
30 |
</dependencySets> |
|
31 |
</assembly> |
|
0 | 32 |
tags/v2_0_0_Build_2042/extensions/org.gvsig.daltransform.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Wed Nov 23 09:48:31 CET 2011 |
|
3 |
buildNumber=2042 |
tags/v2_0_0_Build_2042/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_2042/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_2042/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_2042/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 org.gvsig.app.ApplicationLibrary; |
|
31 |
import org.gvsig.fmap.dal.DALLibrary; |
|
32 |
import org.gvsig.tools.library.AbstractLibrary; |
|
33 |
import org.gvsig.tools.library.LibraryException; |
|
34 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
35 |
|
|
36 |
/** |
|
37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
38 |
*/ |
|
39 |
public class DataTransformLibrary extends AbstractLibrary { |
|
40 |
|
|
41 |
@Override |
|
42 |
public void doRegistration() { |
|
43 |
registerAsAPI(DataTransformLibrary.class); |
|
44 |
require(DALLibrary.class); |
|
45 |
require(ApplicationLibrary.class); |
|
46 |
} |
|
47 |
|
|
48 |
@Override |
|
49 |
protected void doInitialize() throws LibraryException { |
|
50 |
} |
|
51 |
|
|
52 |
@Override |
|
53 |
protected void doPostInitialize() throws LibraryException { |
|
54 |
// Validate there is any implementation registered. |
|
55 |
DataTransformManager dataTransformManager = DataTransformLocator.getDataTransformManager(); |
|
56 |
if (dataTransformManager == null) { |
|
57 |
throw new ReferenceNotRegisteredException( |
|
58 |
DataTransformLocator.DATA_TRANSFORM_MANAGER_NAME, DataTransformLocator.getInstance()); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
|
|
64 |
|
|
0 | 65 |
tags/v2_0_0_Build_2042/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_2042/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.PluginServices; |
|
36 |
import org.gvsig.andami.plugins.Extension; |
|
37 |
import org.gvsig.andami.ui.ToolsWindowManager; |
|
38 |
import org.gvsig.app.ApplicationLocator; |
|
39 |
import org.gvsig.app.ApplicationManager; |
|
40 |
import org.gvsig.daltransform.DataTransformLocator; |
|
41 |
import org.gvsig.daltransform.DataTransformManager; |
|
42 |
import org.gvsig.daltransform.swing.JDialogDataTransformList; |
|
43 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
44 |
|
|
45 |
/** |
|
46 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
|
47 |
*/ |
|
48 |
public class DataTransformExtension extends Extension { |
|
49 |
|
|
50 |
/* |
|
51 |
* (non-Javadoc) |
|
52 |
* |
|
53 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
54 |
*/ |
|
55 |
public void execute(String actionCommand) { |
|
56 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
57 |
DataTransformManager manager = |
|
58 |
DataTransformLocator.getDataTransformManager(); |
|
59 |
|
|
60 |
if ("CREATE".equalsIgnoreCase(actionCommand)) { |
|
61 |
try { |
|
62 |
PluginServices.getMDIManager().addWindow( |
|
63 |
manager.createWizard().getWindow()); |
|
64 |
|
|
65 |
} catch (Exception e) { |
|
66 |
JOptionPane.showInternalMessageDialog( |
|
67 |
(Component) PluginServices.getMDIManager(), PluginServices |
|
68 |
.getText(this, "transform_create_wizard_exception"), |
|
69 |
PluginServices.getText(this, "feature_transform"), |
|
70 |
JOptionPane.ERROR_MESSAGE); |
|
71 |
} |
|
72 |
} else |
|
73 |
if ("VIEW".equalsIgnoreCase(actionCommand)) { |
|
74 |
|
|
75 |
// there is no layer loaded |
|
76 |
if (application.getActiveDocument() == null) { |
|
77 |
JOptionPane.showMessageDialog(null, |
|
78 |
"_There_is_not_any_layer_loaded.", "_View_Transforms", |
|
79 |
JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE); |
|
80 |
return; |
|
81 |
} |
|
82 |
|
|
83 |
// Document doc = |
|
84 |
// application.getActiveDocument(ViewManager.TYPENAME); |
|
85 |
// |
|
86 |
// //no active document |
|
87 |
// if (doc == null) { |
|
88 |
// JOptionPane.showMessageDialog(null, |
|
89 |
// "_There_is_not_any_layer_loaded.", "_View_Transforms", |
|
90 |
// JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE); |
|
91 |
// return; |
|
92 |
// } |
|
93 |
|
|
94 |
JDialogDataTransformList dialog = |
|
95 |
manager.createJDialogDataTransformList(); |
|
96 |
|
|
97 |
ToolsWindowManager wm = new ToolsWindowManager(); |
|
98 |
wm.showWindow(dialog, "_View_transforms", |
|
99 |
WindowManager.MODE.WINDOW, GridBagConstraints.CENTER); |
|
100 |
} |
|
101 |
|
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* |
|
107 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
108 |
*/ |
|
109 |
public void initialize() { |
|
110 |
registerIcons(); |
|
111 |
} |
|
112 |
|
|
113 |
/* |
|
114 |
* (non-Javadoc) |
|
115 |
* |
|
116 |
* @see com.iver.andami.plugins.Extension#postInitialize() |
|
117 |
*/ |
|
118 |
@Override |
|
119 |
public void postInitialize() { |
|
120 |
super.postInitialize(); |
|
121 |
} |
|
122 |
|
|
123 |
private void registerIcons() { |
|
124 |
PluginServices.getIconTheme().registerDefault( |
|
125 |
"feature-transform", |
|
126 |
this.getClass().getClassLoader() |
|
127 |
.getResource("images/transform.png")); |
|
128 |
} |
|
129 |
|
|
130 |
/* |
|
131 |
* (non-Javadoc) |
|
132 |
* |
|
133 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
134 |
*/ |
|
135 |
public boolean isEnabled() { |
|
136 |
return true; |
|
137 |
} |
|
138 |
|
|
139 |
/* |
|
140 |
* (non-Javadoc) |
|
141 |
* |
|
142 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
143 |
*/ |
|
144 |
public boolean isVisible() { |
|
145 |
return true; |
|
146 |
} |
|
147 |
} |
|
0 | 148 |
tags/v2_0_0_Build_2042/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_2042/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_2042/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_2042/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/DefaultJDataTransformList.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.impl; |
|
23 |
|
|
24 |
import java.awt.Color; |
|
25 |
|
|
26 |
import javax.swing.DefaultListModel; |
|
27 |
import javax.swing.JList; |
|
28 |
import javax.swing.ListSelectionModel; |
|
29 |
import javax.swing.event.ListSelectionEvent; |
|
30 |
import javax.swing.event.ListSelectionListener; |
|
31 |
|
|
32 |
import org.gvsig.daltransform.swing.JDataTransformList; |
|
33 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
34 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransform; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
|
36 |
|
|
37 |
/** |
|
38 |
* @author gvSIG Team |
|
39 |
* @version $Id$ |
|
40 |
* |
|
41 |
*/ |
|
42 |
public class DefaultJDataTransformList extends JDataTransformList { |
|
43 |
|
|
44 |
private static final long serialVersionUID = 3179282558802329381L; |
|
45 |
|
|
46 |
private FeatureStore store; |
|
47 |
private JList l; |
|
48 |
DefaultListModel model; |
|
49 |
|
|
50 |
public DefaultJDataTransformList(FeatureStore store) { |
|
51 |
this.store = store; |
|
52 |
createComponents(); |
|
53 |
} |
|
54 |
|
|
55 |
private void createComponents() { |
|
56 |
FeatureStoreTransforms transforms = this.store.getTransforms(); |
|
57 |
model = new DefaultListModel(); |
|
58 |
for (int i = 0; i < transforms.size(); i++) { |
|
59 |
model.addElement(new ItemData(transforms.getTransform(i))); |
|
60 |
} |
|
61 |
l = new JList(model); |
|
62 |
l.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
|
63 |
this.add(l); |
|
64 |
this.setBackground(Color.WHITE); |
|
65 |
|
|
66 |
} |
|
67 |
|
|
68 |
@Override |
|
69 |
public void addListSelectionListener(ListSelectionListener actionListener) { |
|
70 |
this.l.addListSelectionListener(new ListSelectionListenerWrapper(this, |
|
71 |
actionListener)); |
|
72 |
} |
|
73 |
|
|
74 |
private class ListSelectionListenerWrapper implements ListSelectionListener { |
|
75 |
|
|
76 |
private DefaultJDataTransformList list; |
|
77 |
private ListSelectionListener listListener; |
|
78 |
|
|
79 |
public ListSelectionListenerWrapper(DefaultJDataTransformList list, |
|
80 |
ListSelectionListener listListener) { |
|
81 |
this.list = list; |
|
82 |
this.listListener = listListener; |
|
83 |
} |
|
84 |
|
|
85 |
public void valueChanged(ListSelectionEvent e) { |
|
86 |
listListener.valueChanged(new ListSelectionEventWrapper(e, list)); |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
private class ListSelectionEventWrapper extends ListSelectionEvent { |
|
91 |
|
|
92 |
private static final long serialVersionUID = -8159225017709144435L; |
|
93 |
|
|
94 |
public ListSelectionEventWrapper(ListSelectionEvent e, |
|
95 |
DefaultJDataTransformList transformList) { |
|
96 |
super(transformList, e.getFirstIndex(), e.getLastIndex(), e |
|
97 |
.getValueIsAdjusting()); |
|
98 |
} |
|
99 |
|
|
100 |
} |
|
101 |
|
|
102 |
private class ItemData { |
|
103 |
|
|
104 |
public FeatureStoreTransform transform; |
|
105 |
|
|
106 |
ItemData(FeatureStoreTransform transform) { |
|
107 |
this.transform = transform; |
|
108 |
} |
|
109 |
|
|
110 |
@Override |
|
111 |
public String toString() { |
|
112 |
return this.transform.getName(); |
|
113 |
} |
|
114 |
|
|
115 |
public FeatureStoreTransform getTransform() { |
|
116 |
return transform; |
|
117 |
} |
|
118 |
|
|
119 |
@Override |
|
120 |
public boolean equals(Object obj) { |
|
121 |
return this.transform.equals(((ItemData) obj).transform); |
|
122 |
} |
|
123 |
} |
|
124 |
|
|
125 |
@Override |
|
126 |
public FeatureStoreTransform getSelected() { |
|
127 |
if ((l != null) && (l.getSelectedValue() != null)) { |
|
128 |
return ((ItemData) l.getSelectedValue()).getTransform(); |
|
129 |
} |
|
130 |
return null; |
|
131 |
} |
|
132 |
|
|
133 |
@Override |
|
134 |
public void remove(FeatureStoreTransform transform) { |
|
135 |
this.store.getTransforms().remove(transform); |
|
136 |
model.removeElement(new ItemData(transform)); |
|
137 |
} |
|
138 |
|
|
139 |
@Override |
|
140 |
public void addTransforms(FeatureStoreTransforms transforms) { |
|
141 |
for (int i = 0; i < transforms.size(); i++) { |
|
142 |
model.addElement(new ItemData(transforms.getTransform(i))); |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
@Override |
|
147 |
public void removeAllTransforms() { |
|
148 |
model.removeAllElements(); |
|
149 |
} |
|
150 |
|
|
151 |
@Override |
|
152 |
public void changeStore(FeatureStore featureStore) { |
|
153 |
this.store = featureStore; |
|
154 |
} |
|
155 |
|
|
156 |
@Override |
|
157 |
public int getTransformsCount() { |
|
158 |
return model.getSize(); |
|
159 |
} |
|
160 |
|
|
161 |
@Override |
|
162 |
public boolean isLastTransform(FeatureStoreTransform selectedTransform) { |
|
163 |
|
|
164 |
ItemData selectedTransformItem = new ItemData(selectedTransform); |
|
165 |
ItemData lastTransformItem = (ItemData) model.get(model.size() - 1); |
|
166 |
|
|
167 |
if (selectedTransformItem.equals(lastTransformItem)) { |
|
168 |
return true; |
|
169 |
} else { |
|
170 |
return false; |
|
171 |
} |
|
172 |
} |
|
173 |
|
|
174 |
@Override |
|
175 |
public int getSelectedIndex() { |
|
176 |
return this.l.getSelectedIndex(); |
|
177 |
} |
|
178 |
|
|
179 |
} |
|
0 | 180 |
tags/v2_0_0_Build_2042/extensions/org.gvsig.daltransform.app.mainplugin/src/main/java/org/gvsig/daltransform/swing/impl/DefaultJDialogDataTransformList.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.impl; |
|
23 |
|
|
24 |
import java.awt.Dimension; |
|
25 |
import java.awt.FlowLayout; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.beans.PropertyChangeListener; |
|
29 |
import java.util.ArrayList; |
|
30 |
import java.util.List; |
|
31 |
|
|
32 |
import javax.swing.Action; |
|
33 |
import javax.swing.ComboBoxModel; |
|
34 |
import javax.swing.JButton; |
|
35 |
import javax.swing.JComboBox; |
|
36 |
import javax.swing.JLabel; |
|
37 |
import javax.swing.JPanel; |
|
38 |
import javax.swing.JScrollPane; |
|
39 |
import javax.swing.border.EmptyBorder; |
|
40 |
import javax.swing.event.ListDataListener; |
|
41 |
import javax.swing.event.ListSelectionEvent; |
|
42 |
import javax.swing.event.ListSelectionListener; |
|
43 |
|
|
44 |
import org.gvsig.app.ApplicationLocator; |
|
45 |
import org.gvsig.app.ApplicationManager; |
|
46 |
import org.gvsig.app.project.Project; |
|
47 |
import org.gvsig.app.project.documents.Document; |
|
48 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
49 |
import org.gvsig.app.project.documents.table.TableManager; |
|
50 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
51 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
52 |
import org.gvsig.daltransform.DataTransformLocator; |
|
53 |
import org.gvsig.daltransform.swing.JDataTransformList; |
|
54 |
import org.gvsig.daltransform.swing.JDialogDataTransformList; |
|
55 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
56 |
import org.gvsig.fmap.dal.feature.FeatureStoreTransforms; |
|
57 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
58 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
59 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
60 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
|
61 |
|
|
62 |
/** |
|
63 |
* @author gvSIG Team |
|
64 |
* @version $Id$ |
|
65 |
* |
|
66 |
*/ |
|
67 |
public class DefaultJDialogDataTransformList extends JDialogDataTransformList { |
|
68 |
|
|
69 |
private static final long serialVersionUID = 8666781163497235054L; |
|
70 |
private JDataTransformList transforms = null; |
|
71 |
|
|
72 |
private JButton botonEliminar; |
|
73 |
private JButton botonCerrar; |
|
74 |
private JComboBox comboBox; |
|
75 |
|
|
76 |
public DefaultJDialogDataTransformList() { |
|
77 |
super(); |
|
78 |
initComponents(); |
|
79 |
createGUI(); |
|
80 |
} |
|
81 |
|
|
82 |
private class MyComboBoxItem { |
|
83 |
|
|
84 |
private String label; |
|
85 |
private FeatureStore store; |
|
86 |
|
|
87 |
MyComboBoxItem(String label, FeatureStore store) { |
|
88 |
this.label = label; |
|
89 |
this.store = store; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public String toString() { |
|
94 |
return label; |
|
95 |
} |
|
96 |
|
|
97 |
public FeatureStore getStore() { |
|
98 |
return this.store; |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
private class MyComboBoxModel implements ComboBoxModel { |
|
103 |
|
|
104 |
private List<MyComboBoxItem> items = new ArrayList<MyComboBoxItem>(); |
|
105 |
private MyComboBoxItem selected = null; |
|
106 |
|
|
107 |
public MyComboBoxModel(List<MyComboBoxItem> items) { |
|
108 |
this.items.addAll(items); |
|
109 |
} |
|
110 |
|
|
111 |
public Object getSelectedItem() { |
|
112 |
return this.selected; |
|
113 |
} |
|
114 |
|
|
115 |
public MyComboBoxItem getSelected() { |
|
116 |
return this.selected; |
|
117 |
} |
|
118 |
|
|
119 |
public void setSelectedItem(Object arg0) { |
|
120 |
this.selected = (MyComboBoxItem) arg0; |
|
121 |
} |
|
122 |
|
|
123 |
public Object getElementAt(int arg0) { |
|
124 |
return this.items.get(arg0); |
|
125 |
} |
|
126 |
|
|
127 |
public MyComboBoxItem get(int arg0) { |
|
128 |
return this.items.get(arg0); |
|
129 |
} |
|
130 |
|
|
131 |
public int getSize() { |
|
132 |
return this.items.size(); |
|
133 |
} |
|
134 |
|
|
135 |
public void removeListDataListener(ListDataListener arg0) { |
|
136 |
// TODO Auto-generated method stub |
|
137 |
|
|
138 |
} |
|
139 |
|
|
140 |
public void addListDataListener(ListDataListener arg0) { |
|
141 |
// TODO Auto-generated method stub |
|
142 |
|
|
143 |
} |
|
144 |
|
|
145 |
} |
|
146 |
|
|
147 |
private void initComponents() { |
|
148 |
MyComboBoxModel comboModel = new MyComboBoxModel(getAllStores()); |
|
149 |
|
|
150 |
comboBox = new JComboBox(comboModel); |
|
151 |
|
|
152 |
comboBox.addActionListener(new ActionListener() { |
|
153 |
|
|
154 |
public void actionPerformed(ActionEvent e) { |
|
155 |
JComboBox jcmbType = (JComboBox) e.getSource(); |
|
156 |
MyComboBoxModel model = (MyComboBoxModel) jcmbType.getModel(); |
|
157 |
updatePanel(model.getSelected().getStore()); |
|
158 |
} |
|
159 |
}); |
|
160 |
|
|
161 |
if (comboModel.getSize() > 0) { |
|
162 |
transforms = |
|
163 |
DataTransformLocator.getDataTransformManager() |
|
164 |
.createJDataTransformList(comboModel.get(0).getStore()); |
|
165 |
comboModel.setSelectedItem(comboModel.get(0)); |
|
166 |
} |
|
167 |
if (transforms != null) { |
|
168 |
transforms.addListSelectionListener(new ListSelectionHandler()); |
|
169 |
} |
|
170 |
} |
|
171 |
|
|
172 |
private List<MyComboBoxItem> getAllStores() { |
|
173 |
List<MyComboBoxItem> stores = new ArrayList<MyComboBoxItem>(); |
|
174 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
175 |
Project project = application.getCurrentProject(); |
|
176 |
|
|
177 |
List<Document> views = project.getDocuments(ViewManager.TYPENAME); |
|
178 |
for (Document doc : views) { |
|
179 |
ViewDocument viewDocument = (ViewDocument) doc; |
|
180 |
|
|
181 |
FLayer[] layers = |
|
182 |
viewDocument.getMapContext().getLayers().getVisibles(); |
|
183 |
if (layers.length > 1) { |
|
184 |
for (int i = 1; i < layers.length; i++) { |
|
185 |
if (layers[i] instanceof FLyrVect) { |
|
186 |
FLyrVect layer = (FLyrVect) layers[i]; |
|
187 |
stores.add(new MyComboBoxItem(layer.getName(), layer |
|
188 |
.getFeatureStore())); |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
List<Document> tables = project.getDocuments(TableManager.TYPENAME); |
|
194 |
for (Document doc : tables) { |
|
195 |
TableDocument tableDocument = (TableDocument) doc; |
|
196 |
stores.add(new MyComboBoxItem(doc.getName(), tableDocument |
|
197 |
.getStore())); |
|
198 |
} |
|
199 |
|
|
200 |
return stores; |
|
201 |
} |
|
202 |
|
|
203 |
private void createGUI() { |
|
204 |
|
|
205 |
java.awt.GridBagConstraints gridBagConstraints; |
|
206 |
this.setLayout(new java.awt.GridBagLayout()); |
|
207 |
|
|
208 |
// Add an empty margin |
|
209 |
this.setBorder(new EmptyBorder(15, 15, 15, 15)); |
|
210 |
|
|
211 |
UsabilitySwingManager usabilitymanager = |
|
212 |
ToolsSwingLocator.getUsabilitySwingManager(); |
|
213 |
|
|
214 |
JLabel layerText = new JLabel("_Select_a_layer:"); |
|
215 |
JLabel transformText = new JLabel("_Select_a_transform:"); |
|
216 |
JPanel botones = new JPanel(); |
|
217 |
|
|
218 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
219 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
|
220 |
gridBagConstraints.gridx = 0; |
|
221 |
gridBagConstraints.gridy = 0; |
|
222 |
gridBagConstraints.weightx = 0.0; |
|
223 |
gridBagConstraints.weighty = 0.0; |
|
224 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
|
225 |
this.add(layerText, gridBagConstraints); |
|
226 |
|
|
227 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
228 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
|
229 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
|
230 |
gridBagConstraints.gridx = 0; |
|
231 |
gridBagConstraints.gridy = 1; |
|
232 |
gridBagConstraints.weightx = 0.0; |
|
233 |
gridBagConstraints.weighty = 0.0; |
|
234 |
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5); |
|
235 |
this.add(comboBox, gridBagConstraints); |
|
236 |
|
|
237 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
238 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; |
|
239 |
gridBagConstraints.gridx = 0; |
|
240 |
gridBagConstraints.gridy = 2; |
|
241 |
gridBagConstraints.weightx = 0.0; |
|
242 |
gridBagConstraints.weighty = 0.0; |
|
243 |
gridBagConstraints.insets = new java.awt.Insets(10, 2, 5, 2); |
|
244 |
this.add(transformText, gridBagConstraints); |
|
245 |
|
|
246 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
247 |
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; |
|
248 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER; |
|
249 |
gridBagConstraints.gridx = 0; |
|
250 |
gridBagConstraints.gridy = 3; |
|
251 |
gridBagConstraints.weightx = 0.0; |
|
252 |
gridBagConstraints.weighty = 1.0; |
|
253 |
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); |
|
254 |
if (transforms != null) { |
|
255 |
JScrollPane scroller = new JScrollPane(transforms); |
|
256 |
this.add(scroller, gridBagConstraints); |
|
257 |
} else { |
|
258 |
JPanel emptyPanel = new JPanel(); |
|
259 |
this.add(emptyPanel, gridBagConstraints); |
|
260 |
} |
|
261 |
|
|
262 |
botones.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 0)); |
|
263 |
botonCerrar = usabilitymanager.createJButton(new ActionClose(this)); |
|
264 |
botonCerrar.setText("_close"); |
|
265 |
botonEliminar = usabilitymanager.createJButton(new ActionRemove(this)); |
|
266 |
botonEliminar.setText("_remove"); |
|
267 |
botones.add(botonEliminar); |
|
268 |
botones.add(botonCerrar); |
|
269 |
botonEliminar.setEnabled(false); |
|
270 |
|
|
271 |
gridBagConstraints = new java.awt.GridBagConstraints(); |
|
272 |
gridBagConstraints.gridx = 0; |
|
273 |
gridBagConstraints.gridy = 4; |
|
274 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH; |
|
275 |
gridBagConstraints.weightx = 0.0; |
|
276 |
gridBagConstraints.weighty = 0.0; |
|
277 |
gridBagConstraints.insets = new java.awt.Insets(10, 2, 2, 2); |
|
278 |
this.add(botones, gridBagConstraints); |
|
279 |
|
|
280 |
botonEliminar.setEnabled(false); |
|
281 |
|
|
282 |
updatePanel(null); |
|
283 |
} |
|
284 |
|
|
285 |
class ListSelectionHandler implements ListSelectionListener { |
|
286 |
|
|
287 |
public void valueChanged(ListSelectionEvent e) { |
|
288 |
|
|
289 |
if ((transforms != null) && (transforms.getSelected() != null)) { |
|
290 |
if (transforms.isLastTransform(transforms.getSelected())) { |
|
291 |
botonEliminar.setEnabled(true); |
|
292 |
return; |
|
293 |
} |
|
294 |
} |
|
295 |
botonEliminar.setEnabled(false); |
|
296 |
} |
|
297 |
|
|
298 |
} |
|
299 |
|
|
300 |
@Override |
|
301 |
public Dimension getPreferredSize() { |
|
302 |
return new Dimension(250, 300); |
|
303 |
} |
|
304 |
|
|
305 |
private class ActionRemove implements Action { |
|
306 |
|
|
307 |
private DefaultJDialogDataTransformList parent; |
|
308 |
|
|
309 |
public ActionRemove(DefaultJDialogDataTransformList parent) { |
|
310 |
this.parent = parent; |
|
311 |
} |
|
312 |
|
|
313 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
314 |
} |
|
315 |
|
|
316 |
public Object getValue(String key) { |
|
317 |
return null; |
|
318 |
} |
|
319 |
|
Also available in: Unified diff