Statistics
| Revision:

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 @ 40596

History | View | Annotate | Download (4.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.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
/**
38
 * Cuando un tema se pone en edici?n se le debe asociar
39
 * un listener de este tipo, que se dispar? cuando se produzca
40
 * un evento de edici?n (borrado, modificaci?n,... sobre la capa.
41
 *
42
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
43
 */
44
public class EditionChangeManager implements Observer{
45
        private FLayer fLayer = null;
46

    
47
        /**
48
         * Constructor
49
         * @param fLayer
50
         * Tema que se est? editando
51
         */
52
        public EditionChangeManager(FLayer fLayer){
53
                this.fLayer = fLayer;
54
        }
55
        /*
56
         *  (non-Javadoc)
57
         * @see com.iver.cit.gvsig.fmap.edition.IEditionListener#afterRowEditEvent(com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent)
58
         */
59
//        public void afterRowEditEvent(IRow feat, AfterRowEditEvent e) {
60
//                IWindow[] views = PluginServices.getMDIManager().getAllWindows();
61
//
62
//                for (int i=0 ; i<views.length ; i++){
63
//                        if (views[i] instanceof Table){
64
////                                Table table=(Table)views[i];
65
//                                ///VCN Creo que no hace falta refrescar la tabla aqu?
66
////                                if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(fLayer))
67
////                                        table.refresh();
68
//                        }else if (views[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View){
69
//                                com.iver.cit.gvsig.project.documents.view.gui.View view=(com.iver.cit.gvsig.project.documents.view.gui.View)views[i];
70
//
71
//                                if (e.getChangeType() == EditionEvent.CHANGE_TYPE_ADD) {
72
//                                        // No redraw, just image paint
73
//                                        view.getMapControl().repaint();
74
//                                }else if (e.getChangeType() == EditionEvent.CHANGE_TYPE_DELETE){
75
//                                        EditionManager em=CADExtension.getEditionManager();
76
//                                        if (em.getActiveLayerEdited()!=null){
77
//                                                VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
78
//                                                try {
79
//                                                        vle.clearSelection(false);
80
//                                                } catch (ReadException e1) {
81
//                                                        NotificationManager.addError(e1);
82
//                                                }
83
//                                        }
84
//                                }else{
85
//                                        fLayer.setDirty(true);
86
//                                        view.getMapControl().rePaintDirtyLayers();
87
//                                }
88
//
89
//                                /* FLayers layers=view.getMapControl().getMapContext().getLayers();
90
//                                for (int j=0;j<layers.getLayersCount();j++){
91
//                                        if (layers.getLayer(j).equals(fLayer)){
92
//                                                view.repaintMap();
93
//                                        }
94
//                                } */
95
//                        }
96
//                }
97
//
98
//        }
99
        public void update(Observable observable, Object notification) {
100
                DefaultFeatureStoreNotification dfsn=(DefaultFeatureStoreNotification)notification;
101
                String type=dfsn.getType();
102
                IWindow[] views = PluginServices.getMDIManager().getAllWindows();
103

    
104
                for (int i=0 ; i<views.length ; i++){
105
                        if (views[i] instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel){
106
                                org.gvsig.app.project.documents.view.gui.DefaultViewPanel view=(org.gvsig.app.project.documents.view.gui.DefaultViewPanel)views[i];
107
                                if (type.equals(DefaultFeatureStoreNotification.AFTER_DELETE)){
108
                                        IEditionManager em = EditionLocator.getEditionManager();
109
                                        if (em.getActiveLayerEdited()!=null){
110
                                                VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited();
111
                                                try {
112
                                                        vle.clearSelection();
113
                                                } catch (DataException e1) {
114
                                                        NotificationManager.addError(e1);
115
                                                }
116
                                        }
117
                                }
118
                                if (type.equals(DefaultFeatureStoreNotification.AFTER_INSERT)){
119
                                        view.getMapControl().repaint();
120
                                }
121
                                if (type.equals(DefaultFeatureStoreNotification.AFTER_UPDATE)
122
                                    || type.equals(DefaultFeatureStoreNotification.AFTER_REDO)
123
                    || type.equals(DefaultFeatureStoreNotification.AFTER_UNDO)) {
124
                                        view.getMapControl().rePaintDirtyLayers();
125
                                }
126
                        }
127
                }
128
        }
129

    
130
}