svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / CADExtension.java @ 25779
History | View | Annotate | Download (15.7 KB)
1 | 3712 | caballero | /* 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 | 4210 | fjp | import java.awt.KeyEventPostProcessor; |
44 | import java.awt.KeyboardFocusManager; |
||
45 | 3712 | caballero | import java.awt.event.ActionEvent; |
46 | 3883 | caballero | import java.awt.event.ActionListener; |
47 | 3712 | caballero | import java.awt.event.KeyEvent; |
48 | 3883 | caballero | import java.awt.event.MouseEvent; |
49 | 3712 | caballero | import java.util.HashMap; |
50 | |||
51 | import javax.swing.AbstractAction; |
||
52 | 3883 | caballero | import javax.swing.JMenuItem; |
53 | import javax.swing.JPopupMenu; |
||
54 | 6528 | caballero | import javax.swing.JTable; |
55 | 5817 | fjp | import javax.swing.KeyStroke; |
56 | 4815 | fjp | import javax.swing.text.JTextComponent; |
57 | 3712 | caballero | |
58 | 21666 | vcaballero | import org.gvsig.fmap.mapcontext.layers.FLayer; |
59 | import org.gvsig.fmap.mapcontrol.MapControl; |
||
60 | |||
61 | 3712 | caballero | import com.iver.andami.PluginServices; |
62 | import com.iver.andami.plugins.Extension; |
||
63 | 11434 | caballero | import com.iver.andami.preferences.IPreference; |
64 | import com.iver.andami.preferences.IPreferenceExtension; |
||
65 | 24538 | vcaballero | import com.iver.andami.ui.mdiManager.IWindow; |
66 | 5845 | fjp | import com.iver.cit.gvsig.gui.accelerators.ForceCursorAccelerator; |
67 | import com.iver.cit.gvsig.gui.accelerators.GridAccelerator; |
||
68 | import com.iver.cit.gvsig.gui.accelerators.OrtoAccelerator; |
||
69 | import com.iver.cit.gvsig.gui.accelerators.RefentAccelerator; |
||
70 | 3712 | caballero | import com.iver.cit.gvsig.gui.cad.CADTool; |
71 | import com.iver.cit.gvsig.gui.cad.CADToolAdapter; |
||
72 | 3883 | caballero | import com.iver.cit.gvsig.gui.cad.tools.CopyCADTool; |
73 | import com.iver.cit.gvsig.gui.cad.tools.RotateCADTool; |
||
74 | import com.iver.cit.gvsig.gui.cad.tools.ScaleCADTool; |
||
75 | 5884 | caballero | import com.iver.cit.gvsig.gui.cad.tools.SymmetryCADTool; |
76 | 11434 | caballero | import com.iver.cit.gvsig.gui.preferences.EditingPage; |
77 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.view.gui.View; |
78 | 7674 | caballero | import com.iver.cit.gvsig.project.documents.view.toc.MenuEntry; |
79 | 4892 | caballero | import com.iver.utiles.console.JConsole; |
80 | 3712 | caballero | import com.iver.utiles.console.ResponseListener; |
81 | 5478 | caballero | import com.iver.utiles.console.jedit.JEditTextArea; |
82 | 5115 | caballero | |
83 | 3712 | caballero | /**
|
84 | 5115 | caballero | * Extensi?n dedicada a controlar las diferentes operaciones sobre el editado de
|
85 | * una capa.
|
||
86 | 3712 | caballero | *
|
87 | * @author Vicente Caballero Navarro
|
||
88 | */
|
||
89 | 11434 | caballero | public class CADExtension extends Extension implements IPreferenceExtension{ |
90 | 6174 | caballero | private static HashMap adapters=new HashMap(); |
91 | 4950 | caballero | |
92 | 5115 | caballero | private static View view; |
93 | 4950 | caballero | |
94 | 5115 | caballero | private MapControl mapControl;
|
95 | 6192 | caballero | private static CADToolAdapter adapter=null; |
96 | 11434 | caballero | private EditingPage editingPage=new EditingPage(); |
97 | 4950 | caballero | |
98 | 24538 | vcaballero | |
99 | public static CADToolAdapter getCADToolAdapter(FLayer layer) { |
||
100 | IWindow[] windows=PluginServices.getMDIManager().getAllWindows();
|
||
101 | for (int i = 0; i < windows.length; i++) { |
||
102 | IWindow window=windows[i]; |
||
103 | if (window instanceof View){ |
||
104 | View v=(View)window; |
||
105 | if (v.getModel().getMapContext().equals(layer.getMapContext())){
|
||
106 | if (!adapters.containsKey(v.getModel())) {
|
||
107 | adapters.put(v.getModel(),new CADToolAdapter());
|
||
108 | } |
||
109 | return (CADToolAdapter)adapters.get(v.getModel());
|
||
110 | } |
||
111 | } |
||
112 | } |
||
113 | return null; |
||
114 | } |
||
115 | |||
116 | 5115 | caballero | public static CADToolAdapter getCADToolAdapter() { |
117 | 6880 | cesar | com.iver.andami.ui.mdiManager.IWindow view=PluginServices.getMDIManager().getActiveWindow(); |
118 | 6174 | caballero | if (view instanceof View) { |
119 | View v=(View)view; |
||
120 | 7546 | caballero | if (!adapters.containsKey(v.getModel())) {
|
121 | adapters.put(v.getModel(),new CADToolAdapter());
|
||
122 | 6174 | caballero | } |
123 | 7546 | caballero | adapter=(CADToolAdapter)adapters.get(v.getModel()); |
124 | 6192 | caballero | return adapter;
|
125 | 6174 | caballero | } |
126 | 6192 | caballero | return adapter;
|
127 | 6174 | caballero | |
128 | 5115 | caballero | } |
129 | 4950 | caballero | |
130 | 5115 | caballero | /**
|
131 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
132 | */
|
||
133 | public void initialize() { |
||
134 | 5478 | caballero | |
135 | 5793 | fjp | // Registramos los Popup menus:
|
136 | 7674 | caballero | MenuEntry.register(); |
137 | 23646 | vcaballero | // Fijamos que los s?mbolos de dibujo tengan outline
|
138 | 5373 | fjp | // TODO: Esto se debe configurar en el cuadro de di?logo de preferencias
|
139 | 10828 | jaume | // jaume, this should be unnecessary
|
140 | // CADTool.drawingSymbol.setOutlined(true);
|
||
141 | // CADTool.drawingSymbol.setOutlineColor(CADTool.drawingSymbol.getColor().darker());
|
||
142 | // CADTool.modifySymbol.setOutlined(true);
|
||
143 | // CADTool.modifySymbol.setOutlineColor(CADTool.modifySymbol.getColor().darker());
|
||
144 | // CADTool.selectSymbol.setOutlined(true);
|
||
145 | // CADTool.selectSymbol.setOutlineColor(CADTool.selectSymbol.getColor().darker());
|
||
146 | 3712 | caballero | |
147 | 5478 | caballero | |
148 | 5115 | caballero | CopyCADTool copy = new CopyCADTool();
|
149 | RotateCADTool rotate = new RotateCADTool();
|
||
150 | ScaleCADTool scale = new ScaleCADTool();
|
||
151 | 5884 | caballero | SymmetryCADTool symmetry=new SymmetryCADTool();
|
152 | 5115 | caballero | addCADTool("_copy", copy);
|
153 | addCADTool("_rotate", rotate);
|
||
154 | addCADTool("_scale", scale);
|
||
155 | 5884 | caballero | addCADTool("_symmetry", symmetry);
|
156 | // Registramos las teclas de acceso r?pido que vamos a usar.
|
||
157 | 5959 | caballero | |
158 | 5845 | fjp | KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0); |
159 | 5959 | caballero | RefentAccelerator accRef = new RefentAccelerator();
|
160 | 5845 | fjp | PluginServices.registerKeyStroke(key, accRef); |
161 | 5115 | caballero | |
162 | 5845 | fjp | key = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0); |
163 | 5959 | caballero | OrtoAccelerator accOrto = new OrtoAccelerator();
|
164 | 5845 | fjp | PluginServices.registerKeyStroke(key, accOrto); |
165 | |||
166 | key = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0); |
||
167 | 5959 | caballero | GridAccelerator accGrid = new GridAccelerator();
|
168 | 5845 | fjp | PluginServices.registerKeyStroke(key, accGrid); |
169 | |||
170 | key = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0); |
||
171 | 5959 | caballero | ForceCursorAccelerator accForce = new ForceCursorAccelerator();
|
172 | 5845 | fjp | PluginServices.registerKeyStroke(key, accForce); |
173 | 5959 | caballero | |
174 | |||
175 | 5115 | caballero | KeyboardFocusManager kfm = KeyboardFocusManager |
176 | .getCurrentKeyboardFocusManager(); |
||
177 | kfm.addKeyEventPostProcessor(new myKeyEventPostProcessor());
|
||
178 | 15637 | jmvivo | |
179 | 14810 | jmvivo | registerIcons(); |
180 | 5115 | caballero | } |
181 | |||
182 | 14810 | jmvivo | private void registerIcons(){ |
183 | 15637 | jmvivo | PluginServices.getIconTheme().registerDefault( |
184 | 14810 | jmvivo | "edition-geometry-copy",
|
185 | this.getClass().getClassLoader().getResource("images/Copy.png") |
||
186 | ); |
||
187 | 15637 | jmvivo | |
188 | PluginServices.getIconTheme().registerDefault( |
||
189 | 14810 | jmvivo | "edition-geometry-symmetry",
|
190 | this.getClass().getClassLoader().getResource("images/Symmetry.png") |
||
191 | ); |
||
192 | 15637 | jmvivo | |
193 | PluginServices.getIconTheme().registerDefault( |
||
194 | 14810 | jmvivo | "edition-geometry-rotate",
|
195 | this.getClass().getClassLoader().getResource("images/Rotation.png") |
||
196 | ); |
||
197 | 15637 | jmvivo | |
198 | PluginServices.getIconTheme().registerDefault( |
||
199 | 14810 | jmvivo | "edition-geometry-scale",
|
200 | 15954 | vcaballero | this.getClass().getClassLoader()
|
201 | .getResource("images/Scale.png"));
|
||
202 | 15637 | jmvivo | |
203 | 15954 | vcaballero | PluginServices.getIconTheme().registerDefault( |
204 | "edition-properties",
|
||
205 | CADExtension.class.getClassLoader().getResource( |
||
206 | "images/EditingProperties.png"));
|
||
207 | 15637 | jmvivo | |
208 | 15954 | vcaballero | PluginServices.getIconTheme().registerDefault( |
209 | "field-expresion",
|
||
210 | CADExtension.class.getClassLoader().getResource( |
||
211 | "images/FieldExpresion.png"));
|
||
212 | PluginServices.getIconTheme().registerDefault( |
||
213 | "flatness-icon",
|
||
214 | CADExtension.class.getClassLoader().getResource( |
||
215 | "images/Flatness.png"));
|
||
216 | PluginServices.getIconTheme().registerDefault( |
||
217 | "grid-icon",
|
||
218 | CADExtension.class.getClassLoader().getResource( |
||
219 | "images/Grid.png"));
|
||
220 | PluginServices.getIconTheme().registerDefault( |
||
221 | "snapper-icon",
|
||
222 | CADExtension.class.getClassLoader().getResource( |
||
223 | "images/Snapper.png"));
|
||
224 | 15637 | jmvivo | } |
225 | |||
226 | 5115 | caballero | /**
|
227 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
228 | */
|
||
229 | public void execute(String s) { |
||
230 | initFocus(); |
||
231 | |||
232 | if (s.equals("_spline") || s.equals("_copy") |
||
233 | || s.equals("_equidistance") || s.equals("_matriz") |
||
234 | || s.equals("_symmetry") || s.equals("_rotate") |
||
235 | || s.equals("_stretch") || s.equals("_scale") |
||
236 | || s.equals("_extend") || s.equals("_trim") |
||
237 | 5884 | caballero | || s.equals("_unit")
|
238 | 5115 | caballero | || s.equals("_chaflan") || s.equals("_join")) { |
239 | setCADTool(s, true);
|
||
240 | } |
||
241 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
242 | cta.configureMenu(); |
||
243 | 5115 | caballero | } |
244 | |||
245 | public static void addCADTool(String name, CADTool c) { |
||
246 | 6174 | caballero | CADToolAdapter.addCADTool(name, c); |
247 | 3712 | caballero | } |
248 | 5115 | caballero | |
249 | public static void setCADTool(String text, boolean showCommand) { |
||
250 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
251 | CADTool ct=cta.getCADTool(text); |
||
252 | |||
253 | 5115 | caballero | if (ct == null) |
254 | throw new RuntimeException("No such cad tool"); |
||
255 | 6713 | caballero | cta.initializeFlatness(); |
256 | 6174 | caballero | cta.setCadTool(ct); |
257 | 3712 | caballero | ct.init(); |
258 | 5115 | caballero | if (showCommand) {
|
259 | 6880 | cesar | if (PluginServices.getMDIManager().getActiveWindow() instanceof View) { |
260 | View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
||
261 | 5959 | caballero | vista.getConsolePanel().addText("\n" + ct.getName(),
|
262 | 5115 | caballero | JConsole.COMMAND); |
263 | 6174 | caballero | cta.askQuestion(); |
264 | 5959 | caballero | } |
265 | 4892 | caballero | } |
266 | 5115 | caballero | // PluginServices.getMainFrame().setSelectedTool("SELECT");
|
267 | // PluginServices.getMainFrame().enableControls();
|
||
268 | 3712 | caballero | } |
269 | |||
270 | 5115 | caballero | public static CADTool getCADTool() { |
271 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
272 | return cta.getCadTool();
|
||
273 | 5115 | caballero | } |
274 | |||
275 | /**
|
||
276 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
277 | */
|
||
278 | public boolean isEnabled() { |
||
279 | 5560 | fjp | // initFocus();
|
280 | 5115 | caballero | return true; |
281 | } |
||
282 | |||
283 | /**
|
||
284 | * @see com.iver.andami.plugins.IExtension#isVisible()
|
||
285 | */
|
||
286 | public boolean isVisible() { |
||
287 | if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
|
||
288 | 6880 | cesar | view = (View) PluginServices.getMDIManager().getActiveWindow();
|
289 | 6604 | caballero | mapControl = view.getMapControl(); |
290 | 5115 | caballero | FLayer[] layers = mapControl.getMapContext().getLayers()
|
291 | .getActives(); |
||
292 | 21666 | vcaballero | // if (!(layers[0] instanceof FLyrAnnotation)) {
|
293 | // return true;
|
||
294 | // }
|
||
295 | 23086 | vcaballero | return true; |
296 | 5115 | caballero | } |
297 | 23086 | vcaballero | return false; |
298 | 5115 | caballero | } |
299 | |||
300 | 3712 | caballero | public MapControl getMapControl() {
|
301 | 6174 | caballero | return getEditionManager().getMapControl();
|
302 | 3712 | caballero | } |
303 | |||
304 | 5115 | caballero | class KeyAction extends AbstractAction { |
305 | |||
306 | 3712 | caballero | private String key; |
307 | |||
308 | 5115 | caballero | public KeyAction(String key) { |
309 | 3712 | caballero | this.key = key;
|
310 | } |
||
311 | |||
312 | 5115 | caballero | /*
|
313 | * (non-Javadoc)
|
||
314 | *
|
||
315 | 3712 | caballero | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
316 | */
|
||
317 | public void actionPerformed(ActionEvent e) { |
||
318 | view.focusConsole(key); |
||
319 | } |
||
320 | |||
321 | } |
||
322 | |||
323 | 5115 | caballero | class MyAction extends AbstractAction { |
324 | 3712 | caballero | private String actionCommand; |
325 | |||
326 | 5115 | caballero | public MyAction(String command) { |
327 | 3712 | caballero | actionCommand = command; |
328 | } |
||
329 | |||
330 | /**
|
||
331 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
332 | */
|
||
333 | public void actionPerformed(ActionEvent e) { |
||
334 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
335 | cta.keyPressed(actionCommand); |
||
336 | 3712 | caballero | } |
337 | |||
338 | } |
||
339 | 4432 | caballero | |
340 | 4210 | fjp | /**
|
341 | * @author fjp
|
||
342 | *
|
||
343 | 5115 | caballero | * La idea es usar esto para recibir lo que el usuario escribe y enviarlo a
|
344 | * la consola de la vista para que salga por all?.
|
||
345 | 4210 | fjp | */
|
346 | 5115 | caballero | private class myKeyEventPostProcessor implements KeyEventPostProcessor { |
347 | 3712 | caballero | |
348 | 4210 | fjp | public boolean postProcessKeyEvent(KeyEvent e) { |
349 | 4748 | fjp | // System.out.println("KeyEvent e = " + e);
|
350 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
351 | if ((cta == null) || (view == null)) |
||
352 | 5115 | caballero | return false; |
353 | |||
354 | 7832 | jmvivo | if (cta.getMapControl() == null){ |
355 | return false; |
||
356 | } |
||
357 | |||
358 | 5115 | caballero | if (e.getID() != KeyEvent.KEY_RELEASED) |
359 | return false; |
||
360 | if (!(e.getComponent() instanceof JTextComponent)) { |
||
361 | if (e.getKeyCode() == KeyEvent.VK_DELETE) |
||
362 | 6174 | caballero | cta.keyPressed("eliminar");
|
363 | 5115 | caballero | else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) |
364 | 6174 | caballero | cta.keyPressed("escape");
|
365 | 5115 | caballero | else if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
366 | // TODO: REVISAR ESTO CUANDO VIENE UN INTRO DESDE UN
|
||
367 | // JTEXTAREA
|
||
368 | // QUE NO ES EL DE CONSOLA
|
||
369 | 6528 | caballero | if (!(e.getSource() instanceof JTable)) |
370 | view.focusConsole("");
|
||
371 | 5115 | caballero | } |
372 | 12739 | caballero | else if ((!e.isActionKey() && e.getKeyCode()!=KeyEvent.VK_TAB)) { |
373 | 5227 | caballero | //if (Character.isLetterOrDigit(e.getKeyChar())) {
|
374 | 5115 | caballero | Character keyChar = new Character(e.getKeyChar()); |
375 | if (e.getComponent().getName() != null) { |
||
376 | System.out
|
||
377 | .println("Evento de teclado desde el componente "
|
||
378 | + e.getComponent().getName()); |
||
379 | if (!e.getComponent().getName().equals(
|
||
380 | "CADConsole")) {
|
||
381 | view.focusConsole(keyChar + "");
|
||
382 | } |
||
383 | } else {
|
||
384 | if (!(e.getComponent() instanceof JTextComponent)) { |
||
385 | view.focusConsole(keyChar + "");
|
||
386 | } |
||
387 | } |
||
388 | 5227 | caballero | //}
|
389 | 5839 | fjp | } |
390 | 5115 | caballero | } |
391 | 4210 | fjp | return false; |
392 | } |
||
393 | 4432 | caballero | |
394 | 4210 | fjp | } |
395 | |||
396 | 5115 | caballero | /*
|
397 | * private void registerKeyStrokes(){ for (char key = '0'; key <= '9';
|
||
398 | * key++){ Character keyChar = new Character(key);
|
||
399 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key),
|
||
400 | * keyChar); mapControl.getActionMap().put(keyChar, new
|
||
401 | * KeyAction(keyChar+"")); } for (char key = 'a'; key <= 'z'; key++){
|
||
402 | * Character keyChar = new Character(key);
|
||
403 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key),
|
||
404 | * keyChar); mapControl.getActionMap().put(keyChar, new
|
||
405 | * KeyAction(keyChar+"")); } for (char key = 'A'; key <= 'Z'; key++){
|
||
406 | * Character keyChar = new Character(key);
|
||
407 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key),
|
||
408 | * keyChar); mapControl.getActionMap().put(keyChar, new
|
||
409 | * KeyAction(keyChar+"")); }
|
||
410 | * //this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||
411 | * 0), "enter"); //this.getActionMap().put("enter", new MyAction("enter"));
|
||
412 | * Character keyChar = new
|
||
413 | * Character(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0).getKeyChar());
|
||
414 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||
415 | * 0),keyChar); mapControl.getActionMap().put(keyChar, new KeyAction(""));
|
||
416 | * // El espacio como si fuera INTRO Character keyCharSpace = new
|
||
417 | * Character(' ');
|
||
418 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('
|
||
419 | * '), keyCharSpace); mapControl.getActionMap().put(keyCharSpace, new
|
||
420 | * KeyAction(""));
|
||
421 | *
|
||
422 | * }
|
||
423 | */
|
||
424 | private static JPopupMenu popup = new JPopupMenu(); |
||
425 | 4432 | caballero | |
426 | 5115 | caballero | public static void clearMenu() { |
427 | 3883 | caballero | popup.removeAll(); |
428 | } |
||
429 | |||
430 | 5115 | caballero | public static void addMenuEntry(String text) { |
431 | 3883 | caballero | JMenuItem menu = new JMenuItem(text); |
432 | menu.setActionCommand(text); |
||
433 | menu.setEnabled(true);
|
||
434 | menu.setVisible(true);
|
||
435 | menu.addActionListener(new ActionListener() { |
||
436 | public void actionPerformed(ActionEvent e) { |
||
437 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
438 | cta.transition(e.getActionCommand()); |
||
439 | 3883 | caballero | } |
440 | }); |
||
441 | |||
442 | popup.add(menu); |
||
443 | } |
||
444 | 5115 | caballero | |
445 | 3883 | caballero | public static void showPopup(MouseEvent e) { |
446 | 5115 | caballero | popup.show(e.getComponent(), e.getX(), e.getY()); |
447 | } |
||
448 | |||
449 | 3883 | caballero | public static View getView() { |
450 | return view;
|
||
451 | } |
||
452 | 4147 | fjp | |
453 | 7832 | jmvivo | public static void clearView() { |
454 | view = null;
|
||
455 | } |
||
456 | |||
457 | 4147 | fjp | /**
|
458 | * @return Returns the editionManager.
|
||
459 | */
|
||
460 | public static EditionManager getEditionManager() { |
||
461 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
462 | return cta.getEditionManager();
|
||
463 | 4147 | fjp | } |
464 | 5115 | caballero | |
465 | public static CADTool[] getCADTools() { |
||
466 | 6174 | caballero | return CADToolAdapter.getCADTools();
|
467 | 4892 | caballero | } |
468 | 4899 | caballero | |
469 | 5115 | caballero | public static void initFocus() { |
470 | 6880 | cesar | view = (View) PluginServices.getMDIManager().getActiveWindow();
|
471 | 6604 | caballero | MapControl mapControl = view.getMapControl(); |
472 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
473 | 5164 | caballero | if (!mapControl.getNamesMapTools().containsKey("cadtooladapter")){ |
474 | 5874 | fjp | // StatusBarListener sbl=new StatusBarListener(view.getMapControl());
|
475 | // mapControl.addMapTool("cadtooladapter", new Behavior[]{adapter,new MouseMovementBehavior(sbl)});
|
||
476 | 6174 | caballero | mapControl.addMapTool("cadtooladapter", cta);
|
477 | 5164 | caballero | } |
478 | 5560 | fjp | // view.getMapControl().setTool("cadtooladapter");
|
479 | 5478 | caballero | JEditTextArea jeta=view.getConsolePanel().getTxt(); |
480 | jeta.requestFocusInWindow(); |
||
481 | jeta.setCaretPosition(jeta.getText().length()); |
||
482 | 5257 | caballero | |
483 | 5115 | caballero | view.addConsoleListener("cad", new ResponseListener() { |
484 | public void acceptResponse(String response) { |
||
485 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
486 | cta.textEntered(response); |
||
487 | 5115 | caballero | // TODO:
|
488 | // FocusManager fm=FocusManager.getCurrentManager();
|
||
489 | // fm.focusPreviousComponent(mapControl);
|
||
490 | /*
|
||
491 | * if (popup.isShowing()){ popup.setVisible(false); }
|
||
492 | */
|
||
493 | |||
494 | } |
||
495 | }); |
||
496 | 6174 | caballero | cta.getEditionManager().setMapControl(mapControl); |
497 | 5115 | caballero | view.getMapControl().setTool("cadtooladapter");
|
498 | 4899 | caballero | } |
499 | 11434 | caballero | |
500 | public IPreference[] getPreferencesPages() { |
||
501 | IPreference[] preferences=new IPreference[1]; |
||
502 | preferences[0]=editingPage;
|
||
503 | return preferences;
|
||
504 | } |
||
505 | 3712 | caballero | } |