svn-gvsig-desktop / trunk / libraries / libDataSource / src / org / gvsig / data / commands / implementation / UpdateAttributeCommand.java @ 20419
History | View | Annotate | Download (1.78 KB)
1 |
package org.gvsig.data.commands.implementation; |
---|---|
2 |
|
3 |
import org.gvsig.data.commands.ICommand; |
4 |
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor; |
5 |
import org.gvsig.data.vectorial.expansionadapter.AttributeManager; |
6 |
|
7 |
public class UpdateAttributeCommand extends AbstractAttributeCommand{ |
8 |
private IFeatureAttributeDescriptor oldAttributeDescriptor;
|
9 |
|
10 |
public UpdateAttributeCommand(AttributeManager attributeManager, IFeatureAttributeDescriptor attributeDescriptor) {
|
11 |
super(attributeManager,attributeDescriptor);
|
12 |
this.oldAttributeDescriptor=attributeDescriptor.getOldAttributeDescriptor();
|
13 |
} |
14 |
|
15 |
public UpdateAttributeCommand(AttributeManager attributeManager, IFeatureAttributeDescriptor attributeDescriptor, String description) { |
16 |
super(attributeManager,attributeDescriptor, description);
|
17 |
this.oldAttributeDescriptor=attributeDescriptor.getOldAttributeDescriptor();
|
18 |
} |
19 |
|
20 |
public void undo() { |
21 |
if (attributeManager.contains(oldAttributeDescriptor.getName())) {
|
22 |
attributeManager.deleteLastAttribute(attributeDescriptor.getName()); |
23 |
} else {
|
24 |
attributeManager.deleteAttribute(attributeDescriptor.getName()); |
25 |
} |
26 |
|
27 |
attributeManager.restoreAttribute(oldAttributeDescriptor.getName()); |
28 |
} |
29 |
public void redo() { |
30 |
execute(); |
31 |
} |
32 |
|
33 |
public String getType() { |
34 |
return ICommand.UPDATE;
|
35 |
} |
36 |
|
37 |
public void execute() { |
38 |
if (!attributeManager.contains(oldAttributeDescriptor.getName())) {
|
39 |
attributeManager.deleteAttribute(oldAttributeDescriptor.getName()); |
40 |
attributeManager.addAttribute(attributeDescriptor); |
41 |
} else {
|
42 |
|
43 |
attributeManager.updateAttribute(attributeDescriptor); |
44 |
} |
45 |
} |
46 |
public IFeatureAttributeDescriptor getOldAttributeDescriptor(){
|
47 |
return oldAttributeDescriptor;
|
48 |
} |
49 |
|
50 |
} |