Statistics
| Revision:

svn-gvsig-desktop / tags / J2ME_compat_v1_2_Build_1209 / libraries / libFMap / src / com / iver / cit / gvsig / fmap / edition / commands / AddRowCommand.java @ 19509

History | View | Annotate | Download (1.59 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
/**
14
 * A?ade una geometr?a nueva al EditableFeatureSource
15
 */
16
public class AddRowCommand extends AbstractCommand {
17
        private IRow row;
18
        private int calculatedIndex;
19
        private EditableAdapter efs;
20
        private int sourceType=EditionEvent.GRAPHIC;
21

    
22
        public AddRowCommand(EditableAdapter ef, IRow row, int calculatedIndex, int sourceType) {
23
                super();
24
                efs = ef;
25
                this.calculatedIndex = calculatedIndex;
26
                this.row = row;
27
                this.sourceType=sourceType;
28
        }
29

    
30
        /**
31
         * @throws IOException
32
         * @throws DriverIOException
33
         * @see com.iver.cit.gvsig.fmap.edition.Command#undo()
34
         */
35
        public void undo() throws EditionCommandException {
36
                efs.undoAddRow(calculatedIndex, sourceType);
37
        }
38

    
39
        /**
40
         * @throws IOException
41
         * @throws DriverIOException
42
         * @see com.iver.cit.gvsig.fmap.edition.Command#redo()
43
         */
44
        public void redo() throws EditionCommandException {
45
                try {
46
                        calculatedIndex=efs.doAddRow(row, sourceType);
47
                } catch (ReadDriverException e) {
48
                        throw new EditionCommandException(efs.getWriter().getName(),e);
49
                } 
50
        }
51

    
52
        public String getType() {
53
                return "Add";
54
        }
55
}