|
From: Lieven D. <ld...@sc...> - 2008-01-23 07:31:12
|
Hi Benoit,
I've also come across this problem. If the enum value that you don't
want to show are consistent throughout your application, you could
modify the enumcomboboxbinder to only show values for which you have
provided a message. Then in your messages you omit the messages for the
values you don't want to show.
Something like this:
@SuppressWarnings("unchecked")
private List<Enum> createEnumSelectableItems(FormModel formModel,
String formPropertyPath)
{
Class propertyType = getPropertyType(formModel, formPropertyPath);
Class<Enum> enumPropertyType = propertyType;
List<Enum> out = new ArrayList<Enum>();
for (Enum e : enumPropertyType.getEnumConstants())
{
String desc = getMessage(enumPropertyType.getName() + "." +
e.name());
if (!StringUtils.isEmpty(desc))
{
out.add(e);
}
}
// return enumPropertyType.getEnumConstants();
return out;
}
and in your createListBinding of your ...Binder you use
binding.setSelectableItems(createEnumSelectableItems(formModel,
formPropertyPath));
That's how I solved it. I had to rewrite TigerEnumComboboxBinder since
message handling over here is a bit different than standard RCP.
Grtz,
Lieven
Benoit Xhenseval schreef:
> Hi,
>
>
>
> I love the TigerEnumComboBoxBinder and the automatic name formatting.
>
>
>
> I have however a case where the application must fill the combo box with
> a SUB-SELECTION of the values of an enum…
>
> How could we do this? Please note that the sub-selection should be
> dynamic and not specified in any xml,etc.
>
>
>
> I think that If the following method was overridable/protected, it would
> be easier to achieve what I need:
>
> *private* Enum[] createEnumSelectableItems(FormModel formModel,
> String formPropertyPath)
>
>
>
> Has anyone done this?
>
>
>
> Thanks & best regards
>
>
>
> Benoit
>
>
>
> ------------------------------
>
> IMPORTANT NOTICE
>
> This communication contains information that is considered confidential
> and may also be privileged . It is for the exclusive use of the intended
> recipient(s). If you are not the intended recipient(s) please note that
> any form of distribution, copying or use of this communication or the
> information in it is strictly prohibited and may be unlawful. If you
> have received this communication in error please return it to the sender
> and delete the original.
>
>
>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Springframework-rcp-dev mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-rcp-dev
|