Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Why is "Preference AND Property page" not standard API?
Why is "Preference AND Property page" not standard API? [message #1797641] Sat, 03 November 2018 12:12 Go to next message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 149
Registered: March 2010
Senior Member
Hi all,

I am writing a plugin and as I am not an expert in Eclipse I need some guidance to ensure I am doing things "the right way".

One thing I wanted to replicate is the ability to have settings that can be set at the workbench level, but overridden on a per-project basis by the user.

My question is: does a "standard" base class exist in the platform to facilitate this?


I have discovered that the workbench level calls settings preferences and uses org.eclipse.jface.preference.PreferencePage, whereas at project-level settings are called properties and are based on org.eclipse.ui.dialogs.PropertyPage which extends the former. I immediately assumed there must be some "SettingsPage" that does both and has automatic control for switching between the two and using the appropriate storage scope and such, but I found nothing.

I know JDT does this so I checked out JDT source code to use as a guide. Looking at JDT sources there is a very convenient org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage which merges the two so that you can use the same class in both the preference and property extension points. There's also very useful code for storing the references at default/instance/project-scope plugin storage with listeners wired to disconnect the workbench level or re-connect it when the user flips the switch (notifying option caches in the model to rebuild using setting values from the new scope).

Unfortunately all this is internal API to JDT (not exported for use if you depend on org.eclipse.jdt.ui).

My initial reaction was surprise because I would expect this to be a fairly common use case. I've been copying over code from JDT to my plugin, but feel like I'm avoiding reinventing the wheel via clutter...

So, is there really no standard facility at the platform level for this, or is JDT source code just old enough to have implemented this internally before that existed? What would more experienced users of the platform API suggest?

[Updated on: Sat, 03 November 2018 12:12]

Report message to a moderator

Re: Why is "Preference AND Property page" not standard API? [message #1797659 is a reply to message #1797641] Sun, 04 November 2018 08:01 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33132
Registered: July 2009
Senior Member
I know the Xext project has this class:
 * Initially copied from Jdt.
 * @author Michael Clay
 * @since 2.1
public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage,
		IWorkbenchPropertyPage {
So I don't think there is a standard way that's reusable without copying the pattern you see in JDT. It's definitely unfortunate though quite common to find things in JDT that would be highly reusable... E.g., org.eclipse.jdt.internal.ui.javaeditor.breadcrumb.BreadcrumbViewer is super useful and reusable to provide breadcrumb support just like what you see in the Java editor...

Ed Merks
Professional Support:
Previous Topic:JUnit question
Next Topic:Editors leaks memory after close?
Goto Forum:

Current Time: Sun Apr 14 13:51:48 GMT 2024

Powered by FUDForum. Page generated in 0.05465 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top