svn-gvsig-desktop / tags / v1_0_RELEASE / applications / appgvSIG / src / com / iver / cit / gvsig / TagExtension.java @ 9167
History | View | Annotate | Download (4.3 KB)
1 | 1418 | vcaballero | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2004 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 | * For more information, contact:
|
||
20 | *
|
||
21 | * Generalitat Valenciana
|
||
22 | * Conselleria d'Infraestructures i Transport
|
||
23 | * Av. Blasco Ib??ez, 50
|
||
24 | * 46010 VALENCIA
|
||
25 | * SPAIN
|
||
26 | *
|
||
27 | * +34 963862235
|
||
28 | * gvsig@gva.es
|
||
29 | * www.gvsig.gva.es
|
||
30 | *
|
||
31 | * or
|
||
32 | *
|
||
33 | * IVER T.I. S.A
|
||
34 | * Salamanca 50
|
||
35 | * 46005 Valencia
|
||
36 | * Spain
|
||
37 | *
|
||
38 | * +34 963163400
|
||
39 | * dac@iver.es
|
||
40 | */
|
||
41 | package com.iver.cit.gvsig; |
||
42 | |||
43 | 3041 | fjp | import javax.swing.JOptionPane; |
44 | |||
45 | 1418 | vcaballero | import org.apache.log4j.Logger; |
46 | |||
47 | import com.iver.andami.PluginServices; |
||
48 | import com.iver.andami.plugins.Extension; |
||
49 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
50 | 1418 | vcaballero | import com.iver.cit.gvsig.gui.layout.Layout; |
51 | 3041 | fjp | import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
52 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
53 | 1418 | vcaballero | |
54 | |||
55 | 5005 | jorpiell | public class TagExtension extends Extension{ |
56 | 1418 | vcaballero | private static Logger logger = Logger.getLogger(TagExtension.class.getName()); |
57 | private Layout layout = null; |
||
58 | /**
|
||
59 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#initialize()
|
60 | 1418 | vcaballero | */
|
61 | 5005 | jorpiell | public void initialize() { |
62 | 1418 | vcaballero | } |
63 | |||
64 | /**
|
||
65 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
66 | 1418 | vcaballero | */
|
67 | public void execute(String s) { |
||
68 | 6880 | cesar | layout = (Layout) PluginServices.getMDIManager().getActiveWindow(); |
69 | 1418 | vcaballero | |
70 | 3041 | fjp | /* FLayoutZooms zooms = new FLayoutZooms(layout);
|
71 | 1418 | vcaballero | logger.debug("Comand : " + s);
|
72 | if (s.compareTo("SET_TAG") == 0) {
|
||
73 | layout.setTool(Layout.SET_TAG);
|
||
74 | 3041 | fjp | } */
|
75 | |||
76 | // FJP: Cambio: abrimos la ventana de tag para
|
||
77 | // asignar el tag a los elementos seleccionados
|
||
78 | if (s.equals("SET_TAG")) |
||
79 | { |
||
80 | IFFrame[] selectedFrames = layout.getFFrameSelected();
|
||
81 | if (selectedFrames.length > 0) |
||
82 | { |
||
83 | String defaultStr = ""; |
||
84 | if (selectedFrames.length == 1) |
||
85 | defaultStr = selectedFrames[0].getTag();
|
||
86 | String theTag = JOptionPane.showInputDialog(null, "Introduzca el tag:", defaultStr); |
||
87 | for (int i=0; i< selectedFrames.length; i++) |
||
88 | selectedFrames[i].setTag(theTag); |
||
89 | } |
||
90 | } |
||
91 | else if (s.equals("VIEW_TAGS")) |
||
92 | { |
||
93 | 3550 | caballero | IFFrame[] frames = layout.getFFrames();
|
94 | for (int i=0; i< frames.length; i++) |
||
95 | 3041 | fjp | { |
96 | 3550 | caballero | IFFrame f = (IFFrame) frames[i]; |
97 | 3041 | fjp | if (f instanceof FFrameText) |
98 | { |
||
99 | FFrameText txt = (FFrameText) f; |
||
100 | 3042 | fjp | if (f.getTag() != null) |
101 | { |
||
102 | txt.clearText(); |
||
103 | txt.addText(f.getTag()); |
||
104 | } |
||
105 | 3041 | fjp | } |
106 | } |
||
107 | 3043 | fjp | layout.setModeDebug(true);
|
108 | 3041 | fjp | layout.refresh(); |
109 | } |
||
110 | 1418 | vcaballero | } |
111 | |||
112 | /**
|
||
113 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
114 | 1418 | vcaballero | */
|
115 | public boolean isEnabled() { |
||
116 | 6880 | cesar | IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
117 | 3041 | fjp | |
118 | if (f == null) { |
||
119 | return false; |
||
120 | } |
||
121 | |||
122 | if (f.getClass() == Layout.class)
|
||
123 | { |
||
124 | layout = (Layout) f; |
||
125 | IFFrame[] selectedFrames = layout.getFFrameSelected();
|
||
126 | if (selectedFrames == null) return false; |
||
127 | return (selectedFrames.length > 0); |
||
128 | } |
||
129 | return false; |
||
130 | 1418 | vcaballero | } |
131 | |||
132 | /**
|
||
133 | 5005 | jorpiell | * @see com.iver.andami.plugins.IExtension#isVisible()
|
134 | 1418 | vcaballero | */
|
135 | public boolean isVisible() { |
||
136 | 6880 | cesar | IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
137 | 1418 | vcaballero | |
138 | if (f == null) { |
||
139 | return false; |
||
140 | } |
||
141 | |||
142 | 5900 | jorpiell | if (f instanceof Layout) { |
143 | 1418 | vcaballero | Layout layout = (Layout) f; |
144 | |||
145 | return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
||
146 | } else {
|
||
147 | return false; |
||
148 | } |
||
149 | } |
||
150 | |||
151 | } |