1 11 12 package org.eclipse.ui.views.bookmarkexplorer; 13 14 import java.util.List ; 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 27 class RemoveBookmarkAction extends BookmarkAction { 28 29 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 45 public void run() { 46 final IStructuredSelection sel = getStructuredSelection(); 47 if (sel.isEmpty()) { 48 return; 49 } 50 List 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 |