Search in sources :

Example 6 with CompositeRuler

use of org.eclipse.jface.text.source.CompositeRuler 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 7 with CompositeRuler

use of org.eclipse.jface.text.source.CompositeRuler in project eclipse.platform.text by eclipse.

the class AbstractDecoratedTextEditor method createColumnSupport.

@Override
protected final IColumnSupport createColumnSupport() {
    return new ColumnSupport(this, RulerColumnRegistry.getDefault()) {

        @Override
        protected void initializeColumn(IContributedRulerColumn column) {
            super.initializeColumn(column);
            RulerColumnDescriptor descriptor = column.getDescriptor();
            IVerticalRuler ruler = internalGetVerticalRuler();
            if (ruler instanceof CompositeRuler) {
                if (AnnotationColumn.ID.equals(descriptor.getId())) {
                    ((AnnotationColumn) column).setDelegate(createAnnotationRulerColumn((CompositeRuler) ruler));
                } else if (LineNumberColumn.ID.equals(descriptor.getId())) {
                    fLineColumn = ((LineNumberColumn) column);
                    fLineColumn.setForwarder(new LineNumberColumn.ICompatibilityForwarder() {

                        @Override
                        public IVerticalRulerColumn createLineNumberRulerColumn() {
                            return AbstractDecoratedTextEditor.this.createLineNumberRulerColumn();
                        }

                        @Override
                        public boolean isQuickDiffEnabled() {
                            return AbstractDecoratedTextEditor.this.isPrefQuickDiffAlwaysOn();
                        }

                        @Override
                        public boolean isLineNumberRulerVisible() {
                            return AbstractDecoratedTextEditor.this.isLineNumberRulerVisible();
                        }
                    });
                }
            }
        }

        @Override
        public void dispose() {
            fLineColumn = null;
            super.dispose();
        }
    };
}
Also used : IContributedRulerColumn(org.eclipse.ui.texteditor.rulers.IContributedRulerColumn) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) AnnotationColumn(org.eclipse.ui.internal.texteditor.AnnotationColumn) RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IVerticalRuler(org.eclipse.jface.text.source.IVerticalRuler) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler)

Example 8 with CompositeRuler

use of org.eclipse.jface.text.source.CompositeRuler in project eclipse.platform.text by eclipse.

the class LineNumberRulerColumnTest method testRedrawAfterDispose.

@Test
public void testRedrawAfterDispose() {
    LineNumberRulerColumn lineNumberRulerColumn = new LineNumberRulerColumn();
    CompositeRuler ruler = new CompositeRuler();
    ruler.addDecorator(0, lineNumberRulerColumn);
    SourceViewer sourceViewer = new SourceViewer(fParent, ruler, SWT.NONE);
    lineNumberRulerColumn.getControl().setSize(10, 10);
    sourceViewer.getTextWidget().dispose();
    lineNumberRulerColumn.redraw();
}
Also used : LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) SourceViewer(org.eclipse.jface.text.source.SourceViewer) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Test(org.junit.Test)

Example 9 with CompositeRuler

use of org.eclipse.jface.text.source.CompositeRuler 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);
    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)

Example 10 with CompositeRuler

use of org.eclipse.jface.text.source.CompositeRuler in project hale by halestudio.

the class GroovyScriptPage method createVerticalRuler.

@Override
protected IVerticalRuler createVerticalRuler() {
    final Display display = Display.getCurrent();
    CompositeRuler ruler = new CompositeRuler(3);
    AnnotationRulerColumn annotations = SimpleAnnotationUtil.createDefaultAnnotationRuler(annotationModel);
    ruler.addDecorator(0, annotations);
    LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
    // SWT.COLOR_INFO_BACKGROUND));
    lineNumbers.setBackground(display.getSystemColor(SWT.COLOR_GRAY));
    // SWT.COLOR_INFO_FOREGROUND));
    lineNumbers.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
    lineNumbers.setFont(JFaceResources.getTextFont());
    ruler.addDecorator(1, lineNumbers);
    return ruler;
}
Also used : AnnotationRulerColumn(org.eclipse.jface.text.source.AnnotationRulerColumn) LineNumberRulerColumn(org.eclipse.jface.text.source.LineNumberRulerColumn) CompositeRuler(org.eclipse.jface.text.source.CompositeRuler) Display(org.eclipse.swt.widgets.Display)

Aggregations

CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)16 LineNumberRulerColumn (org.eclipse.jface.text.source.LineNumberRulerColumn)11 Display (org.eclipse.swt.widgets.Display)6 IVerticalRuler (org.eclipse.jface.text.source.IVerticalRuler)5 StyledText (org.eclipse.swt.custom.StyledText)3 RGB (org.eclipse.swt.graphics.RGB)3 FillLayout (org.eclipse.swt.layout.FillLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 SQLDocument (com.cubrid.common.ui.query.editor.SQLDocument)2 SQLPartitionScanner (com.cubrid.common.ui.query.editor.SQLPartitionScanner)2 SQLTextViewer (com.cubrid.common.ui.query.editor.SQLTextViewer)2 SQLViewerConfiguration (com.cubrid.common.ui.query.editor.SQLViewerConfiguration)2 Document (org.eclipse.jface.text.Document)2 DocumentEvent (org.eclipse.jface.text.DocumentEvent)2 IDocument (org.eclipse.jface.text.IDocument)2 IDocumentListener (org.eclipse.jface.text.IDocumentListener)2 IDocumentPartitioner (org.eclipse.jface.text.IDocumentPartitioner)2 TextViewerUndoManager (org.eclipse.jface.text.TextViewerUndoManager)2 FastPartitioner (org.eclipse.jface.text.rules.FastPartitioner)2 AnnotationRulerColumn (org.eclipse.jface.text.source.AnnotationRulerColumn)2