Problem视图增加Marker

首先,需要得到Problems视图窗口: IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); IViewReference problemView = page.findViewReference(IPageLayout.ID_PROBLEM_VIEW); 其次,要向Problem View里写message, 需要创建相应的Marker。 参考代码如下: /** * Problem marker id */ public static final String PROBLEMS_MARKER_ID = "org.eclipse.core.resources.problemmarker"; public static void addMarker( IResource resource, String message, int lineNumber, int severity, int priority ) throws CoreException { if ( resource != null ) { IMarker marker = resource.createMarker( PROBLEMS_MARKER_ID ); if ( message != null ) marker.setAttribute( IMarker.MESSAGE, message ); if ( lineNumber >= 0 ) marker.setAttribute( IMarker.LINE_NUMBER, lineNumber ); marker.setAttribute( IMarker.SEVERITY, severity ); marker.setAttribute( IMarker.PRIORITY, priority ); } }

你可能感兴趣的:(eclipse)