Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Is it possible to use the MessageRegistry with Choiceboxes?
Is it possible to use the MessageRegistry with Choiceboxes? [message #1600654] Wed, 04 February 2015 11:41 Go to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
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 #1600687 is a reply to message #1600654] Wed, 04 February 2015 12:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I see two options:

1. add a register method to the generated MessageRegistry (or create another MessageRegistry that extends the generated one) that takes a Consumer<Collection<String>>
2. don't use the MessageRegistry for that case but implement the Eclipse Translation Pattern manually by adding a method that gets the Message instance injected
Re: Is it possible to use the MessageRegistry with Choiceboxes? [message #1600722 is a reply to message #1600654] Wed, 04 February 2015 12:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Feel free to file an enhancement request for l10n and describe your usecase

Tom

On 04.02.15 12:41, Thomas Elskens wrote:
> 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 14:20 Go to previous message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
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
Previous Topic:Warning about number of arguments in property change handler method
Next Topic:view selection event
Goto Forum:
  


Current Time: Thu Apr 25 16:04:23 GMT 2024

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

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

Back to the top