本文整理汇总了Java中org.eclipse.ui.texteditor.IDocumentProvider.getAnnotationModel方法的典型用法代码示例。如果您正苦于以下问题:Java IDocumentProvider.getAnnotationModel方法的具体用法?Java IDocumentProvider.getAnnotationModel怎么用?Java IDocumentProvider.getAnnotationModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.texteditor.IDocumentProvider
的用法示例。
在下文中一共展示了IDocumentProvider.getAnnotationModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attach
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* Attaches a coverage annotation model for the given editor if the editor can
* be annotated. Does nothing if the model is already attached.
*
* @param editor
* Editor to attach a annotation model to
*/
public static void attach(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
// there may be text editors without document providers (SF #1725100)
if (provider == null)
return;
IAnnotationModel model = provider.getAnnotationModel(editor
.getEditorInput());
if (!(model instanceof IAnnotationModelExtension))
return;
IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
IDocument document = provider.getDocument(editor.getEditorInput());
CoverageAnnotationModel coveragemodel = (CoverageAnnotationModel) modelex
.getAnnotationModel(KEY);
if (coveragemodel == null) {
coveragemodel = new CoverageAnnotationModel(editor, document);
modelex.addAnnotationModel(KEY, coveragemodel);
}
}
示例2: initializeSourceViewer
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void initializeSourceViewer(final IEditorInput input) {
final IDocumentProvider documentProvider = getDocumentProvider();
final IAnnotationModel model = documentProvider.getAnnotationModel(input);
final IDocument document = documentProvider.getDocument(input);
if (document != null) {
fSourceViewer.setDocument(document, model);
fSourceViewer.setEditable(isEditable());
fSourceViewer.showAnnotations(model != null);
}
if (fElementStateListener instanceof IElementStateListenerExtension) {
boolean isStateValidated = false;
if (documentProvider instanceof IDocumentProviderExtension)
isStateValidated = ((IDocumentProviderExtension) documentProvider).isStateValidated(input);
final IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
extension.elementStateValidationChanged(input, isStateValidated);
}
}
示例3: initializeSourceViewer
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void initializeSourceViewer(IEditorInput input) {
IDocumentProvider documentProvider = getDocumentProvider();
IAnnotationModel model = documentProvider.getAnnotationModel(input);
IDocument document = documentProvider.getDocument(input);
if (document != null) {
fSourceViewer.setDocument(document, model);
fSourceViewer.setEditable(isEditable());
fSourceViewer.showAnnotations(model != null);
}
if (fElementStateListener instanceof IElementStateListenerExtension) {
boolean isStateValidated = false;
if (documentProvider instanceof IDocumentProviderExtension)
isStateValidated = ((IDocumentProviderExtension) documentProvider)
.isStateValidated(input);
IElementStateListenerExtension extension = (IElementStateListenerExtension) fElementStateListener;
extension.elementStateValidationChanged(input, isStateValidated);
}
}
示例4: removeOccurrenceAnnotations
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private void removeOccurrenceAnnotations() {
// fMarkOccurrenceModificationStamp=
// IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
// fMarkOccurrenceTargetRegion= null;
IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider == null)
return;
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null || fOccurrenceAnnotations == null)
return;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
} else {
for (int i = 0, length = fOccurrenceAnnotations.length; i < length; i++)
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
}
fOccurrenceAnnotations = null;
}
}
示例5: getGWTProblemsInEditor
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private List<GWTJavaProblem> getGWTProblemsInEditor(CompilationUnitEditor editor)
throws Exception {
List<GWTJavaProblem> problems = new ArrayList<GWTJavaProblem>();
Field annotationProblemField = CompilationUnitDocumentProvider.ProblemAnnotation.class.getDeclaredField("fProblem");
annotationProblemField.setAccessible(true);
IEditorInput editorInput = editor.getEditorInput();
IDocumentProvider documentProvider = editor.getDocumentProvider();
IAnnotationModel annotationModel = documentProvider.getAnnotationModel(editorInput);
Iterator<?> iter = annotationModel.getAnnotationIterator();
while (iter.hasNext()) {
Object annotation = iter.next();
if (annotation instanceof CompilationUnitDocumentProvider.ProblemAnnotation) {
CompilationUnitDocumentProvider.ProblemAnnotation problemAnnotation = (ProblemAnnotation) annotation;
if (problemAnnotation.getMarkerType().equals(GWTJavaProblem.MARKER_ID)) {
GWTJavaProblem problem = (GWTJavaProblem) annotationProblemField.get(problemAnnotation);
problems.add(problem);
}
}
}
return problems;
}
示例6: removeOccurrenceAnnotations
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
void removeOccurrenceAnnotations() {
fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
fMarkOccurrenceTargetRegion= null;
IDocumentProvider documentProvider= getDocumentProvider();
if (documentProvider == null)
return;
IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null || fOccurrenceAnnotations == null)
return;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
} else {
for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
}
fOccurrenceAnnotations= null;
}
}
示例7: detach
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* Detaches the coverage annotation model from the given editor. If the editor
* does not have a model attached, this method does nothing.
*
* @param editor
* Editor to detach the annotation model from
*/
public static void detach(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
// there may be text editors without document providers (SF #1725100)
if (provider == null)
return;
IAnnotationModel model = provider.getAnnotationModel(editor
.getEditorInput());
if (!(model instanceof IAnnotationModelExtension))
return;
IAnnotationModelExtension modelex = (IAnnotationModelExtension) model;
modelex.removeAnnotationModel(KEY);
}
示例8: getAnnotationModel
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private AbstractMarkerAnnotationModel getAnnotationModel(ITextEditor editor) {
IDocumentProvider provider = editor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel(editor.getEditorInput());
if (model instanceof AbstractMarkerAnnotationModel)
return (AbstractMarkerAnnotationModel) model;
return null;
}
示例9: getProblemRequestorExtension
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* Returns the problem requestor for the editor's input element.
*
* @return the problem requestor for the editor's input element
*/
private IProblemRequestorExtension getProblemRequestorExtension() {
IDocumentProvider p = editor.getDocumentProvider();
if (p == null) return null;
IAnnotationModel m = p.getAnnotationModel(editor.getEditorInput());
if (m instanceof IProblemRequestorExtension) {
return (IProblemRequestorExtension) m;
}
return null;
}
示例10: getAnnotationModel
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
private IAnnotationModel getAnnotationModel() {
IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider == null) {
return null;
}
return documentProvider.getAnnotationModel(getEditorInput());
}
示例11: getAnnotationModel
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
protected IAnnotationModel getAnnotationModel(XtextEditor editor) {
if(editor != null) {
IEditorInput editorInput = editor.getEditorInput();
if(editorInput != null) {
IDocumentProvider documentProvider = editor.getDocumentProvider();
if(documentProvider != null) {
return documentProvider.getAnnotationModel(editorInput);
}
}
}
return null;
}
示例12: addAnnotation
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
public static void addAnnotation(IMarker marker, ITextEditor editor,
String annotation, int offset, int length) {
// The DocumentProvider enables to get the document currently loaded in
// the editor
IDocumentProvider idp = editor.getDocumentProvider();
// This is the document we want to connect to. This is taken from the
// current editor input.
IDocument document = idp.getDocument(editor.getEditorInput());
// The IannotationModel enables to add/remove/change annotation to a
// Document loaded in an Editor
IAnnotationModel iamf = idp.getAnnotationModel(editor.getEditorInput());
// Note: The annotation type id specify that you want to create one of
// your annotations
String an = "";
if (annotation.equals("1")) {
an = ANNOTATION_COLOR1;
} else if (annotation.equals("2")) {
an = ANNOTATION_COLOR2;
} else if (annotation.equals("3")) {
an = ANNOTATION_COLOR3;
}
SimpleMarkerAnnotation ma = new SimpleMarkerAnnotation(an, marker);
// Finally add the new annotation to the model
iamf.connect(document);
iamf.addAnnotation(ma, new Position(offset, length));
iamf.disconnect(document);
}
示例13: reportProblems
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* Reports problems found in reconcile to the annotation model so we can draw them on the editor without creating
* markers on the underlying resource.
*
* @param context
* @param monitor
*/
private void reportProblems(ReconcileContext context, IProgressMonitor monitor)
{
AbstractThemeableEditor editor = fEditor;
if (editor == null)
{
return;
}
IDocumentProvider docProvider = editor.getDocumentProvider();
if (docProvider == null)
{
return;
}
IEditorInput editorInput = editor.getEditorInput();
if (editorInput == null)
{
return;
}
IAnnotationModel model = docProvider.getAnnotationModel(editorInput);
if (!(model instanceof ICommonAnnotationModel))
{
return;
}
ICommonAnnotationModel caModel = (ICommonAnnotationModel) model;
// Now report them all to the annotation model!
caModel.reportProblems(context.getProblems(), monitor);
}
示例14: getAnnotationModel
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
/**
* getAnnotationModel
*
* @return
*/
protected IAnnotationModel getAnnotationModel() {
IDocumentProvider documentProvider = getDocumentProvider();
IEditorInput editorInput = getEditorInput();
IAnnotationModel result = null;
if (documentProvider != null && editorInput != null) {
result = documentProvider.getAnnotationModel(editorInput);
}
return result;
}
示例15: getAnnotationModel
import org.eclipse.ui.texteditor.IDocumentProvider; //导入方法依赖的package包/类
@Override
protected IAnnotationModel getAnnotationModel() {
final IDocumentProvider documentProvider= fEditor.getDocumentProvider();
if (documentProvider == null)
return null;
return documentProvider.getAnnotationModel(fEditor.getEditorInput());
}