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 / CircleCRExtension.java @ 72
History | View | Annotate | Download (2.19 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.circlecr.CircleCREditingProviderFactory; |
18 |
|
19 |
public class CircleCRExtension extends BaseEditingServiceExtension { |
20 |
|
21 |
public void initialize() { |
22 |
// TODO Auto-generated method stub
|
23 |
|
24 |
} |
25 |
|
26 |
public void execute(String arg0) { |
27 |
|
28 |
DefaultViewPanel view = getActiveView(); |
29 |
swingManager.activateService(CircleCREditingProviderFactory.PROVIDER_NAME, view.getMapControl()); |
30 |
|
31 |
registerIcons(); |
32 |
} |
33 |
|
34 |
private void registerIcons() { |
35 |
IconThemeHelper.registerIcon("action", "layer-insert-circle", this); |
36 |
} |
37 |
|
38 |
public boolean isEnabled() { |
39 |
EditingServiceInfo Circle2PInfo; |
40 |
try {
|
41 |
Circle2PInfo = manager.getServiceInfo(CircleCREditingProviderFactory.PROVIDER_NAME); |
42 |
DefaultViewPanel view = getActiveView(); |
43 |
FLyrVect layer = getActiveLayer(view); |
44 |
|
45 |
int[] supportedTypes = Circle2PInfo.getSupportedPrimitiveGeometryTypes(); |
46 |
GeometryType[] supportedGeoTypes = loadGeometryTypes(supportedTypes);
|
47 |
|
48 |
if (isApplicable(supportedGeoTypes, layer.getShapeType())) {
|
49 |
return true; |
50 |
} |
51 |
|
52 |
return false; |
53 |
|
54 |
} |
55 |
catch (ServiceException e1) {
|
56 |
// TODO Auto-generated catch block
|
57 |
e1.printStackTrace(); |
58 |
} |
59 |
catch (ReadException e) {
|
60 |
// TODO Auto-generated catch block
|
61 |
e.printStackTrace(); |
62 |
} |
63 |
return false; |
64 |
} |
65 |
|
66 |
public boolean isVisible() { |
67 |
DefaultViewPanel view = getActiveView(); |
68 |
if (view != null) { |
69 |
FLyrVect layer = getActiveLayer(view); |
70 |
if (layer != null && layer.isEditing()) { |
71 |
return true; |
72 |
} |
73 |
} |
74 |
return false; |
75 |
} |
76 |
|
77 |
} |