This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 413943 - [Workbench] Make "instance/org.eclipse.ui.ide/WORKSPACE_NAME" a public preference
Summary: [Workbench] Make "instance/org.eclipse.ui.ide/WORKSPACE_NAME" a public prefer...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: IDE (show other bugs)
Version: 4.4   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: 4.4 M5   Edit
Assignee: Paul Webster CLA
QA Contact: Paul Webster CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-29 14:55 EDT by Eike Stepper CLA
Modified: 2014-01-23 20:15 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Stepper CLA 2013-07-29 14:55:51 EDT
A normal call to a core API, i.e., EclipsePreferences.put() for key "instance/org.eclipse.ui.ide/WORKSPACE_NAME", leads to this exception in the UI:

org.eclipse.swt.SWTException: Invalid thread access
	at org.eclipse.swt.SWT.error(SWT.java:4397)
	at org.eclipse.swt.SWT.error(SWT.java:4312)
	at org.eclipse.swt.SWT.error(SWT.java:4283)
	at org.eclipse.swt.widgets.Widget.error(Widget.java:472)
	at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:363)
	at org.eclipse.swt.widgets.Decorations.getText(Decorations.java:747)
	at org.eclipse.ui.internal.WorkbenchWindowConfigurer.getTitle(WorkbenchWindowConfigurer.java:301)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor.recomputeTitle(IDEWorkbenchWindowAdvisor.java:421)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor.updateTitle(IDEWorkbenchWindowAdvisor.java:498)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor.access$3(IDEWorkbenchWindowAdvisor.java:461)
	at org.eclipse.ui.internal.ide.application.IDEWorkbenchWindowAdvisor$5.propertyChange(IDEWorkbenchWindowAdvisor.java:353)
	at org.eclipse.ui.preferences.ScopedPreferenceStore$3.run(ScopedPreferenceStore.java:375)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.preferences.ScopedPreferenceStore.firePropertyChangeEvent(ScopedPreferenceStore.java:372)
	at org.eclipse.ui.preferences.ScopedPreferenceStore$2.preferenceChange(ScopedPreferenceStore.java:194)
	at org.eclipse.core.internal.preferences.EclipsePreferences$3.run(EclipsePreferences.java:896)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.preferences.EclipsePreferences.firePreferenceEvent(EclipsePreferences.java:899)
	at org.eclipse.core.internal.preferences.EclipsePreferences.put(EclipsePreferences.java:912)

The private method IDEWorkbenchWindowAdvisor.recomputeTitle() seems to assume that it's always being called on the UI thread, but it's not.
Comment 1 Paul Webster CLA 2013-07-29 15:00:53 EDT
That preference key is considered an "internal detail" (i.e. it's not published in org.eclipse.ui.IWorkbenchPreferenceConstants) and does expect to be set/processed on the UI thread.

PW
Comment 2 Eike Stepper CLA 2013-07-29 15:20:20 EDT
Any idea why it's private?
Comment 3 Paul Webster CLA 2013-07-29 15:26:15 EDT
It's the other way around :-)  It was never made public as their was no reason to make that pref API.  It's a user pref, and there was never a request to set it in plugin_customization.ini or one of the other mechanisms.

You can fix the UI thread issue by changing the pref in an a/syncExec(*).

PW
Comment 4 Eike Stepper CLA 2013-07-30 01:02:27 EDT
(In reply to comment #3)
> You can fix the UI thread issue by changing the pref in an a/syncExec(*).

Sure, I did it already ;-)

> It's the other way around :-)  It was never made public as their was no
> reason to make that pref API.  It's a user pref, and there was never a
> request to set it in plugin_customization.ini or one of the other mechanisms.

Given the current complaints about lack of user preference scopes I am trying to automate the setting of preferences (and various other things) from an external workspace setup model. To identify the correct keys of preferences it is handy to export the preferences into two .epf files and compare the two. That's why I never thought about "public visibility". Do you think it would make sense to add this specific preference to the set of public preferences and add the Display.asyncExec() call to IDEWorkbenchWindowAdvisor.recomputeTitle()?

If so I would change this bugzilla to an enhancement request, otherwise I can close it as worksforme.
Comment 5 Paul Webster CLA 2013-07-30 14:05:11 EDT
(In reply to comment #4)
> Do
> you think it would make sense to add this specific preference to the set of
> public preferences and add the Display.asyncExec() call to
> IDEWorkbenchWindowAdvisor.recomputeTitle()?

I can consider making this public pref constant for Luna, but leave it as a UI preference (it should only be changed on the UI thread).  recomputeTitle() is called frequently enough that I don't want to put a sync guard around it.

PW
Comment 6 Eike Stepper CLA 2013-07-30 23:57:03 EDT
> I can consider making this public pref constant for Luna, 

That would be great. I've changed the bugzilla accordingly.

> but leave it as a
> UI preference (it should only be changed on the UI thread). 
> recomputeTitle() is called frequently enough that I don't want to put a sync
> guard around it.

I think I can live with this restriction. Is there a way to find out programmatically what preferences are "UI Preferences"?
Comment 8 Eike Stepper CLA 2014-01-15 00:42:51 EST
Thank you Paul!
Comment 9 Paul Webster CLA 2014-01-21 14:12:14 EST
2 problems:

1) I can't find IIDEPreferenceConstants in the javadoc of Help>Help Contents>Platform Plug-in Development>Reference>API References>org.eclipse.ui.ide

2) apparently it should go into org.eclipse.ui.ide.IDE.Preferences

PW
Comment 11 Paul Webster CLA 2014-01-23 20:15:27 EST
In 4.4.0.I20140123-1600