Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMF Forms] Changing visible columns and their order in a table
[EMF Forms] Changing visible columns and their order in a table [message #1790712] Thu, 14 June 2018 18:10 Go to next message
Nikola Veber is currently offline Nikola VeberFriend
Messages: 23
Registered: December 2017
Junior Member
Hi,

I have been trying to allow users to configure some of the tables in my app.
In the simple example, I am implementing custom table renderer, extending TableControlSWTRenderer.

I have tried following, which worked in a static example:

VTableDomainModelReference domainModelReference = (VTableDomainModelReference)((VTableControl)getVElement()).getDomainModelReference();
domainModelReference.getColumnDomainModelReferences().clear();
VFeaturePathDomainModelReference colRef2 = VViewFactory.eINSTANCE.createFeaturePathDomainModelReference();
colRef2.setDomainModelEFeature(Elements2Package.Literals.FIELD__FIELD_NAME);
domainModelReference.getColumnDomainModelReferences().add(colRef2);


When I make the setting dynamic, the implementation stops working producing exceptions like:
org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException: The resolved Object FieldNew doesn't contain the feature xyz.
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.emf.ecore.impl.EAttributeImpl cannot be cast to org.eclipse.emf.ecore.EReference)
org.eclipse.emfforms.spi.core.services.databinding.DatabindingFailedException: The resolved Object FieldNew doesn't contain the feature alias.


By dynamic, I mean that the list of provided EAttributes (feature paths as well, worked in the static case) changes between renderings.


After a while, I realized that there were still columns defined in the viewmodel, which could not be rendered, as the DomainModelReferences list has been cleared.
After removing all column configurations from the viewmodel, the problem remains similar, with exceptions like
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: elements2.impl.ColConfigImpl cannot be cast to org.eclipse.emf.ecore.EStructuralFeature$Setting)

ColConfigImpl being the class containing the feature refenced via the feature path.

My guess is that touching the domain model references is not the way to go, and one should rather change the viewmodel itself? (how?!)

I would be grateful for any tips!


Best regards
Nikola
Re: [EMF Forms] Changing visible columns and their order in a table [message #1790737 is a reply to message #1790712] Fri, 15 June 2018 08:30 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 147
Registered: May 2015
Senior Member
Hi Nikola,

how do you trigger a rerendering after the changes on the DomainModelReferences?

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Changing visible columns and their order in a table [message #1790738 is a reply to message #1790737] Fri, 15 June 2018 08:45 Go to previous messageGo to next message
Nikola Veber is currently offline Nikola VeberFriend
Messages: 23
Registered: December 2017
Junior Member
Hi Eugen,

I have tried changing them in constructor, after calling super constructor, before calling super constructor (super(tesChange(vElement), viewContext,...), as well as by overriding the render method, to make changes before calling "return super.render(cell, parent); (in TableControlSWTRenderer)".

I am using the renderer in an extension of Generic Editor. Settings are made in Eclipse Preferences, where I keep a map of columns (EAttributes for DomainModelEFeature and lists of EReferences for DomainModelEReferencePath).
Rendering is trigered by the navigation in the tree, next time an object of that type is selected.

(Table Renderer is applied to a table defined in a ViewModel for one type, so the rendering is triggered by the framework / GenericEditor).

Thanks,
Nikola

P.S.
I tried just for fun to shuffle the list, doing
domainModelReference.getColumnDomainModelReferences().move(0, domainModelReference.getColumnDomainModelReferences().size()-1);


producing following stack trace (which may show in more detail how the rendering is triggered)

!ENTRY org.eclipse.ui 4 0 2018-06-15 10:33:18.160
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: elements2.impl.ColConfigImpl cannot be cast to org.eclipse.emf.ecore.EStructuralFeature$Setting)
	at org.eclipse.swt.SWT.error(SWT.java:4491)
	at org.eclipse.swt.SWT.error(SWT.java:4406)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4155)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3772)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)
Caused by: java.lang.ClassCastException: elements2.impl.ColConfigImpl cannot be cast to org.eclipse.emf.ecore.EStructuralFeature$Setting
	at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSetting(BasicEObjectImpl.java:1596)
	at org.eclipse.emfforms.core.services.databinding.featurepath.FeaturePathDomainModelReferenceConverter.getSetting(FeaturePathDomainModelReferenceConverter.java:173)
	at org.eclipse.emfforms.internal.core.services.databinding.EMFFormsDatabindingImpl.getSetting(EMFFormsDatabindingImpl.java:257)
	at org.eclipse.emfforms.internal.core.services.mappingprovider.table.EMFFormsMappingProviderTable.getMappingFor(EMFFormsMappingProviderTable.java:94)
	at org.eclipse.emfforms.internal.core.services.mappingprovider.EMFFormsMappingProviderManagerImpl.getAllSettingsFor(EMFFormsMappingProviderManagerImpl.java:101)
	at org.eclipse.emfforms.internal.core.services.controlmapper.SettingToControlMapperImpl.updateControlMapping(SettingToControlMapperImpl.java:188)
	at org.eclipse.emfforms.internal.core.services.controlmapper.SettingToControlMapperImpl.checkAndUpdateSettingToControlMapping(SettingToControlMapperImpl.java:303)
	at org.eclipse.emfforms.internal.core.services.controlmapper.SettingToControlMapperImpl.vControlAdded(SettingToControlMapperImpl.java:274)
	at org.eclipse.emfforms.internal.core.services.controlmapper.SettingToControlMapperImpl$ModelChangeAddRemoveListenerImplementation.notifyAdd(SettingToControlMapperImpl.java:67)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl$ViewModelContentAdapter.addAdapter(ViewModelContextImpl.java:634)
	at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:219)
	at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:182)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:419)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:193)
	at org.eclipse.emf.ecore.util.EContentAdapter.addAdapter(EContentAdapter.java:349)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl$ViewModelContentAdapter.addAdapter(ViewModelContextImpl.java:627)
	at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:219)
	at org.eclipse.emf.ecore.util.EContentAdapter.setTarget(EContentAdapter.java:182)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.didAdd(BasicNotifierImpl.java:121)
	at org.eclipse.emf.common.util.BasicEList.addUnique(BasicEList.java:419)
	at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:303)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl$EAdapterList.add(BasicNotifierImpl.java:193)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.instantiate(ViewModelContextImpl.java:281)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.<init>(ViewModelContextImpl.java:205)
	at org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory.createViewModelContext(ViewModelContextFactory.java:55)
	at org.eclipse.emfforms.spi.swt.treemasterdetail.TreeMasterDetailComposite$UpdateDetailRunnable.run(TreeMasterDetailComposite.java:606)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 24 more

[Updated on: Fri, 15 June 2018 08:49]

Report message to a moderator

Re: [EMF Forms] Changing visible columns and their order in a table [message #1790748 is a reply to message #1790738] Fri, 15 June 2018 13:43 Go to previous messageGo to next message
Eugen Neufeld is currently offline Eugen NeufeldFriend
Messages: 147
Registered: May 2015
Senior Member
Hi Nikola,

I still don't get how you do the rerendering after a change of the domain model references.

Nonetheless I think it would be cleaner to modify the view model instead of changing something in the renderer.

Cheers,
Eugen


--
Eugen Neufeld

Get professional Eclipse developer support:
http://eclipsesource.com/en/services/developer-support/
Re: [EMF Forms] Changing visible columns and their order in a table [message #1790751 is a reply to message #1790748] Fri, 15 June 2018 14:42 Go to previous messageGo to next message
Nikola Veber is currently offline Nikola VeberFriend
Messages: 23
Registered: December 2017
Junior Member
Hi Eugen,

I have found a promising example of ViewModel modification in org.eclipse.emfforms.internal.editor.ecore.GroupExpansionViewModelService
Will report after I finish trying it out!

Thanks for your time!
Cheers
Nikola
Re: [EMF Forms] Changing visible columns and their order in a table [message #1790811 is a reply to message #1790751] Mon, 18 June 2018 10:17 Go to previous messageGo to next message
Nikola Veber is currently offline Nikola VeberFriend
Messages: 23
Registered: December 2017
Junior Member
Hi Eugen,

after playing around I have done following:
- load viewModel model from my editor plugin resource
- change column configuration (by adding FeaturePathDomainModelReferences of the visible columns in the required order)
- saving the resource back to the viewmodel file in my plugin

This seems to work after eclipse restart. (which is a bit inconvenient, but ok)
Everything seems to work fine (manually changed column widths are persisted correctly etc)

Is there a way to reload viewmodels "on the fly"?
Are there any downsides to overwriting the viewmodel in the plugin I would need to be aware of? This is actually a bad practice.... but it works.

Thanks,
Nikola
Re: [EMF Forms] Changing visible columns and their order in a table [message #1790816 is a reply to message #1790811] Mon, 18 June 2018 13:14 Go to previous message
Nikola Veber is currently offline Nikola VeberFriend
Messages: 23
Registered: December 2017
Junior Member
In reply to my own question:
ViewModelFileExtensionsManager.dispose();

seems to do the trick!

The next time a new model is required, the ViewModelFileExtensionsManager will be reinitialized with current values.
Previous Topic:[EMF Forms] Move from 1.9 to 1.17
Next Topic:[Edapt] Feature not found when migrating
Goto Forum:
  


Current Time: Wed Sep 19 18:29:50 GMT 2018

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

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

Back to the top