Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / app / mainplugin / DataTransformExtension.java @ 38564

History | View | Annotate | Download (4.16 KB)

1 28893 jpiera
/* gvSIG. Geographic Information System of the Valencian Government
2 35605 nfrancisco
 *
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 28893 jpiera
23
/*
24 35605 nfrancisco
 * AUTHORS (In addition to CIT):
25
 * 2009 {Iver T.I.}   {Task}
26
 */
27
28 35510 nfrancisco
package org.gvsig.daltransform.app.mainplugin;
29 28893 jpiera
30 29524 jpiera
import java.awt.Component;
31 35605 nfrancisco
import java.awt.GridBagConstraints;
32 29524 jpiera
33
import javax.swing.JOptionPane;
34
35 38564 jjdelcerro
import org.gvsig.andami.IconThemeHelper;
36 29627 jpiera
import org.gvsig.andami.PluginServices;
37
import org.gvsig.andami.plugins.Extension;
38 35605 nfrancisco
import org.gvsig.andami.ui.ToolsWindowManager;
39
import org.gvsig.app.ApplicationLocator;
40
import org.gvsig.app.ApplicationManager;
41 35510 nfrancisco
import org.gvsig.daltransform.DataTransformLocator;
42 35605 nfrancisco
import org.gvsig.daltransform.DataTransformManager;
43
import org.gvsig.daltransform.swing.JDialogDataTransformList;
44 37817 jpiera
import org.gvsig.i18n.Messages;
45 35605 nfrancisco
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
46 28893 jpiera
47
/**
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
49
 */
50 35605 nfrancisco
public class DataTransformExtension extends Extension {
51 28893 jpiera
52 35605 nfrancisco
    /*
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 35740 nfrancisco
        DataTransformManager manager =
60
            DataTransformLocator.getDataTransformManager();
61
62
        if ("CREATE".equalsIgnoreCase(actionCommand)) {
63 35605 nfrancisco
            try {
64
                PluginServices.getMDIManager().addWindow(
65 35740 nfrancisco
                    manager.createWizard().getWindow());
66
67 35605 nfrancisco
            } catch (Exception e) {
68
                JOptionPane.showInternalMessageDialog(
69 37817 jpiera
                    (Component) PluginServices.getMDIManager(),
70
                    Messages.getText("transform_create_wizard_exception"),
71
                    Messages.getText("feature_transform"),
72 35605 nfrancisco
                    JOptionPane.ERROR_MESSAGE);
73
            }
74
        } else
75
            if ("VIEW".equalsIgnoreCase(actionCommand)) {
76 35740 nfrancisco
77 36000 nfrancisco
                // there is no layer loaded
78
                if (application.getActiveDocument() == null) {
79
                    JOptionPane.showMessageDialog(null,
80 37817 jpiera
                        Messages.getText("not_featurestore_loaded"),
81
                        Messages.getText("view_transforms"),
82 36000 nfrancisco
                        JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE);
83
                    return;
84
                }
85
86 35605 nfrancisco
                JDialogDataTransformList dialog =
87 36000 nfrancisco
                    manager.createJDialogDataTransformList();
88
89 35605 nfrancisco
                ToolsWindowManager wm = new ToolsWindowManager();
90 37817 jpiera
                wm.showWindow(dialog, Messages.getText("view_transforms"),
91 35740 nfrancisco
                    WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
92 35605 nfrancisco
            }
93 28893 jpiera
94 35605 nfrancisco
    }
95 28893 jpiera
96 35605 nfrancisco
    /*
97
     * (non-Javadoc)
98
     *
99
     * @see com.iver.andami.plugins.IExtension#initialize()
100
     */
101
    public void initialize() {
102 38564 jjdelcerro
            IconThemeHelper.registerIcon("feature-transform-tools", "feature-transform-wizard", this);
103 35605 nfrancisco
    }
104 28893 jpiera
105 35605 nfrancisco
    /*
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 28893 jpiera
}