Search in sources :

Example 1 with ITextEditorExtension2

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

the class LineNumberColumn method getQuickDiffPreference.

/**
 * Returns whether quick diff info should be visible upon opening an editor
 * according to the preference store settings.
 *
 * @return <code>true</code> if the line numbers should be visible
 */
private boolean getQuickDiffPreference() {
    if (fForwarder != null)
        return fForwarder.isQuickDiffEnabled();
    IPreferenceStore store = getPreferenceStore();
    boolean setting = store != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false;
    if (!setting)
        return false;
    boolean modifiable;
    ITextEditor editor = getEditor();
    if (editor instanceof ITextEditorExtension2) {
        ITextEditorExtension2 ext = (ITextEditorExtension2) editor;
        modifiable = ext.isEditorInputModifiable();
    } else if (editor instanceof ITextEditorExtension) {
        ITextEditorExtension ext = (ITextEditorExtension) editor;
        modifiable = ext.isEditorInputReadOnly();
    } else if (editor != null) {
        modifiable = editor.isEditable();
    } else {
        modifiable = true;
    }
    return modifiable;
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) ITextEditorExtension2(org.eclipse.ui.texteditor.ITextEditorExtension2) ITextEditorExtension(org.eclipse.ui.texteditor.ITextEditorExtension) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Aggregations

IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)1 ITextEditorExtension (org.eclipse.ui.texteditor.ITextEditorExtension)1 ITextEditorExtension2 (org.eclipse.ui.texteditor.ITextEditorExtension2)1