01: /*
02: * uDig - User Friendly Desktop Internet GIS client
03: * http://udig.refractions.net
04: * (C) 2004, Refractions Research Inc.
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library 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 GNU
14: * Lesser General Public License for more details.
15: *
16: */
17: package net.refractions.udig.project.ui.internal;
18:
19: import java.io.IOException;
20:
21: import org.eclipse.core.runtime.IStatus;
22: import org.eclipse.core.runtime.Status;
23: import org.eclipse.jface.action.IAction;
24: import org.eclipse.jface.viewers.ISelection;
25: import org.eclipse.ui.IEditorActionDelegate;
26: import org.eclipse.ui.IEditorPart;
27:
28: /**
29: * Provides ...TODO summary sentence
30: * <p>
31: * TODO Description
32: * </p>
33: * <p>
34: * Responsibilities:
35: * <ul>
36: * <li>
37: * <li>
38: * </ul>
39: * </p>
40: * <p>
41: * Example Use:
42: *
43: * <pre><code>
44: * RollbackAction x = new RollbackAction( ... );
45: * TODO code example
46: * </code></pre>
47: *
48: * </p>
49: *
50: * @author jones
51: * @since 0.3
52: */
53: public class RollbackAction implements IEditorActionDelegate {
54: private MapEditor editor;
55:
56: /**
57: * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction,
58: * org.eclipse.ui.IEditorPart)
59: */
60: public void setActiveEditor(IAction action, IEditorPart targetEditor) {
61: editor = (MapEditor) targetEditor;
62: }
63:
64: /**
65: * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
66: */
67: public void run(IAction action) {
68: try {
69: editor.getMap().getEditManagerInternal()
70: .rollbackTransaction();
71: } catch (IOException e) {
72: // Shouldn't happen but...
73: ProjectUIPlugin
74: .getDefault()
75: .getLog()
76: .log(
77: new Status(
78: IStatus.ERROR,
79: "net.refractions.udig.project", 0, "Error commiting transaction", e)); //$NON-NLS-1$ //$NON-NLS-2$
80: }
81: }
82:
83: /**
84: * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
85: * org.eclipse.jface.viewers.ISelection)
86: */
87: public void selectionChanged(IAction action, ISelection selection) {
88: // do nothing
89: }
90:
91: }
|