use of org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter in project eclipse.platform.text by eclipse.
the class AbstractTextEditor method updateContributedRulerColumns.
/**
* Adds enabled ruler contributions to the vertical ruler.
* <p>
* Clients may extend or replace.</p>
*
* @param ruler the composite ruler to add contributions to
* @since 3.3
*/
protected void updateContributedRulerColumns(CompositeRuler ruler) {
IColumnSupport support = getAdapter(IColumnSupport.class);
if (support == null)
return;
RulerColumnPreferenceAdapter adapter = null;
if (fPreferenceStore != null)
adapter = new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS);
RulerColumnRegistry registry = RulerColumnRegistry.getDefault();
List<RulerColumnDescriptor> descriptors = registry.getColumnDescriptors();
for (Iterator<RulerColumnDescriptor> it = descriptors.iterator(); it.hasNext(); ) {
final RulerColumnDescriptor descriptor = it.next();
support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor));
}
}
use of org.eclipse.ui.texteditor.rulers.RulerColumnPreferenceAdapter 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);
}
}
Aggregations