33 |
33 |
import org.gvsig.annotation.swing.AnnotationSwingManager;
|
34 |
34 |
import org.gvsig.annotation.swing.AnnotationWindowManager;
|
35 |
35 |
import org.gvsig.annotation.swing.JAnnotationCreationServicePanel;
|
|
36 |
import org.gvsig.app.ApplicationLocator;
|
|
37 |
import org.gvsig.app.ApplicationManager;
|
36 |
38 |
import org.gvsig.app.project.documents.view.ViewDocument;
|
37 |
|
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
|
38 |
|
import org.gvsig.editing.EditionUtilities;
|
|
39 |
import org.gvsig.app.project.documents.view.ViewManager;
|
39 |
40 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
40 |
41 |
import org.gvsig.fmap.mapcontext.MapContext;
|
41 |
42 |
import org.gvsig.fmap.mapcontext.layers.FLayer;
|
... | ... | |
86 |
87 |
|
87 |
88 |
}
|
88 |
89 |
|
89 |
|
public void execute(String actionCommand) {
|
90 |
|
org.gvsig.andami.ui.mdiManager.IWindow window = PluginServices.getMDIManager().getActiveWindow();
|
|
90 |
private FLyrVect getCurrentLayer() {
|
|
91 |
return this.getCurrentLayer(null);
|
|
92 |
}
|
|
93 |
|
|
94 |
private FLyrVect getCurrentLayer(MapContext mapContext) {
|
|
95 |
FLyrVect layer = null;
|
|
96 |
|
|
97 |
if( mapContext == null ) {
|
|
98 |
ApplicationManager application = ApplicationLocator.getManager();
|
91 |
99 |
|
92 |
|
if (window instanceof DefaultViewPanel) {
|
93 |
|
DefaultViewPanel viewPanel = (DefaultViewPanel) window;
|
94 |
|
ViewDocument viewDocument = viewPanel.getModel();
|
95 |
|
MapContext mapContext = viewDocument.getMapContext();
|
96 |
|
FLayer[] actives = mapContext.getLayers().getActives();
|
|
100 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
|
|
101 |
if( view == null ) {
|
|
102 |
return null;
|
|
103 |
}
|
|
104 |
mapContext = view.getMapContext();
|
|
105 |
}
|
|
106 |
FLayer[] actives = mapContext.getLayers().getActives();
|
97 |
107 |
|
98 |
|
FLyrVect fLyrVect = null;
|
99 |
|
for (int i=0 ; i<actives.length ; i++){
|
100 |
|
if (actives[i] instanceof FLyrVect){
|
101 |
|
fLyrVect = (FLyrVect)actives[i];
|
102 |
|
break;
|
103 |
|
}
|
|
108 |
for (int i=0 ; i<actives.length ; i++){
|
|
109 |
if (actives[i] instanceof FLyrVect){
|
|
110 |
layer = (FLyrVect)actives[i];
|
|
111 |
break;
|
104 |
112 |
}
|
|
113 |
}
|
|
114 |
return layer;
|
|
115 |
}
|
|
116 |
|
|
117 |
public void execute(String actionCommand) {
|
|
118 |
ApplicationManager application = ApplicationLocator.getManager();
|
105 |
119 |
|
106 |
|
if (fLyrVect == null){
|
107 |
|
return;
|
108 |
|
}
|
109 |
|
|
110 |
|
showAnnotation(manager, (FeatureStore)fLyrVect.getDataStore(), viewPanel);
|
|
120 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
|
|
121 |
if( view == null ) {
|
|
122 |
return;
|
111 |
123 |
}
|
|
124 |
MapContext mapContext = view.getMapContext();
|
|
125 |
FLyrVect layer = getCurrentLayer(mapContext);
|
|
126 |
if (layer == null){
|
|
127 |
return;
|
|
128 |
}
|
|
129 |
showAnnotation(manager, layer.getFeatureStore(), mapContext);
|
112 |
130 |
}
|
113 |
131 |
|
114 |
|
public void showAnnotation(AnnotationManager manager, FeatureStore featureStore, DefaultViewPanel defaultViewPanel) {
|
|
132 |
public void showAnnotation(AnnotationManager manager, FeatureStore featureStore, MapContext mapContext) {
|
115 |
133 |
try {
|
116 |
134 |
AnnotationCreationService service =
|
117 |
135 |
(AnnotationCreationService) manager.getAnnotationCreationService(featureStore);
|
118 |
|
service.setAnnotationCreationFinishAction(new AddLayerFinishAction(defaultViewPanel));
|
|
136 |
service.setAnnotationCreationFinishAction(new AddLayerFinishAction(mapContext));
|
119 |
137 |
|
120 |
138 |
JAnnotationCreationServicePanel panel =
|
121 |
139 |
swingManager.createAnnotation(service);
|
... | ... | |
128 |
146 |
}
|
129 |
147 |
|
130 |
148 |
public boolean isEnabled() {
|
131 |
|
int status = EditionUtilities.getEditionStatus();
|
132 |
|
if (( status == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE || status == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
133 |
|
|| (status == EditionUtilities.EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE)|| (status == EditionUtilities.EDITION_STATUS_MULTIPLE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE))
|
134 |
|
{
|
135 |
|
return true;
|
|
149 |
FLayer layer = getCurrentLayer();
|
|
150 |
if( layer == null ) {
|
|
151 |
return false;
|
136 |
152 |
}
|
137 |
|
return false;
|
|
153 |
return true;
|
138 |
154 |
}
|
139 |
155 |
|
140 |
156 |
public boolean isVisible() {
|
141 |
|
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
|
142 |
|
.getActiveWindow();
|
|
157 |
ApplicationManager application = ApplicationLocator.getManager();
|
143 |
158 |
|
144 |
|
if (f == null) {
|
|
159 |
ViewDocument view = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME);
|
|
160 |
if( view == null ) {
|
145 |
161 |
return false;
|
146 |
162 |
}
|
147 |
|
|
148 |
|
if (f instanceof DefaultViewPanel) {
|
149 |
|
return true;
|
150 |
|
}
|
151 |
|
return false;
|
|
163 |
return true;
|
152 |
164 |
}
|
153 |
165 |
}
|