svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / dialog / RasterPropertiesTocMenuEntry.java @ 12225
History | View | Annotate | Download (4.11 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 |
* Entrada en del men? contextual del TOC correspondiente al cuadro de
|
36 |
* propiedades del raster
|
37 |
*
|
38 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
39 |
*/
|
40 |
public class RasterPropertiesTocMenuEntry extends AbstractTocContextMenuAction { |
41 |
private PropertiesRasterRegistrableDialog properties = null; |
42 |
private ArrayList listeners = new ArrayList(); |
43 |
private FLayer lyr = null; |
44 |
|
45 |
/**
|
46 |
* Variable para controlar si los eventos de los paneles se deben interpretar.
|
47 |
* En la carga inicial se deben desactivar todos los eventos
|
48 |
*/
|
49 |
public static boolean enableEvents = false; |
50 |
|
51 |
public String getGroup() { |
52 |
return "raster"; |
53 |
} |
54 |
|
55 |
public int getGroupOrder() { |
56 |
return 60; |
57 |
} |
58 |
|
59 |
public int getOrder() { |
60 |
return 0; |
61 |
} |
62 |
|
63 |
public String getText() { |
64 |
return PluginServices.getText(this, "propiedades_raster"); |
65 |
} |
66 |
|
67 |
/**
|
68 |
* Los objetos que quieren que se ejecute su listerner deben ser registrados a
|
69 |
* traves de este m?todo. Cuando se ejecute el actionPerformed se buscar?
|
70 |
* todos los objetos registrados y ejecutar? el actionPerformed de cada uno,
|
71 |
*
|
72 |
* @param obj Objeto a registrar
|
73 |
*/
|
74 |
public void register(Object obj) { |
75 |
if (obj instanceof IRasterPropertiesRegistrable) |
76 |
listeners.add(obj); |
77 |
} |
78 |
|
79 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
80 |
return selectedItems.length == 1; |
81 |
} |
82 |
|
83 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
84 |
if (isTocItemBranch(item))
|
85 |
return (getNodeLayer(item) instanceof FLyrRasterSE); |
86 |
return false; |
87 |
} |
88 |
|
89 |
/**
|
90 |
* Gestiona la apertura del dialogo de propiedades de raster cuando se pulsa
|
91 |
* la opci?n asignando a este las propiedades iniciales.
|
92 |
*/
|
93 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
94 |
if (selectedItems.length == 1 ) |
95 |
lyr = selectedItems[0];
|
96 |
else
|
97 |
return;
|
98 |
|
99 |
if (properties == null) |
100 |
properties = new PropertiesRasterRegistrableDialog(lyr.getName());
|
101 |
|
102 |
//Asigna la capa a cada panel registrado para que puedan operar
|
103 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
104 |
ExtensionPoint extensionPoint = (ExtensionPoint)extensionPoints.get("RasterSEPropertiesDialog");
|
105 |
if (extensionPoint == null) |
106 |
return;
|
107 |
|
108 |
enableEvents = false;
|
109 |
|
110 |
Iterator iterator = extensionPoint.keySet().iterator();
|
111 |
while (iterator.hasNext()) {
|
112 |
try {
|
113 |
String key = (String) iterator.next(); |
114 |
Object obj = extensionPoint.get(key);
|
115 |
if (obj instanceof IRegistrablePanel) |
116 |
((IRegistrablePanel) obj).setLayer(lyr); |
117 |
} catch (ClassCastException e) { |
118 |
//No se a?ade el panel y se sigue con el siguiente
|
119 |
continue;
|
120 |
} |
121 |
} |
122 |
|
123 |
enableEvents = true;
|
124 |
PluginServices.getMDIManager().addWindow(properties); |
125 |
|
126 |
} |
127 |
} |