Skip to main content



      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 06:41 Go to next message
Eclipse UserFriend
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 07:13 Go to previous messageGo to next message
Eclipse UserFriend
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 07:43 Go to previous messageGo to next message
Eclipse UserFriend
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 09:20 Go to previous message
Eclipse UserFriend
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: Sun Jul 20 16:26:28 EDT 2025

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

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

Back to the top