[CommonNavigator] Programmatically / Automatically refresh non-resource content [message #541506] |
Mon, 21 June 2010 12:20 |
Xavier Coulon Messages: 58 Registered: July 2009 |
Member |
|
|
Hello,
I'm working on a plugin that's aimed at helping Web developpers building RESTFul applications using the JAX-RS spec, within Eclipse
For now, I have a builder that is configured with a facet and that builds an internal JAX-RS "registry", which is stored in the Project's session properties. This "registry" is based on annotations found on classes of the project, so it is not bound to a particular resource.
To display this registry, I added a custom navigatorContent that is associated to the "Project Explorer" viewer.
This works almost fine : when I clean the project, a "full build" is triggered, and the "registry" is initialized and stored in the project. But on the UI side, I cannot programmatically refresh the viewer.
I tried to add a my ITreeContentProvider impl as an IResourceChangeListener for POST_BUILD event as below:
public ContentProvider() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_BUILD);
}
, so that when the build is done, I can trigger a viewer.refresh() :
public void resourceChanged(IResourceChangeEvent event) {
((TreeViewer)viewer).refresh();
}
But this approach fails with a SWTException :
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:3884)
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.Widget.checkWidget(Widget.java:355)
at org.eclipse.swt.widgets.Widget.getData(Widget.java:521)
at org.eclipse.jface.viewers.AbstractTreeViewer.getTreePathFromItem(AbstractTreeViewer.java:2866)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalGetWidgetToSelect(AbstractTreeViewer.java:1679)
at org.eclipse.jface.viewers.AbstractTreeViewer.internalExpand(AbstractTreeViewer.java:1574)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2463)
at org.eclipse.ui.navigator.CommonViewer.setSelectionToWidget(CommonViewer.java:451)
at org.eclipse.jface.viewers.AbstractTreeViewer.setSelectionToWidget(AbstractTreeViewer.java:2900)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1399)
at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:402)
at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1353)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1482)
at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:548)
at org.eclipse.ui.navigator.CommonViewer.refresh(CommonViewer.java:358)
at org.eclipse.ui.navigator.CommonViewer.refresh(CommonViewer.java:515)
at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1414)
at org.bytesparadise.tools.jaxrs.ui.cnf.ContentProvider.resourceChanged(ContentProvider.java:103)
at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:291)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149)
at org.eclipse.core.internal.resources.Workspace.broadcastBuildEvent(Workspace.java:297)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
How can I automatically/programmatically refresh the navigator content, since the content is not bound to a particular resource ?
Thank you in advance
Regards,
Xavier
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04131 seconds