Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Eclipse RCP Data Binding with WritableValue - Int vs. Integer
Eclipse RCP Data Binding with WritableValue - Int vs. Integer [message #1358942] Fri, 16 May 2014 05:33 Go to next message
Florian Klein is currently offline Florian KleinFriend
Messages: 5
Registered: May 2014
Junior Member
Hello,

I'm using Eclipse RCP 4 and I've little problem with my WritableValue:

I use the WritableValue in a data binding (see below) and whenever I set the value of my WritableValue with an object that contains an int attribute (part of the binding), then I receive a ClassCastException:

WritableValue<PlantBE> writableValue;
...
writableValue.setValue(somePlantBEEntity)


Caused by: java.lang.ClassCastException: Cannot cast java.lang.Integer to int
	at java.lang.Class.cast(Unknown Source)        
    at org.eclipse.core.internal.databinding.beans.PojoValueProperty.doGetValue(PojoValueProperty.java:62)
	at org.eclipse.core.databinding.property.value.ValueProperty.getValue(ValueProperty.java:60)
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.notifyIfChanged(SimplePropertyObservableValue.java:119)
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.doGetValue(SimplePropertyObservableValue.java:101)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.getValue(AbstractObservableValue.java:81)
	at org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue.doGetValue(DetailObservableValue.java:150)
	at org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue$2.handleValueChange(DetailObservableValue.java:96)
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:71)
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:127)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java:76)
	at org.eclipse.core.databinding.observable.value.WritableValue.doSetValue(WritableValue.java:94)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.setValue(AbstractObservableValue.java:60)



This is my binding:

 IObservableValue<?> model2 = PojoProperties.value(PlantBE.class,
				"maxAge").observeDetail(writableValue);
    ISWTObservableValue<String> view2 = WidgetProperties.textText(SWT.Modify)
                .observe(getDialogView().getTxtMaxAge().getText());
    this.getDataBindingContext().bindValue(model2, view2);


The Entity (PlantBE) looks like that:

  public class PlantBE implements Serializable {
	private int maxAge;

	public int getMaxAge() {
		return maxAge;
	}

	public void setMaxAge(int maxAge) {
		this.maxAge = maxAge;
	}
    }


It would be great to get some help on that. Maybe you've an idea what the issue could be.

Thanks and best regards
Re: Eclipse RCP Data Binding with WritableValue - Int vs. Integer [message #1359954 is a reply to message #1358942] Fri, 16 May 2014 15:35 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
What target platform do you use?
It seems that you are using a jface databinding that has support for java 5 generics... I cant remember an official release of jface databinding with generics.

Effectively, the executed code does (something like) this:

int.class.cast(new Integer(0))


Florian Klein wrote on Fri, 16 May 2014 07:33
Hello,

I'm using Eclipse RCP 4 and I've little problem with my WritableValue:

I use the WritableValue in a data binding (see below) and whenever I set the value of my WritableValue with an object that contains an int attribute (part of the binding), then I receive a ClassCastException:

WritableValue<PlantBE> writableValue;
...
writableValue.setValue(somePlantBEEntity)


Caused by: java.lang.ClassCastException: Cannot cast java.lang.Integer to int
	at java.lang.Class.cast(Unknown Source)        
    at org.eclipse.core.internal.databinding.beans.PojoValueProperty.doGetValue(PojoValueProperty.java:62)
	at org.eclipse.core.databinding.property.value.ValueProperty.getValue(ValueProperty.java:60)
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.notifyIfChanged(SimplePropertyObservableValue.java:119)
	at org.eclipse.core.internal.databinding.property.value.SimplePropertyObservableValue.doGetValue(SimplePropertyObservableValue.java:101)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.getValue(AbstractObservableValue.java:81)
	at org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue.doGetValue(DetailObservableValue.java:150)
	at org.eclipse.core.internal.databinding.observable.masterdetail.DetailObservableValue$2.handleValueChange(DetailObservableValue.java:96)
	at org.eclipse.core.databinding.observable.value.ValueChangeEvent.dispatch(ValueChangeEvent.java:71)
	at org.eclipse.core.databinding.observable.ChangeManager.fireEvent(ChangeManager.java:127)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.fireValueChange(AbstractObservableValue.java:76)
	at org.eclipse.core.databinding.observable.value.WritableValue.doSetValue(WritableValue.java:94)
	at org.eclipse.core.databinding.observable.value.AbstractObservableValue.setValue(AbstractObservableValue.java:60)



This is my binding:

 IObservableValue<?> model2 = PojoProperties.value(PlantBE.class,
				"maxAge").observeDetail(writableValue);
    ISWTObservableValue<String> view2 = WidgetProperties.textText(SWT.Modify)
                .observe(getDialogView().getTxtMaxAge().getText());
    this.getDataBindingContext().bindValue(model2, view2);


The Entity (PlantBE) looks like that:

  public class PlantBE implements Serializable {
	private int maxAge;

	public int getMaxAge() {
		return maxAge;
	}

	public void setMaxAge(int maxAge) {
		this.maxAge = maxAge;
	}
    }


It would be great to get some help on that. Maybe you've an idea what the issue could be.

Thanks and best regards

Re: Eclipse RCP Data Binding with WritableValue - Int vs. Integer [message #1361977 is a reply to message #1359954] Sat, 17 May 2014 12:24 Go to previous messageGo to next message
Florian Klein is currently offline Florian KleinFriend
Messages: 5
Registered: May 2014
Junior Member
Thanks for your reply.

I'm using Kepler 4.3.2 as a target platform. The included plugins look like that:

Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Require-Bundle: javax.inject;bundle-version="1.0.0";visibility:=reexport,
 org.eclipse.swt;bundle-version="3.102.1";visibility:=reexport,
 org.eclipse.jface;bundle-version="3.9.1";visibility:=reexport,
 org.eclipse.core.runtime;bundle-version="3.9.100";visibility:=reexport,
 org.eclipse.osgi;visibility:=reexport,
 org.eclipse.e4.core.di;visibility:=reexport,
 org.eclipse.e4.ui.model.workbench;visibility:=reexport,
 org.eclipse.e4.core.commands;bundle-version="0.10.2";visibility:=reexport,
 org.eclipse.e4.tools.services;visibility:=reexport,
 org.eclipse.e4.ui.workbench;visibility:=reexport,
 org.eclipse.e4.core.contexts;visibility:=reexport,
 org.eclipse.e4.ui.services;bundle-version="1.0.1";visibility:=reexport,
 org.eclipse.e4.ui.di;bundle-version="1.0.0";visibility:=reexport,
 org.eclipse.e4.ui.workbench.addons.swt;bundle-version="1.0.2";visibility:=reexport,
 org.eclipse.e4.core.services;bundle-version="1.1.0";visibility:=reexport,
 org.eclipse.core.jobs,

 org.eclipse.jface.databinding;bundle-version="1.7.0";visibility:=reexport,
 org.eclipse.core.databinding;bundle-version="1.5.0";visibility:=reexport
 org.eclipse.core.databinding.beans;bundle-version="1.5.0";visibility:=reexport,
 org.eclipse.core.databinding.property;bundle-version="1.5.0";visibility:=reexport,


So maybe I'm using the wrong plugin combination. I was trying to chose always the newest version.

Best regards,
Florian
Re: Eclipse RCP Data Binding with WritableValue - Int vs. Integer [message #1362018 is a reply to message #1361977] Sat, 17 May 2014 12:46 Go to previous messageGo to next message
Florian Klein is currently offline Florian KleinFriend
Messages: 5
Registered: May 2014
Junior Member
Ok, now it's working Smile. I've changed the plugin version for org.eclipse.core.databinding.beans from 1.5 -> 1.2.2 in my target platform.

I've attached a file with my current configuration of the target platform. Right now I don't like the mixing of the 1.5 version with the lower version. What do you think on that?

Still my question would be why the 1.5 version did not work. I was trying to find the source code for the 1.5 version without any success.

Re: Eclipse RCP Data Binding with WritableValue - Int vs. Integer [message #1362051 is a reply to message #1362018] Sat, 17 May 2014 13:07 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
1.5 is experimental code from the e4 project - the sources are hosted at
http://git.eclipse.org/c/e4/org.eclipse.e4.databinding.git/

Tom

On 17.05.14 14:46, Florian Klein wrote:
> Ok, now it's working :). I've changed the plugin version for org.eclipse.core.databinding.beans from 1.5 -> 1.2.2 in my target platform.
>
> I've attached a file with my current configuration of the target platform. Right now I don't like the mixing of the 1.5 version with the lower version. What do you think on that?
>
> Still my question would be why the 1.5 version did not work. I was trying to find the source code for the 1.5 version without any success.
>
>
Previous Topic:Broken popup menu with compatibility layer
Next Topic:Looking for an Eclipse build for Linux AArch64
Goto Forum:
  


Current Time: Tue Mar 19 02:17:26 GMT 2024

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

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

Back to the top