Statistics
| Revision:

gvsig-raster / org.gvsig.raster.multifile / trunk / org.gvsig.raster.multifile / org.gvsig.raster.multifile.app.multifileclient / src / main / java / org / gvsig / raster / multifile / app / MultifileClientExtension.java @ 5988

History | View | Annotate | Download (4.56 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
package org.gvsig.raster.multifile.app;
23

    
24
import java.awt.event.ActionEvent;
25
import java.awt.event.ActionListener;
26
import java.util.Locale;
27

    
28
import javax.swing.JComponent;
29

    
30
import org.gvsig.andami.IconThemeHelper;
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.andami.plugins.Extension;
33
import org.gvsig.i18n.Messages;
34
import org.gvsig.raster.multifile.app.panel.BandSelectorPanel;
35
import org.gvsig.raster.multifile.app.panel.MainWindow;
36
import org.gvsig.raster.swing.RasterSwingLocator;
37
import org.gvsig.raster.swing.basepanel.IButtonsPanel;
38
import org.gvsig.raster.swing.newlayer.CreateNewLayerPanel;
39
import org.gvsig.tools.ToolsLocator;
40
import org.gvsig.tools.extensionpoint.ExtensionPoint;
41
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
42

    
43
/**
44
 * Extension for adding grid netcdf support to gvSIG.
45
 * @author Nacho Brodin (nachobrodin@gmail.com)
46
 */
47
public class MultifileClientExtension extends Extension implements ActionListener {
48
        private CreateNewLayerPanel             newLayerPanel        = null;
49
        private MainWindow                      layerNamewindow      = null;
50
        private MainWindow                      bandSelectorwindow   = null;
51
        private MainDialogActions               actions              = null;
52

    
53
        public void initialize() {
54
                ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
55

    
56
                ExtensionPoint point = extensionPoints.get("AplicationPreferences");
57
                point = extensionPoints.get("RasterSEPropertiesDialog");
58
                point.append("Bandas", "", BandSelectorPanel.class);
59

    
60
                point = extensionPoints.add("GenericToolBarMenu");
61
                point.append("Multifile", "", MultiFileCreatorTocMenuEntry.getSingleton());
62
                MultiFileCreatorTocMenuEntry.setExtension(this);
63

    
64
                if (!Messages.hasLocales()) {
65
                        Messages.addLocale(Locale.getDefault());
66
                }
67

    
68
                Messages.addResourceFamily("org.gvsig.raster.multifile.app.i18n.text",
69
                                MultifileClientExtension.class.getClassLoader(),
70
                                MultifileClientExtension.class.getClass().getName());
71

    
72
                initilizeIcons();
73
        }
74

    
75
        public void execute(String actionCommand) {
76
                if (actionCommand.compareTo("MultifileCreator") == 0) {
77
                        layerNamewindow = new MainWindow((JComponent)getNewLayerPanel(),
78
                                        Messages.getText("select_output_file"), 300, 150, this);
79
                        PluginServices.getMDIManager().addCentredWindow(layerNamewindow);
80
            }
81
        }
82

    
83
        private void initilizeIcons() {
84
                IconThemeHelper.registerIcon(null, "multifile-icon", this);
85
    }
86

    
87
        public boolean isEnabled() {
88
                return true;
89
        }
90

    
91
        public boolean isVisible() {
92
                return true;
93
        }
94

    
95
        /**
96
         * @return CreateNewLayerPanel
97
         */
98
        public CreateNewLayerPanel getNewLayerPanel() {
99
                if(newLayerPanel == null) {
100
                        newLayerPanel = RasterSwingLocator.getSwingManager().createNewLayerPanel();
101
                }
102
                return newLayerPanel;
103
        }
104

    
105
        public void actionPerformed(ActionEvent e) {
106
                //Accept the window with the layer name
107
                if(e.getSource() == layerNamewindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_ACCEPT)) {
108
                        String file = getNewLayerPanel().getFileSelected();
109
                        String folder = getNewLayerPanel().getDirectorySelected();
110
                        BandSelectorPanel panel = new BandSelectorPanel(BandSelectorPanel.TYPE_DIALOG);
111
                        panel.getListener().setDestination(file, folder);
112
                        actions = new MainDialogActions(panel, file, folder);
113
                        bandSelectorwindow = new MainWindow(panel, Messages.getText("add_files"), 500, 400, this, true);
114
                        PluginServices.getMDIManager().addCentredWindow(bandSelectorwindow);
115
                }
116

    
117
                //Button of load layer in the main dialog
118
                if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1)) {
119
                        actions.loadLayer();
120
                }
121

    
122
                //Button of create one file with al files
123
                if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2)) {
124
                        actions.buildOneLayer();
125
                }
126

    
127
        }
128
}