01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.tools.edit.commands;
16:
17: import net.refractions.udig.project.command.AbstractCommand;
18: import net.refractions.udig.project.command.UndoableCommand;
19: import net.refractions.udig.project.ui.render.displayAdapter.ViewportPane;
20: import net.refractions.udig.tool.edit.internal.Messages;
21: import net.refractions.udig.tools.edit.support.EditBlackboard;
22: import net.refractions.udig.tools.edit.support.Selection;
23:
24: import org.eclipse.core.runtime.IProgressMonitor;
25:
26: /**
27: * Moves a selection on the edit blackboard.
28: *
29: * @author Jesse
30: * @since 1.1.0
31: */
32: public class MoveSelectionCommand extends AbstractCommand implements
33: UndoableCommand {
34:
35: private int deltaX;
36: private int deltaY;
37: private EditBlackboard editBlackboard;
38: private Selection selection;
39:
40: public MoveSelectionCommand(EditBlackboard editBlackboard,
41: int deltaX, int deltaY, Selection toMove) {
42: this .editBlackboard = editBlackboard;
43: this .deltaX = deltaX;
44: this .deltaY = deltaY;
45: this .selection = toMove;
46: }
47:
48: public void rollback(IProgressMonitor monitor) throws Exception {
49: editBlackboard.moveSelection(-deltaX, -deltaY, selection);
50: ((ViewportPane) getMap().getRenderManagerInternal()
51: .getMapDisplay()).repaint();
52: }
53:
54: public void run(IProgressMonitor monitor) throws Exception {
55: editBlackboard.moveSelection(deltaX, deltaY, selection);
56: ((ViewportPane) getMap().getRenderManagerInternal()
57: .getMapDisplay()).repaint();
58: }
59:
60: public String getName() {
61: return Messages.MoveSelectionCommand_name;
62: }
63:
64: }
|