KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > bookmarkexplorer > BookmarkAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.views.bookmarkexplorer;
13
14 import org.eclipse.core.commands.ExecutionException;
15 import org.eclipse.core.commands.operations.IUndoableOperation;
16 import org.eclipse.core.runtime.CoreException;
17 import org.eclipse.core.runtime.IAdaptable;
18 import org.eclipse.core.runtime.IProgressMonitor;
19 import org.eclipse.jface.dialogs.ErrorDialog;
20 import org.eclipse.ui.PlatformUI;
21 import org.eclipse.ui.actions.SelectionProviderAction;
22 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
23
24 /**
25  * An abstract class for all bookmark view actions.
26  */

27 abstract class BookmarkAction extends SelectionProviderAction {
28     private BookmarkNavigator view;
29
30     /**
31      * Creates a bookmark action.
32      */

33     protected BookmarkAction(BookmarkNavigator view, String JavaDoc label) {
34         super(view.getViewer(), label);
35         this.view = view;
36     }
37
38     /**
39      * Returns the bookmarks view.
40      */

41     public BookmarkNavigator getView() {
42         return view;
43     }
44     
45     /**
46      * Execute the specified undoable operation
47      */

48     void execute(IUndoableOperation operation, String JavaDoc title,
49             IProgressMonitor monitor, IAdaptable uiInfo) {
50         try {
51             PlatformUI.getWorkbench().getOperationSupport()
52                     .getOperationHistory().execute(operation, monitor, uiInfo);
53         } catch (ExecutionException e) {
54             if (e.getCause() instanceof CoreException) {
55                ErrorDialog.openError(view.getShell(), title,
56                         null, ((CoreException)e.getCause()).getStatus());
57             } else {
58                 IDEWorkbenchPlugin.log(title, e);
59             }
60         }
61     }
62
63 }
64
Popular Tags