Search in sources :

Example 1 with SimpleMarkerAnnotation

use of org.eclipse.ui.texteditor.SimpleMarkerAnnotation in project webtools.sourceediting by eclipse.

the class GotoAnnotationAction method updateAnnotationViews.

/**
 * Updates the annotation views that show the given annotation.
 *
 * @param annotation
 *            the annotation
 */
protected void updateAnnotationViews(Annotation annotation) {
    IMarker marker = null;
    if (annotation instanceof SimpleMarkerAnnotation)
        marker = ((SimpleMarkerAnnotation) annotation).getMarker();
    if (marker != null) {
        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);
                    }
                    if (view == null) {
                        view = page.findView("org.eclipse.ui.views.AllMarkersView");
                    }
                    // interact with it
                    if (view != null) {
                        // $NON-NLS-1$
                        Method method = view.getClass().getMethod("setSelection", new Class[] { IStructuredSelection.class, boolean.class });
                        if (method != null) {
                            method.invoke(view, new Object[] { new StructuredSelection(marker), Boolean.TRUE });
                            page.bringToTop(view);
                        }
                    }
                }
            }
        }// statusline
         catch (CoreException x) {
        // 
        } catch (NoSuchMethodException x) {
        // 
        } catch (IllegalAccessException x) {
        // 
        } catch (InvocationTargetException x) {
        // 
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) CoreException(org.eclipse.core.runtime.CoreException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IMarker(org.eclipse.core.resources.IMarker) Method(java.lang.reflect.Method) SimpleMarkerAnnotation(org.eclipse.ui.texteditor.SimpleMarkerAnnotation) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 IMarker (org.eclipse.core.resources.IMarker)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IViewPart (org.eclipse.ui.IViewPart)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 SimpleMarkerAnnotation (org.eclipse.ui.texteditor.SimpleMarkerAnnotation)1