1 11 12 package org.eclipse.ui.views.markers.internal; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.core.resources.IMarker; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.jface.viewers.ISelectionProvider; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.ui.IEditorPart; 20 import org.eclipse.ui.IWorkbenchPart; 21 import org.eclipse.ui.ide.IDE; 22 import org.eclipse.ui.ide.ResourceUtil; 23 24 29 public class ActionRevealMarker extends MarkerSelectionProviderAction { 30 31 protected IWorkbenchPart part; 32 33 38 public ActionRevealMarker(IWorkbenchPart part, ISelectionProvider provider) { 39 super(provider, Util.EMPTY_STRING); 40 this.part = part; 41 } 42 43 48 public void run() { 49 50 IEditorPart editor = part.getSite().getPage().getActiveEditor(); 51 if (editor == null) { 52 return; 53 } 54 IFile file = ResourceUtil.getFile(editor.getEditorInput()); 55 if (file != null) { 56 IMarker marker = getSelectedMarker(); 57 if (marker.getResource().equals(file)) { 58 try { 59 IDE.openEditor(part.getSite().getPage(), 60 marker, false); 61 } catch (CoreException e) { 62 } 63 } 64 } 65 } 66 67 70 public void selectionChanged(IStructuredSelection selection) { 71 setEnabled(Util.isSingleConcreteSelection(selection)); 72 } 73 } 74 | Popular Tags |