svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / StopEditing.java @ 1649
History | View | Annotate | Download (3.73 KB)
1 | 1520 | fernando | /*
|
---|---|---|---|
2 | * Created on 21-feb-2005
|
||
3 | *
|
||
4 | * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
5 | *
|
||
6 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
7 | *
|
||
8 | * This program is free software; you can redistribute it and/or
|
||
9 | * modify it under the terms of the GNU General Public License
|
||
10 | * as published by the Free Software Foundation; either version 2
|
||
11 | * of the License, or (at your option) any later version.
|
||
12 | *
|
||
13 | * This program is distributed in the hope that it will be useful,
|
||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
16 | * GNU General Public License for more details.
|
||
17 | *
|
||
18 | * You should have received a copy of the GNU General Public License
|
||
19 | * along with this program; if not, write to the Free Software
|
||
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||
21 | USA.
|
||
22 | *
|
||
23 | * For more information, contact:
|
||
24 | *
|
||
25 | * Generalitat Valenciana
|
||
26 | * Conselleria d'Infraestructures i Transport
|
||
27 | * Av. Blasco Ib??ez, 50
|
||
28 | * 46010 VALENCIA
|
||
29 | * SPAIN
|
||
30 | *
|
||
31 | * +34 963862235
|
||
32 | * gvsig@gva.es
|
||
33 | * www.gvsig.gva.es
|
||
34 | *
|
||
35 | * or
|
||
36 | *
|
||
37 | * IVER T.I. S.A
|
||
38 | * Salamanca 50
|
||
39 | * 46005 Valencia
|
||
40 | * Spain
|
||
41 | *
|
||
42 | * +34 963163400
|
||
43 | * dac@iver.es
|
||
44 | */
|
||
45 | package com.iver.cit.gvsig; |
||
46 | |||
47 | import com.iver.andami.PluginServices; |
||
48 | import com.iver.andami.plugins.Extension; |
||
49 | |||
50 | import com.iver.cit.gvsig.fmap.FMap; |
||
51 | import com.iver.cit.gvsig.fmap.edition.EditionException; |
||
52 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
53 | import com.iver.cit.gvsig.fmap.layers.layerOperations.EditableVectorialLayer; |
||
54 | import com.iver.cit.gvsig.gui.View; |
||
55 | import com.iver.cit.gvsig.project.ProjectView; |
||
56 | |||
57 | |||
58 | /**
|
||
59 | * DOCUMENT ME!
|
||
60 | *
|
||
61 | * @author Fernando Gonz?lez Cort?s
|
||
62 | */
|
||
63 | public class StopEditing implements Extension { |
||
64 | /**
|
||
65 | * @see com.iver.andami.plugins.Extension#inicializar()
|
||
66 | */
|
||
67 | public void inicializar() { |
||
68 | } |
||
69 | |||
70 | /**
|
||
71 | * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
||
72 | */
|
||
73 | public void execute(String actionCommand) { |
||
74 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
75 | .getActiveView(); |
||
76 | |||
77 | if (f.getClass() == View.class) { |
||
78 | View vista = (View) f; |
||
79 | ProjectView model = vista.getModel(); |
||
80 | FMap mapa = model.getMapContext(); |
||
81 | EditableVectorialLayer capa = (EditableVectorialLayer) mapa.getLayers() |
||
82 | .getActives()[0];
|
||
83 | |||
84 | try {
|
||
85 | 1570 | fernando | if (actionCommand.equals("STOP")){ |
86 | capa.stopEdition(); |
||
87 | 1636 | fernando | }else if (actionCommand.equals("CANCELEDITION")){ |
88 | capa.cancelEdition(); |
||
89 | 1570 | fernando | }else if (actionCommand.equals("SHOWGRID")){ |
90 | vista.getMapControl().getCadToolAdapter().setGrid(true);
|
||
91 | }else if (actionCommand.equals("HIDEGRID")){ |
||
92 | vista.getMapControl().getCadToolAdapter().setGrid(false);
|
||
93 | }else if (actionCommand.equals("SETADJUSTGRID")){ |
||
94 | 1571 | fernando | vista.getMapControl().getCadToolAdapter().setAdjustGrid(true);
|
95 | }else if (actionCommand.equals("NOTADJUSTGRID")){ |
||
96 | 1570 | fernando | vista.getMapControl().getCadToolAdapter().setAdjustGrid(false);
|
97 | } |
||
98 | 1520 | fernando | } catch (EditionException e) {
|
99 | e.printStackTrace(); |
||
100 | } |
||
101 | } |
||
102 | } |
||
103 | |||
104 | /**
|
||
105 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
106 | */
|
||
107 | public boolean isEnabled() { |
||
108 | return true; |
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * @see com.iver.andami.plugins.Extension#isVisible()
|
||
113 | */
|
||
114 | public boolean isVisible() { |
||
115 | com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
||
116 | .getActiveView(); |
||
117 | |||
118 | if (f == null) { |
||
119 | return false; |
||
120 | } |
||
121 | |||
122 | if (f.getClass() == View.class) { |
||
123 | View vista = (View) f; |
||
124 | ProjectView model = vista.getModel(); |
||
125 | FMap mapa = model.getMapContext(); |
||
126 | |||
127 | FLayer[] capas = mapa.getLayers().getActives();
|
||
128 | |||
129 | for (int i = 0; i < capas.length; i++) { |
||
130 | if (capas[i] instanceof EditableVectorialLayer) { |
||
131 | return ((EditableVectorialLayer) capas[i]).isEditing();
|
||
132 | } |
||
133 | } |
||
134 | } |
||
135 | |||
136 | return false; |
||
137 | } |
||
138 | } |