本文整理匯總了Java中org.eclipse.jface.text.source.ISourceViewer.getAnnotationModel方法的典型用法代碼示例。如果您正苦於以下問題:Java ISourceViewer.getAnnotationModel方法的具體用法?Java ISourceViewer.getAnnotationModel怎麽用?Java ISourceViewer.getAnnotationModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.ISourceViewer
的用法示例。
在下文中一共展示了ISourceViewer.getAnnotationModel方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getHoverInfo
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的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: ensureAnnotationModelInstalled
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的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: getMarkerPosition
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
/**
* Returns the actual position of <i>marker</i> or null if the marker was
* deleted. Code inspired by
* @param marker
* @param sourceViewer
* @return
*/
private static int[] getMarkerPosition(IMarker marker, ISourceViewer sourceViewer) {
int[] p = new int[2];
p[0] = marker.getAttribute(IMarker.CHAR_START, -1);
p[1] = marker.getAttribute(IMarker.CHAR_END, -1);
// look up the current range of the marker when the document has been edited
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model instanceof AbstractMarkerAnnotationModel) {
AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
Position pos= markerModel.getMarkerPosition(marker);
if (pos != null && !pos.isDeleted()) {
// use position instead of marker values
p[0] = pos.getOffset();
p[1] = pos.getOffset() + pos.getLength();
}
if (pos != null && pos.isDeleted()) {
// do nothing if position has been deleted
return null;
}
}
return p;
}
示例4: uninstallAnnotationModel
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的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());
}
}
}
示例5: getHoverInfo
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
/**
* Find a problem marker from the given line and return its error message.
*
* @param sourceViewer the source viewer
* @param lineNumber line number in the file, starting from zero
* @return the message of the marker of null, if no marker at the specified line
*/
public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
IDocument document= sourceViewer.getDocument();
IAnnotationModel model= sourceViewer.getAnnotationModel();
if (model == null)
return null;
List<String> lineMarkers = null;
Iterator<Annotation> e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation o= e.next();
if (o instanceof MarkerAnnotation) {
MarkerAnnotation a= (MarkerAnnotation) o;
if (isRulerLine(model.getPosition(a), document, lineNumber)) {
if (lineMarkers == null)
lineMarkers = new LinkedList<String>();
lineMarkers.add(a.getMarker().getAttribute(IMarker.MESSAGE, null));
}
}
}
if (lineMarkers != null)
return getMessage(lineMarkers);
return null;
}