root / branches / v2_0_0_prep / extensions / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / app / mainplugin / DataTransformExtension.java @ 35740
History | View | Annotate | Download (5.55 KB)
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.app.project.documents.Document; |
41 |
import org.gvsig.app.project.documents.view.ViewDocument; |
42 |
import org.gvsig.app.project.documents.view.ViewManager; |
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; |
50 |
|
51 |
/**
|
52 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
|
53 |
*/
|
54 |
public class DataTransformExtension extends Extension { |
55 |
|
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 = |
64 |
DataTransformLocator.getDataTransformManager(); |
65 |
|
66 |
if ("CREATE".equalsIgnoreCase(actionCommand)) { |
67 |
try {
|
68 |
PluginServices.getMDIManager().addWindow( |
69 |
manager.createWizard().getWindow()); |
70 |
|
71 |
} catch (Exception e) { |
72 |
JOptionPane.showInternalMessageDialog(
|
73 |
(Component) PluginServices.getMDIManager(), PluginServices
|
74 |
.getText(this, "transform_create_wizard_exception"), |
75 |
PluginServices.getText(this, "feature_transform"), |
76 |
JOptionPane.ERROR_MESSAGE);
|
77 |
} |
78 |
} else
|
79 |
if ("VIEW".equalsIgnoreCase(actionCommand)) { |
80 |
|
81 |
// TODO: no retorna null si no hay activeDocument
|
82 |
System.out.println("no retorna null si no hay activeDocument: "); |
83 |
Document doc =
|
84 |
application.getActiveDocument(ViewManager.TYPENAME); |
85 |
|
86 |
if (doc == null) { |
87 |
System.out.println("activeDocument es null"); |
88 |
// TODO
|
89 |
return;
|
90 |
} |
91 |
ViewDocument viewDocument = (ViewDocument) doc; |
92 |
FLayer[] activeLayers =
|
93 |
viewDocument.getMapContext().getLayers().getActives(); |
94 |
|
95 |
if (activeLayers.length < 1) { |
96 |
// TODO
|
97 |
System.out.println("one layer must be active (selected): " |
98 |
+ activeLayers.length); |
99 |
return;
|
100 |
} |
101 |
if (activeLayers.length > 1) { |
102 |
// TODO
|
103 |
System.out
|
104 |
.println("there must be just one layer selected ");
|
105 |
return;
|
106 |
} |
107 |
if (!(activeLayers[0] instanceof FLyrVect)) { |
108 |
// TODO
|
109 |
System.out.println("activeLayers[0] is not FLyrVect"); |
110 |
return;
|
111 |
} |
112 |
FLyrVect layer = (FLyrVect) activeLayers[0];
|
113 |
|
114 |
JDialogDataTransformList dialog = |
115 |
manager.createJDialogDataTransformList((FeatureStore) layer |
116 |
.getDataStore()); |
117 |
ToolsWindowManager wm = new ToolsWindowManager();
|
118 |
wm.showWindow(dialog, "_View_transforms",
|
119 |
WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
|
120 |
} |
121 |
|
122 |
} |
123 |
|
124 |
/*
|
125 |
* (non-Javadoc)
|
126 |
*
|
127 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
128 |
*/
|
129 |
public void initialize() { |
130 |
registerIcons(); |
131 |
} |
132 |
|
133 |
/*
|
134 |
* (non-Javadoc)
|
135 |
*
|
136 |
* @see com.iver.andami.plugins.Extension#postInitialize()
|
137 |
*/
|
138 |
@Override
|
139 |
public void postInitialize() { |
140 |
super.postInitialize();
|
141 |
} |
142 |
|
143 |
private void registerIcons() { |
144 |
PluginServices.getIconTheme().registerDefault( |
145 |
"feature-transform",
|
146 |
this.getClass().getClassLoader()
|
147 |
.getResource("images/transform.png"));
|
148 |
} |
149 |
|
150 |
/*
|
151 |
* (non-Javadoc)
|
152 |
*
|
153 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
154 |
*/
|
155 |
public boolean isEnabled() { |
156 |
return true; |
157 |
} |
158 |
|
159 |
/*
|
160 |
* (non-Javadoc)
|
161 |
*
|
162 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
163 |
*/
|
164 |
public boolean isVisible() { |
165 |
return true; |
166 |
} |
167 |
} |