Revision 35605 branches/v2_0_0_prep/extensions/extDalTransform/src/main/java/org/gvsig/daltransform/app/mainplugin/DataTransformExtension.java
DataTransformExtension.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 22 |
|
23 | 23 |
/* |
24 |
* AUTHORS (In addition to CIT): |
|
25 |
* 2009 {Iver T.I.} {Task} |
|
26 |
*/ |
|
27 |
|
|
24 |
* AUTHORS (In addition to CIT):
|
|
25 |
* 2009 {Iver T.I.} {Task}
|
|
26 |
*/
|
|
27 |
|
|
28 | 28 |
package org.gvsig.daltransform.app.mainplugin; |
29 | 29 |
|
30 | 30 |
import java.awt.Component; |
31 |
import java.awt.GridBagConstraints; |
|
31 | 32 |
|
32 | 33 |
import javax.swing.JOptionPane; |
33 | 34 |
|
34 | 35 |
import org.gvsig.andami.PluginServices; |
35 | 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.app.project.documents.Document; |
|
41 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
42 |
import org.gvsig.app.project.documents.view.ViewManager; |
|
36 | 43 |
import org.gvsig.daltransform.DataTransformLocator; |
44 |
import org.gvsig.daltransform.DataTransformManager; |
|
45 |
import org.gvsig.daltransform.swing.JDialogDataTransformList; |
|
46 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
47 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
48 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
49 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
37 | 50 |
|
38 |
|
|
39 | 51 |
/** |
40 | 52 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
41 | 53 |
*/ |
42 |
public class DataTransformExtension extends Extension{ |
|
43 |
|
|
44 |
/* (non-Javadoc) |
|
45 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
46 |
*/ |
|
47 |
public void execute(String actionCommand) { |
|
48 |
try { |
|
49 |
PluginServices.getMDIManager().addWindow(DataTransformLocator.getDataTransformManager().createWizard().getWindow()); |
|
50 |
} catch (Exception e) { |
|
51 |
JOptionPane.showInternalMessageDialog((Component)PluginServices.getMDIManager(), |
|
52 |
PluginServices.getText(this, "transform_create_wizard_exception"), |
|
53 |
PluginServices.getText(this, "feature_transform"), |
|
54 |
JOptionPane.ERROR_MESSAGE); |
|
55 |
} |
|
56 |
} |
|
54 |
public class DataTransformExtension extends Extension { |
|
57 | 55 |
|
58 |
/* (non-Javadoc) |
|
59 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
60 |
*/ |
|
61 |
public void initialize() { |
|
62 |
registerIcons(); |
|
63 |
} |
|
64 |
|
|
65 |
/* (non-Javadoc) |
|
66 |
* @see com.iver.andami.plugins.Extension#postInitialize() |
|
67 |
*/ |
|
68 |
public void postInitialize() { |
|
69 |
super.postInitialize(); |
|
70 |
} |
|
56 |
/* |
|
57 |
* (non-Javadoc) |
|
58 |
* |
|
59 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
60 |
*/ |
|
61 |
public void execute(String actionCommand) { |
|
62 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
63 |
DataTransformManager manager = DataTransformLocator.getDataTransformManager(); |
|
64 |
|
|
65 |
if ("CREATE".equalsIgnoreCase(actionCommand) ) { |
|
66 |
try { |
|
67 |
PluginServices.getMDIManager().addWindow( |
|
68 |
manager.createWizard().getWindow()); |
|
69 |
} catch (Exception e) { |
|
70 |
JOptionPane.showInternalMessageDialog( |
|
71 |
(Component) PluginServices.getMDIManager(), PluginServices |
|
72 |
.getText(this, "transform_create_wizard_exception"), |
|
73 |
PluginServices.getText(this, "feature_transform"), |
|
74 |
JOptionPane.ERROR_MESSAGE); |
|
75 |
} |
|
76 |
} else |
|
77 |
if ("VIEW".equalsIgnoreCase(actionCommand)) { |
|
78 |
Document doc = |
|
79 |
application.getActiveDocument(ViewManager.TYPENAME); |
|
80 |
if (doc == null) { |
|
81 |
// TODO |
|
82 |
return; |
|
83 |
} |
|
84 |
ViewDocument viewDocument = (ViewDocument) doc; |
|
85 |
FLayer[] activeLayers = |
|
86 |
viewDocument.getMapContext().getLayers().getActives(); |
|
87 |
if (activeLayers.length < 1) { |
|
88 |
// TODO |
|
89 |
return; |
|
90 |
} |
|
91 |
if (activeLayers.length > 1) { |
|
92 |
// TODO |
|
93 |
return; |
|
94 |
} |
|
95 |
if (!(activeLayers[0] instanceof FLyrVect)) { |
|
96 |
// TODO |
|
97 |
return; |
|
98 |
} |
|
99 |
FLyrVect layer = (FLyrVect) activeLayers[0]; |
|
100 |
JDialogDataTransformList dialog = |
|
101 |
manager.createJDialogDataTransformList((FeatureStore) layer |
|
102 |
.getDataStore()); |
|
103 |
ToolsWindowManager wm = new ToolsWindowManager(); |
|
104 |
wm.showWindow(dialog, "TODO", WindowManager.MODE.WINDOW, |
|
105 |
GridBagConstraints.CENTER); |
|
106 |
} |
|
71 | 107 |
|
72 |
private void registerIcons(){ |
|
73 |
PluginServices.getIconTheme().registerDefault( |
|
74 |
"feature-transform", |
|
75 |
this.getClass().getClassLoader().getResource("images/transform.png") |
|
76 |
); |
|
77 |
} |
|
108 |
} |
|
78 | 109 |
|
79 |
/* (non-Javadoc) |
|
80 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
81 |
*/ |
|
82 |
public boolean isEnabled() { |
|
83 |
return true; |
|
84 |
} |
|
110 |
/* |
|
111 |
* (non-Javadoc) |
|
112 |
* |
|
113 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
114 |
*/ |
|
115 |
public void initialize() { |
|
116 |
registerIcons(); |
|
117 |
} |
|
85 | 118 |
|
86 |
/* (non-Javadoc) |
|
87 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
88 |
*/ |
|
89 |
public boolean isVisible() { |
|
90 |
return true; |
|
91 |
} |
|
119 |
/* |
|
120 |
* (non-Javadoc) |
|
121 |
* |
|
122 |
* @see com.iver.andami.plugins.Extension#postInitialize() |
|
123 |
*/ |
|
124 |
@Override |
|
125 |
public void postInitialize() { |
|
126 |
super.postInitialize(); |
|
127 |
} |
|
128 |
|
|
129 |
private void registerIcons() { |
|
130 |
PluginServices.getIconTheme().registerDefault( |
|
131 |
"feature-transform", |
|
132 |
this.getClass().getClassLoader() |
|
133 |
.getResource("images/transform.png")); |
|
134 |
} |
|
135 |
|
|
136 |
/* |
|
137 |
* (non-Javadoc) |
|
138 |
* |
|
139 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
140 |
*/ |
|
141 |
public boolean isEnabled() { |
|
142 |
return true; |
|
143 |
} |
|
144 |
|
|
145 |
/* |
|
146 |
* (non-Javadoc) |
|
147 |
* |
|
148 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
149 |
*/ |
|
150 |
public boolean isVisible() { |
|
151 |
return true; |
|
152 |
} |
|
92 | 153 |
} |
93 |
|
Also available in: Unified diff