Revision 38764
branches/v2_0_0_prep/extensions/extEditing/config/text.properties | ||
---|---|---|
317 | 317 |
_Enable_snap_to_grid=Activar snapping a la rejilla |
318 | 318 |
_Disable_snap_to_grid=Desactivar snapping a la rejilla |
319 | 319 |
Edit=Editar |
320 |
_Toggle_show_grid=Mostrar-ocultar rejilla |
|
321 |
_Toggle_snapping=Activar-desactivar snapping |
|
322 |
_Toggle_snap_to_grid=Activar-desactivar snapping a la rejilla |
branches/v2_0_0_prep/extensions/extEditing/config/text_en.properties | ||
---|---|---|
314 | 314 |
_Enable_snap_to_grid=Enable snapping to grid |
315 | 315 |
_Disable_snap_to_grid=Disable snapping to grid |
316 | 316 |
Edit=Edit |
317 |
_Toggle_show_grid=Toggle display grid |
|
318 |
_Toggle_snapping=Toggle snapping |
|
319 |
_Toggle_snap_to_grid=Toggle snapping to grid |
branches/v2_0_0_prep/extensions/extEditing/config/config.xml | ||
---|---|---|
54 | 54 |
|
55 | 55 |
<action |
56 | 56 |
name="show-grid-toggle-display-grid" |
57 |
label="_Show_grid"
|
|
58 |
tooltip="_Show_grid"
|
|
57 |
label="_Toggle_show_grid"
|
|
58 |
tooltip="_Toggle_show_grid"
|
|
59 | 59 |
position="000400300100" |
60 | 60 |
action-command="show-grid-toggle-display-grid" |
61 | 61 |
icon="show-grid-toggle-display-grid" |
... | ... | |
63 | 63 |
/> |
64 | 64 |
<menu |
65 | 65 |
name="show-grid-toggle-display-grid" |
66 |
text="Show/Grid/_Show_grid"
|
|
66 |
text="Show/Grid/_Toggle_show_grid"
|
|
67 | 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 |
/> |
|
68 |
|
|
82 | 69 |
</extension> |
83 | 70 |
|
84 | 71 |
<!-- ================== --> |
... | ... | |
88 | 75 |
active="true"> |
89 | 76 |
|
90 | 77 |
<action |
91 |
name="edit-toggle-enable-snapping"
|
|
92 |
label="_Enable_snapping"
|
|
93 |
tooltip="_Enable_snapping"
|
|
78 |
name="edit-toggle-snapping" |
|
79 |
label="_Toggle_snapping"
|
|
80 |
tooltip="_Toggle_snapping"
|
|
94 | 81 |
position="000208000000" |
95 |
action-command="edit-toggle-enable-snapping"
|
|
96 |
icon="edit-toggle-enable-snapping"
|
|
82 |
action-command="edit-toggle-snapping" |
|
83 |
icon="edit-toggle-snapping" |
|
97 | 84 |
accelerator="F3" |
98 | 85 |
/> |
99 | 86 |
<menu |
100 |
name="edit-toggle-enable-snapping"
|
|
101 |
text="Edit/_Enable_snapping"
|
|
87 |
name="edit-toggle-snapping" |
|
88 |
text="Edit/_Toggle_snapping"
|
|
102 | 89 |
/> |
103 | 90 |
|
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="Edit/_Disable_snapping" |
|
116 |
/> |
|
117 | 91 |
</extension> |
118 | 92 |
|
119 | 93 |
<!-- ================== --> |
... | ... | |
123 | 97 |
active="true"> |
124 | 98 |
|
125 | 99 |
<action |
126 |
name="show-grid-toggle-enable-snap-to-grid"
|
|
127 |
label="_Enable_snap_to_grid"
|
|
128 |
tooltip="_Enable_snap_to_grid"
|
|
100 |
name="show-grid-toggle-snap-to-grid" |
|
101 |
label="_Toggle_snap_to_grid"
|
|
102 |
tooltip="_Toggle_snap_to_grid"
|
|
129 | 103 |
position="000400300200" |
130 |
action-command="show-grid-toggle-enable-snap-to-grid"
|
|
131 |
icon="show-grid-toggle-enable-snap-to-grid"
|
|
104 |
action-command="show-grid-toggle-snap-to-grid" |
|
105 |
icon="show-grid-toggle-snap-to-grid" |
|
132 | 106 |
accelerator="F9" |
133 | 107 |
/> |
134 | 108 |
<menu |
135 |
name="show-grid-toggle-enable-snap-to-grid"
|
|
136 |
text="Show/Grid/_Enable_snap_to_grid"
|
|
109 |
name="show-grid-toggle-snap-to-grid" |
|
110 |
text="Show/Grid/_Toggle_snap_to_grid"
|
|
137 | 111 |
/> |
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 |
/> |
|
112 |
|
|
152 | 113 |
</extension> |
153 | 114 |
|
154 | 115 |
<!-- ================== --> |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/EnableSnappingExtension.java | ||
---|---|---|
22 | 22 |
*/ |
23 | 23 |
package org.gvsig.editing.toggle; |
24 | 24 |
|
25 |
import java.util.prefs.Preferences; |
|
26 |
|
|
25 | 27 |
import org.gvsig.andami.PluginServices; |
26 | 28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
29 |
import org.gvsig.app.gui.preferencespage.GridPage; |
|
27 | 30 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
28 | 31 |
import org.gvsig.fmap.mapcontrol.MapControl; |
29 | 32 |
|
... | ... | |
34 | 37 |
*/ |
35 | 38 |
public class EnableSnappingExtension extends AbstractTogglePropertyExtension { |
36 | 39 |
|
37 |
protected void doSetValue(MapControl mc, boolean new_value) { |
|
40 |
|
|
41 |
protected void doToggleValue(MapControl mc) { |
|
38 | 42 |
|
39 |
mc.setRefentEnabled(new_value); |
|
43 |
boolean curr = mc.isRefentEnabled(); |
|
44 |
mc.setRefentEnabled(!curr); |
|
40 | 45 |
// Not clear if this can be saved in prefs: |
41 | 46 |
// Preferences prefs = SnapConfigPage... |
42 | 47 |
// prefs.putBoolean("???", mc.isRefentEnabled()); |
48 |
|
|
43 | 49 |
} |
44 | 50 |
|
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 |
} |
|
51 |
protected String getActionCommand() { |
|
52 |
return "edit-toggle-snapping"; |
|
54 | 53 |
} |
55 | 54 |
|
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 |
} |
|
55 |
|
|
56 |
|
|
57 |
|
|
65 | 58 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/AbstractTogglePropertyExtension.java | ||
---|---|---|
45 | 45 |
public void initialize() { |
46 | 46 |
} |
47 | 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 | 48 |
public void execute(String actionCommand) { |
74 | 49 |
|
75 | 50 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
... | ... | |
77 | 52 |
logger.info("Executing toggle extension when window is not view (?)"); |
78 | 53 |
return; |
79 | 54 |
} |
80 |
|
|
81 |
MapControl mc=((DefaultViewPanel)v).getMapControl(); |
|
82 | 55 |
|
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 |
} |
|
56 |
if (actionCommand.compareTo(getActionCommand()) != 0) { |
|
57 |
logger.info("Executing toggle extension. Unexpected command: " + actionCommand |
|
58 |
+ ". Expected: " + getActionCommand()); |
|
59 |
return; |
|
93 | 60 |
} |
94 |
|
|
95 |
doSetValue(mc, new_value);
|
|
96 |
PluginServices.getMainFrame().enableControls();
|
|
61 |
|
|
62 |
MapControl mc=((DefaultViewPanel)v).getMapControl();
|
|
63 |
doToggleValue(mc);
|
|
97 | 64 |
} |
98 | 65 |
|
99 |
protected abstract void doSetValue(MapControl mc, boolean new_value); |
|
100 | 66 |
|
101 | 67 |
public boolean isEnabled() { |
102 |
return false;
|
|
68 |
return isVisible();
|
|
103 | 69 |
} |
104 | 70 |
|
105 | 71 |
public boolean isVisible() { |
106 |
return false;
|
|
72 |
return optionMustBeAvailable();
|
|
107 | 73 |
} |
108 | 74 |
|
109 | 75 |
// ======================== |
... | ... | |
112 | 78 |
return (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE); |
113 | 79 |
} |
114 | 80 |
|
115 |
protected abstract boolean isToggleActive(); |
|
116 |
|
|
117 |
protected abstract String getActionCommand(boolean on_off); |
|
118 |
|
|
119 |
|
|
81 |
protected abstract String getActionCommand(); |
|
82 |
protected abstract void doToggleValue(MapControl mc); |
|
120 | 83 |
|
121 | 84 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/DisplayGridExtension.java | ||
---|---|---|
37 | 37 |
*/ |
38 | 38 |
public class DisplayGridExtension extends AbstractTogglePropertyExtension { |
39 | 39 |
|
40 |
protected void doSetValue(MapControl mc, boolean new_value) {
|
|
40 |
protected void doToggleValue(MapControl mc) {
|
|
41 | 41 |
|
42 |
mc.setGridVisibility(new_value); |
|
42 |
Boolean curr = mc.getGrid().isShowGrid(); |
|
43 |
mc.setGridVisibility(!curr); |
|
43 | 44 |
Preferences prefs = GridPage.prefs; |
44 | 45 |
prefs.putBoolean("grid.showgrid", mc.getGrid().isShowGrid()); |
45 | 46 |
} |
46 | 47 |
|
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 |
} |
|
48 |
protected String getActionCommand() { |
|
49 |
return "show-grid-toggle-display-grid"; |
|
56 | 50 |
} |
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 | 51 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/EnableSnapToGridExtension.java | ||
---|---|---|
37 | 37 |
*/ |
38 | 38 |
public class EnableSnapToGridExtension extends AbstractTogglePropertyExtension { |
39 | 39 |
|
40 |
protected void doSetValue(MapControl mc, boolean new_value) { |
|
40 |
|
|
41 |
protected void doToggleValue(MapControl mc) { |
|
41 | 42 |
|
42 |
mc.setAdjustGrid(new_value); |
|
43 |
boolean curr = mc.getGrid().isAdjustGrid(); |
|
44 |
mc.setAdjustGrid(!curr); |
|
43 | 45 |
Preferences prefs = GridPage.prefs; |
44 | 46 |
prefs.putBoolean("grid.adjustgrid", mc.getGrid().isAdjustGrid()); |
47 |
|
|
45 | 48 |
} |
46 | 49 |
|
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 |
} |
|
50 |
protected String getActionCommand() { |
|
51 |
return "show-grid-toggle-snap-to-grid"; |
|
56 | 52 |
} |
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 | 53 |
|
68 |
|
|
69 |
|
|
70 |
|
|
71 | 54 |
} |
Also available in: Unified diff