Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » how to refresh Common Navigator after workspace modifications?
how to refresh Common Navigator after workspace modifications? [message #488190] Fri, 25 September 2009 19:43 Go to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
R3.4.1; WinXP

I am using the org.eclipse.ui.navigator.CommonNavigator, and have also
implemented a File->Import action; all fine.

Now I create an action which modifies the resources (writes some files);
the files are written; all fine. This is done within a
WorkspaceModifyOperation, and the progress-monitor is working fine, too.

But -- I do not see the files in the Comm-Nav, unless the *_user_*
clicks F5/Refresh!

I have tried calling refreshLocal() which makes no difference, and
touch(), which also does not help. The WorkspaceModifyOperation of the
File->Import ("file system") does not seem to do anything special, that
I can find.

I imagine the correct way is to trigger a resource-notification: how do
I do that?

thanks,
Paul
Re: how to refresh Common Navigator after workspace modifications? [message #488263 is a reply to message #488190] Sun, 27 September 2009 02:02 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
Yes, you need to tell the CommonViewer about the changes with the normal viewer methods to add, update, refresh, or delete.

The org.eclipse.ui.model.WorkbenchContentProvider has an example of doing this in response to resource change notifications.


Re: how to refresh Common Navigator after workspace modifications? [message #488459 is a reply to message #488263] Mon, 28 September 2009 19:13 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Francis Upton wrote:
> Yes, you need to tell the CommonViewer about the changes with the normal
> viewer methods to add, update, refresh, or delete.
>
> The org.eclipse.ui.model.WorkbenchContentProvider has an example of
> doing this in response to resource change notifications.

Strange -- the UI of the Common Navigator provides, e.g., a means to
delete things, and that already sends an update; plus, the little
import-file action I plugged in also triggers the correct update,
without my having created any listeners or even sent any updates of my
own -- the code that is executed is
WizardNewFileCreationPage.createNewFile().

So it seems like the CommonNavigator *already* has the listeners it
needs. (I don't find where they are in reading the code of
CommonNavigator; I could set a breakpoint somewhere and watch the
resource-change-notification come in -- if I knew what method and what
class was being used, but that's exactly what I don't know ...)

Also, even if I added my own ResourceChangeListener mechanism, per the
example you mention, I would still be in the exact same position, of
needing to know how to *trigger* /*send* a ResourceChangeEvent.

I'll try copying the WizardNewFileCreationPage.createNewFile() code ...

-Paul
Re: how to refresh Common Navigator after workspace modifications? [message #488460 is a reply to message #488459] Mon, 28 September 2009 19:19 Go to previous messageGo to next message
Francis Upton IV is currently offline Francis Upton IVFriend
Messages: 472
Registered: July 2009
Location: Oakland, CA
Senior Member
ResourceExtensionContentProvider is the class you want.

Re: how to refresh Common Navigator after workspace modifications? => ResourceExtensionContentPro [message #488509 is a reply to message #488460] Tue, 29 September 2009 01:32 Go to previous messageGo to next message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Francis Upton wrote:
> ResourceExtensionContentProvider is the class you want.

=> "EXPERIMENTAL. This class or interface has been added as part of a
work in progress. There is a guarantee neither that this API will work
nor that it will remain the same. Please do not use this API without
consulting with the Platform/UI team."

OK, I'm consulting -- who from that team can help me out here?

thanks,
Paul
Re: how to refresh Common Navigator after workspace modifications? [message #488515 is a reply to message #488460] Tue, 29 September 2009 04:07 Go to previous message
Paul E. Keyser is currently offline Paul E. KeyserFriend
Messages: 878
Registered: July 2009
Senior Member
Francis Upton wrote:
> ResourceExtensionContentProvider is the class you want.

Yep, when I set a break-point in the processDelta() method of that
class, I can see that the File -> Import triggers notifications in this
method of NotifcationManager (at the line tagged with /*******/):

public void broadcastChanges(ElementTree lastState, ResourceChangeEvent
event, boolean lockTree) {
final int type = event.getType();
try {
// Do the notification if there are listeners for events of the given
type.
if (!listeners.hasListenerFor(type))
return;
isNotifying = true;
ResourceDelta delta = getDelta(lastState, type);
//don't broadcast POST_CHANGE or autobuild events if the delta is empty
/*?????*/ if (delta == null || delta.getKind() == 0) {
int trigger = event.getBuildKind();
if (trigger == IncrementalProjectBuilder.AUTO_BUILD || trigger == 0)
return;
}
event.setDelta(delta);
long start = System.currentTimeMillis();
/*******/ notify(getListeners(), event, lockTree);
lastNotifyDuration = System.currentTimeMillis() - start;
} finally {
// Update the state regardless of whether people are listening.
isNotifying = false;
cleanUp(lastState, type);
}
}

BUT ====================

When I use my own WorkspaceModifyOperation, and the same method of the
NotificationManager is reached, then the (trigger == 0) and the
(delta.getKind() == 0) and so ALL notifications are skipped! (See the if
tagged w/ /*?????*/.)

That means that the ResourceDeltaFactory.computeDelta() is returning an
incorrect result -- but I don't understand that code at all, and so I
have no clue what to do so that the ResourceDeltaFactory.computeDelta()
will return a delta that will not be empty -- how do I do that?

thanks,
Paul
Previous Topic:[DataBinding] Does there exist a BufferedObservable?
Next Topic:How to use Standard commands
Goto Forum:
  


Current Time: Sat Nov 22 10:37:40 GMT 2014

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

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