本文整理汇总了Java中org.eclipse.jface.text.source.IAnnotationModelExtension类的典型用法代码示例。如果您正苦于以下问题:Java IAnnotationModelExtension类的具体用法?Java IAnnotationModelExtension怎么用?Java IAnnotationModelExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAnnotationModelExtension类属于org.eclipse.jface.text.source包,在下文中一共展示了IAnnotationModelExtension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attach
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的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: ensureAnnotationModelInstalled
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
private void ensureAnnotationModelInstalled() {
LinkedPositionAnnotations lpa = fCurrentTarget.fAnnotationModel;
if (lpa != null) {
ITextViewer viewer = fCurrentTarget.getViewer();
if (viewer instanceof ISourceViewer) {
ISourceViewer sv = (ISourceViewer) viewer;
IAnnotationModel model = sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext = (IAnnotationModelExtension) model;
IAnnotationModel ourModel = ext.getAnnotationModel(getUniqueKey());
if (ourModel == null) {
ext.addAnnotationModel(getUniqueKey(), lpa);
}
}
}
}
}
示例3: removeOccurrenceAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的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;
}
}
示例4: updateAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
protected void updateAnnotations(IProgressMonitor monitor, List<Annotation> toBeRemoved,
Map<Annotation, Position> annotationToPosition) {
if (monitor.isCanceled()) {
return;
}
if (annotationModel instanceof IAnnotationModelExtension) {
Annotation[] removedAnnotations = toBeRemoved.toArray(new Annotation[toBeRemoved.size()]);
((IAnnotationModelExtension) annotationModel).replaceAnnotations(removedAnnotations, annotationToPosition);
} else {
for (Annotation annotation : toBeRemoved) {
if (monitor.isCanceled()) {
return;
}
annotationModel.removeAnnotation(annotation);
}
for (Map.Entry<Annotation, Position> entry : annotationToPosition.entrySet()) {
if (monitor.isCanceled()) {
return;
}
annotationModel.addAnnotation(entry.getKey(), entry.getValue());
}
}
}
示例5: removeOccurrenceAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的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;
}
}
示例6: ExternalBreakpointWatcher
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
public ExternalBreakpointWatcher(IEditorInput input, IDocument document, IAnnotationModel annotationModel) {
this.location = EditorUtils.getLocationOrNull(input);
this.document = assertNotNull(document);
this.annotationModel = assertNotNull(annotationModel);
if(annotationModel instanceof IAnnotationModelExtension) {
this.annotationModelExt = (IAnnotationModelExtension) annotationModel;
} else {
this.annotationModelExt = null;
}
if(location != null) {
ResourceUtils.connectResourceListener(resourceListener, this::initializeFromResources,
getWorkspaceRoot(), owned);
}
}
示例7: detach
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的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: uninstallAnnotationModel
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
private void uninstallAnnotationModel(LinkedModeUITarget target) {
ITextViewer viewer = target.getViewer();
if (viewer instanceof ISourceViewer) {
ISourceViewer sv = (ISourceViewer) viewer;
IAnnotationModel model = sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext = (IAnnotationModelExtension) model;
ext.removeAnnotationModel(getUniqueKey());
}
}
}
示例9: announceAnnotationChanged
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
protected void announceAnnotationChanged(Annotation annotation) {
if (annotationModel instanceof XtextResourceMarkerAnnotationModel)
((XtextResourceMarkerAnnotationModel) annotationModel).fireAnnotationChangedEvent(annotation);
else {
Position position = annotationModel.getPosition(annotation);
if (annotationModel instanceof IAnnotationModelExtension)
((IAnnotationModelExtension) annotationModel).modifyAnnotationPosition(annotation, position);
else {
annotationModel.removeAnnotation(annotation);
annotationModel.addAnnotation(annotation, position);
}
}
}
示例10: run
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
@Override
protected IStatus run(IProgressMonitor monitor) {
final XtextEditor editor = initialEditor;
final boolean isMarkOccurrences = initialIsMarkOccurrences;
final ITextSelection selection = initialSelection;
final SubMonitor progress = SubMonitor.convert(monitor, 2);
if (!progress.isCanceled()) {
final Map<Annotation, Position> annotations = (isMarkOccurrences) ? occurrenceComputer.createAnnotationMap(editor, selection,
progress.newChild(1)) : Collections.<Annotation, Position>emptyMap();
if (!progress.isCanceled()) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
if (!progress.isCanceled()) {
final IAnnotationModel annotationModel = getAnnotationModel(editor);
if (annotationModel instanceof IAnnotationModelExtension)
((IAnnotationModelExtension) annotationModel).replaceAnnotations(
getExistingOccurrenceAnnotations(annotationModel), annotations);
else if(annotationModel != null)
throw new IllegalStateException(
"AnnotationModel does not implement IAnnotationModelExtension"); //$NON-NLS-1$
}
}
});
}
}
return progress.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
示例11: removeAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
/**
* Removes all override indicators from this manager's annotation model.
*/
void removeAnnotations() {
if (fOverrideAnnotations == null)
return;
synchronized (fAnnotationModelLockObject) {
if (fAnnotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, null);
} else {
for (int i= 0, length= fOverrideAnnotations.length; i < length; i++)
fAnnotationModel.removeAnnotation(fOverrideAnnotations[i]);
}
fOverrideAnnotations= null;
}
}
示例12: updateAnnotations
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
private void updateAnnotations() {
if (edit == null) {
return;
}
IDocumentProvider provider = edit.getDocumentProvider();
if (provider == null) {
return;
}
IAnnotationModel model = provider.getAnnotationModel(edit.getEditorInput());
if (model == null) {
return;
}
IAnnotationModelExtension modelExtension = (IAnnotationModelExtension) model;
List<Annotation> existing = new ArrayList<Annotation>();
Iterator<Annotation> it = model.getAnnotationIterator();
if (it == null) {
return;
}
while (it.hasNext()) {
existing.add(it.next());
}
IDocument doc = edit.getDocument();
IResource resource = PyMarkerUtils.getResourceForTextEditor(edit);
IEditorInput externalFileEditorInput = AbstractBreakpointRulerAction.getExternalFileEditorInput(edit);
List<IMarker> markers = AbstractBreakpointRulerAction.getMarkersFromEditorResource(resource, doc,
externalFileEditorInput, 0, false, model);
Map<Annotation, Position> annotationsToAdd = new HashMap<Annotation, Position>();
for (IMarker m : markers) {
Position pos = PyMarkerUtils.getMarkerPosition(doc, m, model);
MarkerAnnotation newAnnotation = new MarkerAnnotation(m);
annotationsToAdd.put(newAnnotation, pos);
}
//update all in a single step
modelExtension.replaceAnnotations(existing.toArray(new Annotation[0]), annotationsToAdd);
}
示例13: execute
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final String styleParameter = event.getParameter(PARAMETER_ID);
final String annotationType = getAnnotationType(styleParameter);
try {
final ITextEditor textEditor = AppUtils.getEditor();
Job job = new Job(Messages.RemoveOccurenciesHandler_addStyleJobName) {
@SuppressWarnings("unchecked")
@Override
protected IStatus run(IProgressMonitor monitor) {
IDocumentProvider idp = textEditor.getDocumentProvider();
final IAnnotationModel annotationModel = idp.getAnnotationModel(textEditor.getEditorInput());
List<Annotation> removeAnnotations = new LinkedList<Annotation>();
Iterator<Annotation> annotationIterator = annotationModel.getAnnotationIterator();
while (annotationIterator.hasNext()) {
Annotation annotation = annotationIterator.next();
if (annotation.getType().equals(annotationType)) {
removeAnnotations.add(annotation);
}
}
Annotation[] annotations = removeAnnotations.toArray(new Annotation[removeAnnotations.size()]);
((IAnnotationModelExtension) annotationModel).replaceAnnotations(annotations, null);
return Status.OK_STATUS;
}
};
job.schedule();
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
示例14: run
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
public IStatus run(IProgressMonitor progressMonitor) {
fProgressMonitor = progressMonitor;
if (isCanceled()) {
if (LinkedModeModel.hasInstalledModel(fDocument)) {
// Template completion applied, remove occurrences
removeOccurrenceAnnotations();
}
return Status.CANCEL_STATUS;
}
ITextViewer textViewer = getViewer();
if (textViewer == null)
return Status.CANCEL_STATUS;
IDocument document = textViewer.getDocument();
if (document == null)
return Status.CANCEL_STATUS;
IAnnotationModel annotationModel = getAnnotationModel();
if (annotationModel == null)
return Status.CANCEL_STATUS;
// Add occurrence annotations
int length = fPositions.length;
Map annotationMap = new HashMap(length);
for (int i = 0; i < length; i++) {
if (isCanceled())
return Status.CANCEL_STATUS;
String message;
Position position = fPositions[i];
// Create & add annotation
try {
message = document.get(position.offset, position.length);
} catch (BadLocationException ex) {
// Skip this match
continue;
}
annotationMap.put(new Annotation("org.eclipse.wst.jsdt.ui.occurrences", false, message), //$NON-NLS-1$
position);
}
if (isCanceled())
return Status.CANCEL_STATUS;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension) annotationModel).replaceAnnotations(fOccurrenceAnnotations,
annotationMap);
} else {
removeOccurrenceAnnotations();
Iterator iter = annotationMap.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry mapEntry = (Map.Entry) iter.next();
annotationModel.addAnnotation((Annotation) mapEntry.getKey(), (Position) mapEntry.getValue());
}
}
fOccurrenceAnnotations = (Annotation[]) annotationMap.keySet()
.toArray(new Annotation[annotationMap.keySet().size()]);
}
return Status.OK_STATUS;
}
示例15: run
import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
@Override
public IStatus run(IProgressMonitor progressMonitor) {
if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS;
ITextViewer textViewer= getViewer();
if (textViewer == null)
return Status.CANCEL_STATUS;
IDocument document= textViewer.getDocument();
if (document == null)
return Status.CANCEL_STATUS;
IDocumentProvider documentProvider= getDocumentProvider();
if (documentProvider == null)
return Status.CANCEL_STATUS;
IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null)
return Status.CANCEL_STATUS;
// Add occurrence annotations
int length= fLocations.length;
Map<Annotation, Position> annotationMap= new HashMap<Annotation, Position>(length);
for (int i= 0; i < length; i++) {
if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS;
OccurrenceLocation location= fLocations[i];
Position position= new Position(location.getOffset(), location.getLength());
String description= location.getDescription();
String annotationType= (location.getFlags() == IOccurrencesFinder.F_WRITE_OCCURRENCE) ? "org.eclipse.jdt.ui.occurrences.write" : "org.eclipse.jdt.ui.occurrences"; //$NON-NLS-1$ //$NON-NLS-2$
annotationMap.put(new Annotation(annotationType, false, description), position);
}
if (isCanceled(progressMonitor))
return Status.CANCEL_STATUS;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
} else {
removeOccurrenceAnnotations();
Iterator<Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
while (iter.hasNext()) {
Entry<Annotation, Position> mapEntry= iter.next();
annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
}
}
fOccurrenceAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
}
return Status.OK_STATUS;
}