Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Comboviewer binding in XWT(How to bind enum value to JFace Comboviewer in XWT)
Comboviewer binding in XWT [message #546834] Wed, 14 July 2010 12:00 Go to next message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
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 12:00]

Report message to a moderator

Re: Comboviewer binding in XWT [message #547015 is a reply to message #546834] Thu, 15 July 2010 01:13 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
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 #547458 is a reply to message #546834] Sat, 17 July 2010 01:51 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
I have made a try. The solution I suggested doesn't work.

I have created a bug to track the development of this feature
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320154

Best regards
Yves YANG
Re: Comboviewer binding in XWT [message #547631 is a reply to message #547458] Mon, 19 July 2010 08:18 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
This featrue is implemented. The modification is committed in CVS. It'll be
available in the next build.

Please read the bug comment to get more information.

Best regards
Yves YANG
"Yves YANG" <yves.yang@soyatec.com> wrote in message
news:i1r2bi$dsg$1@build.eclipse.org...
>I have made a try. The solution I suggested doesn't work.
> I have created a bug to track the development of this feature
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=320154
>
> Best regards
> Yves YANG
Re: Comboviewer binding in XWT [message #548079 is a reply to message #547631] Tue, 20 July 2010 15:25 Go to previous messageGo to next message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member

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
Re: Comboviewer binding in XWT [message #548253 is a reply to message #547631] Wed, 21 July 2010 09:14 Go to previous messageGo to next message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
There is an other issue on comboviewer, the setselection invoked before the setinput, which means, the comboviewer does not show the value from the model at first time.
Re: Comboviewer binding in XWT [message #548657 is a reply to message #548253] Thu, 22 July 2010 14:47 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
I have noticed this t. it is fixed in the same time .

Best regards
Yves YANG
"Istvan Benedek" <istvan.benedek@bestest.hu> wrote in message
news:i26dp3$36j$1@build.eclipse.org...
> There is an other issue on comboviewer, the setselection invoked before
> the setinput, which means, the comboviewer does not show the value from
> the model at first time.
Re: Comboviewer binding in XWT [message #549223 is a reply to message #548657] Mon, 26 July 2010 07:55 Go to previous messageGo to next message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
Thx!
Re: Comboviewer binding in XWT [message #549971 is a reply to message #546834] Wed, 28 July 2010 15:33 Go to previous messageGo to next message
Mo P. is currently offline Mo P.
Messages: 24
Registered: July 2010
Junior Member
org.eclipse.e4.xwt.XWTException: Type cannot be a content of java.lang.Object org.eclipse.e4.xwt.internal.core.Binding.source


When I try the ComboViewer examples I get that exception. Did I forget anything?
Re: Comboviewer binding in XWT [message #550227 is a reply to message #549971] Thu, 29 July 2010 14:50 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Please check with the testcase first.

Best regards
Yves YANG
"Mo P." <moritzpavlik@gmx.de> wrote in message
news:i2pijs$6m0$1@build.eclipse.org...
>
> org.eclipse.e4.xwt.XWTException: Type cannot be a content of
> java.lang.Object org.eclipse.e4.xwt.internal.core.Binding.source
>
>
> When I try the ComboViewer examples I get that exception. Did I forget
> anything?
Re: Comboviewer binding in XWT [message #550231 is a reply to message #546834] Thu, 29 July 2010 15:00 Go to previous messageGo to next message
Mo P. is currently offline Mo P.
Messages: 24
Registered: July 2010
Junior Member
I tried the ComboViewer_enum and ComboViewer_enum_singleSelection which are both in ...tests.jface.enumeration.
Re: Comboviewer binding in XWT [message #550604 is a reply to message #550231] Sat, 31 July 2010 08:44 Go to previous messageGo to next message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
The testcase works fine for me. Please make sure you have used the last
build.

Best regards
Yves YANG
"Mo P." <moritzpavlik@gmx.de> wrote in message
news:i2s51m$eo8$1@build.eclipse.org...
>I tried the ComboViewer_enum and ComboViewer_enum_singleSelection which are
>both in ...tests.jface.enumeration.
Re: Comboviewer binding in XWT [message #553086 is a reply to message #546834] Mon, 16 August 2010 12:39 Go to previous messageGo to next message
Mo P. is currently offline Mo P.
Messages: 24
Registered: July 2010
Junior Member
where can i get the latest build? do i have to check out the classes and build the jar on my own?

when i download the latest release of eclipse e4 the filename is org.eclipse.e4.xwt_0.9.1.v20100720-1930.jar. why isnt that jar updated?

thanks in advance
Re: Comboviewer binding in XWT [message #553800 is a reply to message #553086] Wed, 18 August 2010 21:54 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
You can find here:
http://download.eclipse.org/e4/downloads/

Best regards
Yves YANG
"Mo P." <moritzpavlik@gmx.de> wrote in message
news:i4bbi7$ikh$1@build.eclipse.org...
> where can i get the latest build? do i have to check out the classes and
> build the jar on my own?
>
> when i download the latest release of eclipse e4 the filename is
> org.eclipse.e4.xwt_0.9.1.v20100720-1930.jar. why isnt that jar updated?
>
> thanks in advance
Re: Comboviewer binding in XWT [message #578898 is a reply to message #547631] Tue, 20 July 2010 15:25 Go to previous message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
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
Re: Comboviewer binding in XWT [message #578966 is a reply to message #547631] Wed, 21 July 2010 09:14 Go to previous message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
There is an other issue on comboviewer, the setselection invoked before the setinput, which means, the comboviewer does not show the value from the model at first time.
Re: Comboviewer binding in XWT [message #579090 is a reply to message #548253] Thu, 22 July 2010 14:47 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
I have noticed this t. it is fixed in the same time .

Best regards
Yves YANG
"Istvan Benedek" <istvan.benedek@bestest.hu> wrote in message
news:i26dp3$36j$1@build.eclipse.org...
> There is an other issue on comboviewer, the setselection invoked before
> the setinput, which means, the comboviewer does not show the value from
> the model at first time.
Re: Comboviewer binding in XWT [message #579446 is a reply to message #548657] Mon, 26 July 2010 07:55 Go to previous message
Istvan Benedek is currently offline Istvan Benedek
Messages: 14
Registered: May 2010
Junior Member
Thx!
Re: Comboviewer binding in XWT [message #579580 is a reply to message #549971] Thu, 29 July 2010 14:50 Go to previous message
Yves YANG is currently offline Yves YANG
Messages: 687
Registered: July 2009
Senior Member
Please check with the testcase first.

Best regards
Yves YANG
"Mo P." <moritzpavlik@gmx.de> wrote in message
news:i2pijs$6m0$1@build.eclipse.org...
>
> org.eclipse.e4.xwt.XWTException: Type cannot be a content of
> java.lang.Object org.eclipse.e4.xwt.internal.core.Binding.source
>
>
> When I try the ComboViewer examples I get that exception. Did I forget
> anything?
Previous Topic:Testing Text style
Next Topic:Comboviewer binding in XWT
Goto Forum:
  


Current Time: Mon Sep 15 09:30:42 GMT 2014

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

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