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 @ 40596
History | View | Annotate | Download (2.78 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.fmap.dal.feature.impl.undo.command; |
25 |
|
26 |
import org.gvsig.fmap.dal.feature.FeatureType; |
27 |
import org.gvsig.fmap.dal.feature.impl.FeatureTypeManager; |
28 |
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 |
} |