本文整理了Java中org.eclipse.jface.text.source.Annotation.<init>()
方法的一些代码示例,展示了Annotation.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.<init>()
方法的具体详情如下:
包路径:org.eclipse.jface.text.source.Annotation
类名称:Annotation
方法名:<init>
[英]Creates a new annotation that is not persistent and type less.
[中]创建一个不持久且类型较少的新注释。
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Sets the positions that should be highlighted as the target positions, i.e.
* as the positions that can be jumped to in a linked set up.
*
* @param positions the new target positions, or <code>null</code> if no target positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
private void setTargetPositions(List<Position> positions) throws BadLocationException {
if (!fMarkTargets)
return;
// remove all positions which are already there
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
List<Annotation> toRemove= new ArrayList<>(fTargetAnnotations.values());
Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
for (Position p : positions) {
if (fTargetAnnotations.containsKey(p)) {
toRemove.remove(fTargetAnnotations.get(p));
} else {
Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
toAdd.put(a, p);
fTargetAnnotations.put(p, a);
}
}
}
fTargetAnnotations.values().removeAll(toRemove);
replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
toRemove.remove(fTargetAnnotations.get(p));
} else {
Annotation a= new Annotation(TARGET_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
toAdd.put(a, p);
fTargetAnnotations.put(p, a);
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
toRemove.remove(fGroupAnnotations.get(p));
} else {
Annotation a= new Annotation(SLAVE_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
toAdd.put(a, p);
fGroupAnnotations.put(p, a);
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Sets the positions that should be highlighted as the slave positions, i.e.
* as the positions that are linked to the focus position.
*
* @param positions the new slave positions, or <code>null</code> if no slave positions are to be set
* @throws BadLocationException in case any of the given positions is invalid
*/
private void setGroupPositions(List<Position> positions) throws BadLocationException {
if (!fMarkSlaves)
return;
// remove all positions which are already there
// Algorithm: toRemove contains all mappings at first, but all that are in
// positions get removed -> toRemove contains the difference set of previous - new
// toAdd are the new positions, which don't exist in previous = new - previous
List<Annotation> toRemove= new ArrayList<>(fGroupAnnotations.values());
Map<Annotation, Position> toAdd= new HashMap<>();
if (positions != null) {
for (Position p : positions) {
if (fGroupAnnotations.containsKey(p)) {
toRemove.remove(fGroupAnnotations.get(p));
} else {
Annotation a= new Annotation(SLAVE_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
toAdd.put(a, p);
fGroupAnnotations.put(p, a);
}
}
}
fGroupAnnotations.values().removeAll(toRemove);
replaceAnnotations(toRemove.toArray(new Annotation[0]), toAdd, false);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
Annotation annotation= new Annotation(annotationType, false, null);
AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
if (preference != null)
return preference.getPresentationLayer() + 1;
else
return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
Annotation annotation= new Annotation(annotationType, false, null);
AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
if (preference != null)
return preference.getPresentationLayer() + 1;
else
return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private static int computeLayer(String annotationType, AnnotationPreferenceLookup lookup) {
Annotation annotation= new Annotation(annotationType, false, null);
AnnotationPreference preference= lookup.getAnnotationPreference(annotation);
if (preference != null)
return preference.getPresentationLayer() + 1;
else
return IAnnotationAccessExtension.DEFAULT_LAYER + 1;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.search
@Override
public void addHighlights(Match[] matches) {
HashMap<Annotation, Position> map= new HashMap<>(matches.length);
for (Match match : matches) {
int offset= match.getOffset();
int length= match.getLength();
if (offset >= 0 && length >= 0) {
Position position= createPosition(match);
if (position != null) {
Annotation annotation= match.isFiltered()
? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null)
: new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
fMatchesToAnnotations.put(match, annotation);
map.put(annotation, position);
}
}
}
addAnnotations(map);
}
代码示例来源:origin: org.eclipse/org.eclipse.search
public void addHighlights(Match[] matches) {
HashMap map= new HashMap(matches.length);
for (int i= 0; i < matches.length; i++) {
int offset= matches[i].getOffset();
int length= matches[i].getLength();
if (offset >= 0 && length >= 0) {
Position position= createPosition(matches[i]);
if (position != null) {
Annotation annotation= matches[i].isFiltered()
? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null)
: new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
fMatchesToAnnotations.put(matches[i], annotation);
map.put(annotation, position);
}
}
}
addAnnotations(map);
}
代码示例来源:origin: org.eclipse/org.eclipse.search
public void addHighlights(Match[] matches) {
Map mapsByAnnotationModel= new HashMap();
for (int i= 0; i < matches.length; i++) {
int offset= matches[i].getOffset();
int length= matches[i].getLength();
if (offset >= 0 && length >= 0) {
try {
Position position= createPosition(matches[i]);
if (position != null) {
Map map= getMap(mapsByAnnotationModel, matches[i]);
if (map != null) {
Annotation annotation= matches[i].isFiltered()
? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null)
: new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
fMatchesToAnnotations.put(matches[i], annotation);
map.put(annotation, position);
}
}
} catch (BadLocationException e) {
SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.EditorAccessHighlighter_error_badLocation, e));
}
}
}
for (Iterator maps= mapsByAnnotationModel.keySet().iterator(); maps.hasNext();) {
IAnnotationModel model= (IAnnotationModel) maps.next();
Map positionMap= (Map) mapsByAnnotationModel.get(model);
addAnnotations(model, positionMap);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.search
@Override
public void addHighlights(Match[] matches) {
Map<IAnnotationModel, HashMap<Annotation, Position>> mapsByAnnotationModel= new HashMap<>();
for (Match match : matches) {
int offset= match.getOffset();
int length= match.getLength();
if (offset >= 0 && length >= 0) {
try {
Position position= createPosition(match);
if (position != null) {
Map<Annotation, Position> map= getMap(mapsByAnnotationModel, match);
if (map != null) {
Annotation annotation= match.isFiltered()
? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null)
: new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
fMatchesToAnnotations.put(match, annotation);
map.put(annotation, position);
}
}
} catch (BadLocationException e) {
SearchPlugin.log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, SearchMessages.EditorAccessHighlighter_error_badLocation, e));
}
}
}
for (Entry<IAnnotationModel, HashMap<Annotation, Position>> entry : mapsByAnnotationModel.entrySet()) {
addAnnotations(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: org.eclipse.xtext/ui
protected void addOccurrenceAnnotation(String type, IDocument document, ITextRegion textRegion,
Map<Annotation, Position> annotationMap) {
try {
if (textRegion != null && textRegion.getLength() > 0) {
Annotation annotation = new Annotation(type, false, document.get(textRegion.getOffset(),
textRegion.getLength()));
annotationMap.put(annotation, new Position(textRegion.getOffset(), textRegion.getLength()));
}
} catch (BadLocationException e) {
LOG.error("Error creating occurrence annotation", e);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
/**
* Sets the position that should be highlighted as the exit position, i.e.
* as the position whose changes are propagated to all its linked positions
* by the linked environment.
*
* @param position the new exit position, or <code>null</code> if no focus is set.
* @throws BadLocationException in case <code>position</code> is invalid
*/
private void setExitPosition(Position position) throws BadLocationException {
if (fMarkExitTarget && getPosition(fExitAnnotation) != position) {
removeAnnotation(fExitAnnotation, false);
if (position != null) {
fExitAnnotation= new Annotation(EXIT_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
addAnnotation(fExitAnnotation, position, false);
} else
fExitAnnotation= null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Sets the position that should be highlighted as the exit position, i.e.
* as the position whose changes are propagated to all its linked positions
* by the linked environment.
*
* @param position the new exit position, or <code>null</code> if no focus is set.
* @throws BadLocationException in case <code>position</code> is invalid
*/
private void setExitPosition(Position position) throws BadLocationException {
if (fMarkExitTarget && getPosition(fExitAnnotation) != position) {
removeAnnotation(fExitAnnotation, false);
if (position != null) {
fExitAnnotation= new Annotation(EXIT_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
addAnnotation(fExitAnnotation, position, false);
} else
fExitAnnotation= null;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
/**
* Sets the position that should be highlighted as the focus position, i.e.
* as the position whose changes are propagated to all its linked positions
* by the linked environment.
*
* @param position the new focus position, or <code>null</code> if no focus is set.
* @throws BadLocationException if <code>position</code> is invalid
*/
private void setFocusPosition(Position position) throws BadLocationException {
if (fMarkFocus && getPosition(fFocusAnnotation) != position) {
removeAnnotation(fFocusAnnotation, false);
if (position != null) {
fFocusAnnotation= new Annotation(FOCUS_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
addAnnotation(fFocusAnnotation, position, false);
} else
fFocusAnnotation= null;
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* Sets the position that should be highlighted as the focus position, i.e.
* as the position whose changes are propagated to all its linked positions
* by the linked environment.
*
* @param position the new focus position, or <code>null</code> if no focus is set.
* @throws BadLocationException if <code>position</code> is invalid
*/
private void setFocusPosition(Position position) throws BadLocationException {
if (fMarkFocus && getPosition(fFocusAnnotation) != position) {
removeAnnotation(fFocusAnnotation, false);
if (position != null) {
fFocusAnnotation= new Annotation(FOCUS_ANNOTATION_TYPE, false, ""); //$NON-NLS-1$
addAnnotation(fFocusAnnotation, position, false);
} else
fFocusAnnotation= null;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
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);
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
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);
代码示例来源:origin: org.apache.uima/ruta-ep-ide-ui
public void highlightElement(int id) {
if (myAnnotations != null && !myAnnotations.isEmpty()) {
removeAnnotations(myAnnotations.keySet());
}
RutaSelectionParser parser = new RutaSelectionParser();
ISourceModule unit = (ISourceModule) getInputModelElement();
ModuleDeclaration parsed = parser.parse(unit);
RutaRuleIdVisitor visitor = new RutaRuleIdVisitor(id);
try {
parsed.traverse(visitor);
} catch (Exception e) {
}
RutaRule rule = visitor.getResult();
myAnnotations = new HashMap<Annotation, Position>();
if (rule != null) {
Annotation annotation = new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
int sourceStart = rule.sourceStart();
int sourceEnd = rule.sourceEnd();
Position position = new Position(sourceStart, sourceEnd - sourceStart);
getSourceViewer().revealRange(sourceStart, sourceEnd - sourceStart);
myAnnotations.put(annotation, position);
}
addAnnotations(myAnnotations);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
annotationMap.put(new Annotation("org.eclipse.jdt.ui.occurrences", false, message), //$NON-NLS-1$
position);
内容来源于网络,如有侵权,请联系作者删除!