Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extEditing / src / com / iver / cit / gvsig / EditionChangeManager.java @ 24500

History | View | Annotate | Download (6.97 KB)

1
package com.iver.cit.gvsig;
2

    
3
import org.gvsig.fmap.dal.exception.DataException;
4
import org.gvsig.fmap.dal.exception.ReadException;
5
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification;
6
import org.gvsig.fmap.mapcontext.layers.FLayer;
7
import org.gvsig.tools.observer.Observable;
8
import org.gvsig.tools.observer.Observer;
9
import org.gvsig.tools.observer.WeakReferencingObservable;
10

    
11
import com.iver.andami.PluginServices;
12
import com.iver.andami.messages.NotificationManager;
13
import com.iver.andami.ui.mdiManager.IWindow;
14
import com.iver.cit.gvsig.layers.VectorialLayerEdited;
15
import com.iver.cit.gvsig.project.documents.table.gui.Table;
16

    
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
 *
19
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
 *
35
 * For more information, contact:
36
 *
37
 *  Generalitat Valenciana
38
 *   Conselleria d'Infraestructures i Transport
39
 *   Av. Blasco Ib??ez, 50
40
 *   46010 VALENCIA
41
 *   SPAIN
42
 *
43
 *      +34 963862235
44
 *   gvsig@gva.es
45
 *      www.gvsig.gva.es
46
 *
47
 *    or
48
 *
49
 *   IVER T.I. S.A
50
 *   Salamanca 50
51
 *   46005 Valencia
52
 *   Spain
53
 *
54
 *   +34 963163400
55
 *   dac@iver.es
56
 */
57
/* CVS MESSAGES:
58
 *
59
 * $Id: EditionChangeManager.java 24500 2008-10-30 11:00:13Z jmvivo $
60
 * $Log$
61
 * Revision 1.16  2007-09-19 15:55:42  jaume
62
 * removed unnecessary imports
63
 *
64
 * Revision 1.15  2007/06/22 10:48:00  caballero
65
 * borrar selecci?n
66
 *
67
 * Revision 1.14  2007/03/21 12:25:41  caballero
68
 * zoom remove cacheDrawing
69
 *
70
 * Revision 1.13  2007/02/13 17:10:06  caballero
71
 * expresion
72
 *
73
 * Revision 1.12  2006/11/28 13:18:32  fjp
74
 * No redibujar cuando se a?ade algo.
75
 * Para que se dibuje con el s?mbolo por defecto del layer, habr? que tocar
76
 * en los CADTool
77
 *
78
 * Revision 1.11  2006/09/15 10:42:17  caballero
79
 * extensibilidad de documentos
80
 *
81
 * Revision 1.10  2006/08/29 07:56:33  cesar
82
 * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
83
 *
84
 * Revision 1.9  2006/08/29 07:13:57  cesar
85
 * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
86
 *
87
 * Revision 1.8  2006/08/08 07:19:05  caballero
88
 * afterRowEditEvent con IRow
89
 *
90
 * Revision 1.7  2006/07/20 11:03:27  fjp
91
 * *** empty log message ***
92
 *
93
 * Revision 1.6  2006/07/13 12:36:01  fjp
94
 * Revisar bien lo de a?adir campos y gestionar un campo gris
95
 *
96
 * Revision 1.5  2006/06/21 07:22:48  fjp
97
 * Posibilidad de marcar capas como "dirty" y tener una que guarde lo que se ha dibujado antes que ella. Al hacer un MapControl.rePaintDirtyLayers(), eso se tiene en cuenta en el redibujado.
98
 *
99
 * Revision 1.4  2006/05/16 07:06:02  caballero
100
 * Saber si se realiza una operaci?n desde la vista o desde la tabla.
101
 *
102
 * Revision 1.3  2006/05/10 06:26:24  caballero
103
 * comprobar si tiene capa asociada
104
 *
105
 * Revision 1.2  2006/05/09 09:26:04  caballero
106
 * refrescar las vistas y tablas
107
 *
108
 * Revision 1.1  2006/05/05 09:06:09  jorpiell
109
 * Se a a?adido la clase EditionChangeManager, que no es m?s que un listener que se ejecuta cuando se produce un evento de edici?n.
110
 *
111
 *
112
 */
113
/**
114
 * Cuando un tema se pone en edici?n se le debe asociar
115
 * un listener de este tipo, que se dispar? cuando se produzca
116
 * un evento de edici?n (borrado, modificaci?n,... sobre la capa.
117
 *
118
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
119
 */
120
public class EditionChangeManager implements Observer{
121
        private FLayer fLayer = null;
122

    
123
        /**
124
         * Constructor
125
         * @param fLayer
126
         * Tema que se est? editando
127
         */
128
        public EditionChangeManager(FLayer fLayer){
129
                this.fLayer = fLayer;
130
        }
131
        /*
132
         *  (non-Javadoc)
133
         * @see com.iver.cit.gvsig.fmap.edition.IEditionListener#afterRowEditEvent(com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent)
134
         */
135
//        public void afterRowEditEvent(IRow feat, AfterRowEditEvent e) {
136
//                IWindow[] views = PluginServices.getMDIManager().getAllWindows();
137
//
138
//                for (int i=0 ; i<views.length ; i++){
139
//                        if (views[i] instanceof Table){
140
////                                Table table=(Table)views[i];
141
//                                ///VCN Creo que no hace falta refrescar la tabla aqu?
142
////                                if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(fLayer))
143
////                                        table.refresh();
144
//                        }else if (views[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View){
145
//                                com.iver.cit.gvsig.project.documents.view.gui.View view=(com.iver.cit.gvsig.project.documents.view.gui.View)views[i];
146
//
147
//                                if (e.getChangeType() == EditionEvent.CHANGE_TYPE_ADD) {
148
//                                        // No redraw, just image paint
149
//                                        view.getMapControl().repaint();
150
//                                }else if (e.getChangeType() == EditionEvent.CHANGE_TYPE_DELETE){
151
//                                        EditionManager em=CADExtension.getEditionManager();
152
//                                        if (em.getActiveLayerEdited()!=null){
153
//                                                VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
154
//                                                try {
155
//                                                        vle.clearSelection(false);
156
//                                                } catch (ReadException e1) {
157
//                                                        NotificationManager.addError(e1);
158
//                                                }
159
//                                        }
160
//                                }else{
161
//                                        fLayer.setDirty(true);
162
//                                        view.getMapControl().rePaintDirtyLayers();
163
//                                }
164
//
165
//                                /* FLayers layers=view.getMapControl().getMapContext().getLayers();
166
//                                for (int j=0;j<layers.getLayersCount();j++){
167
//                                        if (layers.getLayer(j).equals(fLayer)){
168
//                                                view.repaintMap();
169
//                                        }
170
//                                } */
171
//                        }
172
//                }
173
//
174
//        }
175
        public void update(WeakReferencingObservable observable, Object notification) {
176
                DefaultFeatureStoreNotification dfsn=(DefaultFeatureStoreNotification)notification;
177
                String type=dfsn.getType();
178
                IWindow[] views = PluginServices.getMDIManager().getAllWindows();
179

    
180
                for (int i=0 ; i<views.length ; i++){
181
                        if (views[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View){
182
                                com.iver.cit.gvsig.project.documents.view.gui.View view=(com.iver.cit.gvsig.project.documents.view.gui.View)views[i];
183
                                if (type.equals(DefaultFeatureStoreNotification.AFTER_DELETE)){
184
                                        EditionManager em=CADExtension.getEditionManager();
185
                                        if (em.getActiveLayerEdited()!=null){
186
                                                VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
187
                                                try {
188
                                                        vle.clearSelection(false);
189
                                                } catch (DataException e1) {
190
                                                        NotificationManager.addError(e1);
191
                                                }
192
                                        }
193
                                }
194
                                if (type.equals(DefaultFeatureStoreNotification.AFTER_INSERT)){
195
                                        view.getMapControl().repaint();
196
                                }
197
                                if (type.equals(type.equals(DefaultFeatureStoreNotification.AFTER_UPDATE))){
198
                                        fLayer.setDirty(true);
199
                                        view.getMapControl().rePaintDirtyLayers();
200
                                }
201
                        }
202
                }
203

    
204
        }
205

    
206
}