gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.app / org.gvsig.raster.app.common / src / main / java / org / gvsig / raster / mainplugin / properties / RasterPropertiesTocMenuEntry.java @ 2861
History | View | Annotate | Download (4.7 KB)
1 | 2861 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | package org.gvsig.raster.mainplugin.properties; |
||
23 | |||
24 | import javax.swing.Icon; |
||
25 | |||
26 | import org.gvsig.andami.ui.mdiManager.WindowInfo; |
||
27 | import org.gvsig.app.panelGroup.PanelGroupDialog; |
||
28 | import org.gvsig.app.panelGroup.loaders.PanelGroupLoaderFromExtensionPoint; |
||
29 | import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
||
30 | import org.gvsig.app.project.documents.view.toc.ITocItem; |
||
31 | import org.gvsig.fmap.IconThemeHelper; |
||
32 | import org.gvsig.fmap.mapcontext.layers.FLayer; |
||
33 | import org.gvsig.gui.beans.panelGroup.PanelGroupManager; |
||
34 | import org.gvsig.gui.beans.panelGroup.tabbedPanel.TabbedPanel; |
||
35 | import org.gvsig.i18n.Messages; |
||
36 | import org.gvsig.raster.fmap.layers.FLyrRaster; |
||
37 | import org.gvsig.raster.fmap.layers.ILayerState; |
||
38 | import org.gvsig.raster.mainplugin.RasterMainPluginUtils; |
||
39 | import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
||
40 | import org.gvsig.raster.swing.RasterSwingLibrary; |
||
41 | |||
42 | /**
|
||
43 | * Entrada en del men? contextual del TOC correspondiente al cuadro de
|
||
44 | * propiedades del raster
|
||
45 | *
|
||
46 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
47 | */
|
||
48 | public class RasterPropertiesTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
||
49 | static private RasterPropertiesTocMenuEntry singleton = null; |
||
50 | private FLayer lyr = null; |
||
51 | |||
52 | /**
|
||
53 | * Variable para controlar si los eventos de los paneles se deben interpretar.
|
||
54 | * En la carga inicial se deben desactivar todos los eventos
|
||
55 | */
|
||
56 | public static boolean enableEvents = false; |
||
57 | |||
58 | /**
|
||
59 | * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
||
60 | * getSingleton()
|
||
61 | */
|
||
62 | private RasterPropertiesTocMenuEntry() {}
|
||
63 | |||
64 | /**
|
||
65 | * Devuelve un objeto unico a dicha clase
|
||
66 | * @return
|
||
67 | */
|
||
68 | static public RasterPropertiesTocMenuEntry getSingleton() { |
||
69 | if (singleton == null) |
||
70 | singleton = new RasterPropertiesTocMenuEntry();
|
||
71 | return singleton;
|
||
72 | } |
||
73 | |||
74 | public String getGroup() { |
||
75 | return "RasterLayer"; |
||
76 | } |
||
77 | |||
78 | public int getGroupOrder() { |
||
79 | return 10; |
||
80 | } |
||
81 | |||
82 | public int getOrder() { |
||
83 | return 10; |
||
84 | } |
||
85 | |||
86 | public String getText() { |
||
87 | return Messages.getText("propiedades_raster"); |
||
88 | } |
||
89 | |||
90 | public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
||
91 | if ((selectedItems == null) || (selectedItems.length != 1)) |
||
92 | return false; |
||
93 | if (selectedItems[0] instanceof ILayerState) { |
||
94 | if (!((ILayerState) selectedItems[0]).isOpen()) |
||
95 | return false; |
||
96 | return true; |
||
97 | } |
||
98 | return false; |
||
99 | } |
||
100 | |||
101 | public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
||
102 | if ((selectedItems == null) || (selectedItems.length != 1)) |
||
103 | return false; |
||
104 | if (selectedItems[0] instanceof FLyrRaster) |
||
105 | return true; |
||
106 | return false; |
||
107 | } |
||
108 | |||
109 | /**
|
||
110 | * Gestiona la apertura del dialogo de propiedades de raster cuando se pulsa
|
||
111 | * la opci?n asignando a este las propiedades iniciales.
|
||
112 | */
|
||
113 | public void execute(ITocItem item, FLayer[] selectedItems) { |
||
114 | if ((selectedItems == null) || (selectedItems.length != 1)) |
||
115 | return;
|
||
116 | |||
117 | lyr = selectedItems[0];
|
||
118 | PanelGroupDialog properties = null;
|
||
119 | try {
|
||
120 | enableEvents = false;
|
||
121 | |||
122 | PanelGroupManager manager = PanelGroupManager.getManager(); |
||
123 | |||
124 | manager.registerPanelGroup(TabbedPanel.class); |
||
125 | manager.setDefaultType(TabbedPanel.class); |
||
126 | |||
127 | TabbedPanel panelGroup = (TabbedPanel) manager.getPanelGroup(lyr); |
||
128 | PanelGroupLoaderFromExtensionPoint loader = new PanelGroupLoaderFromExtensionPoint("RasterSEPropertiesDialog"); |
||
129 | |||
130 | properties = new PanelGroupDialog(lyr.getName() ,Messages.getText("propiedades_raster"), 550, 450, (byte) (WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE), panelGroup); |
||
131 | properties.loadPanels(loader); |
||
132 | enableEvents = true;
|
||
133 | RasterMainPluginUtils.addWindow(properties); |
||
134 | } catch (Exception e) { |
||
135 | RasterSwingLibrary.messageBoxInfo("error_props_tabs", properties, e);
|
||
136 | } finally {
|
||
137 | enableEvents = true;
|
||
138 | } |
||
139 | } |
||
140 | |||
141 | public Icon getIcon() { |
||
142 | return IconThemeHelper.getImageIcon("layer-properties-raster"); |
||
143 | } |
||
144 | } |