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