Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » TableViewer setSelection resulting in IllegalArgumentException
TableViewer setSelection resulting in IllegalArgumentException [message #556114] Mon, 30 August 2010 20:45 Go to next message
PM  is currently offline PM Friend
Messages: 14
Registered: July 2009
Junior Member
Hi,

There is an issue in my code, not always re-produceable. Async updates take place on tableviewer (display.syncExec). When i try and set selection back in tableviewer, i think thats when the exception is getting thrown. Here is the snippet from my code.

display.syncExec (new Runnable () {
public void run () {
if( display != null && !display.isDisposed() )
updateViewer();
}
});

public void updateViewer()
{
// some updates take place here...
StructuredSelection sel = new StructuredSelection(ticket);
tableViewer.setSelection(sel, true);
}

TableViewer is defined as SWT.VIRTUAL

This is the stackTrace..

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException: Argument not valid)
at org.eclipse.swt.SWT.error(SWT.java:3884)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3476)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2405)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 21)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at com.etrade.tops.container.TopsContainerApplication.start(Unk nown Source)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:194)
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(EclipseS tarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
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: 559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.WebStartMain.basicRun(WebStartM ain.java:79)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.WebStartMain.main(WebStartMain. java:57)
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 com.sun.javaws.Launcher.executeApplication(Unknown Source)
at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
at com.sun.javaws.Launcher.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Argument not valid
at org.eclipse.swt.SWT.error(SWT.java:3865)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770)
at org.eclipse.swt.widgets.Widget.error(Widget.java:463)
at org.eclipse.swt.widgets.Table.showItem(Table.java:5164)
at org.eclipse.jface.viewers.TableViewer.doShowItem(TableViewer .java:273)
at org.eclipse.jface.viewers.AbstractTableViewer.virtualSetSele ctionToWidget(AbstractTableViewer.java:1012)
at org.eclipse.jface.viewers.AbstractTableViewer.setSelectionTo Widget(AbstractTableViewer.java:885)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWid get(StructuredViewer.java:1711)
at org.eclipse.jface.viewers.StructuredViewer.setSelection(Stru cturedViewer.java:1667)
at org.eclipse.jface.viewers.TableViewer.setSelection(TableView er.java:158)
at com.etrade.tops.bops.views.BrokerReviewReleaseView$24$1.run( Unknown Source)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
... 33 more
Re: TableViewer setSelection resulting in IllegalArgumentException [message #556282 is a reply to message #556114] Tue, 31 August 2010 15:23 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

The stack trace shows that the exception is thrown by Table.showItem. The javadoc of this method says that the IllegalArgumentException (argument not valid) is thrown if the item is disposed. So, looks like the item you are trying to set selection on is disposed.


Lakshmi P Shanmugam
Re: TableViewer setSelection resulting in IllegalArgumentException [message #556309 is a reply to message #556282] Tue, 31 August 2010 17:19 Go to previous messageGo to next message
PM  is currently offline PM Friend
Messages: 14
Registered: July 2009
Junior Member
i will put a check item.isDisposed() before setting the selection back. Something like this, hopefully it should fix the problem.

TableItem item = tableViewer.getTable().getItem(index);
if (!item.isDisposed() && !tableViewer.getTable().getParent().isDisposed())
tableViewer.setSelection(sel, true);
Re: TableViewer setSelection resulting in IllegalArgumentException [message #556390 is a reply to message #556309] Wed, 01 September 2010 06:54 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 31/08/10 10:49 PM, PM wrote:
> i will put a check item.isDisposed() before setting the selection back.
> Something like this, hopefully it should fix the problem.
>
> TableItem item = tableViewer.getTable().getItem(index);
> if (!item.isDisposed() && !tableViewer.getTable().getParent().isDisposed())
> tableViewer.setSelection(sel, true);

Not sure of the contents of the 'sel' in your code. But when you are
setting the selection on the Viewers, the selection should contain your
model elements, not the UI elements (TableItem/TreeItem etc)


--
- Prakash
Platform UI Team, IBM

www.eclipse-tips.com
Re: TableViewer setSelection resulting in IllegalArgumentException [message #556846 is a reply to message #556390] Thu, 02 September 2010 19:24 Go to previous message
PM  is currently offline PM Friend
Messages: 14
Registered: July 2009
Junior Member
Thanx Prakash/Lakshmi for ur feedback.
This is how i set my selection back. Is this incorrect??

StructuredSelection sel = new StructuredSelection(ticket);
tableViewer.setSelection(sel, true);

"ticket" is an object from my model. Pl let me know if this is not the correct way to set the selection back.
Previous Topic:Clipboard problem on Windows
Next Topic:Min size of a component? layout question
Goto Forum:
  


Current Time: Fri Apr 19 23:13:18 GMT 2024

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

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

Back to the top