gvsig-vectorediting / org.gvsig.vectorediting / trunk / org.gvsig.vectorediting / org.gvsig.vectorediting.app / org.gvsig.vectorediting.app.mainplugin / src / main / java / org / gvsig / vectorediting / app / mainplugin / extensions / EditingExtension.java @ 89
History | View | Annotate | Download (2.07 KB)
1 |
/*
|
---|---|
2 |
* Copyright 2014 DiSiD Technologies S.L.L. All rights reserved.
|
3 |
*
|
4 |
* Project : DiSiD org.gvsig.vectorediting.app.mainplugin
|
5 |
* SVN Id : $Id$
|
6 |
*/
|
7 |
package org.gvsig.vectorediting.app.mainplugin.extensions; |
8 |
|
9 |
import org.gvsig.andami.IconThemeHelper; |
10 |
import org.gvsig.app.ApplicationLocator; |
11 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
12 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
13 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
14 |
import org.gvsig.fmap.mapcontrol.MapControl; |
15 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
16 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
17 |
import org.gvsig.vectorediting.app.mainplugin.BaseEditingServiceExtension; |
18 |
import org.gvsig.vectorediting.swing.api.EditingContext; |
19 |
|
20 |
public class EditingExtension extends BaseEditingServiceExtension { |
21 |
|
22 |
public void execute(String actionCommand) { |
23 |
|
24 |
if ("start-edit".equals(actionCommand)) { |
25 |
DefaultViewPanel view = getActiveView(); |
26 |
|
27 |
if (view != null) { |
28 |
FLyrVect layer = getActiveLayer(view); |
29 |
|
30 |
if (canBeEdited(layer)) {
|
31 |
EditingContext editingContext = swingManager.getEditingContext(view |
32 |
.getMapControl()); |
33 |
MapControl mapControl = view.getMapControl(); |
34 |
StatusBarListener sbl = new StatusBarListener(mapControl);
|
35 |
editingContext.beginEdition(layer, |
36 |
new Behavior[] { new MouseMovementBehavior(sbl) }); |
37 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
38 |
} |
39 |
} |
40 |
} |
41 |
} |
42 |
|
43 |
public void initialize() { |
44 |
|
45 |
registerIcons(); |
46 |
} |
47 |
|
48 |
private void registerIcons() { |
49 |
IconThemeHelper.registerIcon("action", "vector-editing", this); |
50 |
} |
51 |
|
52 |
public boolean isEnabled() { |
53 |
DefaultViewPanel vista = getActiveView(); |
54 |
FLyrVect activeLayer = getActiveLayer(vista); |
55 |
|
56 |
return (canBeEdited(activeLayer));
|
57 |
|
58 |
} |
59 |
|
60 |
public boolean isVisible() { |
61 |
DefaultViewPanel vista = getActiveView(); |
62 |
FLyrVect activeLayer = getActiveLayer(vista); |
63 |
|
64 |
return (vista != null && activeLayer != null && !activeLayer.isEditing()); |
65 |
} |
66 |
|
67 |
} |