Search in sources :

Example 1 with IOverviewRulerExtension

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

the class AbstractDecoratedTextEditor method handlePreferenceStoreChanged.

@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    try {
        ISourceViewer sourceViewer = getSourceViewer();
        if (sourceViewer == null)
            return;
        String property = event.getProperty();
        if (fSourceViewerDecorationSupport != null && fOverviewRuler != null && OVERVIEW_RULER.equals(property)) {
            if (isOverviewRulerVisible())
                showOverviewRuler();
            else
                hideOverviewRuler();
            return;
        }
        if (USE_SATURATED_COLORS_IN_OVERVIEW_RULER.equals(property)) {
            if (fOverviewRuler instanceof IOverviewRulerExtension) {
                ((IOverviewRulerExtension) fOverviewRuler).setUseSaturatedColors(isPrefUseSaturatedColorsOn());
                fOverviewRuler.update();
            }
        }
        if (DISABLE_OVERWRITE_MODE.equals(property)) {
            enableOverwriteMode(isOverwriteModeEnabled());
            return;
        }
        if (LINE_NUMBER_RULER.equals(property)) {
            // only handle visibility of the combined column, but not the number/change only state
            IColumnSupport columnSupport = getAdapter(IColumnSupport.class);
            if (isLineNumberRulerVisible() && fLineColumn == null) {
                RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
                if (lineNumberColumnDescriptor != null)
                    columnSupport.setColumnVisible(lineNumberColumnDescriptor, true);
            } else if (!isLineNumberRulerVisible() && fLineColumn != null && !fLineColumn.isShowingChangeInformation()) {
                columnSupport.setColumnVisible(fLineColumn.getDescriptor(), false);
                fLineColumn = null;
            }
            return;
        }
        if (AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON.equals(property)) {
            showChangeInformation(isPrefQuickDiffAlwaysOn());
        }
        if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
            IPreferenceStore store = getPreferenceStore();
            if (store != null)
                sourceViewer.getTextWidget().setTabs(store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
            if (isTabsToSpacesConversionEnabled()) {
                uninstallTabsToSpacesConverter();
                installTabsToSpacesConverter();
            }
            return;
        }
        if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(property)) {
            if (isTabsToSpacesConversionEnabled())
                installTabsToSpacesConverter();
            else
                uninstallTabsToSpacesConverter();
            return;
        }
        if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE.equals(property) && sourceViewer instanceof ITextViewerExtension6) {
            IPreferenceStore store = getPreferenceStore();
            if (store != null)
                ((ITextViewerExtension6) sourceViewer).getUndoManager().setMaximalUndoLevel(store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNDO_HISTORY_SIZE));
            return;
        }
        if (AbstractDecoratedTextEditorPreferenceConstants.SHOW_RANGE_INDICATOR.equals(property)) {
            if (isRangeIndicatorEnabled()) {
                getSourceViewer().setRangeIndicator(getRangeIndicator());
            } else {
                getSourceViewer().removeRangeIndication();
                getSourceViewer().setRangeIndicator(null);
            }
        }
        if (sourceViewer instanceof ITextViewerExtension6) {
            HyperlinkDetectorDescriptor[] descriptor = EditorsUI.getHyperlinkDetectorRegistry().getHyperlinkDetectorDescriptors();
            for (int i = 0; i < descriptor.length; i++) {
                if (descriptor[i].getId().equals(property) || (descriptor[i].getId() + HyperlinkDetectorDescriptor.STATE_MASK_POSTFIX).equals(property)) {
                    IHyperlinkDetector[] detectors = getSourceViewerConfiguration().getHyperlinkDetectors(sourceViewer);
                    int stateMask = getSourceViewerConfiguration().getHyperlinkStateMask(sourceViewer);
                    ITextViewerExtension6 textViewer6 = (ITextViewerExtension6) sourceViewer;
                    textViewer6.setHyperlinkDetectors(detectors, stateMask);
                    return;
                }
            }
        }
    } finally {
        super.handlePreferenceStoreChanged(event);
    }
}
Also used : IHyperlinkDetector(org.eclipse.jface.text.hyperlink.IHyperlinkDetector) ITextViewerExtension6(org.eclipse.jface.text.ITextViewerExtension6) RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) IOverviewRulerExtension(org.eclipse.jface.text.source.IOverviewRulerExtension) Point(org.eclipse.swt.graphics.Point)

Example 2 with IOverviewRulerExtension

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

the class AbstractDecoratedTextEditor method createPartControl.

/*
	 * @see org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    if (fSourceViewerDecorationSupport != null)
        fSourceViewerDecorationSupport.install(getPreferenceStore());
    IColumnSupport columnSupport = getAdapter(IColumnSupport.class);
    if (isLineNumberRulerVisible()) {
        RulerColumnDescriptor lineNumberColumnDescriptor = RulerColumnRegistry.getDefault().getColumnDescriptor(LineNumberColumn.ID);
        if (lineNumberColumnDescriptor != null)
            columnSupport.setColumnVisible(lineNumberColumnDescriptor, true);
    }
    if (isPrefQuickDiffAlwaysOn())
        showChangeInformation(true);
    if (fOverviewRuler instanceof IOverviewRulerExtension)
        ((IOverviewRulerExtension) fOverviewRuler).setUseSaturatedColors(isPrefUseSaturatedColorsOn());
    if (!isOverwriteModeEnabled())
        enableOverwriteMode(false);
    if (!isRangeIndicatorEnabled()) {
        getSourceViewer().removeRangeIndication();
        getSourceViewer().setRangeIndicator(null);
    }
    // Assign the quick assist assistant to the annotation access.
    ISourceViewer viewer = getSourceViewer();
    if (fAnnotationAccess instanceof IAnnotationAccessExtension2 && viewer instanceof ISourceViewerExtension3)
        ((IAnnotationAccessExtension2) fAnnotationAccess).setQuickAssistAssistant(((ISourceViewerExtension3) viewer).getQuickAssistAssistant());
    createOverviewRulerContextMenu();
}
Also used : RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IAnnotationAccessExtension2(org.eclipse.jface.text.source.IAnnotationAccessExtension2) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer) ISourceViewerExtension3(org.eclipse.jface.text.source.ISourceViewerExtension3) IOverviewRulerExtension(org.eclipse.jface.text.source.IOverviewRulerExtension)

Aggregations

IOverviewRulerExtension (org.eclipse.jface.text.source.IOverviewRulerExtension)2 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)2 IColumnSupport (org.eclipse.ui.texteditor.rulers.IColumnSupport)2 RulerColumnDescriptor (org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ITextViewerExtension6 (org.eclipse.jface.text.ITextViewerExtension6)1 IHyperlinkDetector (org.eclipse.jface.text.hyperlink.IHyperlinkDetector)1 IAnnotationAccessExtension2 (org.eclipse.jface.text.source.IAnnotationAccessExtension2)1 ISourceViewerExtension3 (org.eclipse.jface.text.source.ISourceViewerExtension3)1 Point (org.eclipse.swt.graphics.Point)1