|
From: Benoit X. <bx...@ob...> - 2008-01-22 18:01:44
|
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.
|
|
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
|
|
From: Benoit X. <bx...@ob...> - 2008-01-23 15:31:50
|
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 =3D (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.=20
Thanks
Regards
Benoit.
------------------------------
IMPORTANT NOTICE=20
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=20
want to show are consistent throughout your application, you could=20
modify the enumcomboboxbinder to only show values for which you have=20
provided a message. Then in your messages you omit the messages for the=20
values you don't want to show.
Something like this:
@SuppressWarnings("unchecked")
private List<Enum> createEnumSelectableItems(FormModel formModel,=20
String formPropertyPath)
{
Class propertyType =3D getPropertyType(formModel, =
formPropertyPath);
Class<Enum> enumPropertyType =3D propertyType;
List<Enum> out =3D new ArrayList<Enum>();
for (Enum e : enumPropertyType.getEnumConstants())
{
String desc =3D getMessage(enumPropertyType.getName() + "." =
+=20
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,=20
formPropertyPath));
That's how I solved it. I had to rewrite TigerEnumComboboxBinder since=20
message handling over here is a bit different than standard RCP.
Grtz,
Lieven
Benoit Xhenseval schreef:
> Hi,
>=20
> =20
>=20
> I love the TigerEnumComboBoxBinder and the automatic name formatting.
>=20
> =20
>=20
> I have however a case where the application must fill the combo box =
with=20
> a SUB-SELECTION of the values of an enum=E2=80=A6
>=20
> How could we do this? Please note that the sub-selection should be=20
> dynamic and not specified in any xml,etc.
>=20
> =20
>=20
> I think that If the following method was overridable/protected, it =
would=20
> be easier to achieve what I need:
>=20
> *private* Enum[] createEnumSelectableItems(FormModel formModel,=20
> String formPropertyPath)
>=20
> =20
>=20
> Has anyone done this?
>=20
> =20
>=20
> Thanks & best regards
>=20
> =20
>=20
> Benoit
>=20
> =20
>=20
> ------------------------------
>=20
> IMPORTANT NOTICE
>=20
> This communication contains information that is considered =
confidential=20
> and may also be privileged . It is for the exclusive use of the =
intended=20
> recipient(s). If you are not the intended recipient(s) please note =
that=20
> any form of distribution, copying or use of this communication or the=20
> information in it is strictly prohibited and may be unlawful. If you=20
> have received this communication in error please return it to the =
sender=20
> and delete the original.
>=20
> =20
>=20
>=20
> =
------------------------------------------------------------------------
>=20
> =
-------------------------------------------------------------------------=
> 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/
>=20
>=20
> =
------------------------------------------------------------------------
>=20
> _______________________________________________
> 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
|
|
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
|