root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / commands / AddRowCommand.java @ 10627
History | View | Annotate | Download (1.7 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 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
13 |
|
14 |
/**
|
15 |
* A?ade una geometr?a nueva al EditableFeatureSource
|
16 |
*/
|
17 |
public class AddRowCommand extends AbstractCommand { |
18 |
private IRow row;
|
19 |
private int calculatedIndex; |
20 |
private EditableAdapter efs;
|
21 |
private int sourceType=EditionEvent.GRAPHIC; |
22 |
|
23 |
public AddRowCommand(EditableAdapter ef, IRow row, int calculatedIndex, int sourceType) { |
24 |
super();
|
25 |
efs = ef; |
26 |
this.calculatedIndex = calculatedIndex;
|
27 |
this.row = row;
|
28 |
this.sourceType=sourceType;
|
29 |
} |
30 |
|
31 |
/**
|
32 |
* @throws IOException
|
33 |
* @throws DriverIOException
|
34 |
* @see com.iver.cit.gvsig.fmap.edition.Command#undo()
|
35 |
*/
|
36 |
public void undo() throws EditionCommandException { |
37 |
efs.undoAddRow(calculatedIndex, sourceType); |
38 |
} |
39 |
|
40 |
/**
|
41 |
* @throws IOException
|
42 |
* @throws DriverIOException
|
43 |
* @see com.iver.cit.gvsig.fmap.edition.Command#redo()
|
44 |
*/
|
45 |
public void redo() throws EditionCommandException { |
46 |
try {
|
47 |
calculatedIndex=efs.doAddRow(row, sourceType); |
48 |
} catch (ReadDriverException e) {
|
49 |
throw new EditionCommandException(efs.getWriter().getName(),e); |
50 |
} catch (ExpansionFileWriteException e) {
|
51 |
throw new EditionCommandException(efs.getWriter().getName(),e); |
52 |
} |
53 |
} |
54 |
|
55 |
public String getType() { |
56 |
return "Add"; |
57 |
} |
58 |
} |