Skip to main content



      Home
Home » Eclipse Projects » NatTable » Adding item to a filtered List
Adding item to a filtered List [message #1828496] Wed, 10 June 2020 15:09 Go to next message
Eclipse UserFriend
Hi all,
I've using GlazedList with NatTable. If I filter the list, it is reduced to the items matching the filter. Now, if I change that element I get an exception while refreshing the list:
21:05:40.161 [Equinox Log Thread - Equinox Container: 9adc8e4d-3c44-497f-ad11-6d744d75bec9] ERROR org.eclipse.e4.ui.workbench - Internal Error
java.lang.IndexOutOfBoundsException: Cannot add at 2 on list of size 1
	at ca.odell.glazedlists.TransformedList.add(TransformedList.java:73) ~[na:na]
	at ca.odell.glazedlists.impl.Diff.replaceAll(Diff.java:84) ~[na:na]
	at ca.odell.glazedlists.impl.Diff.replaceAll(Diff.java:29) ~[na:na]
	at ca.odell.glazedlists.GlazedLists.replaceAll(GlazedLists.java:69) ~[na:na]
	at de.mypackage.MyListTable.lambda$1(MyListTable.java:373) ~[na:na]
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) ~[na:na]
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185) ~[na:na]
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3963) ~[na:na]
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3590) ~[na:na]
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160) ~[na:na]
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) ~[na:na]
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049) ~[na:na]
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) ~[na:na]
	at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:166) ~[na:na]
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) ~[na:na]
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) ~[na:na]
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) ~[na:na]
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) ~[na:na]
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657) ~[org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar:na]
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594) ~[org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar:na]
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465) ~[org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar:na]
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438) ~[org.eclipse.equinox.launcher_1.5.600.v20191014-2022.jar:na]


I've called
GlazedLists.replaceAll(treeFilteredIssues, listFromDatabase, false);


How can I fix this? Thanks in advance,

Ralf

[Updated on: Wed, 10 June 2020 15:15] by Moderator

Re: Adding item to a filtered List [message #1828498 is a reply to message #1828496] Wed, 10 June 2020 17:10 Go to previous messageGo to next message
Eclipse UserFriend
Hard to tell without a context. But maybe the reason is that no write lock is acquired.
Re: Adding item to a filtered List [message #1828503 is a reply to message #1828498] Thu, 11 June 2020 01:59 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I think the reason is that treeFilteredIssues only has one element (the one matching the filter), but listFromDatabase is the complete list of all relevant records from database. So, a "replaceAll" fails because there are not "enough" entries in the list. But I don't know how to handle this. I've built the layer stack according to one of your GlazedLists examples.

/Ralf
Re: Adding item to a filtered List [message #1828525 is a reply to message #1828503] Thu, 11 June 2020 07:07 Go to previous messageGo to next message
Eclipse UserFriend
And why are you not operating on the base EventList instead of the FilterList? The filter and the tree structure should reapply because of the change Events fired by the base list changes.
Re: Adding item to a filtered List [message #1828526 is a reply to message #1828525] Thu, 11 June 2020 07:23 Go to previous message
Eclipse UserFriend
...because I'm always choosing the most complicated solution :-) Many thanks for your help, this solved my problem :-D
Previous Topic:Automatically Wrap the text in a Gridlayer
Next Topic:summary row
Goto Forum:
  


Current Time: Sat May 24 12:26:49 EDT 2025

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

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

Back to the top