Bug 517573 - ObservableMapCellLabelProvider always uses first property
Summary: ObservableMapCellLabelProvider always uses first property
Status: RESOLVED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.4   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.10   Edit
Assignee: Jens Lideström CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2017-05-31 11:37 EDT by Jens Lideström CLA
Modified: 2018-09-11 16:28 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Lideström CLA 2017-05-31 11:37:35 EDT
ObservableMapCellLabelProvider#update methods looks like this:

	public void update(ViewerCell cell) {
		Object element = cell.getElement();
		Object value = attributeMaps[0].get(element);
		cell.setText(value == null ? "" : value.toString()); //$NON-NLS-1$
	}

This code always gets the first element of the attributeMaps array. The result is that the property that is set for the first column in a GUI table is displayed in all table columns.

The fix is to use the column index of the argument cell:

	Object value = attributeMaps[cell.getColumnIndex()].get(element);

The work around for this is to extends ObservableMapCellLabelProvider and override update with a version that does this.

Link to the source code:

https://git.eclipse.org/c/gerrit/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/viewers/ObservableMapCellLabelProvider.java?id=008dad8edbf50352221d9e833876a8a4bc2ec573#n91
Comment 1 Andrey Loskutov CLA 2017-06-01 02:49:54 EDT
Thanks for the pointer. Can you please provide a Gerrit patch?
https://wiki.eclipse.org/Platform_UI/How_to_Contribute
Comment 2 Jens Lideström CLA 2018-02-24 05:24:02 EST
I plan do some work to solve this. Expect a Gerrit change shortly.
Comment 3 Eclipse Genie CLA 2018-02-25 10:53:50 EST
New Gerrit change created: https://git.eclipse.org/r/118112
Comment 4 Jens Lideström CLA 2018-02-25 10:56:39 EST
It turns out that using only the map on index 0 is actually the intended and documented (although weird) behaviour for ObservableMapCellLabelProvider.

So I made a change with some added documentation about this and a test case.

This bug report can be closed now, both if the change in merged but also if it is not.
Comment 5 Jens Lideström CLA 2018-02-25 10:59:50 EST
I had some problems with getting Mockito to work when launched from Eclipse. I got an error like this:

Caused by: java.lang.SecurityException: class "org.eclipse.jface.viewers.ViewerCell$$EnhancerByMockitoWithCGLIB$$df9318f7"'s signer information does not match signer information of other classes in the same package

It turned out that this happens if the org.mockito bundle is signed while the org.eclipse.jface bundle is not. I solved it by manually removing the singing stuff from the org.mockito bundle in my target definition.

Also, to use Mockito I had to add org.objenesis as an explicit dependency to the test project. That is weird, because org.mockito already depend on that bundle. But I shouldn't hurt anyone, so I guess that is okay.
Comment 7 Dani Megert CLA 2018-03-14 05:08:01 EDT
This broke the tests completely, see http://download.eclipse.org/eclipse/downloads/drops4/I20180312-2000/testresults/html/org.eclipse.jface.tests.databinding_ep48I-unit-cen64-gtk2_linux.gtk.x86_64_8.0.html


From the log:
!ENTRY org.mockito 4 0 2018-03-13 22:40:13.551
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.mockito [276]
  Unresolved requirement: Import-Package: COM.jrockit.reflect; resolution:="optional"
  Unresolved requirement: Import-Package: jrockit.vm; resolution:="optional"
  Unresolved requirement: Import-Package: org.hamcrest; version="[1.0.0,2.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1682)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1661)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1624)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1555)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)



Several possible issues
- version for mockito not indicated
- issues wit obenensis (we've never used it directly so far)

Take a look at 'org.eclipse.e4.ui.tests' which works fine.
Comment 8 Dani Megert CLA 2018-03-15 04:40:01 EDT
Please fix this so that the official tests run again.

I'll revert the change tomorrow if they still fail.
Comment 9 Eclipse Genie CLA 2018-03-15 10:56:34 EDT
New Gerrit change created: https://git.eclipse.org/r/119509
Comment 11 Dani Megert CLA 2018-03-16 03:59:16 EDT
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/119509 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=512017c8db66550018bb67a0da2e5cc7684c4806
> 

That did not do the trick.

==>

!ENTRY org.mockito 4 0 2018-03-15 22:34:39.445
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.mockito [276]
  Unresolved requirement: Import-Package: COM.jrockit.reflect; resolution:="optional"
  Unresolved requirement: Import-Package: jrockit.vm; resolution:="optional"
  Unresolved requirement: Import-Package: org.hamcrest; version="[1.0.0,2.0.0)"

	at org.eclipse.osgi.container.Module.start(Module.java:444)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1682)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1661)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1624)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1555)
	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Comment 12 Dani Megert CLA 2018-03-16 04:11:56 EDT
OK, the specified version is not the one used by the other test bundles and probably not available in the official build. I've replaced it with the version we use in the other test bundles:
org.mockito;bundle-version="1.8.4"

Fixed with http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=239c4d36bb71344cf0e5619f3292e104059b00a1
Comment 13 Karsten Thoms CLA 2018-03-16 04:19:06 EDT
Orbit contains Mockito 1.9.5, but suspicious are the import directives for JRockit. They are optional and there is no bundle providing JRockit on Orbit, so it might be that the deployed 1.9.5 version is not valid to use.

Mockito  1.8.4 does not have that dependency. But both have a requirement for org.hamcrest package. That bundle is definetely on Orbit and exports the package. I cannot explain why there is a problem for that package, and expect that it now will fail for it. But let's see.
Comment 14 Dani Megert CLA 2018-03-17 04:42:36 EDT
As suspected this did not work. Hence I removed the test and reverted the changes to MANIFEST.MF.

Now the tests pass again with I20180316-2000.
Comment 15 Karsten Thoms CLA 2018-03-19 13:57:43 EDT
There was recently some change regarding Hamcrwst on platform that made all builds fail. Would it be worth to retry the change?
Comment 16 Dani Megert CLA 2018-03-20 10:29:15 EDT
(In reply to Karsten Thoms from comment #15)
> There was recently some change regarding Hamcrwst on platform that made all
> builds fail. Would it be worth to retry the change?

I don't think it would make a difference as the other UI test bundle just worked fine in the official build.

If you try it again, please make sure to immediately revert if it fails.
Comment 17 Dani Megert CLA 2018-03-20 10:43:19 EDT
(In reply to Dani Megert from comment #16)
> (In reply to Karsten Thoms from comment #15)
> > There was recently some change regarding Hamcrwst on platform that made all
> > builds fail. Would it be worth to retry the change?
> 
> I don't think it would make a difference as the other UI test bundle just
> worked fine in the official build.

We also improved the version for some required bundles. So, please try it out and we'll see.
Comment 18 Dani Megert CLA 2018-05-10 10:31:06 EDT
PING!
Comment 19 Eclipse Genie CLA 2018-05-10 16:54:43 EDT
New Gerrit change created: https://git.eclipse.org/r/122443
Comment 21 Karsten Thoms CLA 2018-05-11 08:36:33 EDT
Can be closed when test ObservableMapCellLabelProviderTest is performed in next nightly build
Comment 22 Eclipse Genie CLA 2018-05-14 02:54:46 EDT
New Gerrit change created: https://git.eclipse.org/r/122553
Comment 24 Karsten Thoms CLA 2018-05-14 02:55:42 EDT
Re-target for 4.9?
Comment 25 Dani Megert CLA 2018-05-14 02:57:34 EDT
(In reply to Karsten Thoms from comment #24)
> Re-target for 4.9?

Done.
Comment 26 Lars Vogel CLA 2018-08-20 08:01:21 EDT
(In reply to Dani Megert from comment #25)
> (In reply to Karsten Thoms from comment #24)
> > Re-target for 4.9?
> 
> Done.

Karsten/Jens, is this still open?
Comment 27 Karsten Thoms CLA 2018-08-20 11:40:01 EDT
Yes, it is still open. We had a problem last time and reverted it. It is waiting for trying it again. Unfortunately I'm busy ATM. Jens, could you provide the patch again?
Comment 28 Jens Lideström CLA 2018-09-01 10:09:46 EDT
(In reply to Karsten Thoms from comment #27)
> Yes, it is still open. We had a problem last time and reverted it. It is
> waiting for trying it again. Unfortunately I'm busy ATM. Jens, could you
> provide the patch again?

I think we should just drop this change; it's not worth the effort; there's nothing very valuable in it.

The problem I think was to get Mockito (or rather Objenesis) to work with the databinding tests. I don't know exactly what the problem was, I have no idea about how to solve it, and I don't have time to put work into it.

I think we should just close it as "WONT_FIX".
Comment 29 Lars Vogel CLA 2018-09-11 16:28:46 EDT
(In reply to Jens Lideström from comment #28)
> I think we should just close it as "WONT_FIX".

As suggested I close this bug as "WONT_FIX".