Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.daltransform.app.mainplugin / src / main / java / org / gvsig / daltransform / app / mainplugin / DataTransformExtension.java @ 40351

History | View | Annotate | Download (4.42 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.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

    
38
import org.gvsig.andami.IconThemeHelper;
39
import org.gvsig.andami.PluginServices;
40
import org.gvsig.andami.plugins.Extension;
41
import org.gvsig.andami.ui.ToolsWindowManager;
42
import org.gvsig.app.ApplicationLocator;
43
import org.gvsig.app.ApplicationManager;
44
import org.gvsig.daltransform.DataTransformLocator;
45
import org.gvsig.daltransform.DataTransformManager;
46
import org.gvsig.daltransform.swing.JDialogDataTransformList;
47
import org.gvsig.i18n.Messages;
48
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
49

    
50
/**
51
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
52
 */
53
public class DataTransformExtension extends Extension {
54
    
55
    private static final Logger logger =
56
        LoggerFactory.getLogger(DataTransformExtension.class);
57

    
58
    /*
59
     * (non-Javadoc)
60
     * 
61
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
62
     */
63
    public void execute(String actionCommand) {
64
        ApplicationManager application = ApplicationLocator.getManager();
65
        DataTransformManager manager =
66
            DataTransformLocator.getDataTransformManager();
67

    
68
        if ("CREATE".equalsIgnoreCase(actionCommand)) {
69
            try {
70
                PluginServices.getMDIManager().addWindow(
71
                    manager.createWizard().getWindow());
72

    
73
            } catch (Exception e) {
74
                
75
                logger.info("Error while creating data transform wizard", e);
76
                ApplicationLocator.getManager().messageDialog(
77
                    Messages.getText("transform_create_wizard_exception") +
78
                    ": " + e.getMessage(),
79
                    Messages.getText("feature_transform"),
80
                    JOptionPane.ERROR_MESSAGE);
81
                
82
            }
83
        } else
84
            if ("VIEW".equalsIgnoreCase(actionCommand)) {
85

    
86
                // there is no layer loaded
87
                if (application.getActiveDocument() == null) {
88
                    JOptionPane.showMessageDialog(null,
89
                        Messages.getText("not_featurestore_loaded"),
90
                        Messages.getText("view_transforms"),
91
                        JOptionPane.OK_OPTION + JOptionPane.WARNING_MESSAGE);
92
                    return;
93
                }
94

    
95
                JDialogDataTransformList dialog =
96
                    manager.createJDialogDataTransformList();
97

    
98
                ToolsWindowManager wm = new ToolsWindowManager();
99
                wm.showWindow(dialog, Messages.getText("view_transforms"),
100
                    WindowManager.MODE.WINDOW, GridBagConstraints.CENTER);
101
            }
102

    
103
    }
104

    
105
    /*
106
     * (non-Javadoc)
107
     * 
108
     * @see com.iver.andami.plugins.IExtension#initialize()
109
     */
110
    public void initialize() {
111
            IconThemeHelper.registerIcon("feature-transform-tools", "feature-transform-wizard", this);
112
    }
113

    
114
    /*
115
     * (non-Javadoc)
116
     * 
117
     * @see com.iver.andami.plugins.Extension#postInitialize()
118
     */
119
    @Override
120
    public void postInitialize() {
121
        super.postInitialize();
122
    }
123

    
124
    /*
125
     * (non-Javadoc)
126
     * 
127
     * @see com.iver.andami.plugins.IExtension#isEnabled()
128
     */
129
    public boolean isEnabled() {
130
        return true;
131
    }
132

    
133
    /*
134
     * (non-Javadoc)
135
     * 
136
     * @see com.iver.andami.plugins.IExtension#isVisible()
137
     */
138
    public boolean isVisible() {
139
        return true;
140
    }
141
}