try {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IViewPart view = null;
if (marker.isSubtypeOf(IMarker.PROBLEM)) {
view = page.findView(IPageLayout.ID_PROBLEM_VIEW);
}
else if (marker.isSubtypeOf(IMarker.TASK)) {
view = page.findView(IPageLayout.ID_TASK_LIST);
}
else if (marker.isSubtypeOf(IMarker.BOOKMARK)) {
view = page.findView(IPageLayout.ID_BOOKMARKS);
}
// else if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
// view = page.findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
// }
if (view == null) {
view = page.findView("org.eclipse.ui.views.AllMarkersView");
}
// If the view isn't open on this perspective, don't
// interact with it
if (view != null) {
Method method = view.getClass().getMethod("setSelection", new Class[]{IStructuredSelection.class, boolean.class}); //$NON-NLS-1$
if (method != null) {
method.invoke(view, new Object[]{new StructuredSelection(marker), Boolean.TRUE});
page.bringToTop(view);
}
}