|
From: Jan H. <jh...@sc...> - 2008-01-25 10:07:57
|
Visibility of createEnumSelectableItems() has changed to protected on
trunk.
Kind Regards,
Jan
On Wed, 2008-01-23 at 15:14 +0000, Benoit Xhenseval wrote:
> Hi Lieven,
>
> Thank you for your reply. I agree with you that sometimes not having all the enum messages will generate a rather nasty exception...
> My issue is slightly different in the sense that user X could see A,B,C but user Y could only see A,B. This is determined by the application.
> So the list of Enums that can be put in the combo varies.
>
> Unfortunately, TigerEnumComboBoxBinder.createEnumSelectableItems is private and cannot be overridden.
> I ended up have to overwrite the createListBinding.
>
> @Override
> protected AbstractListBinding createListBinding(final JComponent control, final FormModel formModel, final String formPropertyPath) {
> final ComboBoxBinding binding = (ComboBoxBinding) super.createListBinding(control, formModel, formPropertyPath);
> binding.setSelectableItems(createEnumSelectableItems(formModel, formPropertyPath));
> return binding;
> }
>
> private Enum[] createEnumSelectableItems(final FormModel formModel, final String formPropertyPath) {
> ... return my list of selectable items
> }
>
> I think it would be better if createEnumSelectableItems was protected.
>
>
> Thanks
>
> 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.
>
>
> -----Original Message-----
> From: spr...@li... [mailto:spr...@li...] On Behalf Of Lieven Doclo
> Sent: 23 January 2008 07:31
> To: spr...@li...
> Subject: Re: [Springframework-rcp-dev] Tiger and Enums
>
> 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
>
>
> -------------------------------------------------------------------------
> 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
>
>
> -------------------------------------------------------------------------
> 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
**** DISCLAIMER ****
http://www.schaubroeck.be/maildisclaimer.htm
|