本文整理匯總了Java中org.eclipse.jface.text.source.Annotation.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.getText方法的具體用法?Java Annotation.getText怎麽用?Java Annotation.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.Annotation
的用法示例。
在下文中一共展示了Annotation.getText方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHoverInfo
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes")
@Override
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IAnnotationModel model = sourceViewer.getAnnotationModel();
Iterator iterator = model.getAnnotationIterator();
while (iterator.hasNext()) {
Annotation annotation = (Annotation) iterator.next();
Position position = model.getPosition(annotation);
try {
int lineOfAnnotation = sourceViewer.getDocument().
getLineOfOffset(position.getOffset());
if (lineNumber == lineOfAnnotation) {
return annotation.getText();
}
} catch (BadLocationException e) {
// TODO: handle exception
}
}
return null;
}
示例2: getHoverInfoInternal
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
@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;
}
示例3: updateStatusLine
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
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 IAnnotation && ((IAnnotation) annotation).isProblem()) {
message = annotation.getText();
}
}
setStatusLineErrorMessage(null);
setStatusLineMessage(message);
}
示例4: createAnnotationInformation
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
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);
}
示例5: updateStatusLine
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
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);
}
示例6: createAnnotationInformation
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
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);
}
示例7: getHoverInfoInternal
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
@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;
}
示例8: includeAnnotation
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
private boolean includeAnnotation(Annotation annotation, Position position, Map<Position, Object> messagesAtPosition)
{
if (!isIncluded(annotation))
{
return false;
}
String text = annotation.getText();
return (text != null && !isDuplicateAnnotation(messagesAtPosition, position, text));
}
示例9: getHoverInfo2
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
IPath path;
IAnnotationModel model;
if (textViewer instanceof ISourceViewer) {
path = null;
model = ((ISourceViewer) textViewer).getAnnotationModel();
} else {
// Get annotation model from file buffer manager
path = getEditorInputPath();
model = getAnnotationModel(path);
}
if (model == null)
return null;
try {
Iterator<Annotation> parent;
if (model instanceof IAnnotationModelExtension2)
parent = ((IAnnotationModelExtension2) model).getAnnotationIterator(hoverRegion.getOffset(),
hoverRegion.getLength() > 0 ? hoverRegion.getLength() : 1, true, true);
else
parent = model.getAnnotationIterator();
Iterator<Annotation> e = new TypeScriptAnnotationIterator(parent, fAllAnnotations);
int layer = -1;
Annotation annotation = null;
Position position = null;
while (e.hasNext()) {
Annotation a = e.next();
AnnotationPreference preference = getAnnotationPreference(a);
if (preference == null || !(preference.getTextPreferenceKey() != null
/*
* && fStore.getBoolean(preference.getTextPreferenceKey()) ||
* (preference.getHighlightPreferenceKey() != null &&
* fStore.getBoolean(preference.getHighlightPreferenceKey()))
*/))
continue;
Position p = model.getPosition(a);
int l = fAnnotationAccess.getLayer(a);
if (l > layer && p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg = a.getText();
if (msg != null && msg.trim().length() > 0) {
layer = l;
annotation = a;
position = p;
}
}
}
if (layer > -1)
return createAnnotationInfo(annotation, position, textViewer);
} finally {
try {
if (path != null) {
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
manager.disconnect(path, LocationKind.NORMALIZE, null);
}
} catch (CoreException ex) {
TypeScriptUIPlugin.log(ex.getStatus());
}
}
return null;
}
示例10: getHoverInfo2
import org.eclipse.jface.text.source.Annotation; //導入方法依賴的package包/類
@Override
public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
IAnnotationModel model = sourceViewer.getAnnotationModel();
@SuppressWarnings("unchecked")
Iterator<Annotation> i = model.getAnnotationIterator();
Annotation provideText = null;
AnnotationPreferenceLookup preferenceLookup = EditorsUI.getAnnotationPreferenceLookup();
int annotationLayer = -1;
while (i.hasNext()) {
Annotation ann = i.next();
Position p = model.getPosition(ann);
if (p == null || !p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
continue;
}
if (UNCHANGED_QUICKDIFF_ANNOTATION.equals(ann.getType())) {
continue; //Ignore unchanged line notification
}
if (provideText == null) {
provideText = ann;
}
AnnotationPreference preference = preferenceLookup.getAnnotationPreference(ann);
if (preference != null && preference.getPresentationLayer() > annotationLayer) {
provideText = ann;
annotationLayer = preference.getPresentationLayer();
}
}
String text = null;
if (provideText != null) {
if (this.hoverContributions.containsKey(provideText.getType())) {
text = this.hoverContributions.get(provideText.getType()).getHoverText(provideText, textViewer, hoverRegion);
}
else {
text = "<b>" + provideText.getText() + "</b>";
}
}
try {
if (text == null) {
IDocument document = textViewer.getDocument();
if (document instanceof IDocumentExtension3) {
IDocumentExtension3 ext3 = (IDocumentExtension3) document;
ITypedRegion partition = ext3.getPartition(EditorConstants.BF_PARTITIONING, hoverRegion.getOffset(), false);
if (EditorConstants.PARTITION_TYPE_BRAINFUCK_CODE.equals(partition.getType())) {
text = "Offset: [<b>" + hoverRegion.getOffset() + "</b>]";
}
}
}
}
catch (BadLocationException | BadPartitioningException ex) {
BfActivator.getDefault().logError("hoverRegion partitioning could not be evaluated", ex);
}
return text;
}