Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » using combobox for non-enums fields
using combobox for non-enums fields [message #1110292] Mon, 16 September 2013 17:20 Go to next message
Peter Benedikovič is currently offline Peter Benedikovič
Messages: 8
Registered: September 2013
Junior Member
Hi,

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.

Thanks for advice!
Re: using combobox for non-enums fields [message #1110360 is a reply to message #1110292] Mon, 16 September 2013 19:41 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 942
Registered: July 2009
Senior Member
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.

<property-editor>
    <property>Jdk</property>
    <style>Sapphire.PropertyEditor.PopUpListField.Strict</style>
</property-editor>


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.
Re: using combobox for non-enums fields [message #1112510 is a reply to message #1110360] Thu, 19 September 2013 20:31 Go to previous messageGo to next message
Peter Benedikovič is currently offline Peter Benedikovič
Messages: 8
Registered: September 2013
Junior Member
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?
Re: using combobox for non-enums fields [message #1112544 is a reply to message #1112510] Thu, 19 September 2013 21:22 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 942
Registered: July 2009
Senior Member
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.
Previous Topic:CountConstraint does not show any error message
Next Topic:Control of underlying browser object
Goto Forum:
  


Current Time: Sat Oct 25 14:55:25 GMT 2014

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

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