本文整理匯總了Java中org.eclipse.jface.text.source.IAnnotationModel.disconnect方法的典型用法代碼示例。如果您正苦於以下問題:Java IAnnotationModel.disconnect方法的具體用法?Java IAnnotationModel.disconnect怎麽用?Java IAnnotationModel.disconnect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.IAnnotationModel
的用法示例。
在下文中一共展示了IAnnotationModel.disconnect方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addAnnotation
import org.eclipse.jface.text.source.IAnnotationModel; //導入方法依賴的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);
}
示例2: createLocationAnnotation
import org.eclipse.jface.text.source.IAnnotationModel; //導入方法依賴的package包/類
/**
* Create a new source location annotation.
*
* @param marker
* The marker to assign to the annotation.
* @param selection
* The selection to highlight.
* @param editor
* The editor to set the annotations in.
* @param variant
* The variant to decide about the marker presentation.
*/
private void createLocationAnnotation(IMarker marker, ITextSelection selection, ITextEditor editor, Variant variant) {
IDocumentProvider idp = editor.getDocumentProvider();
IEditorInput editorInput = editor.getEditorInput();
IDocument document = idp.getDocument(editorInput);
IAnnotationModel annotationModel = idp.getAnnotationModel(editorInput);
String annotationType = getAnnotationType(variant);
SimpleMarkerAnnotation annotation = new SimpleMarkerAnnotation(annotationType, marker);
annotationModel.connect(document);
annotationModel.addAnnotation(annotation, new Position(selection.getOffset(), selection.getLength()));
annotationModel.disconnect(document);
}
示例3: createAnnotation
import org.eclipse.jface.text.source.IAnnotationModel; //導入方法依賴的package包/類
/**
* Creates the corresponding annotation for a given marker according to the given marker type.
*
* @param marker the given marker.
* @param selection the selection to highlight.
* @param editor the underlying editor.
* @param markerType the given marker type.
*/
private void createAnnotation(IMarker marker, ITextSelection selection, ITextEditor editor, MarkerType markerType) {
IDocumentProvider idp = editor.getDocumentProvider();
IDocument document = idp.getDocument(editorInput);
IAnnotationModel annotationModel = idp.getAnnotationModel(editorInput);
String annotationType = UIConstants.ANNOTATION_TO_ID.get(markerType);
SimpleMarkerAnnotation annotation = new SimpleMarkerAnnotation(annotationType, marker);
annotationModel.connect(document);
annotationModel.addAnnotation(annotation, new Position(selection.getOffset(), selection.getLength()));
annotationModel.disconnect(document);
}
示例4: addAnnotation
import org.eclipse.jface.text.source.IAnnotationModel; //導入方法依賴的package包/類
/*******************************************************
* Adds an annotation of the specified type to the specified marker in the
* specified editor.
*
* @param editor
* The text editor in which text will be annotated.
* @param marker
* The marker that will be used for annotation.
* @param annotationType
* The type of the annotation as specified in the Manifest file.
* @param startPos
* The starting position of the text to annotate.
* @param length
* The length of the text to annotate
*******************************************************/
public static void addAnnotation(ITextEditor editor, IMarker marker, String annotationType, int startPos, int length)
{
if (editor == null || marker == null || annotationType == null)
throw new IllegalArgumentException();
if (startPos < 0 || length <= 0)
throw new IllegalArgumentException("Invalid marker positions!");
// The DocumentProvider enables to get the document currently loaded in
// the editor
IDocumentProvider docProvider = editor.getDocumentProvider();
// This is the document we want to connect to. This is taken from
// the current editor input.
IDocument document = docProvider.getDocument(editor.getEditorInput());
// The IannotationModel enables to add/remove/change annotation to a
// Document loaded in an Editor
IAnnotationModel annotationModel = docProvider.getAnnotationModel(editor.getEditorInput());
// Note: The annotation type id specify that you want to create one of
// your annotations
SimpleMarkerAnnotation markerAnnotation = new SimpleMarkerAnnotation(annotationType, marker);
// Finally add the new annotation to the model
annotationModel.connect(document);
annotationModel.addAnnotation(markerAnnotation, new Position(startPos, length));
annotationModel.disconnect(document);
}