root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutEditableControls.java @ 9212
History | View | Annotate | Download (5.19 KB)
1 | 6393 | caballero | /*
|
---|---|---|---|
2 | * Created on 05-may-2004
|
||
3 | *
|
||
4 | * To change the template for this generated file go to
|
||
5 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
6 | */
|
||
7 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
8 | *
|
||
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | *
|
||
25 | * For more information, contact:
|
||
26 | *
|
||
27 | * Generalitat Valenciana
|
||
28 | * Conselleria d'Infraestructures i Transport
|
||
29 | * Av. Blasco Ib??ez, 50
|
||
30 | * 46010 VALENCIA
|
||
31 | * SPAIN
|
||
32 | *
|
||
33 | * +34 963862235
|
||
34 | * gvsig@gva.es
|
||
35 | * www.gvsig.gva.es
|
||
36 | *
|
||
37 | * or
|
||
38 | *
|
||
39 | * IVER T.I. S.A
|
||
40 | * Salamanca 50
|
||
41 | * 46005 Valencia
|
||
42 | * Spain
|
||
43 | *
|
||
44 | * +34 963163400
|
||
45 | * dac@iver.es
|
||
46 | */
|
||
47 | package com.iver.cit.gvsig; |
||
48 | |||
49 | import java.awt.event.KeyEvent; |
||
50 | |||
51 | import javax.swing.KeyStroke; |
||
52 | |||
53 | import com.iver.andami.PluginServices; |
||
54 | import com.iver.andami.plugins.Extension; |
||
55 | 6877 | cesar | import com.iver.andami.ui.mdiManager.IWindow; |
56 | 6393 | caballero | import com.iver.cit.gvsig.gui.layout.Layout; |
57 | 7304 | caballero | import com.iver.cit.gvsig.project.documents.layout.LayoutKeyEvent; |
58 | 6393 | caballero | |
59 | |||
60 | /**
|
||
61 | * Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout.
|
||
62 | *
|
||
63 | * @author Vicente Caballero Navarro
|
||
64 | */
|
||
65 | public class LayoutEditableControls extends Extension { |
||
66 | private Layout layout = null; |
||
67 | private static LayoutKeyEvent lke=new LayoutKeyEvent(); |
||
68 | private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK); |
||
69 | private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK); |
||
70 | private static KeyStroke pasteLayout = KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK); |
||
71 | private static KeyStroke leftLayout = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,0); |
||
72 | private static KeyStroke rightLayout = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0); |
||
73 | private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP,0); |
||
74 | private static KeyStroke downLayout = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0); |
||
75 | private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK); |
||
76 | private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK); |
||
77 | private static KeyStroke del1Layout = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); |
||
78 | private static KeyStroke del2Layout = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0); |
||
79 | /**
|
||
80 | * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
||
81 | */
|
||
82 | public void execute(String s) { |
||
83 | 6880 | cesar | layout = (Layout) PluginServices.getMDIManager().getActiveWindow(); |
84 | 6393 | caballero | if (s.equals("PROPERTIES")) { |
85 | layout.showFProperties(); |
||
86 | } |
||
87 | } |
||
88 | /**
|
||
89 | * @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
||
90 | */
|
||
91 | public boolean isVisible() { |
||
92 | 6880 | cesar | IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
93 | 6393 | caballero | |
94 | if (f == null) { |
||
95 | return false; |
||
96 | } |
||
97 | |||
98 | if (f instanceof Layout) { |
||
99 | // Layout layout = (Layout) f;
|
||
100 | |||
101 | return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
||
102 | } |
||
103 | 7083 | caballero | return false; |
104 | 6393 | caballero | } |
105 | |||
106 | /**
|
||
107 | * @see com.iver.andami.plugins.IExtension#initialize()
|
||
108 | */
|
||
109 | public void initialize() { |
||
110 | registerKeys(); |
||
111 | } |
||
112 | private static void registerKeys() { |
||
113 | PluginServices.registerKeyStroke(copyLayout, lke); |
||
114 | PluginServices.registerKeyStroke(cutLayout, lke); |
||
115 | PluginServices.registerKeyStroke(pasteLayout, lke); |
||
116 | PluginServices.registerKeyStroke(leftLayout, lke); |
||
117 | PluginServices.registerKeyStroke(rightLayout, lke); |
||
118 | PluginServices.registerKeyStroke(upLayout, lke); |
||
119 | PluginServices.registerKeyStroke(downLayout, lke); |
||
120 | PluginServices.registerKeyStroke(undoLayout, lke); |
||
121 | PluginServices.registerKeyStroke(redoLayout, lke); |
||
122 | PluginServices.registerKeyStroke(del1Layout, lke); |
||
123 | PluginServices.registerKeyStroke(del2Layout, lke); |
||
124 | } |
||
125 | private static void unregisterKeys() { |
||
126 | PluginServices.unRegisterKeyStroke(copyLayout); |
||
127 | PluginServices.unRegisterKeyStroke(cutLayout); |
||
128 | PluginServices.unRegisterKeyStroke(pasteLayout); |
||
129 | PluginServices.unRegisterKeyStroke(leftLayout); |
||
130 | PluginServices.unRegisterKeyStroke(rightLayout); |
||
131 | PluginServices.unRegisterKeyStroke(upLayout); |
||
132 | PluginServices.unRegisterKeyStroke(downLayout); |
||
133 | PluginServices.unRegisterKeyStroke(undoLayout); |
||
134 | PluginServices.unRegisterKeyStroke(redoLayout); |
||
135 | PluginServices.unRegisterKeyStroke(del1Layout); |
||
136 | PluginServices.unRegisterKeyStroke(del2Layout); |
||
137 | } |
||
138 | /**
|
||
139 | * @see com.iver.andami.plugins.IExtension#isEnabled()
|
||
140 | */
|
||
141 | public boolean isEnabled() { |
||
142 | 6880 | cesar | layout = (Layout) PluginServices.getMDIManager().getActiveWindow(); |
143 | 6393 | caballero | if (layout.isEditable())
|
144 | return true; |
||
145 | return false; |
||
146 | } |
||
147 | |||
148 | /**
|
||
149 | * Devuelve el Layout sobre el que se opera.
|
||
150 | *
|
||
151 | * @return Layout.
|
||
152 | */
|
||
153 | public Layout getLayout() {
|
||
154 | return layout;
|
||
155 | } |
||
156 | } |