/** * Connect the CompilationUnitDocumentProvider to the * * @input and connect the annotation model from the provider to the IDocument of the * @input. */ protected void connect(IEditorInput input, ICompilationUnit cu) throws CoreException { if (input != null && javaWorkingCopyManager != null && cuDocumentProvider != null ) { javaWorkingCopyManager.connect(input); getEditorInputs().put(cu, input); IDocument doc = cuDocumentProvider.getDocument(input); if (doc != null && cuDocumentProvider.getAnnotationModel(input)!= null) cuDocumentProvider.getAnnotationModel(input).connect(doc); } }
/** * Disonnect the CompilationUnitDocumentProvider from the * * @input and disconnect the annotation model from the provider from the IDocument of the * @input. */ protected void disconnect(IEditorInput input) { IDocument doc = cuDocumentProvider.getDocument(input); cuDocumentProvider.getAnnotationModel(input).disconnect(doc); javaWorkingCopyManager.disconnect(input); }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
protected void revert(IEditorInput input) { try { cuDocumentProvider.resetDocument(input); } catch (CoreException e) { Logger.getLogger().logError(e); } IDocument doc = cuDocumentProvider.getDocument(input); IAnnotationModel model = cuDocumentProvider.getAnnotationModel(input); if (model instanceof AbstractMarkerAnnotationModel) { AbstractMarkerAnnotationModel markerModel = (AbstractMarkerAnnotationModel) model; markerModel.resetMarkers(); } model.disconnect(doc); javaWorkingCopyManager.disconnect(input); }
private static IProblemLocation findProblemLocation(IEditorInput input, IMarker marker) { IAnnotationModel model= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(input); if (model != null) { // open in editor Iterator iter= model.getAnnotationIterator(); while (iter.hasNext()) { Object curr= iter.next(); if (curr instanceof JavaMarkerAnnotation) { JavaMarkerAnnotation annot= (JavaMarkerAnnotation) curr; if (marker.equals(annot.getMarker())) { Position pos= model.getPosition(annot); if (pos != null) { return new ProblemLocation(pos.getOffset(), pos.getLength(), annot); } } } } } else { // not open in editor ICompilationUnit cu= getCompilationUnit(marker); return createFromMarker(marker, cu); } return null; }
private static IProblemLocation findProblemLocation(IEditorInput input, IMarker marker) { IAnnotationModel model= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(input); if (model != null) { // open in editor Iterator<Annotation> iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation curr= iter.next(); if (curr instanceof JavaMarkerAnnotation) { JavaMarkerAnnotation annot= (JavaMarkerAnnotation) curr; if (marker.equals(annot.getMarker())) { Position pos= model.getPosition(annot); if (pos != null) { return new ProblemLocation(pos.getOffset(), pos.getLength(), annot); } } } } } else { // not open in editor ICompilationUnit cu= getCompilationUnit(marker); return createFromMarker(marker, cu); } return null; }
public static IProblemLocation findProblemLocation(IEditorInput input, IMarker marker) { if (marker.getResource() instanceof IFolder) { ICompilationUnit cu= getCompilationUnit(marker); return createFromMarker(marker, cu); } IAnnotationModel model= JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(input); if (model != null) { // open in editor Iterator<Annotation> iter= model.getAnnotationIterator(); while (iter.hasNext()) { Annotation curr= iter.next(); if (curr instanceof JavaMarkerAnnotation) { JavaMarkerAnnotation annot= (JavaMarkerAnnotation) curr; if (marker.equals(annot.getMarker())) { Position pos= model.getPosition(annot); if (pos != null) { return new ProblemLocation(pos.getOffset(), pos.getLength(), annot); } } } } } else { // not open in editor ICompilationUnit cu= getCompilationUnit(marker); return createFromMarker(marker, cu); } return null; }