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