use of org.eclipse.jface.text.source.IAnnotationHover in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method showRulerAnnotationInformation.
/**
* Opens a sticky annotation ruler hover for the caret line. Does nothing if no annotation hover
* is available.
*
* @since 3.6
*/
private void showRulerAnnotationInformation() {
ISourceViewer sourceViewer = getSourceViewer();
IAnnotationHover hover = getSourceViewerConfiguration().getAnnotationHover(sourceViewer);
int caretOffset = sourceViewer.getTextWidget().getCaretOffset();
showFocusedRulerHover(hover, sourceViewer, caretOffset);
}
use of org.eclipse.jface.text.source.IAnnotationHover in project eclipse.platform.text by eclipse.
the class AbstractDecoratedTextEditor method showChangeRulerInformation.
/**
* Opens a sticky change ruler hover for the caret line. Does nothing if no change hover is
* available.
*
* @since 3.5
*/
private void showChangeRulerInformation() {
IVerticalRuler ruler = getVerticalRuler();
if (!(ruler instanceof CompositeRuler) || fLineColumn == null)
return;
CompositeRuler compositeRuler = (CompositeRuler) ruler;
// fake a mouse move (some hovers rely on this to determine the hovered line):
int x = fLineColumn.getControl().getLocation().x;
ISourceViewer sourceViewer = getSourceViewer();
StyledText textWidget = sourceViewer.getTextWidget();
int caretOffset = textWidget.getCaretOffset();
int caretLine = textWidget.getLineAtOffset(caretOffset);
int y = textWidget.getLinePixel(caretLine);
compositeRuler.setLocationOfLastMouseButtonActivity(x, y);
IAnnotationHover hover = fLineColumn.getHover();
showFocusedRulerHover(hover, sourceViewer, caretOffset);
}
use of org.eclipse.jface.text.source.IAnnotationHover in project xtext-xtend by eclipse.
the class DerivedSourceView method createSourceViewer.
@Override
protected SourceViewer createSourceViewer(Composite parent) {
IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
IOverviewRuler overviewRuler = new OverviewRuler(defaultMarkerAnnotationAccess, OVERVIEW_RULER_WIDTH, getSharedTextColors());
AnnotationRulerColumn annotationRulerColumn = new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, defaultMarkerAnnotationAccess);
@SuppressWarnings("unchecked") List<AnnotationPreference> annotationPreferences = markerAnnotationPreferences.getAnnotationPreferences();
for (AnnotationPreference annotationPreference : annotationPreferences) {
String key = annotationPreference.getVerticalRulerPreferenceKey();
boolean showAnnotation = true;
if (key != null && store.contains(key)) {
showAnnotation = store.getBoolean(key);
}
if (showAnnotation) {
annotationRulerColumn.addAnnotationType(annotationPreference.getAnnotationType());
}
}
annotationRulerColumn.addAnnotationType(Annotation.TYPE_UNKNOWN);
lineNumberRulerColumn = new LineNumberRulerColumn();
CompositeRuler compositeRuler = new CompositeRuler();
compositeRuler.addDecorator(0, annotationRulerColumn);
compositeRuler.addDecorator(1, lineNumberRulerColumn);
javaSourceViewer = new JavaSourceViewer(parent, compositeRuler, overviewRuler, true, SWT.V_SCROLL | SWT.H_SCROLL, store);
javaSourceViewerConfiguration = new SimpleJavaSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, true) {
@Override
public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
return new IInformationControlCreator() {
@Override
public IInformationControl createInformationControl(final Shell parent) {
return new DefaultInformationControl(parent, true);
}
};
}
@Override
public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
return new DefaultAnnotationHover();
}
};
javaSourceViewer.configure(javaSourceViewerConfiguration);
javaSourceViewer.setEditable(false);
javaSourceViewer.showAnnotations(true);
sourceViewerDecorationSupport = new SourceViewerDecorationSupport(javaSourceViewer, overviewRuler, defaultMarkerAnnotationAccess, getSharedTextColors());
for (AnnotationPreference annotationPreference : annotationPreferences) {
sourceViewerDecorationSupport.setAnnotationPreference(annotationPreference);
}
sourceViewerDecorationSupport.install(preferenceStoreAccess.getPreferenceStore());
return javaSourceViewer;
}
Aggregations