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 / MoveGeometryExtension.java @ 40557
History | View | Annotate | Download (2.82 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.messages.NotificationManager; |
28 |
import org.gvsig.andami.plugins.Extension; |
29 |
import org.gvsig.editing.gui.cad.tools.MoveCADTool; |
30 |
import org.gvsig.fmap.dal.exception.ReadException; |
31 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
32 |
import org.gvsig.fmap.mapcontrol.MapControl; |
33 |
|
34 |
|
35 |
/**
|
36 |
* Extensi?n que gestiona la herramienta de mover.
|
37 |
*
|
38 |
* @author Vicente Caballero Navarro
|
39 |
*/
|
40 |
public class MoveGeometryExtension extends Extension { |
41 |
|
42 |
private MapControl mapControl;
|
43 |
private MoveCADTool move;
|
44 |
/**
|
45 |
* @see org.gvsig.andami.plugins.IExtension#initialize()
|
46 |
*/
|
47 |
public void initialize() { |
48 |
move=new MoveCADTool();
|
49 |
CADExtension.addCADTool("_move",move);
|
50 |
|
51 |
registerIcons(); |
52 |
} |
53 |
|
54 |
private void registerIcons(){ |
55 |
IconThemeHelper.registerIcon("action", "layer-modify-move", this); |
56 |
} |
57 |
/**
|
58 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
59 |
*/
|
60 |
public void execute(String s) { |
61 |
CADExtension.initFocus(); |
62 |
if ("layer-modify-move".equalsIgnoreCase(s)) { |
63 |
CADExtension.setCADTool("_move",true); |
64 |
} |
65 |
CADExtension.getEditionManager().setMapControl(mapControl); |
66 |
CADExtension.getCADToolAdapter().configureMenu(); |
67 |
} |
68 |
|
69 |
/**
|
70 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled()
|
71 |
*/
|
72 |
public boolean isEnabled() { |
73 |
if (CADExtension.getEditionManager().getActiveLayerEdited()==null) |
74 |
return false; |
75 |
FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer(); |
76 |
try {
|
77 |
return move.isApplicable(lv.getShapeType());
|
78 |
} catch (ReadException e) {
|
79 |
NotificationManager.addError(e.getMessage(),e); |
80 |
} |
81 |
return false; |
82 |
} |
83 |
|
84 |
/**
|
85 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
86 |
*/
|
87 |
public boolean isVisible() { |
88 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE){
|
89 |
return true; |
90 |
} |
91 |
return false; |
92 |
} |
93 |
} |