svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / toggle / AbstractTogglePropertyExtension.java @ 40557
History | View | Annotate | Download (2.83 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.editing.toggle; |
25 |
|
26 |
import org.slf4j.Logger; |
27 |
import org.slf4j.LoggerFactory; |
28 |
|
29 |
import org.gvsig.andami.IconThemeHelper; |
30 |
import org.gvsig.andami.PluginServices; |
31 |
import org.gvsig.andami.plugins.Extension; |
32 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
33 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
34 |
import org.gvsig.editing.EditionUtilities; |
35 |
import org.gvsig.fmap.mapcontrol.MapControl; |
36 |
|
37 |
|
38 |
/**
|
39 |
* @author jldominguez
|
40 |
*
|
41 |
*/
|
42 |
public abstract class AbstractTogglePropertyExtension extends Extension { |
43 |
|
44 |
private static Logger logger = |
45 |
LoggerFactory.getLogger(AbstractTogglePropertyExtension.class); |
46 |
|
47 |
public void initialize() { |
48 |
} |
49 |
|
50 |
public void execute(String actionCommand) { |
51 |
|
52 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
53 |
if (!(v instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel)) { |
54 |
logger.info("Executing toggle extension when window is not view (?)");
|
55 |
return;
|
56 |
} |
57 |
|
58 |
if (actionCommand.compareTo(getActionCommand()) != 0) { |
59 |
logger.info("Executing toggle extension. Unexpected command: " + actionCommand
|
60 |
+ ". Expected: " + getActionCommand());
|
61 |
return;
|
62 |
} |
63 |
|
64 |
MapControl mc=((DefaultViewPanel)v).getMapControl(); |
65 |
doToggleValue(mc); |
66 |
} |
67 |
|
68 |
|
69 |
public boolean isEnabled() { |
70 |
return isVisible();
|
71 |
} |
72 |
|
73 |
public boolean isVisible() { |
74 |
return optionMustBeAvailable();
|
75 |
} |
76 |
|
77 |
// ========================
|
78 |
|
79 |
protected boolean optionMustBeAvailable() { |
80 |
return (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE);
|
81 |
} |
82 |
|
83 |
protected abstract String getActionCommand(); |
84 |
protected abstract void doToggleValue(MapControl mc); |
85 |
|
86 |
} |