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 / EditionChangeManager.java @ 40557
History | View | Annotate | Download (7.91 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.PluginServices; |
27 |
import org.gvsig.andami.messages.NotificationManager; |
28 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
29 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification; |
32 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
33 |
import org.gvsig.tools.observer.Observable; |
34 |
import org.gvsig.tools.observer.Observer; |
35 |
|
36 |
|
37 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
38 |
*
|
39 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
40 |
*
|
41 |
* This program is free software; you can redistribute it and/or
|
42 |
* modify it under the terms of the GNU General Public License
|
43 |
* as published by the Free Software Foundation; either version 2
|
44 |
* of the License, or (at your option) any later version.
|
45 |
*
|
46 |
* This program is distributed in the hope that it will be useful,
|
47 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
48 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
49 |
* GNU General Public License for more details.
|
50 |
*
|
51 |
* You should have received a copy of the GNU General Public License
|
52 |
* along with this program; if not, write to the Free Software
|
53 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
54 |
*
|
55 |
* For more information, contact:
|
56 |
*
|
57 |
* Generalitat Valenciana
|
58 |
* Conselleria d'Infraestructures i Transport
|
59 |
* Av. Blasco Ib??ez, 50
|
60 |
* 46010 VALENCIA
|
61 |
* SPAIN
|
62 |
*
|
63 |
* +34 963862235
|
64 |
* gvsig@gva.es
|
65 |
* www.gvsig.gva.es
|
66 |
*
|
67 |
* or
|
68 |
*
|
69 |
* IVER T.I. S.A
|
70 |
* Salamanca 50
|
71 |
* 46005 Valencia
|
72 |
* Spain
|
73 |
*
|
74 |
* +34 963163400
|
75 |
* dac@iver.es
|
76 |
*/
|
77 |
/* CVS MESSAGES:
|
78 |
*
|
79 |
* $Id: EditionChangeManager.java 39582 2013-01-10 13:19:27Z jldominguez $
|
80 |
* $Log$
|
81 |
* Revision 1.16 2007-09-19 15:55:42 jaume
|
82 |
* removed unnecessary imports
|
83 |
*
|
84 |
* Revision 1.15 2007/06/22 10:48:00 caballero
|
85 |
* borrar selecci?n
|
86 |
*
|
87 |
* Revision 1.14 2007/03/21 12:25:41 caballero
|
88 |
* zoom remove cacheDrawing
|
89 |
*
|
90 |
* Revision 1.13 2007/02/13 17:10:06 caballero
|
91 |
* expresion
|
92 |
*
|
93 |
* Revision 1.12 2006/11/28 13:18:32 fjp
|
94 |
* No redibujar cuando se a?ade algo.
|
95 |
* Para que se dibuje con el s?mbolo por defecto del layer, habr? que tocar
|
96 |
* en los CADTool
|
97 |
*
|
98 |
* Revision 1.11 2006/09/15 10:42:17 caballero
|
99 |
* extensibilidad de documentos
|
100 |
*
|
101 |
* Revision 1.10 2006/08/29 07:56:33 cesar
|
102 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
103 |
*
|
104 |
* Revision 1.9 2006/08/29 07:13:57 cesar
|
105 |
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
|
106 |
*
|
107 |
* Revision 1.8 2006/08/08 07:19:05 caballero
|
108 |
* afterRowEditEvent con IRow
|
109 |
*
|
110 |
* Revision 1.7 2006/07/20 11:03:27 fjp
|
111 |
* *** empty log message ***
|
112 |
*
|
113 |
* Revision 1.6 2006/07/13 12:36:01 fjp
|
114 |
* Revisar bien lo de a?adir campos y gestionar un campo gris
|
115 |
*
|
116 |
* Revision 1.5 2006/06/21 07:22:48 fjp
|
117 |
* 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.
|
118 |
*
|
119 |
* Revision 1.4 2006/05/16 07:06:02 caballero
|
120 |
* Saber si se realiza una operaci?n desde la vista o desde la tabla.
|
121 |
*
|
122 |
* Revision 1.3 2006/05/10 06:26:24 caballero
|
123 |
* comprobar si tiene capa asociada
|
124 |
*
|
125 |
* Revision 1.2 2006/05/09 09:26:04 caballero
|
126 |
* refrescar las vistas y tablas
|
127 |
*
|
128 |
* Revision 1.1 2006/05/05 09:06:09 jorpiell
|
129 |
* 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.
|
130 |
*
|
131 |
*
|
132 |
*/
|
133 |
/**
|
134 |
* Cuando un tema se pone en edici?n se le debe asociar
|
135 |
* un listener de este tipo, que se dispar? cuando se produzca
|
136 |
* un evento de edici?n (borrado, modificaci?n,... sobre la capa.
|
137 |
*
|
138 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
139 |
*/
|
140 |
public class EditionChangeManager implements Observer{ |
141 |
private FLayer fLayer = null; |
142 |
|
143 |
/**
|
144 |
* Constructor
|
145 |
* @param fLayer
|
146 |
* Tema que se est? editando
|
147 |
*/
|
148 |
public EditionChangeManager(FLayer fLayer){
|
149 |
this.fLayer = fLayer;
|
150 |
} |
151 |
/*
|
152 |
* (non-Javadoc)
|
153 |
* @see com.iver.cit.gvsig.fmap.edition.IEditionListener#afterRowEditEvent(com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent)
|
154 |
*/
|
155 |
// public void afterRowEditEvent(IRow feat, AfterRowEditEvent e) {
|
156 |
// IWindow[] views = PluginServices.getMDIManager().getAllWindows();
|
157 |
//
|
158 |
// for (int i=0 ; i<views.length ; i++){
|
159 |
// if (views[i] instanceof Table){
|
160 |
//// Table table=(Table)views[i];
|
161 |
// ///VCN Creo que no hace falta refrescar la tabla aqu?
|
162 |
//// if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(fLayer))
|
163 |
//// table.refresh();
|
164 |
// }else if (views[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View){
|
165 |
// com.iver.cit.gvsig.project.documents.view.gui.View view=(com.iver.cit.gvsig.project.documents.view.gui.View)views[i];
|
166 |
//
|
167 |
// if (e.getChangeType() == EditionEvent.CHANGE_TYPE_ADD) {
|
168 |
// // No redraw, just image paint
|
169 |
// view.getMapControl().repaint();
|
170 |
// }else if (e.getChangeType() == EditionEvent.CHANGE_TYPE_DELETE){
|
171 |
// EditionManager em=CADExtension.getEditionManager();
|
172 |
// if (em.getActiveLayerEdited()!=null){
|
173 |
// VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
|
174 |
// try {
|
175 |
// vle.clearSelection(false);
|
176 |
// } catch (ReadException e1) {
|
177 |
// NotificationManager.addError(e1);
|
178 |
// }
|
179 |
// }
|
180 |
// }else{
|
181 |
// fLayer.setDirty(true);
|
182 |
// view.getMapControl().rePaintDirtyLayers();
|
183 |
// }
|
184 |
//
|
185 |
// /* FLayers layers=view.getMapControl().getMapContext().getLayers();
|
186 |
// for (int j=0;j<layers.getLayersCount();j++){
|
187 |
// if (layers.getLayer(j).equals(fLayer)){
|
188 |
// view.repaintMap();
|
189 |
// }
|
190 |
// } */
|
191 |
// }
|
192 |
// }
|
193 |
//
|
194 |
// }
|
195 |
public void update(Observable observable, Object notification) { |
196 |
DefaultFeatureStoreNotification dfsn=(DefaultFeatureStoreNotification)notification; |
197 |
String type=dfsn.getType();
|
198 |
IWindow[] views = PluginServices.getMDIManager().getAllWindows();
|
199 |
|
200 |
for (int i=0 ; i<views.length ; i++){ |
201 |
if (views[i] instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel){ |
202 |
org.gvsig.app.project.documents.view.gui.DefaultViewPanel view=(org.gvsig.app.project.documents.view.gui.DefaultViewPanel)views[i]; |
203 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_DELETE)){
|
204 |
IEditionManager em = EditionLocator.getEditionManager(); |
205 |
if (em.getActiveLayerEdited()!=null){ |
206 |
VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited(); |
207 |
try {
|
208 |
vle.clearSelection(); |
209 |
} catch (DataException e1) {
|
210 |
NotificationManager.addError(e1); |
211 |
} |
212 |
} |
213 |
} |
214 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_INSERT)){
|
215 |
view.getMapControl().repaint(); |
216 |
} |
217 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_UPDATE)
|
218 |
|| type.equals(DefaultFeatureStoreNotification.AFTER_REDO) |
219 |
|| type.equals(DefaultFeatureStoreNotification.AFTER_UNDO)) { |
220 |
view.getMapControl().rePaintDirtyLayers(); |
221 |
} |
222 |
} |
223 |
} |
224 |
} |
225 |
|
226 |
} |