Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / undo / command / FTypeUpdateCommand.java @ 43840

History | View | Annotate | Download (2.79 KB)

1 40559 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40559 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5 40435 jjdelcerro
 *
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 40559 jjdelcerro
 * as published by the Free Software Foundation; either version 3
9 40435 jjdelcerro
 * 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 40559 jjdelcerro
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20 40435 jjdelcerro
 *
21 40559 jjdelcerro
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23 40435 jjdelcerro
 */
24
package org.gvsig.fmap.dal.feature.impl.undo.command;
25
26
import org.gvsig.fmap.dal.feature.FeatureType;
27 43840 jjdelcerro
import org.gvsig.fmap.dal.feature.impl.editing.memory.FeatureTypeManager;
28 40435 jjdelcerro
import org.gvsig.tools.undo.RedoException;
29
import org.gvsig.tools.undo.UndoException;
30
31
32
/**
33
 * DOCUMENT ME!
34
 *
35
 * @author Vicente Caballero Navarro
36
 */
37
public class FTypeUpdateCommand extends AbstractFTypeCommand {
38
    private FeatureType oldType;
39
    private int position=-1;
40
41
    public FTypeUpdateCommand(FeatureTypeManager expansionManager,
42
        FeatureType type, FeatureType oldType, String description) {
43
        super(expansionManager, type, description);
44
        this.oldType = oldType;
45
    }
46
47
    /* (non-Javadoc)
48
    * @see org.gvsig.fmap.dal.commands.Command#undo()
49
    */
50
    public void undo() throws UndoException {
51
//        if (expansionManager.contains(oldFeature.getReference())) {
52
//            expansionManager.deleteLastFeature(feature.getReference());
53
//        } else {
54
//            expansionManager.delete(type.getId());
55
//        }
56
57
        expansionManager.restore(oldType.getId(),position);
58
    }
59
60
    /* (non-Javadoc)
61
     * @see org.gvsig.fmap.dal.commands.Command#redo()
62
     */
63
    public void redo() throws RedoException {
64
        execute();
65
    }
66
67
    public int getType() {
68
        return UPDATE;
69
    }
70
71
    /* (non-Javadoc)
72
     * @see org.gvsig.fmap.dal.commands.Command#execute()
73
     */
74
    public void execute() {
75
        //                 Si la geometr?a no ha sido modificada
76
//        if (!expansionManager.contains(oldType.getId())) {
77
//        if (expansionManager.delete(oldType.getId())!=null){
78
//            expansionManager.add(type);
79
//        } else {
80
          position =  expansionManager.update(type, oldType);
81
//        }
82
    }
83
84
        public FeatureType getOldFeatureType() {
85
                return oldType;
86
        }
87 40596 jjdelcerro
}