Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / LayoutEditableControls.java @ 9532

History | View | Annotate | Download (4.88 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 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
import com.iver.andami.ui.mdiManager.IWindow;
56
import com.iver.cit.gvsig.project.documents.layout.LayoutKeyEvent;
57
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
58

    
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 static LayoutKeyEvent lke=new LayoutKeyEvent();
67
        private static KeyStroke copyLayout = KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_MASK);
68
        private static KeyStroke cutLayout = KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.CTRL_MASK);
69
        private static KeyStroke pasteLayout = KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_MASK);
70
        private static KeyStroke leftLayout = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT,0);
71
        private static KeyStroke rightLayout = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT,0);
72
        private static KeyStroke upLayout = KeyStroke.getKeyStroke(KeyEvent.VK_UP,0);
73
        private static KeyStroke downLayout = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN,0);
74
        private static KeyStroke undoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Z, KeyEvent.CTRL_MASK);
75
        private static KeyStroke redoLayout = KeyStroke.getKeyStroke(KeyEvent.VK_Y, KeyEvent.CTRL_MASK);
76
        private static KeyStroke del1Layout = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
77
        private static KeyStroke del2Layout = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0);
78
        /**
79
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
80
         */
81
        public void execute(String s) {
82
                Layout layout = (Layout) PluginServices.getMDIManager().getActiveWindow();
83
                if (s.equals("PROPERTIES")) {
84
                        if (layout.showFProperties()) {
85
                                layout.getModel().setModified(true);
86
                        }
87
                }
88
        }
89
        /**
90
         * @see com.iver.mdiApp.plugins.IExtension#isVisible()
91
         */
92
        public boolean isVisible() {
93
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
94

    
95
                if (f == null) {
96
                        return false;
97
                }
98

    
99
                if (f instanceof Layout) {
100
                        return true;
101
                }
102
                return false;
103
        }
104

    
105
        /**
106
         * @see com.iver.andami.plugins.IExtension#initialize()
107
         */
108
        public void initialize() {
109
                registerKeys();
110
        }
111
        private static void registerKeys() {
112
                PluginServices.registerKeyStroke(copyLayout, lke);
113
                PluginServices.registerKeyStroke(cutLayout, lke);
114
                PluginServices.registerKeyStroke(pasteLayout, lke);
115
                PluginServices.registerKeyStroke(leftLayout, lke);
116
                PluginServices.registerKeyStroke(rightLayout, lke);
117
                PluginServices.registerKeyStroke(upLayout, lke);
118
                PluginServices.registerKeyStroke(downLayout, lke);
119
                PluginServices.registerKeyStroke(undoLayout, lke);
120
                PluginServices.registerKeyStroke(redoLayout, lke);
121
                PluginServices.registerKeyStroke(del1Layout, lke);
122
                PluginServices.registerKeyStroke(del2Layout, lke);
123
        }
124
        private static void unregisterKeys() {
125
                PluginServices.unRegisterKeyStroke(copyLayout);
126
                PluginServices.unRegisterKeyStroke(cutLayout);
127
                PluginServices.unRegisterKeyStroke(pasteLayout);
128
                PluginServices.unRegisterKeyStroke(leftLayout);
129
                PluginServices.unRegisterKeyStroke(rightLayout);
130
                PluginServices.unRegisterKeyStroke(upLayout);
131
                PluginServices.unRegisterKeyStroke(downLayout);
132
                PluginServices.unRegisterKeyStroke(undoLayout);
133
                PluginServices.unRegisterKeyStroke(redoLayout);
134
                PluginServices.unRegisterKeyStroke(del1Layout);
135
                PluginServices.unRegisterKeyStroke(del2Layout);
136
        }
137
        /**
138
         * @see com.iver.andami.plugins.IExtension#isEnabled()
139
         */
140
        public boolean isEnabled() {
141
                return true;
142
        }
143
}