|
|
Re: how to refresh Common Navigator after workspace modifications? [message #488459 is a reply to message #488263] |
Mon, 28 September 2009 19:13 |
Paul E. Keyser 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 #488515 is a reply to message #488460] |
Tue, 29 September 2009 04:07 |
Paul E. Keyser 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
|
|
|
Powered by
FUDForum. Page generated in 0.02588 seconds