root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / dialog / RasterPropertiesTocMenuEntry.java @ 10799
History | View | Annotate | Download (3.81 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.properties.dialog; |
20 |
|
21 |
import java.util.ArrayList; |
22 |
import java.util.Iterator; |
23 |
|
24 |
import org.gvsig.fmap.layers.FLyrRasterSE; |
25 |
|
26 |
import com.iver.andami.PluginServices; |
27 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
28 |
import com.iver.cit.gvsig.gui.panels.IRasterPropertiesRegistrable; |
29 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
30 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
31 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
32 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
33 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
34 |
|
35 |
|
36 |
/**
|
37 |
* Entrada en del men? contextual del TOC correspondiente al cuadro de
|
38 |
* propiedades del raster
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
40 |
*
|
41 |
*/
|
42 |
public class RasterPropertiesTocMenuEntry extends AbstractTocContextMenuAction { |
43 |
private PropertiesRasterRegistrableDialog properties = null; |
44 |
private ArrayList listeners = new ArrayList(); |
45 |
private FLayer lyr = null; |
46 |
|
47 |
public String getGroup() { |
48 |
return "raster"; |
49 |
} |
50 |
|
51 |
public int getGroupOrder() { |
52 |
return 60; |
53 |
} |
54 |
|
55 |
public int getOrder() { |
56 |
return 0; |
57 |
} |
58 |
|
59 |
public String getText() { |
60 |
return PluginServices.getText(this, "propiedades_raster"); |
61 |
} |
62 |
|
63 |
/**
|
64 |
* Los objetos que quieren que se ejecute su listerner deben ser
|
65 |
* registrados a traves de este m?todo. Cuando se ejecute el actionPerformed
|
66 |
* se buscar? todos los objetos registrados y ejecutar? el actionPerformed de
|
67 |
* cada uno,
|
68 |
* @param obj Objeto a registrar
|
69 |
*/
|
70 |
public void register(Object obj){ |
71 |
if(obj instanceof IRasterPropertiesRegistrable) |
72 |
listeners.add(obj); |
73 |
} |
74 |
|
75 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
76 |
return selectedItems.length == 1; |
77 |
} |
78 |
|
79 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
80 |
if (isTocItemBranch(item))
|
81 |
return (getNodeLayer(item) instanceof FLyrRasterSE); |
82 |
return false; |
83 |
} |
84 |
|
85 |
/**
|
86 |
* Gestiona la apertura del dialogo de propiedades de raster cuando se pulsa
|
87 |
* la opci?n asignando a este las propiedades iniciales.
|
88 |
*/
|
89 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
90 |
if (selectedItems.length == 1 ) |
91 |
lyr = selectedItems[0];
|
92 |
else
|
93 |
return;
|
94 |
|
95 |
if(properties == null) |
96 |
properties = new PropertiesRasterRegistrableDialog();
|
97 |
|
98 |
//Asigna la capa a cada panel registrado para que puedan operar
|
99 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
100 |
ExtensionPoint extensionPoint = (ExtensionPoint)extensionPoints.get("RasterSEPropertiesDialog");
|
101 |
if(extensionPoint == null) |
102 |
return;
|
103 |
Iterator iterator = extensionPoint.keySet().iterator();
|
104 |
while (iterator.hasNext()) {
|
105 |
try {
|
106 |
String key = (String)iterator.next(); |
107 |
Object obj = extensionPoint.get(key);
|
108 |
if(obj instanceof IRegistrablePanel) |
109 |
((IRegistrablePanel)obj).setLayer(lyr); |
110 |
} catch (ClassCastException e) { |
111 |
//No se a?ade el panel y se sigue con el siguiente
|
112 |
continue;
|
113 |
} |
114 |
} |
115 |
|
116 |
PluginServices.getMDIManager().addWindow(properties); |
117 |
} |
118 |
|
119 |
} |