Content / Label provider in project explorer not refreshing with IResource.refreshLocal [message #1756394] |
Thu, 16 March 2017 07:13  |
Eclipse User |
|
|
|
I set up some custom navigatorContent with custom content and label provider. Basically, this puts a tree under files of a specific type. The content provider is a subtype of ObservableListTreeContentProvider. The file is EMF data, persisted as XMI, and I use a global EditingDomain with EMF Transaction.
I now have a custom editor for the files of that specific type, handling edits in the same editing domain as the content provider. When I save the file, I call IResource.refreshLocal on the corresponding IFile instance, which DOES cause the file to be refreshed (when I open the file in a standard text editor parallel to the custom one, I see the changes in the XMI file), but the project explorer is not refreshed. I have to press F5 here.
So how do I "press F5" programmatically?
|
|
|
Re: Content / Label provider in project explorer not refreshing with IResource.refreshLocal [message #1756401 is a reply to message #1756394] |
Thu, 16 March 2017 08:31   |
Eclipse User |
|
|
|
I came up with this workaround which I execute after the save was successful (Scala):
getSite.
getWorkbenchWindow.
getPages.
flatMap(_.getViewReferences).
filter(_.getId.equals("org.eclipse.ui.navigator.ProjectExplorer")).
map(_.getView(false)).
filter(x => x != null).
map(_.getSite).
flatMap {
case e: IEditorSite => Some(e.getActionBars)
case v: IViewSite => Some(v.getActionBars)
case _ => None
}.
map(_.getGlobalActionHandler(REFRESH.getId)).
filter(x => x != null).
foreach(_.run)
So, what I basically do, is: I go through all currently open views, find the ones with the Project Explorer id, get their ActionBars, from these, get the global refresh command, and run it.
However, this looks a bit hackish, so is there a better way?
|
|
|
|
Re: Content / Label provider in project explorer not refreshing with IResource.refreshLocal [message #1756448 is a reply to message #1756422] |
Fri, 17 March 2017 01:21  |
Eclipse User |
|
|
|
It seems to me some aspect of notification is missing from your design/implementation. But looking at the class, I really have no idea how that is supposed to work. Certainly there appears to be various listeners attached. And surely a change to the model being used to provide the tree structure ought to directly inform the viewer about the updates. In fact, if you're using a shared editing domain, I imagine it should show the same tree/out as the editor and update as the editor changes it...
|
|
|
Powered by
FUDForum. Page generated in 0.04699 seconds