root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / extension / LayoutEditableControls.java @ 31496
History | View | Annotate | Download (4.91 KB)
1 |
/*
|
---|---|
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 org.gvsig.app.extension; |
48 |
|
49 |
import java.awt.event.KeyEvent; |
50 |
|
51 |
import javax.swing.KeyStroke; |
52 |
|
53 |
import org.gvsig.andami.PluginServices; |
54 |
import org.gvsig.andami.plugins.Extension; |
55 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
56 |
import org.gvsig.app.project.documents.layout.LayoutKeyEvent; |
57 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
58 |
|
59 |
|
60 |
|
61 |
/**
|
62 |
* Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout.
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
*/
|
66 |
public class LayoutEditableControls extends Extension { |
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 org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
81 |
*/
|
82 |
public void execute(String s) { |
83 |
LayoutPanel layout = (LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
84 |
if (s.equals("PROPERTIES")) { |
85 |
if (layout.showFProperties()) {
|
86 |
layout.getModel().setModified(true);
|
87 |
} |
88 |
} |
89 |
} |
90 |
/**
|
91 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
92 |
*/
|
93 |
public boolean isVisible() { |
94 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
95 |
|
96 |
if (f == null) { |
97 |
return false; |
98 |
} |
99 |
|
100 |
if (f instanceof LayoutPanel) { |
101 |
return true; |
102 |
} |
103 |
return false; |
104 |
} |
105 |
|
106 |
/**
|
107 |
* @see org.gvsig.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 org.gvsig.andami.plugins.IExtension#isEnabled()
|
140 |
*/
|
141 |
public boolean isEnabled() { |
142 |
return true; |
143 |
} |
144 |
} |