Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » "this" keyword equivalent for XWT databinding(bind an ui component with an attribute on the ui backing class)
"this" keyword equivalent for XWT databinding [message #839540] Sun, 08 April 2012 22:15 Go to next message
Rafael Ribeiro is currently offline Rafael RibeiroFriend
Messages: 17
Registered: April 2012
Junior Member
Hi all,

Is there any "this" keyword equivalent to be used in XWT databinding? To make things clearer, I am implementing a view which simply has a a JFace ListViewer and two buttons, one for adding elements and one for removing (in fact it is still kind of a proof of concept). For simplicity of the implementation I was willing to have the backing list directly as an attribute of the underlying class of the XWT view, so, the event listener code could be as simple as list.add(something) and the inclusion would be reflected into the view.

I saw a sample on E4 CVS that the ObjectInstance property for a CustomDataProvider class had the value of "{Binding}" (CustomDataProvider_Switch.xwt sorry but I could not paste the links since I have not yet posted more than 25 messages)and tried this on ObjectDataProvider but with no success (XWT designer fails with an StringIndexOutOfBounds which makes me wonder if this isn't valid).

Does anyone know which combination of DataProvider and input property value (as in ListViewer_BindingPath.xwt) that could achieve what I am trying to do?

best regards,

[Updated on: Sun, 08 April 2012 22:17]

Report message to a moderator

Re: "this" keyword equivalent for XWT databinding [message #840001 is a reply to message #839540] Mon, 09 April 2012 14:36 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 756
Registered: July 2009
Senior Member
There is a test case at: .../databinding/self/DecoratedText.xwt
Maybe, that is what you are looking for...
Re: "this" keyword equivalent for XWT databinding [message #840941 is a reply to message #840001] Tue, 10 April 2012 17:51 Go to previous messageGo to next message
Rafael Ribeiro is currently offline Rafael RibeiroFriend
Messages: 17
Registered: April 2012
Junior Member
Worked like a charm but I think I've come across a bug.
I have an attribute like this in my bean:
	private WritableList directories = new WritableList(new ArrayList<String>(),String.class);

with proper getters and setters... and if I specify the databinding thru XWT as follows:
<Composite xmlns="eclipse.org/xwt/presentation" 
	xmlns:x="eclipse.org/xwt" 
	x:Class="br.rar.dups.SetupAnalysisComposite" 
	xmlns:f="clr-namespace:org.eclipse.e4.xwt.jface" xmlns:v="clr-namespace:org.eclipse.jface.viewers" 
	name="root" loaded="onLoad">
	<ListViewer x:Style="BORDER | V_SCROLL" x:name="listViewer" input="{Binding elementName=root, path=directories, updateSourceTrigger=PropertyChanged}">

the following exception is thrown:
java.lang.ClassCastException: org.eclipse.core.databinding.observable.list.WritableList cannot be cast to org.eclipse.core.databinding.observable.value.IObservableValue
	at org.eclipse.e4.xwt.internal.core.ScopeManager.observeValue(ScopeManager.java:402)
	at org.eclipse.e4.xwt.internal.core.ScopeManager.observeValue(ScopeManager.java:390)
	at org.eclipse.e4.xwt.databinding.ControlDataBinding.getValue(ControlDataBinding.java:55)
	at org.eclipse.e4.xwt.internal.core.Binding.getValue(Binding.java:229)
	at org.eclipse.e4.xwt.converters.BindingToObject.convert(BindingToObject.java:26)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initSegmentAttribute(ResourceLoader.java:1619)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initAttribute(ResourceLoader.java:1414)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:676)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:670)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:467)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.createCLRElement(ResourceLoader.java:371)
	at org.eclipse.e4.xwt.internal.core.Core.createCLRElement(Core.java:617)
	at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:674)
	at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:644)
	at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java:836)
	at org.eclipse.e4.xwt.XWTLoader$1.run(XWTLoader.java:769)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.xwt.XWTLoader.open(XWTLoader.java:763)
	at org.eclipse.e4.xwt.XWTLoader.open(XWTLoader.java:715)
	at org.eclipse.e4.xwt.XWT.open(XWT.java:416)
	at br.rar.dups.SetupAnalysisComposite.main(SetupAnalysisComposite.java:60)

And I gave a look at ScopeManager and it seems like it wrongly thinks everything must be an IObservableValue and under no circumstances it can be an IObservableList...
for now I resorted to bind it manually using the onload event but isn't it a bug? Or I am simply binding it wrong?

P.S.: XML namespaces were ommitted due to the forum link limitation... Confused
Re: "this" keyword equivalent for XWT databinding [message #840958 is a reply to message #840941] Tue, 10 April 2012 18:26 Go to previous messageGo to next message
Rafael Ribeiro is currently offline Rafael RibeiroFriend
Messages: 17
Registered: April 2012
Junior Member
I changed back from WritableList to List and it is working fine... I thought that with WritableList I wouldn't have to call refresh on ListViewer after model changes but I still had to call so it made no difference.
But I think I've NOW hit a bug... with the example you provided everything is working fine but window builder designer fails complaining it could not find the property on Composite class... which obviously does not have that property but the question is WHY window builder designer is trying to lookup the property on Composite class instead of the backing class...
Re: "this" keyword equivalent for XWT databinding [message #840959 is a reply to message #840958] Tue, 10 April 2012 18:26 Go to previous messageGo to next message
Rafael Ribeiro is currently offline Rafael RibeiroFriend
Messages: 17
Registered: April 2012
Junior Member
forgot to paste the stacktrace
org.eclipse.e4.xwt.XWTException:  Property "directories" is not found in the class org.eclipse.swt.widgets.Composite
	at org.eclipse.e4.xwt.dataproviders.ObjectDataProvider$1.toModelPropertyType(ObjectDataProvider.java:53)
	at org.eclipse.e4.xwt.internal.core.ScopeManager$ObservableValueBuilder.observe(ScopeManager.java:194)
	at org.eclipse.e4.xwt.internal.core.ScopeManager.observe(ScopeManager.java:434)
	at org.eclipse.e4.xwt.databinding.DataBinding.getObservableSource(DataBinding.java:155)
	at org.eclipse.e4.xwt.databinding.DataBinding.getObservableWidget(DataBinding.java:174)
	at org.eclipse.e4.xwt.databinding.DataBinding.getValue(DataBinding.java:56)
	at org.eclipse.e4.xwt.internal.core.Binding.getValue(Binding.java:241)
	at org.eclipse.e4.xwt.converters.BindingToObject.convert(BindingToObject.java:26)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initSegmentAttribute(ResourceLoader.java:1619)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.initAttribute(ResourceLoader.java:1414)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:676)
	at org.eclipse.wb.internal.xwt.parser.XwtRenderer$5$1.doCreate(XwtRenderer.java:240)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:670)
	at org.eclipse.wb.internal.xwt.parser.XwtRenderer$5$1.doCreate(XwtRenderer.java:240)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.doCreate(ResourceLoader.java:467)
	at org.eclipse.wb.internal.xwt.parser.XwtRenderer$5$1.doCreate(XwtRenderer.java:240)
	at org.eclipse.e4.xwt.javabean.ResourceLoader.createCLRElement(ResourceLoader.java:371)
	at org.eclipse.e4.xwt.internal.core.Core.createCLRElement(Core.java:617)
	at org.eclipse.e4.xwt.internal.core.Core.load(Core.java:674)
	at org.eclipse.e4.xwt.XWTLoader.loadWithOptions(XWTLoader.java:864)
	at org.eclipse.e4.xwt.XWT.loadWithOptions(XWT.java:486)
	at org.eclipse.wb.internal.xwt.parser.XwtRenderer.render(XwtRenderer.java:261)
	at org.eclipse.wb.internal.xwt.model.widgets.ControlInfo.refresh_create(ControlInfo.java:94)
	at org.eclipse.wb.core.model.ObjectInfo.refreshCreate0(ObjectInfo.java:550)
	at org.eclipse.wb.core.model.ObjectInfo.access$0(ObjectInfo.java:546)
	at org.eclipse.wb.core.model.ObjectInfo$5$1.run(ObjectInfo.java:486)
	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runDesignTime(ExecutionUtils.java:139)
	at org.eclipse.wb.core.model.ObjectInfo$5.run(ObjectInfo.java:484)
	at org.eclipse.wb.core.model.ObjectInfo.execRefreshOperation(ObjectInfo.java:514)
	at org.eclipse.wb.core.model.ObjectInfo.refresh(ObjectInfo.java:482)
	at org.eclipse.wb.internal.core.xml.editor.XmlDesignPage.internal_refreshGEF(XmlDesignPage.java:459)
	at org.eclipse.wb.internal.core.xml.editor.XmlDesignPage.internal_refreshGEF(XmlDesignPage.java:390)
	at org.eclipse.wb.internal.core.xml.editor.UndoManager.refreshDesignerEditor(UndoManager.java:252)
	at org.eclipse.wb.internal.core.xml.editor.UndoManager.activate(UndoManager.java:85)
	at org.eclipse.wb.internal.core.xml.editor.XmlDesignPage.setActive(XmlDesignPage.java:171)
	at org.eclipse.wb.internal.core.xml.editor.AbstractXmlEditor.pageChange(AbstractXmlEditor.java:651)
	at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1061)
	at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2745)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1432)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
Re: "this" keyword equivalent for XWT databinding [message #861584 is a reply to message #840959] Sat, 28 April 2012 16:44 Go to previous message
Hans Mueller is currently offline Hans MuellerFriend
Messages: 28
Registered: April 2012
Junior Member
very good
Previous Topic:solution to "WorkbenchWindowAdvisor.createWindowContents(Shell))" not working in eclipse 4
Next Topic:How to create an eclipse 4 project that includes JDT and PDE ?
Goto Forum:
  


Current Time: Thu Dec 18 09:48:23 GMT 2014

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

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