Revision 18824
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/generictoolbar/GenericToolBarPanel.java | ||
---|---|---|
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.event.ActionEvent; |
|
22 |
import java.awt.event.ActionListener; |
|
23 |
import java.util.Iterator; |
|
24 |
|
|
25 |
import javax.swing.BoxLayout; |
|
26 |
import javax.swing.JButton; |
|
27 |
import javax.swing.JToolBar; |
|
28 |
|
|
29 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.DefaultComboBoxConfigurableLookUpModel; |
|
30 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
|
31 |
import org.gvsig.gui.beans.controls.combobutton.ComboButton; |
|
32 |
import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
|
33 |
|
|
34 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
35 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
36 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
|
37 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
38 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
39 |
/** |
|
40 |
* Componente que contiene los objetos visuales de la barra de herramientas |
|
41 |
* generica |
|
42 |
* |
|
43 |
* @version 13/02/2008 |
|
44 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
45 |
*/ |
|
46 |
public class GenericToolBarPanel extends JToolBar implements ActionListener { |
|
47 |
private JComboBoxConfigurableLookUp jCBCLU; |
|
48 |
private ComboButton buttonGroup = new ComboButton(); |
|
49 |
private ComboButton buttonMenu = new ComboButton(); |
|
50 |
private FLayers lastLayers = null; |
|
51 |
|
|
52 |
public GenericToolBarPanel() { |
|
53 |
super("GenericToolBarPanel"); |
|
54 |
initialize(); |
|
55 |
} |
|
56 |
|
|
57 |
/** |
|
58 |
* Especifica que las capas de la vista han cambiado. |
|
59 |
* @param layers |
|
60 |
*/ |
|
61 |
public void setLayers(FLayers layers) { |
|
62 |
lastLayers = layers; |
|
63 |
|
|
64 |
getComboBoxConfigurableLookUp().removeAllItems(); |
|
65 |
for (int i = 0; i < layers.getLayersCount(); i++) |
|
66 |
getComboBoxConfigurableLookUp().addItem(layers.getLayer(i).getName()); |
|
67 |
|
|
68 |
getComboBoxConfigurableLookUp().setSelectedItem(layers.getActives()[0].getName()); |
|
69 |
getComboBoxConfigurableLookUp().hidePopup(); |
|
70 |
|
|
71 |
reloadSubMenu(); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Devuelve un combo de busqueda de items. |
|
76 |
* @return |
|
77 |
*/ |
|
78 |
private JComboBoxConfigurableLookUp getComboBoxConfigurableLookUp() { |
|
79 |
if (jCBCLU == null) { |
|
80 |
jCBCLU = new JComboBoxConfigurableLookUp(); |
|
81 |
((DefaultComboBoxConfigurableLookUpModel) jCBCLU.getModel()).setShowAllItemsInListBox(false); |
|
82 |
if (jCBCLU.getModel() instanceof DefaultComboBoxConfigurableLookUpModel) { |
|
83 |
((DefaultComboBoxConfigurableLookUpModel) jCBCLU.getModel()).setLookUpAgent(new BinarySearch()); |
|
84 |
jCBCLU.setOnlyOneColorOnText(true); |
|
85 |
} |
|
86 |
} |
|
87 |
return jCBCLU; |
|
88 |
} |
|
89 |
|
|
90 |
private void initialize() { |
|
91 |
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
|
92 |
|
|
93 |
buttonGroup.addActionListener(this); |
|
94 |
buttonGroup.setName("Menu principal"); |
|
95 |
reloadMenuGroup(); |
|
96 |
add(buttonGroup); |
|
97 |
|
|
98 |
buttonMenu.addActionListener(this); |
|
99 |
buttonMenu.setName("Submenus"); |
|
100 |
reloadMenuGroup(); |
|
101 |
add(buttonMenu); |
|
102 |
|
|
103 |
add(getComboBoxConfigurableLookUp()); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Recarga los items del menu global dejando seleccionado el item que habia |
|
108 |
* previamente, en caso de que exista |
|
109 |
*/ |
|
110 |
public void reloadMenuGroup() { |
|
111 |
String actionCommand = buttonGroup.getActionCommand(); |
|
112 |
buttonGroup.clearButtons(); |
|
113 |
buttonMenu.clearButtons(); |
|
114 |
Iterator iterator = null; |
|
115 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
116 |
ExtensionPoint extensionPoint = (ExtensionPoint) extensionPoints.get("GenericToolBarGroup"); |
|
117 |
if (extensionPoint == null) |
|
118 |
return; |
|
119 |
iterator = extensionPoint.keySet().iterator(); |
|
120 |
while (iterator.hasNext()) { |
|
121 |
String key = (String) iterator.next(); |
|
122 |
Object object = ((Object) extensionPoint.get(key)); |
|
123 |
if (object instanceof IGenericToolBarMenuItem) { |
|
124 |
IGenericToolBarMenuItem item = (IGenericToolBarMenuItem) object; |
|
125 |
JButton button2 = new JButton(item.getText(), item.getIcon()); |
|
126 |
button2.setActionCommand(key); |
|
127 |
buttonGroup.addButton(button2); |
|
128 |
} |
|
129 |
} |
|
130 |
buttonGroup.setSelectedItem(actionCommand); |
|
131 |
reloadSubMenu(); |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Recarga los items del submenu dejando seleccionado el item que habia |
|
136 |
* previamente, en caso de que exista |
|
137 |
*/ |
|
138 |
public void reloadSubMenu() { |
|
139 |
String actionCommand = buttonMenu.getActionCommand(); |
|
140 |
buttonMenu.clearButtons(); |
|
141 |
Iterator iterator = null; |
|
142 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
143 |
ExtensionPoint extensionPoint = (ExtensionPoint) extensionPoints.get("GenericToolBarMenu"); |
|
144 |
if (extensionPoint == null) |
|
145 |
return; |
|
146 |
iterator = extensionPoint.keySet().iterator(); |
|
147 |
FLayer[] layers = new FLayer[] {getLayerSelected()}; |
|
148 |
while (iterator.hasNext()) { |
|
149 |
String key = (String) iterator.next(); |
|
150 |
Object object = ((Object) extensionPoint.get(key)); |
|
151 |
if (object instanceof IGenericToolBarMenuItem) { |
|
152 |
IGenericToolBarMenuItem item = (IGenericToolBarMenuItem) object; |
|
153 |
if (!buttonGroup.getActionCommand().equals(item.getGroup())) |
|
154 |
continue; |
|
155 |
if (!item.isVisible(null, layers)) |
|
156 |
continue; |
|
157 |
// Mirar pq no se puede poner disabled un item del menu |
|
158 |
if (!item.isEnabled(null, layers)) |
|
159 |
continue; |
|
160 |
JButton button2 = new JButton(item.getText(), item.getIcon()); |
|
161 |
button2.setActionCommand(key); |
|
162 |
buttonMenu.addButton(button2); |
|
163 |
} |
|
164 |
} |
|
165 |
buttonMenu.setSelectedItem(actionCommand); |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* Devuelve el layer seleccionado en el combobox |
|
170 |
* @return |
|
171 |
*/ |
|
172 |
public FLayer getLayerSelected() { |
|
173 |
if (lastLayers == null) |
|
174 |
return null; |
|
175 |
for (int i = 0; i < lastLayers.getLayersCount(); i++) { |
|
176 |
if (lastLayers.getLayer(i).getName().equals(getComboBoxConfigurableLookUp().getEditor().getItem())) { |
|
177 |
return lastLayers.getLayer(i); |
|
178 |
} |
|
179 |
} |
|
180 |
return null; |
|
181 |
} |
|
182 |
|
|
183 |
/* |
|
184 |
* (non-Javadoc) |
|
185 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
|
186 |
*/ |
|
187 |
public void actionPerformed(ActionEvent e) { |
|
188 |
if (e.getSource() == buttonGroup) { |
|
189 |
reloadSubMenu(); |
|
190 |
return; |
|
191 |
} |
|
192 |
if (e.getSource() == buttonMenu) { |
|
193 |
Iterator iterator = null; |
|
194 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
195 |
ExtensionPoint extensionPoint = (ExtensionPoint) extensionPoints.get("GenericToolBarMenu"); |
|
196 |
if (extensionPoint == null) |
|
197 |
return; |
|
198 |
iterator = extensionPoint.keySet().iterator(); |
|
199 |
while (iterator.hasNext()) { |
|
200 |
String key = (String) iterator.next(); |
|
201 |
if (!key.equals(e.getActionCommand())) |
|
202 |
continue; |
|
203 |
Object object = ((Object) extensionPoint.get(key)); |
|
204 |
if (object instanceof IGenericToolBarMenuItem) { |
|
205 |
IGenericToolBarMenuItem item = (IGenericToolBarMenuItem) object; |
|
206 |
|
|
207 |
if (getLayerSelected() != null) { |
|
208 |
item.execute(null, new FLayer[] {getLayerSelected()}); |
|
209 |
reloadSubMenu(); |
|
210 |
} |
|
211 |
return; |
|
212 |
} |
|
213 |
} |
|
214 |
return; |
|
215 |
} |
|
216 |
} |
|
217 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/generictoolbar/GenericToolBarMenuItem.java | ||
---|---|---|
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 javax.swing.Icon; |
|
22 |
|
|
23 |
import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
|
24 |
|
|
25 |
import com.iver.andami.PluginServices; |
|
26 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
27 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
|
28 |
/** |
|
29 |
* Clase que implementa un IGenericToolBarMenuItem para evitar tener que crear |
|
30 |
* clases para items de menu sencillas |
|
31 |
* |
|
32 |
* @version 06/02/2008 |
|
33 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
34 |
*/ |
|
35 |
public class GenericToolBarMenuItem implements IGenericToolBarMenuItem { |
|
36 |
private String text = ""; |
|
37 |
private int order = 0; |
|
38 |
private Icon icon = null; |
|
39 |
private String group = ""; |
|
40 |
|
|
41 |
public GenericToolBarMenuItem(String text, Icon icon) { |
|
42 |
this(text, icon, "", 0); |
|
43 |
} |
|
44 |
|
|
45 |
public GenericToolBarMenuItem(String text) { |
|
46 |
this(text, PluginServices.getIconTheme().get("blank-icon"), "", 0); |
|
47 |
} |
|
48 |
|
|
49 |
public GenericToolBarMenuItem(String text, Icon icon, String group, int order) { |
|
50 |
this.text = text; |
|
51 |
this.order = order; |
|
52 |
this.icon = icon; |
|
53 |
this.group = group; |
|
54 |
} |
|
55 |
|
|
56 |
public GenericToolBarMenuItem(String text, Icon icon, String group) { |
|
57 |
this(text, icon, group, 0); |
|
58 |
} |
|
59 |
|
|
60 |
public GenericToolBarMenuItem(String text, Icon icon, int order) { |
|
61 |
this(text, icon, "", 0); |
|
62 |
} |
|
63 |
|
|
64 |
/* |
|
65 |
* (non-Javadoc) |
|
66 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#getGroup() |
|
67 |
*/ |
|
68 |
public String getGroup() { |
|
69 |
return group; |
|
70 |
} |
|
71 |
|
|
72 |
/* |
|
73 |
* (non-Javadoc) |
|
74 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getOrder() |
|
75 |
*/ |
|
76 |
public int getOrder() { |
|
77 |
return order; |
|
78 |
} |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getText() |
|
83 |
*/ |
|
84 |
public String getText() { |
|
85 |
return text; |
|
86 |
} |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon() |
|
91 |
*/ |
|
92 |
public Icon getIcon() { |
|
93 |
return icon; |
|
94 |
} |
|
95 |
|
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
99 |
*/ |
|
100 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
|
101 |
return true; |
|
102 |
} |
|
103 |
|
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
107 |
*/ |
|
108 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
|
109 |
return true; |
|
110 |
} |
|
111 |
|
|
112 |
/* |
|
113 |
* (non-Javadoc) |
|
114 |
* @see org.gvsig.raster.gui.IGenericToolBarMenuItem#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[]) |
|
115 |
*/ |
|
116 |
public void execute(ITocItem item, FLayer[] selectedItems) {} |
|
117 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/generictoolbar/GenericToolBarModule.java | ||
---|---|---|
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, 23)); |
|
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 |
} |
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/generictoolbar/BinarySearch.java | ||
---|---|---|
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.util.Arrays; |
|
22 |
import java.util.List; |
|
23 |
import java.util.Vector; |
|
24 |
|
|
25 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp; |
|
26 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.JComboBoxConfigurableLookUp; |
|
27 |
import org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator; |
|
28 |
/** |
|
29 |
* Clase para reimplementar una nueva busqueda para el componente |
|
30 |
* {@link JComboBoxConfigurableLookUp} |
|
31 |
* |
|
32 |
* @version 13/02/2008 |
|
33 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
34 |
*/ |
|
35 |
public class BinarySearch implements ILookUp { |
|
36 |
/* |
|
37 |
* (non-Javadoc) |
|
38 |
* @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpConsideringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator) |
|
39 |
*/ |
|
40 |
public List doLookUpConsideringCaseSensitive(String text, Vector sortOrderedItems, StringComparator comp) { |
|
41 |
Vector list = new Vector(); |
|
42 |
for (int i = 0; i < sortOrderedItems.size(); i++) |
|
43 |
if (sortOrderedItems.get(i).toString().indexOf(text) != -1) |
|
44 |
list.add(sortOrderedItems.get(i)); |
|
45 |
return Arrays.asList(list.toArray()); |
|
46 |
} |
|
47 |
|
|
48 |
/* |
|
49 |
* (non-Javadoc) |
|
50 |
* @see org.gvsig.gui.beans.comboboxconfigurablelookup.ILookUp#doLookUpIgnoringCaseSensitive(java.lang.String, java.util.Vector, org.gvsig.gui.beans.comboboxconfigurablelookup.StringComparator) |
|
51 |
*/ |
|
52 |
public List doLookUpIgnoringCaseSensitive(String text, Vector sortOrderedItems, StringComparator comp) { |
|
53 |
Vector list = new Vector(); |
|
54 |
for (int i = 0; i < sortOrderedItems.size(); i++) |
|
55 |
if (sortOrderedItems.get(i).toString().toLowerCase().indexOf(text.toLowerCase()) != -1) |
|
56 |
list.add(sortOrderedItems.get(i)); |
|
57 |
return Arrays.asList(list.toArray()); |
|
58 |
} |
|
59 |
} |
Also available in: Unified diff