Revision 41264 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/MeasureExtension.java
MeasureExtension.java | ||
---|---|---|
29 | 29 |
import org.gvsig.app.project.documents.view.ViewDocument; |
30 | 30 |
import org.gvsig.app.project.documents.view.gui.IView; |
31 | 31 |
import org.gvsig.fmap.mapcontext.MapContext; |
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
33 | 32 |
import org.gvsig.fmap.mapcontrol.MapControl; |
34 | 33 |
|
35 | 34 |
/** |
... | ... | |
70 | 69 |
public void execute(String s) { |
71 | 70 |
ApplicationManager application = ApplicationLocator.getManager(); |
72 | 71 |
|
73 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
74 |
if (document == null) {
|
|
72 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
73 |
if (view == null) {
|
|
75 | 74 |
return; |
76 | 75 |
} |
77 |
IView view = (IView) document.getMainComponent(); |
|
78 | 76 |
MapControl mapCtrl = view.getMapControl(); |
79 | 77 |
|
80 | 78 |
if (s.equals("view-query-distance")) { |
... | ... | |
87 | 85 |
public boolean isEnabled() { |
88 | 86 |
ApplicationManager application = ApplicationLocator.getManager(); |
89 | 87 |
|
90 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
91 |
if (document == null) {
|
|
88 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
89 |
if (view == null) {
|
|
92 | 90 |
return false; |
93 | 91 |
} |
94 |
MapContext mapa = document.getMapContext(); |
|
95 |
FLayer[] layers = mapa.getLayers().getActives(); |
|
96 |
for (int i = 0; i < layers.length; i++) { |
|
97 |
if (layers[i].isAvailable()) { |
|
98 |
return true; |
|
99 |
} |
|
100 |
} |
|
101 |
return false; |
|
92 |
ViewDocument document = view.getViewDocument(); |
|
93 |
return document.getMapContext().hasActiveVectorLayers(); |
|
102 | 94 |
} |
103 | 95 |
|
104 | 96 |
public boolean isVisible() { |
105 | 97 |
ApplicationManager application = ApplicationLocator.getManager(); |
106 | 98 |
|
107 |
ViewDocument document = (ViewDocument) application.getActiveDocument(ViewDocument.class);
|
|
108 |
if (document == null) {
|
|
99 |
IView view = (IView) application.getActiveComponent(ViewDocument.class);
|
|
100 |
if (view == null) {
|
|
109 | 101 |
return false; |
110 | 102 |
} |
103 |
ViewDocument document = view.getViewDocument(); |
|
111 | 104 |
MapContext mapa = document.getMapContext(); |
112 | 105 |
return mapa.getLayers().getLayersCount() > 0; |
113 | 106 |
} |
Also available in: Unified diff