Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Binding to "nested" properties
Binding to "nested" properties [message #918153] Thu, 20 September 2012 19:56 Go to next message
Mark Rowe is currently offline Mark RoweFriend
Messages: 23
Registered: January 2012
Junior Member
Firstly I hope I am using the correct terminology "nested property".

The model and code is from the RCP Vision tutorial "WindowBuilder: installing and EMF databinding" which is in turn from the official EMF documentation, but I have added a "Country" object.

Library ----->0..*Authors
                  name: EString
                  surname: EString
                  country: Country

                  Country
                  name: EString



Following the tutorial, I have a RCP plugin with a view containing a TableViewer. I can use WindowBuilder to bind name and surname which works fine, but if I try to find the nested property country.name then the binding fails and I get the following exception when I click "OK" on the "Edit Data Binding" dialog:

org.eclipse.wb.internal.core.utils.check.AssertionFailedException: 3 expected, but 2 found
	at org.eclipse.wb.internal.core.utils.check.Assert.fail(Assert.java:225)
	at org.eclipse.wb.internal.core.utils.check.Assert.equals(Assert.java:346)
	at org.eclipse.wb.internal.core.utils.check.Assert.equals(Assert.java:329)
	at org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo.setProperties(MapsEmfObservableInfo.java:73)
	at org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.InputElementUiContentProvider.saveToObject(InputElementUiContentProvider.java:92)
	at org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider.saveToObject(ChooseClassAndPropertiesUiContentProvider.java:476)
	at org.eclipse.wb.internal.core.databinding.ui.editor.UiContentProviderComposite.performFinish(UiContentProviderComposite.java:91)
	at org.eclipse.wb.internal.core.databinding.ui.BindWizardPage.performFinish(BindWizardPage.java:81)
	at org.eclipse.wb.internal.core.databinding.ui.BindWizard$1.runObject(BindWizard.java:64)
	at org.eclipse.wb.internal.core.databinding.ui.BindWizard$1.runObject(BindWizard.java:1)
	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runObjectLog(ExecutionUtils.java:298)
	at org.eclipse.wb.internal.core.databinding.ui.BindWizard.performFinish(BindWizard.java:62)
	at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:827)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:432)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3554)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3179)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
	at org.eclipse.jface.window.Window.open(Window.java:801)
	at org.eclipse.wb.internal.core.databinding.ui.property.AbstractObserveProperty.createBinding(AbstractObserveProperty.java:83)
	at org.eclipse.wb.internal.core.databinding.ui.property.SingleObserveBindingProperty.editBinding(SingleObserveBindingProperty.java:66)
	at org.eclipse.wb.internal.core.databinding.ui.property.SingleObserveBindingAction.runEx(SingleObserveBindingAction.java:48)
	at org.eclipse.wb.internal.core.model.util.ObjectInfoAction$1$1.run(ObjectInfoAction.java:86)
	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.run(ExecutionUtils.java:318)
	at org.eclipse.wb.internal.core.model.util.ObjectInfoAction$1.run(ObjectInfoAction.java:84)
	at org.eclipse.wb.internal.core.utils.execution.ExecutionUtils.runLog(ExecutionUtils.java:100)
	at org.eclipse.wb.internal.core.model.util.ObjectInfoAction.run(ObjectInfoAction.java:81)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3554)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3179)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1022)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:916)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:86)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:585)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:540)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	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:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)


Is it possible to use WindowBuilder to bind nested properties in this way?

I am using the default ObservableMapLabelProvider, is that correct for this type of binding?

Many thanks for any help Smile
Re: Binding to "nested" properties [message #918194 is a reply to message #918153] Thu, 20 September 2012 20:53 Go to previous messageGo to next message
Mark Rowe is currently offline Mark RoweFriend
Messages: 23
Registered: January 2012
Junior Member
A little more information...

WindowBuilder generates this code:

IObservableMap[] observeMaps = EMFObservables.observeMaps(listContentProvider.getKnownElements(), new EStructuralFeature[]{Literals.AUTHOR__NAME, Literals.AUTHOR__SURNAME});


Whereas to use the nested property, I *think* it is not possible to use EMFObservables.observeMaps(), instead the maps have to be created separately for direct and FeaturePath observable values, like this:

		IObservableSet knownElements = listContentProvider.getKnownElements();
		final IObservableMap firstNames = EMFProperties.value(Literals.AUTHOR__NAME).observeDetail(knownElements);
		final IObservableMap lastNames = EMFProperties.value(Literals.AUTHOR__SURNAME).observeDetail(knownElements);
		final IObservableMap countries = EMFProperties.value(FeaturePath.fromList(Literals.AUTHOR__COUNTRY, Literals.COUNTRY__NAME)).observeDetail(knownElements);
		
	    IObservableMap[] observeMaps = { firstNames, lastNames, countries };


I am not sure if this is a bug or a limitation or just if I am using the tool wrongly?
Re: Binding to "nested" properties [message #918198 is a reply to message #918153] Thu, 20 September 2012 20:54 Go to previous messageGo to next message
Mark Rowe is currently offline Mark RoweFriend
Messages: 23
Registered: January 2012
Junior Member
Duplicate post added by accident.

[Updated on: Thu, 20 September 2012 21:34]

Report message to a moderator

Re: Binding to "nested" properties [message #918272 is a reply to message #918198] Thu, 20 September 2012 22:32 Go to previous message
Stefano Cottafavi is currently offline Stefano CottafaviFriend
Messages: 53
Registered: July 2009
Member
Hi Mark,
think I have the same problem here.
I have EMF model structured as follow
Model:
prop1:
.name
.value
prop2:
.name
.value
etc...

In the Bindings page, on the left panel I select target widget (text), in the righ panel I select EMF, Model, and property "value" of the object prop1; in the right panel, above the filter textfield I read what I suppose to be the correct form model.prop1.value for the binding source.

After confirmation, the binding is added to the table at the top (bound properties), but in the column "Model" I have model.value and not model.prop1.value as expected.

Of course the binding for me it isn't working. I get a null object from the model.

Is the same for you? Is this right behaviour?
Anyone out there that can confirm/correct/suggest ?

Thanks.

Cheers,
Stefano
Previous Topic:WindowBuilder not behaving in Mountain Lion
Next Topic:Customization of Palette and Properties
Goto Forum:
  


Current Time: Thu Nov 27 00:23:30 GMT 2014

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

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