Is it possible to use the MessageRegistry with Choiceboxes? [message #1600654] |
Wed, 04 February 2015 06:41  |
Eclipse User |
|
|
|
Hello,
I would like to populate the items of a choicebox with strings from my messageregistry, but I have a mismatch: the choicebox takes an ObservableList as argument, and the register method a Consumer<String>.
How could I do this, preferably without touching the MessageRegistry itself, as it is a generated from a l10n-file ?
Any ideas would be welcome,
Thomas
|
|
|
|
|
Re: Is it possible to use the MessageRegistry with Choiceboxes? [message #1600827 is a reply to message #1600722] |
Wed, 04 February 2015 09:20  |
Eclipse User |
|
|
|
Thanks for the suggestion : the classic pattern (which I had not yet used, as I am quite new to RCP) works very well in this case :
@Inject
private void updateChoiceBox(@Translation LoginMessages messages)
{
if (languageBox != null)
{
ObservableList<String> items = FXCollections.observableArrayList() ;
items.add(English_Index, messages.eng) ;
items.add(French_Index, messages.fr) ;
items.add(Dutch_Index, messages.nl) ;
languageBox.setItems(items);
languageBox.setValue(languageBox.getItems().get(localeIndex));
}
}
I don't think this would make a good enhancement request because of the behavior of the choicebox, which has to be taken care of when its values are changed.
Thanks for the very rapid reactions,
Thomas
|
|
|
Powered by
FUDForum. Page generated in 0.04721 seconds