01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.views.bookmarkexplorer;
11:
12: import org.eclipse.core.commands.ExecutionException;
13: import org.eclipse.core.commands.operations.IUndoableOperation;
14: import org.eclipse.core.runtime.CoreException;
15: import org.eclipse.core.runtime.IAdaptable;
16: import org.eclipse.core.runtime.IProgressMonitor;
17: import org.eclipse.jface.dialogs.ErrorDialog;
18: import org.eclipse.ui.PlatformUI;
19: import org.eclipse.ui.actions.SelectionProviderAction;
20: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
21:
22: /**
23: * An abstract class for all bookmark view actions.
24: */
25: abstract class BookmarkAction extends SelectionProviderAction {
26: private BookmarkNavigator view;
27:
28: /**
29: * Creates a bookmark action.
30: */
31: protected BookmarkAction(BookmarkNavigator view, String label) {
32: super (view.getViewer(), label);
33: this .view = view;
34: }
35:
36: /**
37: * Returns the bookmarks view.
38: */
39: public BookmarkNavigator getView() {
40: return view;
41: }
42:
43: /**
44: * Execute the specified undoable operation
45: */
46: void execute(IUndoableOperation operation, String title,
47: IProgressMonitor monitor, IAdaptable uiInfo) {
48: try {
49: PlatformUI.getWorkbench().getOperationSupport()
50: .getOperationHistory().execute(operation, monitor,
51: uiInfo);
52: } catch (ExecutionException e) {
53: if (e.getCause() instanceof CoreException) {
54: ErrorDialog.openError(view.getShell(), title, null,
55: ((CoreException) e.getCause()).getStatus());
56: } else {
57: IDEWorkbenchPlugin.log(title, e);
58: }
59: }
60: }
61:
62: }
|