Comboviewer binding in XWT [message #546834] |
Wed, 14 July 2010 08:00  |
Eclipse User |
|
|
|
Hi,
I have an object model which contains an enumeration field. I would like to create for it an comboviewer on my xwt form.
I've put the chooseable items by setinput, I also define the contentprovider, labelprovider, everything works fine but the binding.
Let's say the model is a Phone entity which has to fields:
- phoneType is an enumeration
- number is a String
I would like to bind the phoneType to a comboviewer, it should be a comboviewer due to I have to provide the forms on many languages, so I have to use labelprovider..
So, any Idea how to bind the comboviewer's selected item to the model's phoneType?
Thx in advance,
Istvan
[Updated on: Wed, 14 July 2010 08:00] by Moderator
|
|
|
Re: Comboviewer binding in XWT [message #547015 is a reply to message #546834] |
Wed, 14 July 2010 21:13   |
Eclipse User |
|
|
|
In general, it should be:
<ComboViewer input="{binding path=phoneType}">
</ComboViewer>
But it needs a content provider to return all literals of enum. Please try
it your-self, If it doesn't work, please report a bug.
Best regards
Yves YANG
"Istvan Benedek" <istvan.benedek@bestest.hu> wrote in message
news:i1k8t1$mgq$1@build.eclipse.org...
> Hi,
> I have an object model which contains an enumeration field. I would like
> to create for it an comboviewer on my xwf form. I've put the chooseable
> items by setinput, I also define the contentprovider, labelprovider,
> everything works fine but the binding.
>
> Let's say the model is a Phone entity which has to fields:
> - phoneType is an enumeration
> - number is a String
>
> I would like to bind the phoneType to a comboviewer, it should be a
> comboviewer due to I have to provide the forms on many languages, so I
> have to use labelprovider..
>
> So, any Idea how to bind the comboviewer's selected item to the model's
> phoneType?
>
>
> Thx in advance,
>
> Istvan
>
>
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Comboviewer binding in XWT [message #578898 is a reply to message #547631] |
Tue, 20 July 2010 11:25  |
Eclipse User |
|
|
|
Hi,
I've just seen your answer.. Thx for the fix. In the meantime we made a workaround...
<ComboViewer name="bloodType"
input="xx.xxx.xxx.xxx.xxx.enums.BloodType">
<ComboViewer.singleSelection>
<Binding path="bloodType">
</Binding>
</ComboViewer.singleSelection>
<ComboViewer.labelProvider>
<c:ServerCoreEnumLabelProvider />
</ComboViewer.labelProvider>
<ComboViewer.contentProvider>
<c:ServerCoreEnumContentProvider />
</ComboViewer.contentProvider>
<ComboViewer.layoutData>
<GridData horizontalAlignment="FILL" verticalAlignment="FILL"
grabExcessHorizontalSpace="true" grabExcessVerticalSpace="true" />
</ComboViewer.layoutData>
<ComboViewer.control>
</ComboViewer.control>
</ComboViewer>
where the ServerCoreEnumContentProvider's getElements
@Override
public Object[] getElements(Object inputElement) {
if(inputElement instanceof String){
try{
Class<?> clazz=Class.forName((String) inputElement);
Method method=clazz.getMethod("values", new Class[]{});
Object [] objectArray=(Object[]) method.invoke(clazz, new Object[]{});
if(objectArray !=null)
return objectArray;
else
return EMPTY;
}catch (Exception e) {
e.printStackTrace();
}
}
return EMPTY;
}
obviously it was hack... btw it works for all enum by name binding input parameter.
Istvan
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07087 seconds