Revision 24346 branches/v2_0_0_prep/libraries/libFMap_data/src/org/gvsig/fmap/data/feature/impl/commands/implementation/SelectionCommandSelect.java

View differences:

SelectionCommandSelect.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
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 2
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
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {Implement data selection}
26
 */
1 27
package org.gvsig.fmap.data.feature.impl.commands.implementation;
2 28

  
29
import org.gvsig.fmap.data.exceptions.DataException;
3 30
import org.gvsig.fmap.data.feature.FeatureReference;
4 31
import org.gvsig.fmap.data.feature.FeatureReferenceSelection;
5 32
import org.gvsig.fmap.data.feature.impl.commands.AbstractCommand;
6
import org.gvsig.tools.exception.NotYetImplemented;
7 33

  
34
/**
35
 * Command to allow undo and redo over a select or deselect operation performed
36
 * on a selection.
37
 * 
38
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
39
 */
8 40
public class SelectionCommandSelect extends AbstractCommand {
9 41

  
10
	public SelectionCommandSelect(FeatureReferenceSelection selection,
11
			FeatureReference reference, boolean b) {
12
		// TODO Auto-generated constructor stub
13
		throw new NotYetImplemented();
42
	private final FeatureReferenceSelection selection;
43
    private final FeatureReference reference;
44
    private final boolean select;
45

  
46
    public SelectionCommandSelect(FeatureReferenceSelection selection,
47
            FeatureReference reference, boolean select) {
48
        this.selection = selection;
49
        this.reference = reference;
50
        this.select = select;
14 51
	}
15 52

  
16 53
	public void execute() {
17
		// TODO Auto-generated method stub
18

  
54
	    // Nothing to do
19 55
	}
20 56

  
21 57
	public String getType() {
22
		// TODO Auto-generated method stub
23
		return null;
58
		return select ? "selectionSelect" : "selectionDeselect";
24 59
	}
60
	
61
	public void undo() throws DataException {
62
        performSelection(!select);
63
    }
25 64

  
26
	public void redo() {
27
		// TODO Auto-generated method stub
28

  
65
	public void redo() throws DataException {
66
        performSelection(select);
29 67
	}
30 68

  
31
	public void undo() {
32
		// TODO Auto-generated method stub
33

  
34
	}
35

  
36
}
69
    private void performSelection(boolean doSelection) {
70
        if (doSelection) {
71
            selection.select(reference);
72
        } else {
73
            selection.deselect(reference);
74
        }
75
    }
76
}

Also available in: Unified diff