root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / commands / ModifyRowCommand.java @ 28367
History | View | Annotate | Download (2.02 KB)
1 |
package com.iver.cit.gvsig.fmap.edition.commands; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
6 |
import com.iver.cit.gvsig.exceptions.commands.EditionCommandException; |
7 |
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileWriteException; |
8 |
import com.iver.cit.gvsig.fmap.core.IRow; |
9 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
10 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
11 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
12 |
|
13 |
public class ModifyRowCommand extends AbstractCommand { |
14 |
|
15 |
private EditableAdapter efs;
|
16 |
private IRow rowNext;
|
17 |
private int calculatedIndexAnt; |
18 |
private int previousIndexInExpansionFile; |
19 |
private int type=EditionEvent.GRAPHIC; |
20 |
/**
|
21 |
* @param ef IEditableSource
|
22 |
* @param calculatedIndex index of modified row
|
23 |
* @param p previous index in expansion file. -1 if previous is from original data source.
|
24 |
* @param newRow
|
25 |
* @throws IOException
|
26 |
* @throws DriverIOException
|
27 |
*/
|
28 |
public ModifyRowCommand(EditableAdapter ef,int calculatedIndex,int previousInExpansionFile,IRow newRow,int type){ |
29 |
super();
|
30 |
efs=ef; |
31 |
calculatedIndexAnt=calculatedIndex; |
32 |
rowNext=newRow; |
33 |
previousIndexInExpansionFile=previousInExpansionFile; |
34 |
this.type=type;
|
35 |
} |
36 |
/**
|
37 |
* @throws DriverIOException
|
38 |
* @throws IOException
|
39 |
* @see com.iver.cit.gvsig.fmap.edition.Command#undo()
|
40 |
*/
|
41 |
public void undo() throws EditionCommandException { |
42 |
previousIndexInExpansionFile=efs.undoModifyRow(calculatedIndexAnt,previousIndexInExpansionFile,type); |
43 |
} |
44 |
/**
|
45 |
* @throws DriverIOException
|
46 |
* @throws IOException
|
47 |
* @see com.iver.cit.gvsig.fmap.edition.Command#redo()
|
48 |
*/
|
49 |
public void redo() throws EditionCommandException { |
50 |
try {
|
51 |
previousIndexInExpansionFile=efs.doModifyRow(calculatedIndexAnt,rowNext,type); |
52 |
} catch (ExpansionFileWriteException e) {
|
53 |
throw new EditionCommandException(efs.getWriter().getName(),e); |
54 |
} catch (ReadDriverException e) {
|
55 |
throw new EditionCommandException(efs.getWriter().getName(),e); |
56 |
} |
57 |
} |
58 |
public String getType() { |
59 |
return "Modify"; |
60 |
} |
61 |
} |