1 11 12 package org.eclipse.ui.views.markers; 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.core.runtime.CoreException; 16 import org.eclipse.jface.viewers.StructuredSelection; 17 import org.eclipse.ui.IPageLayout; 18 import org.eclipse.ui.IViewPart; 19 import org.eclipse.ui.IWorkbenchPage; 20 import org.eclipse.ui.views.markers.internal.MarkerView; 21 22 25 public class MarkerViewUtil { 26 27 34 public static final String PATH_ATTRIBUTE = "org.eclipse.ui.views.markers.path"; 36 43 public static final String NAME_ATTRIBUTE = "org.eclipse.ui.views.markers.name"; 45 53 public static String getViewId(IMarker marker) throws CoreException { 54 if (marker.isSubtypeOf(IMarker.TASK)) { 55 return IPageLayout.ID_TASK_LIST; 56 } else if (marker.isSubtypeOf(IMarker.PROBLEM)) { 57 return IPageLayout.ID_PROBLEM_VIEW; 58 } else if (marker.isSubtypeOf(IMarker.BOOKMARK)) { 59 return IPageLayout.ID_BOOKMARKS; 60 } 61 return null; 62 } 63 64 76 public static boolean showMarker(IWorkbenchPage page, IMarker marker, 77 boolean showView) { 78 try { 79 String viewId = getViewId(marker); 80 if (viewId != null) { 81 IViewPart view = showView ? page.showView(viewId) : page 82 .findView(viewId); 83 if (view instanceof MarkerView) { 84 StructuredSelection selection = new StructuredSelection( 85 marker); 86 MarkerView markerView = (MarkerView) view; 87 markerView.setSelection(selection, true); 88 return true; 89 90 } 92 } 93 } catch (CoreException e) { 94 } 96 return false; 97 } 98 99 } 100 | Popular Tags |