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 java.util.List;
13:
14: import org.eclipse.core.commands.operations.IUndoableOperation;
15: import org.eclipse.core.resources.IMarker;
16: import org.eclipse.jface.viewers.IStructuredSelection;
17: import org.eclipse.ui.PlatformUI;
18: import org.eclipse.ui.ide.undo.DeleteMarkersOperation;
19: import org.eclipse.ui.ide.undo.WorkspaceUndoUtil;
20: import org.eclipse.ui.internal.views.bookmarkexplorer.BookmarkMessages;
21:
22: /**
23: * Action to remove the selected bookmarks.
24: */
25: class RemoveBookmarkAction extends BookmarkAction {
26:
27: /**
28: * Create a new instance of this class.
29: *
30: * @param view the view
31: */
32: public RemoveBookmarkAction(BookmarkNavigator view) {
33: super (view, BookmarkMessages.RemoveBookmark_text);
34: setToolTipText(BookmarkMessages.RemoveBookmark_toolTip);
35: PlatformUI.getWorkbench().getHelpSystem().setHelp(this ,
36: IBookmarkHelpContextIds.REMOVE_BOOKMARK_ACTION);
37: setEnabled(false);
38: }
39:
40: /**
41: * Delete the marker selection.
42: */
43: public void run() {
44: final IStructuredSelection sel = getStructuredSelection();
45: if (sel.isEmpty()) {
46: return;
47: }
48: List list = sel.toList();
49: IMarker[] markers = new IMarker[list.size()];
50: list.toArray(markers);
51: IUndoableOperation op = new DeleteMarkersOperation(markers,
52: BookmarkMessages.RemoveBookmark_undoText);
53: execute(op, BookmarkMessages.RemoveBookmark_errorTitle, null,
54: WorkspaceUndoUtil
55: .getUIInfoAdapter(getView().getShell()));
56: }
57:
58: public void selectionChanged(IStructuredSelection sel) {
59: setEnabled(!sel.isEmpty());
60: }
61: }
|