svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.editing.app / org.gvsig.editing.app.mainplugin / src / main / java / org / gvsig / editing / InternalPolygonExtension.java @ 40557
History | View | Annotate | Download (3.87 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.editing; |
25 |
|
26 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.andami.messages.NotificationManager; |
29 |
import org.gvsig.andami.plugins.Extension; |
30 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
31 |
import org.gvsig.editing.gui.cad.tools.InternalPolygonCADTool; |
32 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
33 |
import org.gvsig.fmap.dal.exception.DataException; |
34 |
import org.gvsig.fmap.dal.exception.ReadException; |
35 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
36 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
37 |
import org.gvsig.fmap.mapcontrol.MapControl; |
38 |
|
39 |
|
40 |
/**
|
41 |
* Extensi?n que gestiona la inserci?n de pol?gonos internos en edici?n.
|
42 |
*
|
43 |
* @author Vicente Caballero Navarro
|
44 |
*/
|
45 |
public class InternalPolygonExtension extends Extension { |
46 |
private DefaultViewPanel view;
|
47 |
|
48 |
private MapControl mapControl;
|
49 |
private InternalPolygonCADTool internalpolygon;
|
50 |
|
51 |
/**
|
52 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
53 |
*/
|
54 |
public void initialize() { |
55 |
internalpolygon = new InternalPolygonCADTool();
|
56 |
CADExtension.addCADTool("_internalpolygon",internalpolygon);
|
57 |
|
58 |
registerIcons(); |
59 |
} |
60 |
|
61 |
private void registerIcons(){ |
62 |
IconThemeHelper.registerIcon("action", "layer-modify-internal-polygon", this); |
63 |
} |
64 |
|
65 |
/**
|
66 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
67 |
*/
|
68 |
public void execute(String s) { |
69 |
CADExtension.initFocus(); |
70 |
if ("layer-modify-internal-polygon".equalsIgnoreCase(s)) { |
71 |
CADExtension.setCADTool("_internalpolygon",true); |
72 |
} |
73 |
CADExtension.getEditionManager().setMapControl(mapControl); |
74 |
CADExtension.getCADToolAdapter().configureMenu(); |
75 |
} |
76 |
|
77 |
/**
|
78 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
79 |
*/
|
80 |
public boolean isEnabled() { |
81 |
|
82 |
try {
|
83 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) {
|
84 |
view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
85 |
mapControl = view.getMapControl(); |
86 |
IEditionManager em = EditionLocator.getEditionManager(); |
87 |
if (em.getActiveLayerEdited()==null) |
88 |
return false; |
89 |
VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited(); |
90 |
if (((FeatureSelection)vle.getFeatureStore().getSelection()).getSize()<1) |
91 |
return false; |
92 |
FLyrVect lv=(FLyrVect)vle.getLayer(); |
93 |
if (internalpolygon.isApplicable(lv.getShapeType())){
|
94 |
return true; |
95 |
} |
96 |
} |
97 |
} catch (ReadException e) {
|
98 |
NotificationManager.addError(e.getMessage(),e); |
99 |
} catch (DataException e) {
|
100 |
NotificationManager.addError(e.getMessage(),e); |
101 |
} |
102 |
return false; |
103 |
} |
104 |
|
105 |
/**
|
106 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
107 |
*/
|
108 |
public boolean isVisible() { |
109 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE)
|
110 |
return true; |
111 |
return false; |
112 |
} |
113 |
} |