Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[e4] Support registration of PreferencePages with E4 #1917

Open
laeubi opened this issue Jun 2, 2024 · 6 comments
Open

[e4] Support registration of PreferencePages with E4 #1917

laeubi opened this issue Jun 2, 2024 · 6 comments
Labels
e4 Eclipse E4 enhancement New feature or request technical debt

Comments

@laeubi
Copy link
Contributor

laeubi commented Jun 2, 2024

Currently it is not possible to add a PreferencePage using E4 to the usual Window > Preferences because org.eclipse.ui.internal.dialogs.WorkbenchPreferenceManager only handles pages from the extension point org.eclipse.ui.preferencePages even though the PreferenceManager itself is already looked up by the E4 Context.

The goal would be to have a new Type preferencePages under the application model:

grafik

here one can add new PreferencePage with the properties:

  • class
  • label
  • category

because of the way E4 works, we don't need any specialization like IWorkbenchPreferencePage and can use the plain JFace PreferencePage here.

@laeubi laeubi added enhancement New feature or request e4 Eclipse E4 technical debt labels Jun 2, 2024
@fipro78
Copy link
Contributor

fipro78 commented Jun 2, 2024

I implemented a plain E4 mechanism based on OSGi DS a while ago.

https://github.com/fipro78/e4-preferences

Maybe it helps.

@laeubi
Copy link
Contributor Author

laeubi commented Jun 2, 2024

@fipro78 many thanks for sharing this, the main pitfall is what I highlighted here:

To open a JFace PreferenceDialog that looks similar to the known Eclipse workbench preference dialog, you need to create a handler that looks similar to the following snippet

So currently there is no way (beside open a complete new/different dialog) for a plugin to contribute this in an application independent way (e.g inside the usual Eclipse-IDE), that's what then can be used e.g. by Eclipse IDE or even by your implementation where one can have a custom handler.

@laeubi
Copy link
Contributor Author

laeubi commented Jun 2, 2024

Actually there is a workaround to achieve this with a standard Eclipse Workbench I described it here:

https://github.com/eclipse-platform/eclipse.platform.ui/wiki/Rich-Client-Platform#registering-preference-pages-using-e4

@fipro78 if you would use a ContextFunction you don't need the annotation to inject the manager and it would be similar possible to what I described there as option (2) to add pages that need E4 injection.

@fipro78
Copy link
Contributor

fipro78 commented Jun 3, 2024

@laeubi
Thanks for the hint. I think I tried to use a IContextFunction in the past, and failed because of a cycling dependency. I came across this again now, but this time I was able to solve it. :)

fipro78/e4-preferences@f2a3e8a

So now my mechanism uses a ContextFunction and there is no need anymore for the annotation.

@merks
Copy link
Contributor

merks commented Jun 3, 2024

Would it not be better/easier to define a new extension point that's effectively a copy of the current one, but has no workbench dependencies? I imagine much of the implementation could just be "moved down" to that new implementation.

The following is quite complex example where the label is translated, the class specifies the factory to be used to create the page instance, and it specifies a reference to the keywords that can be used to easily locate a preference on the page:

image

I'm trying to imagine how all this this fits into the UI model. It seems there is nothing really quite analogous in the model currently which makes me wonder how it should fit and whether it is a good fit...

@laeubi
Copy link
Contributor Author

laeubi commented Jun 3, 2024

Would it not be better/easier to define a new extension point that's effectively a copy of the current one, but has no workbench dependencies?

The E4 Model is "the extension point", especially because otherwise the dependency injection won't work and one can't target a specific application.

Translation should already be possible: https://wiki.eclipse.org/Eclipse4/RCP/Modeled_UI/Localization

Keywords is something I would like to omit for the moment, but one can specify a property fro that later on when it becomes relevant but keywords are acutally also an E3 concept that I'm not sure there is any match in E4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e4 Eclipse E4 enhancement New feature or request technical debt
Projects
None yet
Development

No branches or pull requests

3 participants