root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / properties / RasterPropertiesTocMenuEntry.java @ 20948
History | View | Annotate | Download (5.59 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; |
20 |
|
21 |
import javax.swing.Icon; |
22 |
|
23 |
import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
24 |
import org.gvsig.fmap.raster.layers.ILayerState; |
25 |
import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
26 |
import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
27 |
import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
28 |
import org.gvsig.raster.util.RasterToolsUtil; |
29 |
|
30 |
//import com.iver.andami.PluginServices;
|
31 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
32 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
33 |
import com.iver.cit.gvsig.panelGroup.PanelGroupDialog; |
34 |
import com.iver.cit.gvsig.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint; |
35 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
36 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
37 |
/**
|
38 |
* Entrada en del men? contextual del TOC correspondiente al cuadro de
|
39 |
* propiedades del raster
|
40 |
*
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class RasterPropertiesTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
44 |
static private RasterPropertiesTocMenuEntry singleton = null; |
45 |
private PanelGroupDialog properties = null; |
46 |
private FLayer lyr = null; |
47 |
|
48 |
/**
|
49 |
* Variable para controlar si los eventos de los paneles se deben interpretar.
|
50 |
* En la carga inicial se deben desactivar todos los eventos
|
51 |
*/
|
52 |
public static boolean enableEvents = false; |
53 |
|
54 |
/**
|
55 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
56 |
* getSingleton()
|
57 |
*/
|
58 |
private RasterPropertiesTocMenuEntry() {}
|
59 |
|
60 |
/**
|
61 |
* Devuelve un objeto unico a dicha clase
|
62 |
* @return
|
63 |
*/
|
64 |
static public RasterPropertiesTocMenuEntry getSingleton() { |
65 |
if (singleton == null) |
66 |
singleton = new RasterPropertiesTocMenuEntry();
|
67 |
return singleton;
|
68 |
} |
69 |
|
70 |
/*
|
71 |
* (non-Javadoc)
|
72 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
|
73 |
*/
|
74 |
public String getGroup() { |
75 |
return "RasterLayer"; |
76 |
} |
77 |
|
78 |
/*
|
79 |
* (non-Javadoc)
|
80 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
|
81 |
*/
|
82 |
public int getGroupOrder() { |
83 |
return 60; |
84 |
} |
85 |
|
86 |
/*
|
87 |
* (non-Javadoc)
|
88 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
89 |
*/
|
90 |
public int getOrder() { |
91 |
return 0; |
92 |
} |
93 |
|
94 |
/*
|
95 |
* (non-Javadoc)
|
96 |
* @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
|
97 |
*/
|
98 |
public String getText() { |
99 |
return RasterToolsUtil.getText(this, "propiedades_raster"); |
100 |
} |
101 |
|
102 |
/*
|
103 |
* (non-Javadoc)
|
104 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
105 |
*/
|
106 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
107 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
108 |
return false; |
109 |
if (selectedItems[0] instanceof ILayerState) { |
110 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
111 |
return false; |
112 |
return true; |
113 |
} |
114 |
return false; |
115 |
} |
116 |
|
117 |
/*
|
118 |
* (non-Javadoc)
|
119 |
* @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
120 |
*/
|
121 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
122 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
123 |
return false; |
124 |
if (selectedItems[0] instanceof FLyrRasterSE) |
125 |
return true; |
126 |
return false; |
127 |
} |
128 |
|
129 |
/**
|
130 |
* Gestiona la apertura del dialogo de propiedades de raster cuando se pulsa
|
131 |
* la opci?n asignando a este las propiedades iniciales.
|
132 |
*/
|
133 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
134 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
135 |
return;
|
136 |
|
137 |
lyr = selectedItems[0];
|
138 |
|
139 |
try {
|
140 |
enableEvents = false;
|
141 |
|
142 |
PanelGroupManager manager = PanelGroupManager.getManager(); |
143 |
|
144 |
manager.registerPanelGroup(TabbedPanel.class); |
145 |
manager.setDefaultType(TabbedPanel.class); |
146 |
|
147 |
TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(lyr); |
148 |
PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint("RasterSEPropertiesDialog"); |
149 |
|
150 |
properties = new PanelGroupDialog(lyr.getName() ,RasterToolsUtil.getText(this, "propiedades_raster"), 550, 450, (byte) (WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE), panelGroup); |
151 |
properties.loadPanels(loader); |
152 |
enableEvents = true;
|
153 |
RasterToolsUtil.addWindow(properties); |
154 |
} catch (Exception e) { |
155 |
RasterToolsUtil.messageBoxInfo("error_props_tabs", this, e); |
156 |
} finally {
|
157 |
enableEvents = true;
|
158 |
} |
159 |
} |
160 |
|
161 |
/*
|
162 |
* (non-Javadoc)
|
163 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
164 |
*/
|
165 |
public Icon getIcon() { |
166 |
return RasterToolsUtil.getIcon("properties-icon"); |
167 |
} |
168 |
} |