svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.daltransform.app / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / app / mainplugin / DataTransformExtension.java @ 40558
History | View | Annotate | Download (4.46 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2009 {Iver T.I.} {Task}
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.daltransform.app.mainplugin; |
30 |
|
31 |
import java.awt.Component; |
32 |
import java.awt.GridBagConstraints; |
33 |
|
34 |
import javax.swing.JOptionPane; |
35 |
|
36 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
import org.gvsig.andami.IconThemeHelper; |
40 |
import org.gvsig.andami.PluginServices; |
41 |
import org.gvsig.andami.plugins.Extension; |
42 |
import org.gvsig.andami.ui.ToolsWindowManager; |
43 |
import org.gvsig.app.ApplicationLocator; |
44 |
import org.gvsig.app.ApplicationManager; |
45 |
import org.gvsig.daltransform.DataTransformLocator; |
46 |
import org.gvsig.daltransform.DataTransformManager; |
47 |
import org.gvsig.daltransform.swing.JDialogDataTransformList; |
48 |
import org.gvsig.i18n.Messages; |
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 |
private static final Logger logger = |
57 |
LoggerFactory.getLogger(DataTransformExtension.class); |
58 |
|
59 |
/*
|
60 |
* (non-Javadoc)
|
61 |
*
|
62 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
63 |
*/
|
64 |
public void execute(String actionCommand) { |
65 |
ApplicationManager application = ApplicationLocator.getManager(); |
66 |
DataTransformManager manager = |
67 |
DataTransformLocator.getDataTransformManager(); |
68 |
|
69 |
if ("CREATE".equalsIgnoreCase(actionCommand)) { |
70 |
try {
|
71 |
PluginServices.getMDIManager().addWindow( |
72 |
manager.createWizard().getWindow()); |
73 |
|
74 |
} catch (Exception e) { |
75 |
|
76 |
logger.info("Error while creating data transform wizard", e);
|
77 |
ApplicationLocator.getManager().messageDialog( |
78 |
Messages.getText("transform_create_wizard_exception") +
|
79 |
": " + e.getMessage(),
|
80 |
Messages.getText("feature_transform"),
|
81 |
JOptionPane.ERROR_MESSAGE);
|
82 |
|
83 |
} |
84 |
} else
|
85 |
if ("VIEW".equalsIgnoreCase(actionCommand)) { |
86 |
|
87 |
// there is no layer loaded
|
88 |
if (application.getActiveDocument() == null) { |
89 |
JOptionPane.showMessageDialog(null, |
90 |
Messages.getText("not_featurestore_loaded"),
|
91 |
Messages.getText("view_transforms"),
|
92 |
JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE); |
93 |
return;
|
94 |
} |
95 |
|
96 |
JDialogDataTransformList dialog = |
97 |
manager.createJDialogDataTransformList(); |
98 |
|
99 |
ToolsWindowManager wm = new ToolsWindowManager();
|
100 |
wm.showWindow(dialog, Messages.getText("view_transforms"),
|
101 |
WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
|
102 |
} |
103 |
|
104 |
} |
105 |
|
106 |
/*
|
107 |
* (non-Javadoc)
|
108 |
*
|
109 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
110 |
*/
|
111 |
public void initialize() { |
112 |
IconThemeHelper.registerIcon("feature-transform-tools", "feature-transform-wizard", this); |
113 |
} |
114 |
|
115 |
/*
|
116 |
* (non-Javadoc)
|
117 |
*
|
118 |
* @see com.iver.andami.plugins.Extension#postInitialize()
|
119 |
*/
|
120 |
@Override
|
121 |
public void postInitialize() { |
122 |
super.postInitialize();
|
123 |
} |
124 |
|
125 |
/*
|
126 |
* (non-Javadoc)
|
127 |
*
|
128 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
129 |
*/
|
130 |
public boolean isEnabled() { |
131 |
return true; |
132 |
} |
133 |
|
134 |
/*
|
135 |
* (non-Javadoc)
|
136 |
*
|
137 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
138 |
*/
|
139 |
public boolean isVisible() { |
140 |
return true; |
141 |
} |
142 |
} |