1 11 12 package org.eclipse.ui.views.bookmarkexplorer; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.resources.IMarker; 16 import org.eclipse.core.resources.IResource; 17 import org.eclipse.jface.viewers.IStructuredSelection; 18 import org.eclipse.ui.PlatformUI; 19 import org.eclipse.ui.internal.views.bookmarkexplorer.BookmarkMessages; 20 21 24 class EditBookmarkAction extends BookmarkAction { 25 26 protected EditBookmarkAction(BookmarkNavigator view) { 27 super(view, BookmarkMessages.Properties_text); 28 PlatformUI.getWorkbench().getHelpSystem().setHelp(this, 29 IBookmarkHelpContextIds.BOOKMARK_PROPERTIES_ACTION); 30 setEnabled(false); 31 } 32 33 private IMarker marker; 34 35 public void run() { 36 if (marker != null) { 37 editBookmark(); 38 } 39 } 40 41 47 public void selectionChanged(IStructuredSelection selection) { 48 marker = null; 49 setEnabled(false); 50 51 if (selection.size() != 1) { 52 return; 53 } 54 55 Object o = selection.getFirstElement(); 56 if (!(o instanceof IMarker)) { 57 return; 58 } 59 60 IMarker selectedMarker = (IMarker) o; 61 IResource resource = selectedMarker.getResource(); 62 if (resource instanceof IFile) { 63 marker = selectedMarker; 64 setEnabled(true); 65 } 66 } 67 68 private void editBookmark() { 69 BookmarkPropertiesDialog dialog = new BookmarkPropertiesDialog( 70 getView().getSite().getShell()); 71 dialog.setMarker(marker); 72 dialog.open(); 73 } 74 } 75 | Popular Tags |