svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / extension / LayoutEditableControls.java @ 46
History | View | Annotate | Download (4.91 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.extension; |
23 |
|
24 |
import java.awt.event.KeyEvent; |
25 |
|
26 |
import javax.swing.KeyStroke; |
27 |
|
28 |
import org.gvsig.andami.PluginServices; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.project.documents.layout.LayoutKeyEvent; |
32 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
33 |
|
34 |
/**
|
35 |
* Extensi?n para controlar las operaciones basicas de edici?n sobre el Layout.
|
36 |
*
|
37 |
* @author Vicente Caballero Navarro
|
38 |
*/
|
39 |
public class LayoutEditableControls extends Extension { |
40 |
|
41 |
private static LayoutKeyEvent lke = new LayoutKeyEvent(); |
42 |
private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C, |
43 |
KeyEvent.CTRL_MASK);
|
44 |
private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X, |
45 |
KeyEvent.CTRL_MASK);
|
46 |
private static KeyStroke pasteLayout = KeyStroke.getKeyStroke( |
47 |
KeyEvent.VK_V, KeyEvent.CTRL_MASK); |
48 |
private static KeyStroke leftLayout = KeyStroke.getKeyStroke( |
49 |
KeyEvent.VK_LEFT, 0); |
50 |
private static KeyStroke rightLayout = KeyStroke.getKeyStroke( |
51 |
KeyEvent.VK_RIGHT, 0); |
52 |
private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP, |
53 |
0);
|
54 |
private static KeyStroke downLayout = KeyStroke.getKeyStroke( |
55 |
KeyEvent.VK_DOWN, 0); |
56 |
private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z, |
57 |
KeyEvent.CTRL_MASK);
|
58 |
private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y, |
59 |
KeyEvent.CTRL_MASK);
|
60 |
private static KeyStroke del1Layout = KeyStroke.getKeyStroke( |
61 |
KeyEvent.VK_DELETE, 0); |
62 |
private static KeyStroke del2Layout = KeyStroke.getKeyStroke( |
63 |
KeyEvent.VK_BACK_SPACE, 0); |
64 |
|
65 |
/**
|
66 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
67 |
*/
|
68 |
public void execute(String s) { |
69 |
LayoutPanel layout = |
70 |
(LayoutPanel) PluginServices.getMDIManager().getActiveWindow(); |
71 |
if (s.equals("layout-properties")) { |
72 |
if (layout.showFProperties()) {
|
73 |
layout.getDocument().setModified(true);
|
74 |
} |
75 |
} |
76 |
} |
77 |
|
78 |
/**
|
79 |
* @see com.iver.mdiApp.plugins.IExtension#isVisible()
|
80 |
*/
|
81 |
public boolean isVisible() { |
82 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
83 |
|
84 |
if (f == null) { |
85 |
return false; |
86 |
} |
87 |
|
88 |
if (f instanceof LayoutPanel) { |
89 |
return true; |
90 |
} |
91 |
return false; |
92 |
} |
93 |
|
94 |
/**
|
95 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
96 |
*/
|
97 |
public void initialize() { |
98 |
registerKeys(); |
99 |
} |
100 |
|
101 |
private static void registerKeys() { |
102 |
PluginServices.registerKeyStroke(copyLayout, lke); |
103 |
PluginServices.registerKeyStroke(cutLayout, lke); |
104 |
PluginServices.registerKeyStroke(pasteLayout, lke); |
105 |
PluginServices.registerKeyStroke(leftLayout, lke); |
106 |
PluginServices.registerKeyStroke(rightLayout, lke); |
107 |
PluginServices.registerKeyStroke(upLayout, lke); |
108 |
PluginServices.registerKeyStroke(downLayout, lke); |
109 |
PluginServices.registerKeyStroke(undoLayout, lke); |
110 |
PluginServices.registerKeyStroke(redoLayout, lke); |
111 |
PluginServices.registerKeyStroke(del1Layout, lke); |
112 |
PluginServices.registerKeyStroke(del2Layout, lke); |
113 |
} |
114 |
|
115 |
// private static void unregisterKeys() {
|
116 |
// PluginServices.unRegisterKeyStroke(copyLayout);
|
117 |
// PluginServices.unRegisterKeyStroke(cutLayout);
|
118 |
// PluginServices.unRegisterKeyStroke(pasteLayout);
|
119 |
// PluginServices.unRegisterKeyStroke(leftLayout);
|
120 |
// PluginServices.unRegisterKeyStroke(rightLayout);
|
121 |
// PluginServices.unRegisterKeyStroke(upLayout);
|
122 |
// PluginServices.unRegisterKeyStroke(downLayout);
|
123 |
// PluginServices.unRegisterKeyStroke(undoLayout);
|
124 |
// PluginServices.unRegisterKeyStroke(redoLayout);
|
125 |
// PluginServices.unRegisterKeyStroke(del1Layout);
|
126 |
// PluginServices.unRegisterKeyStroke(del2Layout);
|
127 |
// }
|
128 |
|
129 |
/**
|
130 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
131 |
*/
|
132 |
public boolean isEnabled() { |
133 |
return true; |
134 |
} |
135 |
} |