Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Invalid thread access Exception

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am making my own Navigator view Plugin for eclipse.
View consists of a TreeViewer.
The issue is I want to refresh(automatic) this view in case of any
addition/deletion/change to the resource workspace.
I refresh my TreeViewer in the code like this:
IResourceChangeListener listener = new MyResourceChangeReporter();
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
....

private class MyResourceChangeReporter implements IResourceChangeListener {
public void resourceChanged(IResourceChangeEvent event) {
try{
treeViewer.refresh();
}
catch(Exception e){
e.printStackTrace();
}
}
}
//inner class ends
I am able to add the resources, but while deleting a Project I get exception:
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:2119)
at org.eclipse.swt.SWT.error(SWT.java:2051)
at org.eclipse.swt.widgets.Widget.error(Widget.java:370)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:301)
at org.eclipse.swt.widgets.Tree.setSelection(Tree.java:932)
at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:207)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:1123)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:939)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:695)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:746)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:708)
at com.glic.ea.framework.ide.views.navigator.FrameworkNavigatorView.refresh(FrameworkNavigatorView.java:705)
at com.glic.ea.framework.ide.views.navigator.FrameworkNavigatorView$MyResourceChangeReporter.resourceChanged(FrameworkNavigatorView.java:137)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:128)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:839)
at org.eclipse.core.runtime.Platform.run(Platform.java:416)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:143)
at org.eclipse.core.internal.events.NotificationManager.deleting(NotificationManager.java:94)
at org.eclipse.core.internal.resources.Workspace.deleting(Workspace.java:685)
at org.eclipse.core.internal.resources.Resource.delete(Resource.java:440)
at org.eclipse.core.internal.resources.Project.delete(Project.java:290)
at org.eclipse.ui.actions.DeleteResourceAction.delete(DeleteResourceAction.java:284)
at org.eclipse.ui.actions.DeleteResourceAction.delete(DeleteResourceAction.java:271)
at org.eclipse.ui.actions.DeleteResourceAction$2.execute(DeleteResourceAction.java:363)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:64)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1378)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:78)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:98)
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:2119)
at org.eclipse.swt.SWT.error(SWT.java:2051)
at org.eclipse.swt.widgets.Widget.error(Widget.java:370)
at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:301)
at org.eclipse.swt.widgets.Tree.setSelection(Tree.java:932)
at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:207)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:1123)
at org.eclipse.jface.viewers.StructuredViewer.setSelectionToWidget(StructuredViewer.java:939)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:695)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:746)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:708)
at com.glic.ea.framework.ide.views.navigator.FrameworkNavigatorView.refresh(FrameworkNavigatorView.java:705)
at com.glic.ea.framework.ide.views.navigator.FrameworkNavigatorView$MyResourceChangeReporter.resourceChanged(FrameworkNavigatorView.java:137)
at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:128)
at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java:839)
at org.eclipse.core.runtime.Platform.run(Platform.java:416)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:143)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:67)
at org.eclipse.core.internal.resources.Workspace.broadcastChanges(Workspace.java:133)
at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:753)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1383)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:78)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:98)

Pls give suggestions.
Deepak
 
Dastardly Dan the Author
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See the SWT FAQ, specifically Why do I get the error "org.eclipse.swt.SWTException: Invalid thread access"?
-- Dan
 
reply
    Bookmark Topic Watch Topic
  • New Topic