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 / PolylineExtension.java @ 59
History | View | Annotate | Download (2.32 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.project.documents.view.gui.DefaultViewPanel; |
11 |
import org.gvsig.fmap.dal.exception.ReadException; |
12 |
import org.gvsig.fmap.geom.type.GeometryType; |
13 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
14 |
import org.gvsig.tools.service.ServiceException; |
15 |
import org.gvsig.vectorediting.app.mainplugin.BaseEditingServiceExtension; |
16 |
import org.gvsig.vectorediting.lib.api.EditingServiceInfo; |
17 |
import org.gvsig.vectorediting.lib.prov.insertpoint.InsertPointEditingProviderFactory; |
18 |
import org.gvsig.vectorediting.lib.prov.polyline.PolylineEditingProviderFactory; |
19 |
|
20 |
|
21 |
public class PolylineExtension extends BaseEditingServiceExtension { |
22 |
|
23 |
public void initialize() { |
24 |
// TODO Auto-generated method stub
|
25 |
|
26 |
} |
27 |
|
28 |
public void execute(String actionCommand) { |
29 |
DefaultViewPanel view = getActiveView(); |
30 |
swingManager.activateTool(PolylineEditingProviderFactory.PROVIDER_NAME, view.getMapControl()); |
31 |
|
32 |
registerIcons(); |
33 |
|
34 |
} |
35 |
|
36 |
private void registerIcons() { |
37 |
IconThemeHelper.registerIcon("action", "layer-insert-polyline", this); |
38 |
} |
39 |
|
40 |
public boolean isEnabled() { |
41 |
EditingServiceInfo polylineServiceInfo; |
42 |
try {
|
43 |
polylineServiceInfo = manager.getServiceInfo(PolylineEditingProviderFactory.PROVIDER_NAME); |
44 |
DefaultViewPanel view = getActiveView(); |
45 |
FLyrVect layer = getActiveLayer(view); |
46 |
|
47 |
int[] supportedTypes = polylineServiceInfo |
48 |
.getSupportedPrimitiveGeometryTypes(); |
49 |
GeometryType[] supportedGeoTypes = loadGeometryTypes(supportedTypes);
|
50 |
|
51 |
if (isApplicable(supportedGeoTypes, layer.getShapeType())) {
|
52 |
return true; |
53 |
} |
54 |
|
55 |
return false; |
56 |
|
57 |
} |
58 |
catch (ServiceException e1) {
|
59 |
// TODO Auto-generated catch block
|
60 |
e1.printStackTrace(); |
61 |
} |
62 |
catch (ReadException e) {
|
63 |
// TODO Auto-generated catch block
|
64 |
e.printStackTrace(); |
65 |
} |
66 |
return false; |
67 |
} |
68 |
|
69 |
public boolean isVisible() { |
70 |
DefaultViewPanel view = getActiveView(); |
71 |
if (view != null) { |
72 |
FLyrVect layer = getActiveLayer(view); |
73 |
if (layer != null && layer.isEditing()) { |
74 |
return true; |
75 |
} |
76 |
} |
77 |
return false; |
78 |
} |
79 |
|
80 |
} |