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: * CommitAction x = new CommitAction( ... );
45: * TODO code example
46: * </code></pre>
47: *
48: * </p>
49: *
50: * @author jones
51: * @since 0.3
52: */
53: public class CommitAction implements IEditorActionDelegate {
54:
55: private MapEditor editor;
56:
57: /**
58: * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction,
59: * org.eclipse.ui.IEditorPart)
60: */
61: public void setActiveEditor(IAction action, IEditorPart targetEditor) {
62: editor = (MapEditor) targetEditor;
63: }
64:
65: /**
66: * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
67: */
68: public void run(IAction action) {
69: try {
70: editor.getMap().getEditManagerInternal()
71: .commitTransaction();
72: } catch (IOException e) {
73: // Shouldn't happen but...
74: ProjectUIPlugin
75: .getDefault()
76: .getLog()
77: .log(
78: new Status(
79: IStatus.ERROR,
80: "net.refractions.udig.project", 0, "Error commiting transaction", e)); //$NON-NLS-1$ //$NON-NLS-2$
81: }
82: }
83:
84: /**
85: * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
86: * org.eclipse.jface.viewers.ISelection)
87: */
88: public void selectionChanged(IAction action, ISelection selection) {
89: // do nothing
90: }
91:
92: }
|