Search in sources :

Example 1 with RulerColumnDescriptor

use of org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor in project dbeaver by serge-rider.

the class SQLEditor method showScriptPositionRuler.

private void showScriptPositionRuler(boolean show) {
    IColumnSupport columnSupport = (IColumnSupport) getAdapter(IColumnSupport.class);
    if (columnSupport != null) {
        RulerColumnDescriptor positionColumn = RulerColumnRegistry.getDefault().getColumnDescriptor(ScriptPositionColumn.ID);
        columnSupport.setColumnVisible(positionColumn, show);
    }
}
Also used : RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport)

Example 2 with RulerColumnDescriptor

use of org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method updateContributedRulerColumns.

/**
 * Adds enabled ruler contributions to the vertical ruler.
 * <p>
 * Clients may extend or replace.</p>
 *
 * @param ruler the composite ruler to add contributions to
 * @since 3.3
 */
protected void updateContributedRulerColumns(CompositeRuler ruler) {
    IColumnSupport support = getAdapter(IColumnSupport.class);
    if (support == null)
        return;
    RulerColumnPreferenceAdapter adapter = null;
    if (fPreferenceStore != null)
        adapter = new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS);
    RulerColumnRegistry registry = RulerColumnRegistry.getDefault();
    List<RulerColumnDescriptor> descriptors = registry.getColumnDescriptors();
    for (Iterator<RulerColumnDescriptor> it = descriptors.iterator(); it.hasNext(); ) {
        final RulerColumnDescriptor descriptor = it.next();
        support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor));
    }
}
Also used : RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) RulerColumnRegistry(org.eclipse.ui.texteditor.rulers.RulerColumnRegistry) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) RulerColumnPreferenceAdapter(org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter)

Example 3 with RulerColumnDescriptor

use of org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor in project eclipse.platform.text by eclipse.

the class AbstractTextEditor method handlePreferenceStoreChanged.

/**
 * Handles a property change event describing a change of the editor's
 * preference store and updates the preference related editor properties.
 * <p>
 * Subclasses may extend.
 * </p>
 *
 * @param event the property change event
 */
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    if (fSourceViewer == null)
        return;
    String property = event.getProperty();
    if (getFontPropertyPreferenceKey().equals(property))
        // There is a separate handler for font preference changes
        return;
    if (PREFERENCE_COLOR_FOREGROUND.equals(property) || PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_BACKGROUND.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property)) {
        initializeViewerColors(fSourceViewer);
    } else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) {
        initializeFindScopeColor(fSourceViewer);
    } else if (PREFERENCE_USE_CUSTOM_CARETS.equals(property)) {
        updateCaret();
    } else if (PREFERENCE_WIDE_CARET.equals(property)) {
        updateCaret();
    }
    if (affectsTextPresentation(event))
        fSourceViewer.invalidateTextPresentation();
    if (PREFERENCE_HYPERLINKS_ENABLED.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension6) {
            IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
            int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
            ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
            textViewer6.setHyperlinkDetectors(detectors, stateMask);
        }
        return;
    }
    if (PREFERENCE_HYPERLINK_KEY_MODIFIER.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension6) {
            ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) fSourceViewer;
            IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(fSourceViewer);
            int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(fSourceViewer);
            textViewer6.setHyperlinkDetectors(detectors, stateMask);
        }
        return;
    }
    if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) {
        String[] difference = StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue());
        IColumnSupport support = getAdapter(IColumnSupport.class);
        for (int i = 0; i < difference.length; i++) {
            RulerColumnDescriptor desc = RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]);
            if (desc != null && support.isColumnSupported(desc)) {
                boolean newState = !support.isColumnVisible(desc);
                support.setColumnVisible(desc, newState);
            }
        }
        return;
    }
    if (PREFERENCE_SHOW_WHITESPACE_CHARACTERS.equals(property) || PREFERENCE_SHOW_LEADING_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES.equals(property) || PREFERENCE_SHOW_LEADING_TABS.equals(property) || PREFERENCE_SHOW_ENCLOSED_TABS.equals(property) || PREFERENCE_SHOW_TRAILING_TABS.equals(property) || PREFERENCE_SHOW_CARRIAGE_RETURN.equals(property) || PREFERENCE_SHOW_LINE_FEED.equals(property) || PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE.equals(property)) {
        IAction action = getAction(ITextEditorActionConstants.SHOW_WHITESPACE_CHARACTERS);
        if (action instanceof IUpdate)
            ((IUpdate) action).update();
        return;
    }
    if (PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED.equals(property)) {
        IPreferenceStore store = getPreferenceStore();
        if (store != null && store.getBoolean(PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED))
            installTextDragAndDrop(getSourceViewer());
        else
            uninstallTextDragAndDrop(getSourceViewer());
        return;
    }
    if (PREFERENCE_HOVER_ENRICH_MODE.equals(property)) {
        if (fSourceViewer instanceof ITextViewerExtension8) {
            IPreferenceStore store = getPreferenceStore();
            if (store != null) {
                ((ITextViewerExtension8) fSourceViewer).setHoverEnrichMode(convertEnrichModePreference(store.getInt(PREFERENCE_HOVER_ENRICH_MODE)));
            }
        }
        return;
    }
}
Also used : IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) IAction(org.eclipse.jface.action.IAction) ITextViewerExtension6(org.eclipse.jface.text.ITextViewerExtension6) Point(org.eclipse.swt.graphics.Point) RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) ITextViewerExtension8(org.eclipse.jface.text.ITextViewerExtension8) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 4 with RulerColumnDescriptor

use of org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor in project eclipse.platform.text by eclipse.

the class AbstractDecoratedTextEditor method doSetInput.

/*
	 * @see AbstractTextEditor#doSetInput(IEditorInput)
	 *
	 * This implementation also updates change information in the quick diff
	 * ruler.
	 */
@Override
protected void doSetInput(IEditorInput input) throws CoreException {
    fIsDerivedStateValidated = false;
    fIsEditingDerivedFileAllowed = true;
    if (fLineColumn != null)
        fLineColumn.hideRevisionInformation();
    super.doSetInput(input);
    RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
    if (lineNumberColumnDescriptor != null) {
        IColumnSupport columnSupport = getAdapter(IColumnSupport.class);
        columnSupport.setColumnVisible(lineNumberColumnDescriptor, isLineNumberRulerVisible() || isPrefQuickDiffAlwaysOn());
    }
}
Also used : RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport)

Example 5 with RulerColumnDescriptor

use of org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor 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)

Aggregations

IColumnSupport (org.eclipse.ui.texteditor.rulers.IColumnSupport)8 RulerColumnDescriptor (org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor)8 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)3 IAction (org.eclipse.jface.action.IAction)2 ITextViewerExtension6 (org.eclipse.jface.text.ITextViewerExtension6)2 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)2 IOverviewRulerExtension (org.eclipse.jface.text.source.IOverviewRulerExtension)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 Point (org.eclipse.swt.graphics.Point)2 RulerColumnPreferenceAdapter (org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter)2 Action (org.eclipse.jface.action.Action)1 ITextViewerExtension8 (org.eclipse.jface.text.ITextViewerExtension8)1 CompositeRuler (org.eclipse.jface.text.source.CompositeRuler)1 IAnnotationAccessExtension2 (org.eclipse.jface.text.source.IAnnotationAccessExtension2)1 ISourceViewerExtension3 (org.eclipse.jface.text.source.ISourceViewerExtension3)1 IVerticalRuler (org.eclipse.jface.text.source.IVerticalRuler)1 CompositeRevertAction (org.eclipse.ui.internal.editors.quickdiff.CompositeRevertAction)1 RestoreAction (org.eclipse.ui.internal.editors.quickdiff.RestoreAction)1 RevertBlockAction (org.eclipse.ui.internal.editors.quickdiff.RevertBlockAction)1 RevertLineAction (org.eclipse.ui.internal.editors.quickdiff.RevertLineAction)1