I am working on a plugin for Eclipse. In one wizard, user has to select JRE. To get advantage of already defined JRE/JDKs in Eclipse, I ould like to present these in a combobox (or some kind of only-one-select-list) with a button that would take user to the Preferences->Define new JRE usecase in case he want to use some other JDK. I would like to save user from finding the JDK on his file system through standard browse button.
Is there a way how to do that? Currently I see only possibility and that is using ContentProposalService.
You can use the pop-up list field property editor with any value property that has a PossibleValuesService. You can see different presentations demonstrated in the Sapphire Gallery sample under Value Properties -> Possible Values.
To use the pop-up list field presentation in a situation that defaults to the text field presentation, you need to specify the style in the property editor definition in sdef. There is a "Style" field all the way at the bottom of the screen in the sdef editor when you have a property editor selected. You will want "Sapphire.PropertyEditor.PopUpListField.Strict" for the JDK property since it doesn't make much sense to allow the user to type in that field.
Besides setting the style, you will need to implement a PossibleValuesService for the Jdk property.
To get a button next to the combo to launch the preferences page, you will need to implement an action and an action handler. You register these for the property editor in sdef. See various action examples in the samples plugin.
Thanks Konstantin. I have one more follow up question. I have defined an action that takes user to the JRE preferences pane. After clicking OK button on this pane, I need to refresh values in list. I tried to call getElementModel().refresh() directly from Action.run method. It seems triggering possible values service to refresh to list values but the ValueLabelService used to show names of JDKs is not called and I still see the same content in popup list. What is the best way to refresh list?
The property editor listens to the PossibleValuesService to know when to refresh list content. To trigger an event, just call broadcast() in your service implementation. Typically, you would add a listener on your source to do that during service init and remove the listener during service dispose.