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
/* 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.IconThemeHelper;
36
import org.gvsig.andami.PluginServices;
37
import org.gvsig.andami.plugins.Extension;
38
import org.gvsig.andami.ui.ToolsWindowManager;
39
import org.gvsig.app.ApplicationLocator;
40
import org.gvsig.app.ApplicationManager;
41
import org.gvsig.daltransform.DataTransformLocator;
42
import org.gvsig.daltransform.DataTransformManager;
43
import org.gvsig.daltransform.swing.JDialogDataTransformList;
44
import org.gvsig.i18n.Messages;
45
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
46

    
47
/**
48
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
49
 */
50
public class DataTransformExtension extends Extension {
51

    
52
    /*
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
        DataTransformManager manager =
60
            DataTransformLocator.getDataTransformManager();
61

    
62
        if ("CREATE".equalsIgnoreCase(actionCommand)) {
63
            try {
64
                PluginServices.getMDIManager().addWindow(
65
                    manager.createWizard().getWindow());
66

    
67
            } catch (Exception e) {
68
                JOptionPane.showInternalMessageDialog(
69
                    (Component) PluginServices.getMDIManager(), 
70
                    Messages.getText("transform_create_wizard_exception"),
71
                    Messages.getText("feature_transform"),
72
                    JOptionPane.ERROR_MESSAGE);
73
            }
74
        } else
75
            if ("VIEW".equalsIgnoreCase(actionCommand)) {
76

    
77
                // there is no layer loaded
78
                if (application.getActiveDocument() == null) {
79
                    JOptionPane.showMessageDialog(null,
80
                        Messages.getText("not_featurestore_loaded"),
81
                        Messages.getText("view_transforms"),
82
                        JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE);
83
                    return;
84
                }
85

    
86
                JDialogDataTransformList dialog =
87
                    manager.createJDialogDataTransformList();
88

    
89
                ToolsWindowManager wm = new ToolsWindowManager();
90
                wm.showWindow(dialog, Messages.getText("view_transforms"),
91
                    WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
92
            }
93

    
94
    }
95

    
96
    /*
97
     * (non-Javadoc)
98
     * 
99
     * @see com.iver.andami.plugins.IExtension#initialize()
100
     */
101
    public void initialize() {
102
            IconThemeHelper.registerIcon("feature-transform-tools", "feature-transform-wizard", this);
103
    }
104

    
105
    /*
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
}