KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.List JavaDoc;
15
16 import org.eclipse.core.commands.operations.IUndoableOperation;
17 import org.eclipse.core.resources.IMarker;
18 import org.eclipse.jface.viewers.IStructuredSelection;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
21 import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
22 import org.eclipse.ui.internal.views.bookmarkexplorer.BookmarkMessages;
23
24 /**
25  * Action to remove the selected bookmarks.
26  */

27 class RemoveBookmarkAction extends BookmarkAction {
28
29     /**
30      * Create a new instance of this class.
31      *
32      * @param view the view
33      */

34     public RemoveBookmarkAction(BookmarkNavigator view) {
35         super(view, BookmarkMessages.RemoveBookmark_text);
36         setToolTipText(BookmarkMessages.RemoveBookmark_toolTip);
37         PlatformUI.getWorkbench().getHelpSystem().setHelp(this,
38                 IBookmarkHelpContextIds.REMOVE_BOOKMARK_ACTION);
39         setEnabled(false);
40     }
41
42     /**
43      * Delete the marker selection.
44      */

45     public void run() {
46         final IStructuredSelection sel = getStructuredSelection();
47         if (sel.isEmpty()) {
48             return;
49         }
50         List JavaDoc list = sel.toList();
51         IMarker[] markers = new IMarker[list.size()];
52         list.toArray(markers);
53         IUndoableOperation op = new DeleteMarkersOperation(markers, BookmarkMessages.RemoveBookmark_undoText);
54         execute(op, BookmarkMessages.RemoveBookmark_errorTitle, null,
55                 WorkspaceUndoUtil.getUIInfoAdapter(getView().getShell()));
56     }
57
58     public void selectionChanged(IStructuredSelection sel) {
59         setEnabled(!sel.isEmpty());
60     }
61 }
62
Popular Tags