Search in sources :

Example 6 with IChangeRulerColumn

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

the class AbstractDecoratedTextEditor method createLineNumberRulerColumn.

/**
 * Creates a new line number ruler column that is appropriately initialized.
 *
 * @return the created line number column
 */
protected IVerticalRulerColumn createLineNumberRulerColumn() {
    /*
		 * Left for compatibility. See LineNumberColumn.
		 */
    fLineNumberRulerColumn = new LineNumberChangeRulerColumn(getSharedColors());
    ((IChangeRulerColumn) fLineNumberRulerColumn).setHover(createChangeHover());
    initializeLineNumberRulerColumn(fLineNumberRulerColumn);
    return fLineNumberRulerColumn;
}
Also used : IChangeRulerColumn(org.eclipse.jface.text.source.IChangeRulerColumn) LineNumberChangeRulerColumn(org.eclipse.jface.text.source.LineNumberChangeRulerColumn)

Example 7 with IChangeRulerColumn

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

the class LineNumberColumn method ensureQuickDiffProvider.

/**
 * Ensures that quick diff information is displayed and the quick diff provider is the one with
 * the specified id. If a different quick diff provider is in use, the user may be asked whether
 * he wants to switch.
 *
 * @param diffProviderId the quick diff provider id to use
 * @return <code>true</code> if quick diff could be enabled for the given id,
 *         <code>false</code> otherwise
 */
private boolean ensureQuickDiffProvider(String diffProviderId) {
    if (!isShowingChangeInformation())
        // FIXME pass provider id
        installChangeRulerModel(fDelegate);
    IAnnotationModel annotationModel = fViewer.getAnnotationModel();
    IAnnotationModel oldDiffer = getDiffer();
    if (oldDiffer == null && annotationModel != null)
        // quick diff is enabled, but no differ? not working for whatever reason
        return false;
    if (annotationModel == null)
        annotationModel = new AnnotationModel();
    if (!(annotationModel instanceof IAnnotationModelExtension))
        return false;
    QuickDiff util = new QuickDiff();
    Object oldDifferId = util.getConfiguredQuickDiffProvider(oldDiffer);
    if (oldDifferId.equals(diffProviderId)) {
        if (oldDiffer instanceof ILineDifferExtension)
            ((ILineDifferExtension) oldDiffer).resume();
        return true;
    }
    // Check whether the desired provider is available at all
    IAnnotationModel newDiffer = util.createQuickDiffAnnotationModel(getEditor(), diffProviderId);
    if (util.getConfiguredQuickDiffProvider(newDiffer).equals(oldDifferId)) {
        if (oldDiffer instanceof ILineDifferExtension)
            ((ILineDifferExtension) oldDiffer).resume();
        return true;
    }
    // quick diff is showing with the wrong provider - ask the user whether he wants to switch
    IPreferenceStore store = EditorsUI.getPreferenceStore();
    if (oldDiffer != null && !store.getString(REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY).equals(MessageDialogWithToggle.ALWAYS)) {
        MessageDialogWithToggle toggleDialog = MessageDialogWithToggle.openOkCancelConfirm(fViewer.getTextWidget().getShell(), RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_title, RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_message, RulerMessages.AbstractDecoratedTextEditor_revision_quickdiff_switch_rememberquestion, true, store, REVISION_ASK_BEFORE_QUICKDIFF_SWITCH_KEY);
        if (toggleDialog.getReturnCode() != Window.OK)
            return false;
    }
    IAnnotationModelExtension modelExtension = (IAnnotationModelExtension) annotationModel;
    modelExtension.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
    modelExtension.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, newDiffer);
    if (fDelegate instanceof IChangeRulerColumn)
        // picks up the new model attachment
        ((IChangeRulerColumn) fDelegate).setModel(annotationModel);
    return true;
}
Also used : QuickDiff(org.eclipse.ui.texteditor.quickdiff.QuickDiff) IChangeRulerColumn(org.eclipse.jface.text.source.IChangeRulerColumn) ILineDifferExtension(org.eclipse.jface.text.source.ILineDifferExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) IAnnotationModelExtension(org.eclipse.jface.text.source.IAnnotationModelExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 8 with IChangeRulerColumn

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

the class LineNumberColumn method uninstallChangeRulerModel.

/**
 * Uninstalls the differ annotation model from the current quick diff display.
 *
 * @param column the column to remove the model from
 */
private void uninstallChangeRulerModel(IVerticalRulerColumn column) {
    if (column instanceof IChangeRulerColumn)
        ((IChangeRulerColumn) column).setModel(null);
    IAnnotationModel model = getDiffer();
    if (model instanceof ILineDifferExtension)
        ((ILineDifferExtension) model).suspend();
    ISourceViewer viewer = fViewer;
    if (viewer != null && viewer.getAnnotationModel() == null)
        viewer.showAnnotations(false);
}
Also used : IChangeRulerColumn(org.eclipse.jface.text.source.IChangeRulerColumn) ILineDifferExtension(org.eclipse.jface.text.source.ILineDifferExtension) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) ISourceViewer(org.eclipse.jface.text.source.ISourceViewer)

Aggregations

IChangeRulerColumn (org.eclipse.jface.text.source.IChangeRulerColumn)8 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)4 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 RGB (org.eclipse.swt.graphics.RGB)3 IAnnotationModelExtension (org.eclipse.jface.text.source.IAnnotationModelExtension)2 ILineDifferExtension (org.eclipse.jface.text.source.ILineDifferExtension)2 MessageDialogWithToggle (org.eclipse.jface.dialogs.MessageDialogWithToggle)1 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)1 AnnotationModel (org.eclipse.jface.text.source.AnnotationModel)1 LineNumberChangeRulerColumn (org.eclipse.jface.text.source.LineNumberChangeRulerColumn)1 QuickDiff (org.eclipse.ui.texteditor.quickdiff.QuickDiff)1