Revision 38764 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/toggle/EnableSnappingExtension.java
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 |
} |
Also available in: Unified diff