Statistics
| Revision:

svn-gvsig-desktop / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / StopEditing.java @ 1763

History | View | Annotate | Download (3.73 KB)

1
/*
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
import com.iver.cit.gvsig.fmap.FMap;
50
import com.iver.cit.gvsig.fmap.edition.EditionException;
51
import com.iver.cit.gvsig.fmap.layers.FLayer;
52
import com.iver.cit.gvsig.fmap.layers.layerOperations.EditableVectorialLayer;
53
import com.iver.cit.gvsig.gui.View;
54
import com.iver.cit.gvsig.project.ProjectView;
55

    
56

    
57
/**
58
 * DOCUMENT ME!
59
 *
60
 * @author Fernando Gonz?lez Cort?s
61
 */
62
public class StopEditing implements Extension {
63
        /**
64
         * @see com.iver.andami.plugins.Extension#inicializar()
65
         */
66
        public void inicializar() {
67
        }
68

    
69
        /**
70
         * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
71
         */
72
        public void execute(String actionCommand) {
73
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
74
                                                                                                                         .getActiveView();
75

    
76
                if (f.getClass() == View.class) {
77
                        View vista = (View) f;
78
                        ProjectView model = vista.getModel();
79
                        FMap mapa = model.getMapContext();
80
                        EditableVectorialLayer capa = (EditableVectorialLayer) mapa.getLayers()
81
                                                                                                                                           .getActives()[0];
82

    
83
                        try {
84
                                if (actionCommand.equals("STOP")){
85
                                        capa.stopEdition();
86
                                }else if (actionCommand.equals("CANCELEDITION")){
87
                                        capa.cancelEdition();
88
                                }else if (actionCommand.equals("SHOWGRID")){
89
                                        vista.getMapControl().getCadToolAdapter().setGrid(true);
90
                                }else if (actionCommand.equals("HIDEGRID")){
91
                                        vista.getMapControl().getCadToolAdapter().setGrid(false);
92
                                }else if (actionCommand.equals("SETADJUSTGRID")){
93
                                        vista.getMapControl().getCadToolAdapter().setAdjustGrid(true);
94
                                }else if (actionCommand.equals("NOTADJUSTGRID")){
95
                                        vista.getMapControl().getCadToolAdapter().setAdjustGrid(false);
96
                                }
97
                        } catch (EditionException e) {
98
                                e.printStackTrace();
99
                        }
100
                }
101
        }
102
                /**
103
         * @see com.iver.andami.plugins.Extension#isEnabled()
104
         */
105
        public boolean isEnabled() {
106
                return true;
107
        }
108

    
109
        /**
110
         * @see com.iver.andami.plugins.Extension#isVisible()
111
         */
112
        public boolean isVisible() {
113
                com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
114
                                                                                                                         .getActiveView();
115

    
116
                if (f == null) {
117
                        return false;
118
                }
119

    
120
                if (f.getClass() == View.class) {
121
                        View vista = (View) f;
122
                        ProjectView model = vista.getModel();
123
                        FMap mapa = model.getMapContext();
124

    
125
                        FLayer[] capas = mapa.getLayers().getActives();
126

    
127
                        for (int i = 0; i < capas.length; i++) {
128
                                if (capas[i] instanceof EditableVectorialLayer) {
129
                                        return ((EditableVectorialLayer) capas[i]).isEditing();
130
                                }
131
                        }
132
                }
133

    
134
                return false;
135
        }
136
}