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