Search in sources :

Example 1 with IAnnotationHover

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);
}
Also used : IAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Point(org.eclipse.swt.graphics.Point)

Example 2 with IAnnotationHover

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);
}
Also used : IAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover) StyledText(org.eclipse.swt.custom.StyledText) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) Point(org.eclipse.swt.graphics.Point)

Example 3 with IAnnotationHover

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;
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SimpleJavaSourceViewerConfiguration(org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration) DefaultInformationControl(org.eclipse.jface.text.DefaultInformationControl) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) SourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport) IAnnotationHover(org.eclipse.jface.text.source.IAnnotationHover) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator) AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) Shell(org.eclipse.swt.widgets.Shell) IInformationControl(org.eclipse.jface.text.IInformationControl) JavaSourceViewer(org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer) OverviewRuler(org.eclipse.jface.text.source.OverviewRuler) IOverviewRuler(org.eclipse.jface.text.source.IOverviewRuler) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnotationPreference(org.eclipse.ui.texteditor.AnnotationPreference) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) DefaultAnnotationHover(org.eclipse.jface.text.source.DefaultAnnotationHover)

Aggregations

IAnnotationHover (org.eclipse.jface.text.source.IAnnotationHover)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)2 Point (org.eclipse.swt.graphics.Point)2 JavaSourceViewer (org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer)1 SimpleJavaSourceViewerConfiguration (org.eclipse.jdt.internal.ui.text.SimpleJavaSourceViewerConfiguration)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 DefaultInformationControl (org.eclipse.jface.text.DefaultInformationControl)1 IInformationControl (org.eclipse.jface.text.IInformationControl)1 IInformationControlCreator (org.eclipse.jface.text.IInformationControlCreator)1 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)1 DefaultAnnotationHover (org.eclipse.jface.text.source.DefaultAnnotationHover)1 IOverviewRuler (org.eclipse.jface.text.source.IOverviewRuler)1 IVerticalRuler (org.eclipse.jface.text.source.IVerticalRuler)1 LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)1 OverviewRuler (org.eclipse.jface.text.source.OverviewRuler)1 StyledText (org.eclipse.swt.custom.StyledText)1 Shell (org.eclipse.swt.widgets.Shell)1 AnnotationPreference (org.eclipse.ui.texteditor.AnnotationPreference)1 SourceViewerDecorationSupport (org.eclipse.ui.texteditor.SourceViewerDecorationSupport)1