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