root / trunk / extensions / extCAD / src / com / iver / cit / gvsig / CADExtension.java @ 30638
History | View | Annotate | Download (16 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 | import com.iver.andami.PluginServices; |
||
59 | import com.iver.andami.plugins.Extension; |
||
60 | 11434 | caballero | import com.iver.andami.preferences.IPreference; |
61 | import com.iver.andami.preferences.IPreferenceExtension; |
||
62 | 24530 | vcaballero | import com.iver.andami.ui.mdiManager.IWindow; |
63 | 3712 | caballero | import com.iver.cit.gvsig.fmap.MapControl; |
64 | 4950 | caballero | import com.iver.cit.gvsig.fmap.layers.FLayer; |
65 | import com.iver.cit.gvsig.fmap.layers.FLyrAnnotation; |
||
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 | 8929 | caballero | import com.iver.cit.gvsig.project.documents.view.snapping.Snapping; |
79 | 7674 | caballero | import com.iver.cit.gvsig.project.documents.view.toc.MenuEntry; |
80 | 4892 | caballero | import com.iver.utiles.console.JConsole; |
81 | 3712 | caballero | import com.iver.utiles.console.ResponseListener; |
82 | 5478 | caballero | import com.iver.utiles.console.jedit.JEditTextArea; |
83 | 5115 | caballero | |
84 | 3712 | caballero | /**
|
85 | 5115 | caballero | * Extensi?n dedicada a controlar las diferentes operaciones sobre el editado de
|
86 | * una capa.
|
||
87 | 3712 | caballero | *
|
88 | * @author Vicente Caballero Navarro
|
||
89 | */
|
||
90 | 11434 | caballero | public class CADExtension extends Extension implements IPreferenceExtension{ |
91 | 6174 | caballero | private static HashMap adapters=new HashMap(); |
92 | 4950 | caballero | |
93 | 5115 | caballero | private static View view; |
94 | 4950 | caballero | |
95 | 5115 | caballero | private MapControl mapControl;
|
96 | 6192 | caballero | private static CADToolAdapter adapter=null; |
97 | 11434 | caballero | private EditingPage editingPage=new EditingPage(); |
98 | 4950 | caballero | |
99 | 24530 | vcaballero | 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 | 5115 | caballero | public static CADToolAdapter getCADToolAdapter() { |
116 | 6880 | cesar | com.iver.andami.ui.mdiManager.IWindow view=PluginServices.getMDIManager().getActiveWindow(); |
117 | 6174 | caballero | if (view instanceof View) { |
118 | View v=(View)view; |
||
119 | 7546 | caballero | if (!adapters.containsKey(v.getModel())) {
|
120 | adapters.put(v.getModel(),new CADToolAdapter());
|
||
121 | 6174 | caballero | } |
122 | 7546 | caballero | adapter=(CADToolAdapter)adapters.get(v.getModel()); |
123 | 6192 | caballero | return adapter;
|
124 | 6174 | caballero | } |
125 | 6192 | caballero | return adapter;
|
126 | 6174 | caballero | |
127 | 5115 | caballero | } |
128 | 4950 | caballero | |
129 | 5115 | caballero | /**
|
130 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
131 | */
|
||
132 | public void initialize() { |
||
133 | 5478 | caballero | |
134 | 5793 | fjp | // Registramos los Popup menus:
|
135 | 7674 | caballero | MenuEntry.register(); |
136 | 8929 | caballero | Snapping.register(); |
137 | 5373 | fjp | // Fijamos que los s?mbolos de dibujo tengan outline
|
138 | // 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 | 30100 | jpiera | PluginServices.getIconTheme().registerDefault( |
225 | "cad-selection-icon",
|
||
226 | CADExtension.class.getClassLoader().getResource( |
||
227 | "images/cadselection.png"));
|
||
228 | 15637 | jmvivo | } |
229 | |||
230 | 5115 | caballero | /**
|
231 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
232 | */
|
||
233 | public void execute(String s) { |
||
234 | initFocus(); |
||
235 | |||
236 | if (s.equals("_spline") || s.equals("_copy") |
||
237 | || s.equals("_equidistance") || s.equals("_matriz") |
||
238 | || s.equals("_symmetry") || s.equals("_rotate") |
||
239 | || s.equals("_stretch") || s.equals("_scale") |
||
240 | || s.equals("_extend") || s.equals("_trim") |
||
241 | 5884 | caballero | || s.equals("_unit")
|
242 | 5115 | caballero | || s.equals("_chaflan") || s.equals("_join")) { |
243 | setCADTool(s, true);
|
||
244 | } |
||
245 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
246 | cta.configureMenu(); |
||
247 | 5115 | caballero | } |
248 | |||
249 | public static void addCADTool(String name, CADTool c) { |
||
250 | 6174 | caballero | CADToolAdapter.addCADTool(name, c); |
251 | 3712 | caballero | } |
252 | 5115 | caballero | |
253 | public static void setCADTool(String text, boolean showCommand) { |
||
254 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
255 | CADTool ct=cta.getCADTool(text); |
||
256 | |||
257 | 5115 | caballero | if (ct == null) |
258 | throw new RuntimeException("No such cad tool"); |
||
259 | 6713 | caballero | cta.initializeFlatness(); |
260 | cta.initializeGrid(); |
||
261 | 6174 | caballero | cta.setCadTool(ct); |
262 | 3712 | caballero | ct.init(); |
263 | 5115 | caballero | if (showCommand) {
|
264 | 6880 | cesar | if (PluginServices.getMDIManager().getActiveWindow() instanceof View) { |
265 | View vista = (View) PluginServices.getMDIManager().getActiveWindow(); |
||
266 | 5959 | caballero | vista.getConsolePanel().addText("\n" + ct.getName(),
|
267 | 5115 | caballero | JConsole.COMMAND); |
268 | 6174 | caballero | cta.askQuestion(); |
269 | 5959 | caballero | } |
270 | 4892 | caballero | } |
271 | 5115 | caballero | // PluginServices.getMainFrame().setSelectedTool("SELECT");
|
272 | // PluginServices.getMainFrame().enableControls();
|
||
273 | 3712 | caballero | } |
274 | |||
275 | 5115 | caballero | public static CADTool getCADTool() { |
276 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
277 | return cta.getCadTool();
|
||
278 | 5115 | caballero | } |
279 | |||
280 | /**
|
||
281 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
282 | */
|
||
283 | public boolean isEnabled() { |
||
284 | 5560 | fjp | // initFocus();
|
285 | 5115 | caballero | return true; |
286 | } |
||
287 | |||
288 | /**
|
||
289 | * @see com.iver.andami.plugins.IExtension#isVisible()
|
||
290 | */
|
||
291 | public boolean isVisible() { |
||
292 | if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
|
||
293 | 6880 | cesar | view = (View) PluginServices.getMDIManager().getActiveWindow();
|
294 | 6604 | caballero | mapControl = view.getMapControl(); |
295 | 5115 | caballero | FLayer[] layers = mapControl.getMapContext().getLayers()
|
296 | .getActives(); |
||
297 | if (!(layers[0] instanceof FLyrAnnotation)) { |
||
298 | return true; |
||
299 | 4950 | caballero | } |
300 | 5115 | caballero | } |
301 | 4950 | caballero | return false; |
302 | 5115 | caballero | } |
303 | |||
304 | 3712 | caballero | public MapControl getMapControl() {
|
305 | 6174 | caballero | return getEditionManager().getMapControl();
|
306 | 3712 | caballero | } |
307 | |||
308 | 5115 | caballero | class KeyAction extends AbstractAction { |
309 | |||
310 | 3712 | caballero | private String key; |
311 | |||
312 | 5115 | caballero | public KeyAction(String key) { |
313 | 3712 | caballero | this.key = key;
|
314 | } |
||
315 | |||
316 | 5115 | caballero | /*
|
317 | * (non-Javadoc)
|
||
318 | *
|
||
319 | 3712 | caballero | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
320 | */
|
||
321 | public void actionPerformed(ActionEvent e) { |
||
322 | view.focusConsole(key); |
||
323 | } |
||
324 | |||
325 | } |
||
326 | |||
327 | 5115 | caballero | class MyAction extends AbstractAction { |
328 | 3712 | caballero | private String actionCommand; |
329 | |||
330 | 5115 | caballero | public MyAction(String command) { |
331 | 3712 | caballero | actionCommand = command; |
332 | } |
||
333 | |||
334 | /**
|
||
335 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
|
||
336 | */
|
||
337 | public void actionPerformed(ActionEvent e) { |
||
338 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
339 | cta.keyPressed(actionCommand); |
||
340 | 3712 | caballero | } |
341 | |||
342 | } |
||
343 | 4432 | caballero | |
344 | 4210 | fjp | /**
|
345 | * @author fjp
|
||
346 | *
|
||
347 | 5115 | caballero | * La idea es usar esto para recibir lo que el usuario escribe y enviarlo a
|
348 | * la consola de la vista para que salga por all?.
|
||
349 | 4210 | fjp | */
|
350 | 5115 | caballero | private class myKeyEventPostProcessor implements KeyEventPostProcessor { |
351 | 3712 | caballero | |
352 | 4210 | fjp | public boolean postProcessKeyEvent(KeyEvent e) { |
353 | 4748 | fjp | // System.out.println("KeyEvent e = " + e);
|
354 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
355 | if ((cta == null) || (view == null)) |
||
356 | 5115 | caballero | return false; |
357 | |||
358 | 7832 | jmvivo | if (cta.getMapControl() == null){ |
359 | return false; |
||
360 | } |
||
361 | |||
362 | 5115 | caballero | if (e.getID() != KeyEvent.KEY_RELEASED) |
363 | return false; |
||
364 | if (!(e.getComponent() instanceof JTextComponent)) { |
||
365 | if (e.getKeyCode() == KeyEvent.VK_DELETE) |
||
366 | 6174 | caballero | cta.keyPressed("eliminar");
|
367 | 5115 | caballero | else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) |
368 | 6174 | caballero | cta.keyPressed("escape");
|
369 | 5115 | caballero | else if (e.getKeyCode() == KeyEvent.VK_ENTER) { |
370 | // TODO: REVISAR ESTO CUANDO VIENE UN INTRO DESDE UN
|
||
371 | // JTEXTAREA
|
||
372 | // QUE NO ES EL DE CONSOLA
|
||
373 | 6528 | caballero | if (!(e.getSource() instanceof JTable)) |
374 | view.focusConsole("");
|
||
375 | 5115 | caballero | } |
376 | 12739 | caballero | else if ((!e.isActionKey() && e.getKeyCode()!=KeyEvent.VK_TAB)) { |
377 | 5227 | caballero | //if (Character.isLetterOrDigit(e.getKeyChar())) {
|
378 | 5115 | caballero | Character keyChar = new Character(e.getKeyChar()); |
379 | if (e.getComponent().getName() != null) { |
||
380 | System.out
|
||
381 | .println("Evento de teclado desde el componente "
|
||
382 | + e.getComponent().getName()); |
||
383 | if (!e.getComponent().getName().equals(
|
||
384 | "CADConsole")) {
|
||
385 | view.focusConsole(keyChar + "");
|
||
386 | } |
||
387 | } else {
|
||
388 | if (!(e.getComponent() instanceof JTextComponent)) { |
||
389 | view.focusConsole(keyChar + "");
|
||
390 | } |
||
391 | } |
||
392 | 5227 | caballero | //}
|
393 | 5839 | fjp | } |
394 | 5115 | caballero | } |
395 | 4210 | fjp | return false; |
396 | } |
||
397 | 4432 | caballero | |
398 | 4210 | fjp | } |
399 | |||
400 | 5115 | caballero | /*
|
401 | * private void registerKeyStrokes(){ for (char key = '0'; key <= '9';
|
||
402 | * key++){ 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+"")); } for (char key = 'A'; key <= 'Z'; key++){
|
||
410 | * Character keyChar = new Character(key);
|
||
411 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key),
|
||
412 | * keyChar); mapControl.getActionMap().put(keyChar, new
|
||
413 | * KeyAction(keyChar+"")); }
|
||
414 | * //this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||
415 | * 0), "enter"); //this.getActionMap().put("enter", new MyAction("enter"));
|
||
416 | * Character keyChar = new
|
||
417 | * Character(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0).getKeyChar());
|
||
418 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,
|
||
419 | * 0),keyChar); mapControl.getActionMap().put(keyChar, new KeyAction(""));
|
||
420 | * // El espacio como si fuera INTRO Character keyCharSpace = new
|
||
421 | * Character(' ');
|
||
422 | * mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('
|
||
423 | * '), keyCharSpace); mapControl.getActionMap().put(keyCharSpace, new
|
||
424 | * KeyAction(""));
|
||
425 | *
|
||
426 | * }
|
||
427 | */
|
||
428 | private static JPopupMenu popup = new JPopupMenu(); |
||
429 | 4432 | caballero | |
430 | 5115 | caballero | public static void clearMenu() { |
431 | 3883 | caballero | popup.removeAll(); |
432 | } |
||
433 | |||
434 | 5115 | caballero | public static void addMenuEntry(String text) { |
435 | 3883 | caballero | JMenuItem menu = new JMenuItem(text); |
436 | menu.setActionCommand(text); |
||
437 | menu.setEnabled(true);
|
||
438 | menu.setVisible(true);
|
||
439 | menu.addActionListener(new ActionListener() { |
||
440 | public void actionPerformed(ActionEvent e) { |
||
441 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
442 | cta.transition(e.getActionCommand()); |
||
443 | 3883 | caballero | } |
444 | }); |
||
445 | |||
446 | popup.add(menu); |
||
447 | } |
||
448 | 5115 | caballero | |
449 | 3883 | caballero | public static void showPopup(MouseEvent e) { |
450 | 5115 | caballero | popup.show(e.getComponent(), e.getX(), e.getY()); |
451 | } |
||
452 | |||
453 | 3883 | caballero | public static View getView() { |
454 | return view;
|
||
455 | } |
||
456 | 4147 | fjp | |
457 | 7832 | jmvivo | public static void clearView() { |
458 | view = null;
|
||
459 | } |
||
460 | |||
461 | 4147 | fjp | /**
|
462 | * @return Returns the editionManager.
|
||
463 | */
|
||
464 | public static EditionManager getEditionManager() { |
||
465 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
466 | return cta.getEditionManager();
|
||
467 | 4147 | fjp | } |
468 | 5115 | caballero | |
469 | public static CADTool[] getCADTools() { |
||
470 | 6174 | caballero | return CADToolAdapter.getCADTools();
|
471 | 4892 | caballero | } |
472 | 4899 | caballero | |
473 | 5115 | caballero | public static void initFocus() { |
474 | 6880 | cesar | view = (View) PluginServices.getMDIManager().getActiveWindow();
|
475 | 6604 | caballero | MapControl mapControl = view.getMapControl(); |
476 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
477 | 5164 | caballero | if (!mapControl.getNamesMapTools().containsKey("cadtooladapter")){ |
478 | 5874 | fjp | // StatusBarListener sbl=new StatusBarListener(view.getMapControl());
|
479 | // mapControl.addMapTool("cadtooladapter", new Behavior[]{adapter,new MouseMovementBehavior(sbl)});
|
||
480 | 6174 | caballero | mapControl.addMapTool("cadtooladapter", cta);
|
481 | 5164 | caballero | } |
482 | 5560 | fjp | // view.getMapControl().setTool("cadtooladapter");
|
483 | 5478 | caballero | JEditTextArea jeta=view.getConsolePanel().getTxt(); |
484 | jeta.requestFocusInWindow(); |
||
485 | jeta.setCaretPosition(jeta.getText().length()); |
||
486 | 5257 | caballero | |
487 | 5115 | caballero | view.addConsoleListener("cad", new ResponseListener() { |
488 | public void acceptResponse(String response) { |
||
489 | 6174 | caballero | CADToolAdapter cta=getCADToolAdapter(); |
490 | cta.textEntered(response); |
||
491 | 5115 | caballero | // TODO:
|
492 | // FocusManager fm=FocusManager.getCurrentManager();
|
||
493 | // fm.focusPreviousComponent(mapControl);
|
||
494 | /*
|
||
495 | * if (popup.isShowing()){ popup.setVisible(false); }
|
||
496 | */
|
||
497 | |||
498 | } |
||
499 | }); |
||
500 | 6174 | caballero | cta.getEditionManager().setMapControl(mapControl); |
501 | 5115 | caballero | view.getMapControl().setTool("cadtooladapter");
|
502 | 4899 | caballero | } |
503 | 11434 | caballero | |
504 | public IPreference[] getPreferencesPages() { |
||
505 | IPreference[] preferences=new IPreference[1]; |
||
506 | preferences[0]=editingPage;
|
||
507 | return preferences;
|
||
508 | } |
||
509 | 3712 | caballero | } |