|Why is "Preference AND Property page" not standard API? [message #1797641]
||Sat, 03 November 2018 12:12
| Alex Mising name
Registered: March 2010
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
| Ed Merks
Registered: July 2009
I know the Xext project has this class:|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...
* Initially copied from Jdt.
* @author Michael Clay
* @since 2.1
public abstract class PropertyAndPreferencePage extends PreferencePage implements IWorkbenchPreferencePage,
Professional Support: https://www.macromodeling.com/
Powered by FUDForum
. Page generated in 0.01466 seconds