[JEM] EMF Workbench [message #82874] |
Wed, 09 March 2005 11:19 |
Eclipse User |
|
|
|
Originally posted by: daniel.rohe.stud.tu-ilmenau.de
In the EMF Workbench (plugin org.eclipse.jem.util) a synchronizer
(org.eclipse.jem.util.emf.workbench.ResourceSetWorkbenchSync hronizer) is
used to react on project changes. Extensions could be added to the
synchronizer programmatically. This extensions then are informed about
changes to the project which is synchronized with the ResourceSet of the
project. Currently the synchronizer only supports notification for project
closing. Notification for changes in a project (moving, creating, deleting,
changing of files) is also provided but never gets called by the
synchronizer.
Isn't it better to also inform extenders about changes in the project, so
they can react on that and for example reload the changed resource in the
ResourceSet?
Code snippet from ResourceSetWorkbenchSynchronizer containing the required
changes.
/*
* @see IResourceChangeListener#resourceChanged(IResourceChangeEvent )
*/
public void resourceChanged(IResourceChangeEvent event) {
currentEventType = event.getType();
currentProjectDelta = null;
if ((currentEventType == IResourceChangeEvent.PRE_CLOSE ||
currentEventType == IResourceChangeEvent.PRE_DELETE)
&& event.getResource().equals(getProject())) {
release();
notifyExtendersOfClose();
} else if (currentEventType == IResourceChangeEvent.POST_CHANGE) {
IResource resource = currentProjectDelta.getResource();
if (resource.getType() == IResource.ROOT) {
IResourceDelta[] projectDelta =
currentProjectDelta.getAffectedChildren();
for (int i = 0; i < projectDelta.length; i++) {
IResource res = projectDelta[i].getResource();
if (resource.getType() == IResource.PROJECT &&
resource.equals(getProject())) {
currentProjectDelta = projectDelta[i];
notifyExtendersIfNecessary();
} else {
currentProjectDelta = null;
}
}
} else if (resource.getType() == IResource.PROJECT) {
if (resource.equals(getProject())) {
notifyExtendersIfNecessary();
}
}
}
currentProjectDelta = null;
}
Greetings
Daniel
|
|
|
Powered by
FUDForum. Page generated in 0.02751 seconds