use of org.eclipse.flux.core.internal.CloudSyncResourceListener in project flux by eclipse.
the class Activator method initCoreService.
private void initCoreService(String userChannel) throws CoreException {
repository = new Repository(messageConnector, userChannel);
liveEditCoordinator = new LiveEditCoordinator(messageConnector);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
resourceListener = new CloudSyncResourceListener(repository);
workspace.addResourceChangeListener(resourceListener, IResourceChangeEvent.POST_CHANGE);
metadataListener = new CloudSyncMetadataListener(repository);
workspace.addResourceChangeListener(metadataListener, IResourceChangeEvent.POST_BUILD);
this.repositoryListener = new IRepositoryListener() {
@Override
public void projectDisconnected(IProject project) {
removeConnectedProjectPreference(project.getName());
}
@Override
public void projectConnected(IProject project) {
addConnectedProjectPreference(project.getName());
}
@Override
public void resourceChanged(IResource resource) {
// nothing
}
};
getRepository().addRepositoryListener(repositoryListener);
workspaceListener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (event.getResource() instanceof IProject) {
IResourceDelta delta = event.getDelta();
if (delta == null) {
return;
}
if (delta.getKind() == IResourceDelta.REMOVED) {
IProject project = (IProject) event.getResource();
removeConnectedProjectPreference(project.getName());
} else if (delta.getKind() == IResourceDelta.CHANGED) {
// TODO, we aren't handling project renaming yet
// IProject project = (IProject) event.getResource();
// String oldName =
// delta.getMovedFromPath().lastSegment();
// removeConnectedProjectPreference(oldName);
// addConnectedProjectPreference(project.getName());
}
}
}
};
workspace.addResourceChangeListener(workspaceListener);
updateProjectConnections();
}
Aggregations