Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Content / Label provider in project explorer not refreshing with IResource.refreshLocal
Content / Label provider in project explorer not refreshing with IResource.refreshLocal [message #1756394] Thu, 16 March 2017 11:13 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
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 12:31 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
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 #1756422 is a reply to message #1756401] Thu, 16 March 2017 16:17 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 772
Registered: January 2012
Senior Member

If you can get the active widget (e.g., SWTBot.tree() if the explorer's tree has focus), you can use #pressShortcut().

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Content / Label provider in project explorer not refreshing with IResource.refreshLocal [message #1756448 is a reply to message #1756422] Fri, 17 March 2017 05:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 29538
Registered: July 2009
Senior Member
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...
Previous Topic:Strategy for fixing installation for buildship upgrade problem?
Next Topic:Import Existing Projects doesnt use project name
Goto Forum:
  


Current Time: Thu Sep 20 02:10:54 GMT 2018

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

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

Back to the top