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 | 2458 | nbrodin | /* 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 | 5988 | fdiaz | *
|
6 | 2458 | nbrodin | * 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 | 5988 | fdiaz | *
|
11 | 2458 | nbrodin | * 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 | 5988 | fdiaz | *
|
16 | 2458 | nbrodin | * 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 | 5988 | fdiaz | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | 2458 | nbrodin | * MA 02110-1301, USA.
|
20 | 5988 | fdiaz | *
|
21 | 2458 | nbrodin | */
|
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 | 5988 | fdiaz | |
53 | 2458 | nbrodin | 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 | 5988 | fdiaz | |
60 | 2458 | nbrodin | point = extensionPoints.add("GenericToolBarMenu");
|
61 | point.append("Multifile", "", MultiFileCreatorTocMenuEntry.getSingleton()); |
||
62 | MultiFileCreatorTocMenuEntry.setExtension(this);
|
||
63 | 5988 | fdiaz | |
64 | 2458 | nbrodin | 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 | 5988 | fdiaz | |
72 | 2458 | nbrodin | initilizeIcons(); |
73 | } |
||
74 | |||
75 | public void execute(String actionCommand) { |
||
76 | if (actionCommand.compareTo("MultifileCreator") == 0) { |
||
77 | 5988 | fdiaz | layerNamewindow = new MainWindow((JComponent)getNewLayerPanel(), |
78 | 2458 | nbrodin | Messages.getText("select_output_file"), 300, 150, this); |
79 | PluginServices.getMDIManager().addCentredWindow(layerNamewindow); |
||
80 | } |
||
81 | } |
||
82 | 5988 | fdiaz | |
83 | 2458 | nbrodin | 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 | 3330 | mcompany | return true; |
93 | 2458 | nbrodin | } |
94 | |||
95 | 5988 | fdiaz | /**
|
96 | * @return CreateNewLayerPanel
|
||
97 | */
|
||
98 | 2458 | nbrodin | 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 | 5988 | fdiaz | |
117 | 2458 | nbrodin | //Button of load layer in the main dialog
|
118 | if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR1)) {
|
||
119 | actions.loadLayer(); |
||
120 | } |
||
121 | 5988 | fdiaz | |
122 | 2458 | nbrodin | //Button of create one file with al files
|
123 | if(e.getSource() == bandSelectorwindow.getButtonsPanel().getButton(IButtonsPanel.BUTTON_USR2)) {
|
||
124 | actions.buildOneLayer(); |
||
125 | } |
||
126 | 5988 | fdiaz | |
127 | 2458 | nbrodin | } |
128 | } |