• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java IAnnotationModelExtension类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jface.text.source.IAnnotationModelExtension的典型用法代码示例。如果您正苦于以下问题:Java IAnnotationModelExtension类的具体用法?Java IAnnotationModelExtension怎么用?Java IAnnotationModelExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IAnnotationModelExtension类属于org.eclipse.jface.text.source包,在下文中一共展示了IAnnotationModelExtension类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
  }
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:28,代码来源:CoverageAnnotationModel.java


示例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);
				}
			}
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:18,代码来源:TweakedLinkedModeUI.java


示例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;
	}
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:24,代码来源:TypeScriptEditor.java


示例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());
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:AnnotationIssueProcessor.java


示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:23,代码来源:JavaEditor.java


示例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);
	}
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:18,代码来源:ExternalBreakpointWatcher.java


示例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);
}
 
开发者ID:eclipse,项目名称:eclemma,代码行数:20,代码来源:CoverageAnnotationModel.java


示例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());
		}
	}
}
 
开发者ID:curiosag,项目名称:ftc,代码行数:12,代码来源:TweakedLinkedModeUI.java


示例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);
		}
	}
}
 
开发者ID:cplutte,项目名称:bts,代码行数:14,代码来源:AnnotationIssueProcessor.java


示例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;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:28,代码来源:OccurrenceMarker.java


示例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;
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:18,代码来源:OverrideIndicatorManager.java


示例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);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:41,代码来源:PyEditBreakpointSync.java


示例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;
}
 
开发者ID:agusevas,项目名称:logan,代码行数:40,代码来源:RemoveOccurenciesHandler.java


示例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;
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:66,代码来源:TypeScriptEditor.java


示例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;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:58,代码来源:JavaEditor.java


示例16: updateAnnotations

import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
/**
 * Updates the override and implements annotations based
 * on the given AST.
 *
 * @param ast the compilation unit AST
 * @param progressMonitor the progress monitor
 * @since 3.0
 */
protected void updateAnnotations(CompilationUnit ast, IProgressMonitor progressMonitor) {

	if (ast == null || progressMonitor.isCanceled())
		return;

	final Map<Annotation, Position> annotationMap= new HashMap<Annotation, Position>(50);

	ast.accept(new ASTVisitor(false) {
		/*
		 * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.MethodDeclaration)
		 */
		@Override
		public boolean visit(MethodDeclaration node) {
			IMethodBinding binding= node.resolveBinding();
			if (binding != null) {
				IMethodBinding definingMethod= Bindings.findOverriddenMethod(binding, true);
				if (definingMethod != null) {

					ITypeBinding definingType= definingMethod.getDeclaringClass();
					String qualifiedMethodName= definingType.getQualifiedName() + "." + binding.getName(); //$NON-NLS-1$

					boolean isImplements= JdtFlags.isAbstract(definingMethod);
					String text;
					if (isImplements)
						text= Messages.format(JavaEditorMessages.OverrideIndicatorManager_implements, BasicElementLabels.getJavaElementName(qualifiedMethodName));
					else
						text= Messages.format(JavaEditorMessages.OverrideIndicatorManager_overrides, BasicElementLabels.getJavaElementName(qualifiedMethodName));

					SimpleName name= node.getName();
					Position position= new Position(name.getStartPosition(), name.getLength());

					annotationMap.put(
							new OverrideIndicator(isImplements, text, binding.getKey()),
							position);

				}
			}
			return true;
		}
	});

	if (progressMonitor.isCanceled())
		return;

	synchronized (fAnnotationModelLockObject) {
		if (fAnnotationModel instanceof IAnnotationModelExtension) {
			((IAnnotationModelExtension)fAnnotationModel).replaceAnnotations(fOverrideAnnotations, annotationMap);
		} else {
			removeAnnotations();
			Iterator<Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
			while (iter.hasNext()) {
				Entry<Annotation, Position> mapEntry= iter.next();
				fAnnotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
			}
		}
		fOverrideAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
	}
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:67,代码来源:OverrideIndicatorManager.java


示例17: removeOccurenceAnnotations

import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
/**
 * @param annotationModel
 */
protected synchronized void removeOccurenceAnnotations(IAnnotationModel annotationModel, BaseEditor pyEdit) {
    //remove the annotations
    Map<String, Object> cache = pyEdit.cache;
    if (cache == null) {
        return;
    }

    //let other threads execute before getting the lock on the annotation model
    Thread.yield();

    Thread thread = Thread.currentThread();
    int initiaThreadlPriority = thread.getPriority();
    //before getting the lock, let's execute with normal priority, to optimize the time that we'll 
    //retain that object locked (the annotation model is used on lots of places, so, retaining the lock
    //on it on a minimum priority thread is not a good thing.
    thread.setPriority(Thread.NORM_PRIORITY);

    try {
        synchronized (getLockObject(annotationModel)) {
            List<Annotation> annotationsToRemove = getOccurrenceAnnotationsInEditor(pyEdit);

            if (annotationModel instanceof IAnnotationModelExtension) {
                //replace those 
                ((IAnnotationModelExtension) annotationModel).replaceAnnotations(
                        annotationsToRemove.toArray(new Annotation[annotationsToRemove.size()]),
                        new HashMap<Annotation, Position>());
            } else {
                Iterator<Annotation> annotationIterator = annotationsToRemove.iterator();

                while (annotationIterator.hasNext()) {
                    annotationModel.removeAnnotation(annotationIterator.next());
                }
            }
            cache.put(getOccurrenceAnnotationsCacheKey(), null);
        }
        //end remove the annotations
    } finally {
        thread.setPriority(initiaThreadlPriority);
    }
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:44,代码来源:BaseMarkOccurrencesJob.java


示例18: endCollecting

import org.eclipse.jface.text.source.IAnnotationModelExtension; //导入依赖的package包/类
@Override
public void endCollecting() {

    List<Object> toRemove = new ArrayList<Object>();

    Object fLockObject;
    if (fAnnotationModel instanceof ISynchronizable) {
        fLockObject = ((ISynchronizable) fAnnotationModel).getLockObject();
    } else {
        fLockObject = new Object();
    }

    //let other threads execute before getting the lock on the annotation model
    Thread.yield();

    Thread thread = Thread.currentThread();
    int initiaThreadlPriority = thread.getPriority();
    try {
        //before getting the lock, let's execute with normal priority, to optimize the time that we'll 
        //retain that object locked (the annotation model is used on lots of places, so, retaining the lock
        //on it on a minimum priority thread is not a good thing.
        thread.setPriority(Thread.NORM_PRIORITY);
        Iterator<Annotation> iter;

        synchronized (fLockObject) {
            iter = fAnnotationModel.getAnnotationIterator();
            while (iter.hasNext()) {
                Object n = iter.next();
                if (n instanceof SpellingAnnotation) {
                    toRemove.add(n);
                }
            }
            iter = null;
        }

        Annotation[] annotationsToRemove = toRemove.toArray(new Annotation[toRemove.size()]);

        //let other threads execute before getting the lock (again) on the annotation model
        Thread.yield();
        synchronized (fLockObject) {
            if (fAnnotationModel instanceof IAnnotationModelExtension) {
                ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(annotationsToRemove,
                        fAddAnnotations);
            } else {
                for (int i = 0; i < annotationsToRemove.length; i++) {
                    fAnnotationModel.removeAnnotation(annotationsToRemove[i]);
                }
                for (iter = fAddAnnotations.keySet().iterator(); iter.hasNext();) {
                    Annotation annotation = iter.next();
                    fAnnotationModel.addAnnotation(annotation, fAddAnnotations.get(annotation));
                }
            }
        }

    } finally {
        thread.setPriority(initiaThreadlPriority);
    }
    fAddAnnotations = null;
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:60,代码来源:PyReconciler.java


示例19: 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();
    final TextSelection selection = AppUtils.getTextSelection();
    final String searchTerm = selection.getText();

    Job job = new Job("Adding Style") { //$NON-NLS-1$
      @Override
      protected IStatus run(IProgressMonitor monitor) {
        final IFile file = (IFile) textEditor.getEditorInput().getAdapter(IFile.class);
        final TextSearchResult textSearchResult = LoganalyserSearchEngine.search(file, searchTerm, monitor);

        Map<Annotation, Position> annotationMap = new HashMap<Annotation, Position>();
        final List<FileMatch> searchResult = LoganalyserSearchEngine.getFileMatches(textSearchResult);
        for (FileMatch fileMatch : searchResult) {
          Position position = new Position(fileMatch.getOffset(), fileMatch.getLength());
          Annotation annotation = new Annotation(false);
          annotation.setType(annotationType);
          annotationMap.put(annotation, position);
        }

        IDocumentProvider idp = textEditor.getDocumentProvider();
        final IAnnotationModel annotationModel = idp.getAnnotationModel(textEditor.getEditorInput());
        ((IAnnotationModelExtension) annotationModel).replaceAnnotations(null, annotationMap);

        return Status.OK_STATUS;
      }
    };

    job.setPriority(Job.INTERACTIVE);
    job.setUser(true);
    job.schedule();

  } catch (Exception ex) {
    ex.printStackTrace();
  }

  return null;
}
 
开发者ID:agusevas,项目名称:logan,代码行数:44,代码来源:MarkOccurenciesHandler.java



注:本文中的org.eclipse.jface.text.source.IAnnotationModelExtension类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ItemNameTag类代码示例发布时间:2022-05-22
下一篇:
Java ExportedPackage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap