svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / generictoolbar / GenericToolBarModule.java @ 18962
History | View | Annotate | Download (7.05 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.generictoolbar; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
|
24 |
import javax.swing.JPanel; |
25 |
import javax.swing.JToolBar; |
26 |
|
27 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
28 |
import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
29 |
import org.gvsig.raster.gui.properties.dialog.RasterPropertiesTocMenuEntry; |
30 |
import org.gvsig.raster.util.RasterToolsUtil; |
31 |
import org.gvsig.rastertools.analysisview.ViewRasterAnalysisTocMenuEntry; |
32 |
import org.gvsig.rastertools.clipping.ClippingTocMenuEntry; |
33 |
import org.gvsig.rastertools.colortable.ColorTableTocMenuEntry; |
34 |
import org.gvsig.rastertools.filter.FilterTocMenuEntry; |
35 |
import org.gvsig.rastertools.geolocation.GeoLocationTocMenuEntry; |
36 |
import org.gvsig.rastertools.histogram.HistogramTocMenuEntry; |
37 |
import org.gvsig.rastertools.overviews.OverviewsTocMenuEntry; |
38 |
import org.gvsig.rastertools.roi.ui.ROIManagerTocMenuEntry; |
39 |
import org.gvsig.rastertools.saveas.SaveAsTocMenuEntry; |
40 |
|
41 |
import com.iver.andami.PluginServices; |
42 |
import com.iver.andami.plugins.Extension; |
43 |
import com.iver.andami.ui.mdiFrame.MDIFrame; |
44 |
import com.iver.cit.gvsig.fmap.MapContext; |
45 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
46 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
47 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
48 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
49 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
50 |
/**
|
51 |
* Extension para la barra de herramientas generica
|
52 |
*
|
53 |
* @version 13/02/2008
|
54 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
55 |
*/
|
56 |
public class GenericToolBarModule extends Extension { |
57 |
private GenericToolBarPanel toolBar = null; |
58 |
|
59 |
/**
|
60 |
* Crea y devuelve la barra de herramientas
|
61 |
* @return
|
62 |
*/
|
63 |
private GenericToolBarPanel getGenericToolBarPanel() {
|
64 |
if (toolBar == null) { |
65 |
MDIFrame f = (MDIFrame) PluginServices.getMainFrame(); |
66 |
if (f == null) |
67 |
return null; |
68 |
for (int i = 0; i < f.getContentPane().getComponentCount(); i++) { |
69 |
if (f.getContentPane().getComponent(i) instanceof JPanel) { |
70 |
JPanel panel = (JPanel) f.getContentPane().getComponent(i); |
71 |
for (int j = 0; j < panel.getComponentCount(); j++) { |
72 |
if (panel.getComponent(i) instanceof JToolBar) { |
73 |
toolBar = new GenericToolBarPanel();
|
74 |
toolBar.setPreferredSize(new Dimension(300, 26)); |
75 |
|
76 |
panel.add(toolBar, BorderLayout.PAGE_START);
|
77 |
return toolBar;
|
78 |
} |
79 |
} |
80 |
} |
81 |
} |
82 |
} |
83 |
return toolBar;
|
84 |
} |
85 |
|
86 |
/*
|
87 |
* (non-Javadoc)
|
88 |
* @see com.iver.andami.plugins.IExtension#initialize()
|
89 |
*/
|
90 |
public void initialize() { |
91 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
92 |
|
93 |
// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
|
94 |
if (!extensionPoints.containsKey("GenericToolBarGroup")) { |
95 |
extensionPoints.put(new ExtensionPoint("GenericToolBarGroup", "Punto de extension para los grupos de menus del GenericToolBarPanel")); |
96 |
} |
97 |
|
98 |
if (!extensionPoints.containsKey("GenericToolBarMenu")) { |
99 |
extensionPoints.put(new ExtensionPoint("GenericToolBarMenu", "Punto de extension para los submenus del GenericToolBarPanel")); |
100 |
} |
101 |
|
102 |
extensionPoints.add("GenericToolBarGroup", "RasterLayer", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "capa_raster"))); |
103 |
extensionPoints.add("GenericToolBarGroup", "RasterProcess", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "process_raster"))); |
104 |
extensionPoints.add("GenericToolBarGroup", "GeoRaster", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "geo_raster"))); |
105 |
extensionPoints.add("GenericToolBarGroup", "RasterExport", new GenericToolBarMenuItem(RasterToolsUtil.getText(this, "raster_export"))); |
106 |
|
107 |
extensionPoints.add("GenericToolBarMenu", "RasterSEProperties", RasterPropertiesTocMenuEntry.getSingleton()); |
108 |
extensionPoints.add("GenericToolBarMenu", "HistogramPanel", HistogramTocMenuEntry.getSingleton()); |
109 |
extensionPoints.add("GenericToolBarMenu", "ViewColorTable", ColorTableTocMenuEntry.getSingleton()); |
110 |
extensionPoints.add("GenericToolBarMenu", "Overviews", OverviewsTocMenuEntry.getSingleton()); |
111 |
extensionPoints.add("GenericToolBarMenu", "RoisManager", ROIManagerTocMenuEntry.getSingleton()); |
112 |
extensionPoints.add("GenericToolBarMenu", "ViewRasterAnalysis", ViewRasterAnalysisTocMenuEntry.getSingleton()); |
113 |
|
114 |
extensionPoints.add("GenericToolBarMenu", "SaveAs", SaveAsTocMenuEntry.getSingleton()); |
115 |
extensionPoints.add("GenericToolBarMenu", "ClippingPanel", ClippingTocMenuEntry.getSingleton()); |
116 |
|
117 |
extensionPoints.add("GenericToolBarMenu", "FilterPanel", FilterTocMenuEntry.getSingleton()); |
118 |
extensionPoints.add("GenericToolBarMenu", "GeoLocation", GeoLocationTocMenuEntry.getSingleton()); |
119 |
|
120 |
if (getGenericToolBarPanel() != null) |
121 |
getGenericToolBarPanel().reloadMenuGroup(); |
122 |
} |
123 |
|
124 |
/*
|
125 |
* (non-Javadoc)
|
126 |
* @see com.iver.andami.plugins.IExtension#isEnabled()
|
127 |
*/
|
128 |
public boolean isEnabled() { |
129 |
System.out.println("GenericToolBarModule::isEnabled"); |
130 |
return false; |
131 |
} |
132 |
|
133 |
/**
|
134 |
* Establece si la barra de herramientas esta visible
|
135 |
* @param enabled
|
136 |
*/
|
137 |
private void setToolBarVisible(boolean enabled) { |
138 |
if (getGenericToolBarPanel() == null) |
139 |
return;
|
140 |
|
141 |
toolBar.setVisible(enabled); |
142 |
} |
143 |
|
144 |
/*
|
145 |
* (non-Javadoc)
|
146 |
* @see com.iver.andami.plugins.IExtension#isVisible()
|
147 |
*/
|
148 |
public boolean isVisible() { |
149 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
150 |
if (f == null) { |
151 |
setToolBarVisible(false);
|
152 |
return false; |
153 |
} |
154 |
|
155 |
if (f instanceof View) { |
156 |
View vista = (View) f; |
157 |
IProjectView model = vista.getModel(); |
158 |
MapContext mapa = model.getMapContext(); |
159 |
if (mapa.getLayers().getLayersCount() > 0) { |
160 |
if (mapa.getLayers().getActives().length == 1 && |
161 |
mapa.getLayers().getActives()[0] instanceof FLyrRasterSE && |
162 |
((FLyrRasterSE)mapa.getLayers().getActives()[0]).isActionEnabled(IRasterLayerActions.FLYRASTER_BAR_TOOLS)) {
|
163 |
setToolBarVisible(true);
|
164 |
if (getGenericToolBarPanel() != null) { |
165 |
getGenericToolBarPanel().setLayers(mapa.getLayers()); |
166 |
} |
167 |
return true; |
168 |
} |
169 |
} |
170 |
} |
171 |
|
172 |
setToolBarVisible(false);
|
173 |
return false; |
174 |
} |
175 |
|
176 |
public void execute(String actionCommand) {} |
177 |
} |