Search in sources :

Example 6 with RulerColumnDescriptor

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

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

the class AbstractDecoratedTextEditor method addRulerContributionActions.

/**
 * Adds "show" actions for all contributed rulers that support it.
 *
 * @param menu the ruler context menu
 * @since 3.3
 */
private void addRulerContributionActions(IMenuManager menu) {
    // store directly in generic editor preferences
    final IColumnSupport support = getAdapter(IColumnSupport.class);
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    final RulerColumnPreferenceAdapter adapter = new RulerColumnPreferenceAdapter(store, AbstractTextEditor.PREFERENCE_RULER_CONTRIBUTIONS);
    List<RulerColumnDescriptor> descriptors = RulerColumnRegistry.getDefault().getColumnDescriptors();
    for (Iterator<RulerColumnDescriptor> t = descriptors.iterator(); t.hasNext(); ) {
        final RulerColumnDescriptor descriptor = t.next();
        if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor))
            continue;
        final boolean isVisible = support.isColumnVisible(descriptor);
        IAction action = new Action(MessageFormat.format(TextEditorMessages.AbstractDecoratedTextEditor_show_ruler_label, new Object[] { descriptor.getName() }), IAction.AS_CHECK_BOX) {

            @Override
            public void run() {
                if (descriptor.isGlobal())
                    // column state is modified via preference listener of AbstractTextEditor
                    adapter.setEnabled(descriptor, !isVisible);
                else
                    // directly modify column for this editor instance
                    support.setColumnVisible(descriptor, !isVisible);
            }
        };
        action.setChecked(isVisible);
        action.setImageDescriptor(descriptor.getIcon());
        menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, action);
    }
}
Also used : RevertLineAction(org.eclipse.ui.internal.editors.quickdiff.RevertLineAction) RevertBlockAction(org.eclipse.ui.internal.editors.quickdiff.RevertBlockAction) BooleanPreferenceToggleAction(org.eclipse.ui.internal.texteditor.BooleanPreferenceToggleAction) RevertSelectionAction(org.eclipse.ui.internal.editors.quickdiff.RevertSelectionAction) CompositeRevertAction(org.eclipse.ui.internal.editors.quickdiff.CompositeRevertAction) RestoreAction(org.eclipse.ui.internal.editors.quickdiff.RestoreAction) IAction(org.eclipse.jface.action.IAction) RefreshEditorAction(org.eclipse.ui.internal.editors.text.RefreshEditorAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) RulerColumnDescriptor(org.eclipse.ui.texteditor.rulers.RulerColumnDescriptor) IColumnSupport(org.eclipse.ui.texteditor.rulers.IColumnSupport) RulerColumnPreferenceAdapter(org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 8 with RulerColumnDescriptor

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

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