Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 327059

Summary: Show Quick Diff and Show Line Number not working when editor extends from AbstractDecoratedTextEditor
Product: [Eclipse Project] Platform Reporter: aokleung
Component: TextAssignee: Platform-Text-Inbox <platform-text-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description aokleung CLA 2010-10-05 23:58:17 EDT
Build Identifier: 3.4.2.M20090127-1700

If I create an editor which extends from AbstractDecoratedTextEditor, the editor has its own preference store, it is not the same as EditorsUI.getPreferenceStore().

In AbstractDecoratedTextEditor.toggleLineNumberRuler(), it sets store as EditorsUI.getPreferenceStore(), but then in isLineNumberRulerVisible(), it just gets the preference store of my editor. The two preference stores are not the same, and the toggle never works. When I commented out "EditorsUI.", the "Show Line Number" action works perfectly.

	private void toggleLineNumberRuler() {
		// globally
		IPreferenceStore store= /*EditorsUI.*/getPreferenceStore();
		store.setValue(LINE_NUMBER_RULER, !isLineNumberRulerVisible());
	}

Similar problem occurs in toggleQuickDiffRuler(). When I commented out "EditorsUI.", the "Show Quick Diff" action works.

	private void toggleQuickDiffRuler() {
		// change the visibility locally if this editor is not in sync with the global preference
		// toggle the preference if we are in sync.
		IPreferenceStore store= /*EditorsUI.*/getPreferenceStore();
		boolean current= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
		if (current == isChangeInformationShowing())
			store.setValue(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, !current);
		else
			showChangeInformation(current);
	}


Reproducible: Always

Steps to Reproduce:
1. Create a plugin that extends org.eclipse.ui.plugin.AbstractUIPlugin

2. Create a preference store:
preferenceStore = new ScopedPreferenceStore(new InstanceScope(),getBundle().getSymbolicName());

3. In initializeDefaultPreferences(IPreferenceStore store):
	store.setDefault("lineNumberRuler", false);
	store.setDefault("quickdiff.quickDiff", false);

4. Create an editor that extends org.eclipse.ui.editors.text.TextEditor

5. Start runtime workbench

6. In the breakpoint popup menu, select "Show Line Number" or "Show Quick Diff", nothing occurs.
Comment 1 Dani Megert CLA 2010-10-06 03:02:01 EDT
Most of the text features are configured through the EditorsUI preference store. This allows users to configure all textual editors at once on the 'Text Editors' preference page.

You need to create a chained preference store:

    ArrayList stores= new ArrayList(2);
    stores.add(YOUR_STORE_GOES_HERE);
    stores.add(EditorsUI.getPreferenceStore());
    new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));