本文整理了Java中org.eclipse.jface.text.source.Annotation.getText()
方法的一些代码示例,展示了Annotation.getText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getText()
方法的具体详情如下:
包路径:org.eclipse.jface.text.source.Annotation
类名称:Annotation
方法名:getText
[英]Returns the text associated with this annotation.
[中]返回与此批注关联的文本。
代码示例来源:origin: org.eclipse.xtext/ui
@Override
protected Object getHoverInfoInternal(final ITextViewer textViewer, final int lineNumber, final int offset) {
final Set<String> messages = Sets.newLinkedHashSet();
List<Annotation> annotations = getAnnotations(lineNumber, offset);
for (Annotation annotation : annotations) {
if (annotation.getText() != null) {
messages.add(annotation.getText().trim());
}
}
if (messages.size()>0)
return formatInfo(messages);
return null;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
@Override
protected void computeInformation() {
if (fSelection != null) {
Rectangle subjectArea= fSelection.canvas.getBounds();
Annotation annotation= fSelection.fAnnotation;
String msg;
if (annotation != null)
msg= annotation.getText();
else
msg= null;
setInformation(msg, subjectArea);
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
private boolean includeAnnotation(Annotation annotation, Position position, HashMap<Position, Object> messagesAtPosition) {
if (!isIncluded(annotation))
return false;
String text= annotation.getText();
return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
protected void computeInformation() {
if (fSelection != null) {
Rectangle subjectArea= fSelection.canvas.getBounds();
Annotation annotation= fSelection.fAnnotation;
String msg;
if (annotation != null)
msg= annotation.getText();
else
msg= null;
setInformation(msg, subjectArea);
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
private boolean includeAnnotation(Annotation annotation, Position position, HashMap<Position, Object> messagesAtPosition) {
if (!isIncluded(annotation))
return false;
String text= annotation.getText();
return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
@Override
protected void computeInformation() {
if (fSelection != null) {
Rectangle subjectArea= fSelection.canvas.getBounds();
Annotation annotation= fSelection.fAnnotation;
String msg;
if (annotation != null)
msg= annotation.getText();
else
msg= null;
setInformation(msg, subjectArea);
}
}
代码示例来源:origin: org.eclipse.xtext/ui
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
Composite composite= new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout layout= new GridLayout(2, false);
layout.marginHeight= 2;
layout.marginWidth= 2;
layout.horizontalSpacing= 0;
composite.setLayout(layout);
final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gridData.widthHint= 17;
gridData.heightHint= 16;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
e.gc.setFont(null);
fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
}
});
StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
String annotationText= annotation.getText();
if (annotationText != null)
text.setText(annotationText);
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
Composite composite= new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout layout= new GridLayout(2, false);
layout.marginHeight= 2;
layout.marginWidth= 2;
layout.horizontalSpacing= 0;
composite.setLayout(layout);
final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gridData.widthHint= 17;
gridData.heightHint= 16;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.setFont(null);
fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
}
});
StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
String annotationText= annotation.getText();
if (annotationText != null)
text.setText(annotationText);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui
private String getAnnotationModelHoverMessage(IAnnotationModel model, IRegion hoverRegion) {
Iterator<Annotation> e = model.getAnnotationIterator();
while (e.hasNext()) {
Annotation a = e.next();
if (a instanceof XMLProblemAnnotation) {
Position p = model.getPosition(a);
if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg = a.getText();
if (msg != null && msg.trim().length() > 0) {
return formatMessage(msg);
}
}
}
}
return null;
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
private void createAnnotationInformation(Composite parent, final Annotation annotation) {
Composite composite= new Composite(parent, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
GridLayout layout= new GridLayout(2, false);
layout.marginHeight= 2;
layout.marginWidth= 2;
layout.horizontalSpacing= 0;
composite.setLayout(layout);
final Canvas canvas= new Canvas(composite, SWT.NO_FOCUS);
GridData gridData= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false);
gridData.widthHint= 17;
gridData.heightHint= 16;
canvas.setLayoutData(gridData);
canvas.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
e.gc.setFont(null);
fMarkerAnnotationAccess.paint(annotation, e.gc, canvas, new Rectangle(0, 0, 16, 16));
}
});
StyledText text= new StyledText(composite, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
GridData data= new GridData(SWT.FILL, SWT.FILL, true, true);
text.setLayoutData(data);
String annotationText= annotation.getText();
if (annotationText != null)
text.setText(annotationText);
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.jface.text
/**
* {@inheritDoc}
*
* @deprecated As of 3.4, replaced by {@link ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)}
*/
@Deprecated
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
IAnnotationModel model= getAnnotationModel(fSourceViewer);
if (model == null)
return null;
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation a= e.next();
if (isIncluded(a)) {
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg= a.getText();
if (msg != null && msg.trim().length() > 0)
return msg;
}
}
}
return null;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jface.text
/**
* {@inheritDoc}
*
* @deprecated As of 3.4, replaced by {@link ITextHoverExtension2#getHoverInfo2(ITextViewer, IRegion)}
*/
@Deprecated
@Override
public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
IAnnotationModel model= getAnnotationModel(fSourceViewer);
if (model == null)
return null;
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation a= e.next();
if (isIncluded(a)) {
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg= a.getText();
if (msg != null && msg.trim().length() > 0)
return msg;
}
}
}
return null;
}
代码示例来源:origin: org.eclipse.xtext/ui
protected void updateStatusLine() {
final ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection();
final Annotation annotation = getAnnotation(selection.getOffset(), selection.getLength());
String message = null;
if (annotation != null) {
updateMarkerViews(annotation);
if (isProblemMarkerAnnotation(annotation)) {
message = annotation.getText();
}
}
setStatusLineMessage(message);
}
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
protected void updateStatusLine() {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
String message= null;
if (annotation != null) {
updateMarkerViews(annotation);
if (annotation instanceof IJavaAnnotation && ((IJavaAnnotation) annotation).isProblem() || isProblemMarkerAnnotation(annotation))
message= annotation.getText();
}
setStatusLineErrorMessage(null);
setStatusLineMessage(message);
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
protected void updateStatusLine() {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
updateMarkerViews(annotation);
if (annotation instanceof IJavaAnnotation && ((IJavaAnnotation) annotation).isProblem())
setStatusLineMessage(annotation.getText());
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
protected void updateStatusLine() {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Annotation annotation= getAnnotation(selection.getOffset(), selection.getLength());
String message= null;
if (annotation != null) {
updateMarkerViews(annotation);
if (annotation instanceof IJavaAnnotation && ((IJavaAnnotation) annotation).isProblem() || isProblemMarkerAnnotation(annotation))
message= annotation.getText();
}
setStatusLineErrorMessage(null);
setStatusLineMessage(message);
}
代码示例来源:origin: org.eclipse.xtext/ui
@Override
protected Object getHoverInfoInternal(ITextViewer textViewer, final int lineNumber, final int offset) {
AnnotationInfo result = recentAnnotationInfo;
if (result != null)
return result;
List<Annotation> annotations = getAnnotations(lineNumber, offset);
if (annotations != null) {
for (Annotation annotation : annotations) {
if (annotation.getText() != null) {
Position position = getAnnotationModel().getPosition(annotation);
final IQuickAssistInvocationContext invocationContext = new QuickAssistInvocationContext(sourceViewer, position.getOffset(), position.getLength(), true);
CompletionProposalRunnable runnable = new CompletionProposalRunnable(invocationContext);
// Note: the resolutions have to be retrieved from the UI thread, otherwise
// workbench.getActiveWorkbenchWindow() will return null in LanguageSpecificURIEditorOpener and
// cause an exception
Display.getDefault().syncExec(runnable);
result = new AnnotationInfo (annotation, position, sourceViewer, runnable.proposals);
recentAnnotationInfo = result;
return result;
}
}
}
return null;
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench.texteditor
/**
* Jumps to the next annotation according to the given direction.
*
* @param forward <code>true</code> if search direction is forward, <code>false</code> if backward
* @return the selected annotation or <code>null</code> if none
* @see #isNavigationTarget(Annotation)
* @see #findAnnotation(int, int, boolean, Position)
* @since 3.2
*/
@Override
public Annotation gotoAnnotation(boolean forward) {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Position position= new Position(0, 0);
Annotation annotation= findAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
selectAndReveal(position.getOffset(), position.getLength());
setStatusLineMessage(annotation.getText());
}
return annotation;
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.workbench.texteditor
/**
* Jumps to the next annotation according to the given direction.
*
* @param forward <code>true</code> if search direction is forward, <code>false</code> if backward
* @return the selected annotation or <code>null</code> if none
* @see #isNavigationTarget(Annotation)
* @see #findAnnotation(int, int, boolean, Position)
* @since 3.2
*/
@Override
public Annotation gotoAnnotation(boolean forward) {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Position position= new Position(0, 0);
Annotation annotation= findAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
selectAndReveal(position.getOffset(), position.getLength());
setStatusLineMessage(annotation.getText());
}
return annotation;
}
代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor
/**
* Jumps to the next annotation according to the given direction.
*
* @param forward <code>true</code> if search direction is forward, <code>false</code> if backward
* @return the selected annotation or <code>null</code> if none
* @see #isNavigationTarget(Annotation)
* @see #findAnnotation(int, int, boolean, Position)
* @since 3.2
*/
public Annotation gotoAnnotation(boolean forward) {
ITextSelection selection= (ITextSelection) getSelectionProvider().getSelection();
Position position= new Position(0, 0);
Annotation annotation= findAnnotation(selection.getOffset(), selection.getLength(), forward, position);
setStatusLineErrorMessage(null);
setStatusLineMessage(null);
if (annotation != null) {
selectAndReveal(position.getOffset(), position.getLength());
setStatusLineMessage(annotation.getText());
}
return annotation;
}
内容来源于网络,如有侵权,请联系作者删除!