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;
}
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;
}
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);
}
Aggregations