svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / feature / impl / undo / command / SelectionCommandSet.java @ 40559
History | View | Annotate | Download (2.59 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2008 {DiSiD Technologies} {Implement data selection}
|
27 |
*/
|
28 |
package org.gvsig.fmap.dal.feature.impl.undo.command; |
29 |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
31 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
32 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
33 |
import org.gvsig.tools.undo.RedoException; |
34 |
import org.gvsig.tools.undo.UndoException; |
35 |
import org.gvsig.tools.undo.command.impl.AbstractCommand; |
36 |
|
37 |
/**
|
38 |
* Command to allow undo and redo over a set selection operation performed on a
|
39 |
* store.
|
40 |
*
|
41 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
42 |
*/
|
43 |
public class SelectionCommandSet extends AbstractCommand { |
44 |
|
45 |
private final FeatureSelection oldSelection; |
46 |
private final FeatureSelection newSelection; |
47 |
private final DefaultFeatureStore store; |
48 |
|
49 |
public SelectionCommandSet(DefaultFeatureStore store,
|
50 |
FeatureSelection oldSelection, FeatureSelection newSelection, |
51 |
String description) {
|
52 |
super(description);
|
53 |
this.store = store;
|
54 |
this.oldSelection = oldSelection;
|
55 |
this.newSelection = newSelection;
|
56 |
} |
57 |
|
58 |
public void execute() { |
59 |
// Nothing to do
|
60 |
} |
61 |
|
62 |
public int getType() { |
63 |
return UPDATE;
|
64 |
} |
65 |
|
66 |
public void undo() throws UndoException { |
67 |
try {
|
68 |
store.setSelection(oldSelection, false);
|
69 |
} catch (DataException ex) {
|
70 |
throw new UndoException(this, ex); |
71 |
} |
72 |
} |
73 |
|
74 |
public void redo() throws RedoException { |
75 |
try {
|
76 |
store.setSelection(newSelection, false);
|
77 |
} catch (DataException ex) {
|
78 |
throw new RedoException(this, ex); |
79 |
} |
80 |
} |
81 |
} |