Revision 38707

View differences:

branches/v2_0_0_prep/extensions/extEditing/config/text.properties
309 309
_Drawing_error=Error en el dibujado
310 310
_Split_line_must_start_and_end_outside_bbox=La l?nea de corte debe empezar y terminar fuera del rect?ngulo que contiene a la geometr?a
311 311
_Invalid_values_in_some_fields_must_be_edited_before_end_editing=Hay valores no v?lidos en algunos campos. Deben editarse antes de cerrar la edici?n
312
_Show=Mostrar
313
_Show_grid=Mostrar la rejilla
314
_Hide_grid=Ocultar la rejilla
315
_Enable_snapping=Activar snapping
316
_Disable_snapping=Desactivar snapping
317
_Enable_snap_to_grid=Activar snapping a la rejilla
318
_Disable_snap_to_grid=Desactivar snapping a la rejilla
branches/v2_0_0_prep/extensions/extEditing/config/text_en.properties
306 306
_Drawing_error=Drawing error
307 307
_Split_line_must_start_and_end_outside_bbox=Split line must start and end outside the geometry's bounding box
308 308
_Invalid_values_in_some_fields_must_be_edited_before_end_editing=Invalid values in some fields must be edited before closing editing session
309

  
310

  
309
_Show=Show
310
_Show_grid=Show grid
311
_Hide_grid=Hide grid
312
_Enable_snapping=Enable snapping
313
_Disable_snapping=Disable snapping
314
_Enable_snap_to_grid=Enable snapping to grid
315
_Disable_snap_to_grid=Disable snapping to grid
branches/v2_0_0_prep/extensions/extEditing/config/config.xml
45 45
                />
46 46
		</extension>	
47 47
		
48
        <!-- ================== -->
49
        <!-- ================== -->
48 50
		
51
		<extension class-name="org.gvsig.editing.toggle.DisplayGridExtension"
52
			description="Extensi?n encargada de mostrar/ocultar la rejilla de edici?n."
53
			active="true">
49 54

  
55
            <action 
56
                name="show-grid-toggle-display-grid"
57
                label="_Show_grid" 
58
                tooltip="_Show_grid" 
59
                position="000400300100" 
60
                action-command="show-grid-toggle-display-grid"
61
                icon="show-grid-toggle-display-grid"
62
                accelerator="F7"
63
                />
64
            <menu
65
                name="show-grid-toggle-display-grid" 
66
                text="Show/Grid/_Show_grid"
67
                />
68
                
69
            <action 
70
                name="show-grid-toggle-hide-grid"
71
                label="_Hide_grid" 
72
                tooltip="_Hide_grid" 
73
                position="000400300100" 
74
                action-command="show-grid-toggle-hide-grid"
75
                icon="show-grid-toggle-hide-grid"
76
                accelerator="F7"
77
                />
78
            <menu
79
                name="show-grid-toggle-hide-grid" 
80
                text="Show/Grid/_Hide_grid"
81
                />
82
		</extension>
83
		
84
        <!-- ================== -->
85
		
86
		<extension class-name="org.gvsig.editing.toggle.EnableSnappingExtension"
87
			description="Extensi?n encargada de activar/desactivar el snapping de edici?n."
88
			active="true">
89

  
90
            <action 
91
                name="edit-toggle-enable-snapping"
92
                label="_Enable_snapping" 
93
                tooltip="_Enable_snapping" 
94
                position="000208000000" 
95
                action-command="edit-toggle-enable-snapping"
96
                icon="edit-toggle-enable-snapping"
97
                accelerator="F3"
98
                />
99
            <menu
100
                name="edit-toggle-enable-snapping" 
101
                text="Edition/_Enable_snapping"
102
                />
103
                
104
            <action 
105
                name="edit-toggle-disable-snapping"
106
                label="_Disable_snapping" 
107
                tooltip="_Disable_snapping" 
108
                position="000208000000" 
109
                action-command="edit-toggle-disable-snapping"
110
                icon="edit-toggle-disable-snapping"
111
                accelerator="F3"
112
                />
113
            <menu
114
                name="edit-toggle-disable-snapping" 
115
                text="Edition/_Disable_snapping"
116
                />
117
		</extension>
118
		
119
        <!-- ================== -->
120
		
121
		<extension class-name="org.gvsig.editing.toggle.EnableSnapToGridExtension"
122
			description="Extensi?n encargada de activar/desactivar el snapping a la rejilla de edici?n."
123
			active="true">
124

  
125
            <action 
126
                name="show-grid-toggle-enable-snap-to-grid"
127
                label="_Enable_snap_to_grid" 
128
                tooltip="_Enable_snap_to_grid" 
129
                position="000400300200" 
130
                action-command="show-grid-toggle-enable-snap-to-grid"
131
                icon="show-grid-toggle-enable-snap-to-grid"
132
                accelerator="F9"
133
                />
134
            <menu
135
                name="show-grid-toggle-enable-snap-to-grid" 
136
                text="Show/Grid/_Enable_snap_to_grid"
137
                />
138
                
139
            <action 
140
                name="show-grid-toggle-disable-snap-to-grid"
141
                label="_Disable_snap_to_grid" 
142
                tooltip="_Disable_snap_to_grid" 
143
                position="000400300200" 
144
                action-command="show-grid-toggle-disable-snap-to-grid"
145
                icon="show-grid-toggle-disable-snap-to-grid"
146
                accelerator="F9"
147
                />
148
            <menu
149
                name="show-grid-toggle-disable-snap-to-grid" 
150
                text="Show/Grid/_Disable_snap_to_grid"
151
                />
152
		</extension>
153

  
154
        <!-- ================== -->
155
        <!-- ================== -->
156

  
50 157
		<extension class-name="org.gvsig.editing.UndoViewExtension"
51 158
			description="Extensi?n encargada de dehacer la edici?n sobre la capa activa."
52 159
			active="true" >
......
63 170
            
64 171
            <menu
65 172
                name="edit-undo-layer" 
66
                text="Edit/Undo"
173
                text="Edition/Undo"
67 174
                />
68 175
                
69 176
            <tool-bar name="edit_tools">
......
90 197
            
91 198
            <menu
92 199
                name="edit-redo-layer" 
93
                text="Edit/Redo"
200
                text="Edition/Redo"
94 201
                />
95 202
                
96 203
            <tool-bar name="edit_tools">
......
115 222
            
116 223
            <menu
117 224
                name="edit-undo-redo-actions-layer" 
118
                text="Edit/Undo_redo_actions"
225
                text="Edition/Undo_redo_actions"
119 226
                />
120 227
                
121 228
            <tool-bar name="edit_tools">
......
142 249
            
143 250
            <menu
144 251
                name="edit-undo-redo-actions-table" 
145
                text="Edit/Undo_redo_actions"
252
                text="Edition/Undo_redo_actions"
146 253
                />
147 254
                
148 255
            <tool-bar name="edit_tools">
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/EnableSnappingExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.editing.toggle;
24

  
25
import org.gvsig.andami.PluginServices;
26
import org.gvsig.andami.ui.mdiManager.IWindow;
27
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
28
import org.gvsig.fmap.mapcontrol.MapControl;
29

  
30

  
31
/**
32
 * @author jldominguez
33
 *
34
 */
35
public class EnableSnappingExtension extends AbstractTogglePropertyExtension {
36

  
37
    protected void doSetValue(MapControl mc, boolean new_value) {
38
        
39
        mc.setRefentEnabled(new_value);
40
        // Not clear if this can be saved in prefs:
41
        // Preferences prefs = SnapConfigPage...
42
        // prefs.putBoolean("???", mc.isRefentEnabled());
43
    }
44
    
45
    protected boolean isToggleActive() {
46
        
47
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
48
        if (v instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel) {
49
            MapControl mc = ((DefaultViewPanel)v).getMapControl();
50
            return mc.isRefentEnabled();
51
        } else {
52
            return false;
53
        }
54
    }
55
    
56
    protected String getActionCommand(boolean on_off) {
57
        
58
        if (on_off) {
59
            return "edit-toggle-enable-snapping";
60
        } else {
61
            return "edit-toggle-disable-snapping";
62
        }
63
        
64
    }
65
}
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/AbstractTogglePropertyExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.editing.toggle;
24

  
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
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.view.gui.DefaultViewPanel;
32
import org.gvsig.editing.EditionUtilities;
33
import org.gvsig.fmap.mapcontrol.MapControl;
34

  
35

  
36
/**
37
 * @author jldominguez
38
 *
39
 */
40
public abstract class AbstractTogglePropertyExtension extends Extension {
41

  
42
    private static Logger logger =
43
        LoggerFactory.getLogger(AbstractTogglePropertyExtension.class);
44
    
45
    public void initialize() {
46
    }
47

  
48
    public boolean canQueryByAction() {
49
        return true;
50
    }
51
    
52
    public boolean isEnabled(String action) {
53
        return optionMustBeAvailable();
54
    }
55
    
56
    public boolean isVisible(String action) {
57
        
58
        if (!optionMustBeAvailable()) {
59
            return false;
60
        }
61
        
62
        boolean curr_value = isToggleActive();
63
        if (curr_value) {
64
            // now it is ON. The one that switches OFF Will be available
65
            return (action.compareTo(getActionCommand(false)) == 0);
66
        } else {
67
            // now it is OFF. The one that switches ON Will be available
68
            return (action.compareTo(getActionCommand(true)) == 0);
69
        }
70
        
71
    }
72
    
73
    public void execute(String actionCommand) {
74
        
75
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
76
        if (!(v instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel)) {
77
            logger.info("Executing toggle extension when window is not view (?)");
78
            return;
79
        }
80
            
81
        MapControl mc=((DefaultViewPanel)v).getMapControl();
82
        
83
        boolean new_value = false;
84
        if (actionCommand.compareTo(getActionCommand(true)) == 0) {
85
            new_value = true;
86
        } else {
87
            if (actionCommand.compareTo(getActionCommand(false)) == 0) {
88
                new_value = false;
89
            } else {
90
                logger.info("Executing toggle extension. Unexpected command: " + actionCommand);
91
                return;
92
            }
93
        }
94
        
95
        doSetValue(mc, new_value);
96
        PluginServices.getMainFrame().enableControls();
97
    }
98

  
99
    protected abstract void doSetValue(MapControl mc, boolean new_value);
100

  
101
    public boolean isEnabled() {
102
        return false;
103
    }
104

  
105
    public boolean isVisible() {
106
        return false;
107
    }
108
    
109
    // ========================
110
    
111
    protected boolean optionMustBeAvailable() {
112
        return (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE);
113
    }
114
    
115
    protected abstract boolean isToggleActive();
116
    
117
    protected abstract String getActionCommand(boolean on_off);
118
    
119
    
120

  
121
}
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/DisplayGridExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.editing.toggle;
24

  
25
import java.util.prefs.Preferences;
26

  
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.gui.preferencespage.GridPage;
30
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
31
import org.gvsig.fmap.mapcontrol.MapControl;
32

  
33

  
34
/**
35
 * @author jldominguez
36
 *
37
 */
38
public class DisplayGridExtension extends AbstractTogglePropertyExtension {
39

  
40
    protected void doSetValue(MapControl mc, boolean new_value) {
41
        
42
        mc.setGridVisibility(new_value);
43
        Preferences prefs = GridPage.prefs;
44
        prefs.putBoolean("grid.showgrid", mc.getGrid().isShowGrid());
45
    }
46
    
47
    protected boolean isToggleActive() {
48
        
49
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
50
        if (v instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel) {
51
            MapControl mc = ((DefaultViewPanel)v).getMapControl();
52
            return mc.getGrid().isShowGrid();
53
        } else {
54
            return false;
55
        }
56
    }
57
    
58
    protected String getActionCommand(boolean on_off) {
59
        
60
        if (on_off) {
61
            return "show-grid-toggle-display-grid";
62
        } else {
63
            return "show-grid-toggle-hide-grid";
64
        }
65
        
66
    }
67
}
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/EnableSnapToGridExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2012 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.editing.toggle;
24

  
25
import java.util.prefs.Preferences;
26

  
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.ui.mdiManager.IWindow;
29
import org.gvsig.app.gui.preferencespage.GridPage;
30
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
31
import org.gvsig.fmap.mapcontrol.MapControl;
32

  
33

  
34
/**
35
 * @author jldominguez
36
 *
37
 */
38
public class EnableSnapToGridExtension extends AbstractTogglePropertyExtension {
39
    
40
    protected void doSetValue(MapControl mc, boolean new_value) {
41
        
42
        mc.setAdjustGrid(new_value);
43
        Preferences prefs = GridPage.prefs;
44
        prefs.putBoolean("grid.adjustgrid", mc.getGrid().isAdjustGrid());
45
    }
46
    
47
    protected boolean isToggleActive() {
48
        
49
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
50
        if (v instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel) {
51
            MapControl mc = ((DefaultViewPanel)v).getMapControl();
52
            return mc.getGrid().isAdjustGrid();
53
        } else {
54
            return false;
55
        }
56
    }
57
    
58
    protected String getActionCommand(boolean on_off) {
59
        
60
        if (on_off) {
61
            return "show-grid-toggle-enable-snap-to-grid";
62
        } else {
63
            return "show-grid-toggle-disable-snap-to-grid";
64
        }
65
        
66
    }
67

  
68

  
69

  
70

  
71
}
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/CADExtension.java
154 154
		addCADTool("_rotate", rotate);
155 155
		addCADTool("_scale", scale);
156 156
		addCADTool("_symmetry", symmetry);
157
	// Registramos las teclas de acceso r?pido que vamos a usar.
158

  
159
		KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0);
160
		RefentAccelerator accRef = new RefentAccelerator();
161
		PluginServices.registerKeyStroke(key, accRef);
162

  
163
		key = KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0);
164
		OrtoAccelerator accOrto = new OrtoAccelerator();
165
		PluginServices.registerKeyStroke(key, accOrto);
166

  
167
		key = KeyStroke.getKeyStroke(KeyEvent.VK_F7, 0);
168
		GridAccelerator accGrid = new GridAccelerator();
169
		PluginServices.registerKeyStroke(key, accGrid);
170

  
171
		key = KeyStroke.getKeyStroke(KeyEvent.VK_F9, 0);
172
		ForceCursorAccelerator accForce = new ForceCursorAccelerator();
173
		PluginServices.registerKeyStroke(key, accForce);
174

  
175

  
157
		
176 158
		KeyboardFocusManager kfm = KeyboardFocusManager
177 159
				.getCurrentKeyboardFocusManager();
178 160
		kfm.addKeyEventPostProcessor(new myKeyEventPostProcessor());

Also available in: Unified diff