Search in sources :

Example 1 with CloudSyncMetadataListener

use of org.eclipse.flux.core.internal.CloudSyncMetadataListener 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();
}
Also used : IResourceChangeEvent(org.eclipse.core.resources.IResourceChangeEvent) IWorkspace(org.eclipse.core.resources.IWorkspace) CloudSyncMetadataListener(org.eclipse.flux.core.internal.CloudSyncMetadataListener) IResourceChangeListener(org.eclipse.core.resources.IResourceChangeListener) CloudSyncResourceListener(org.eclipse.flux.core.internal.CloudSyncResourceListener) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) IResourceDelta(org.eclipse.core.resources.IResourceDelta)

Aggregations

IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IResourceChangeEvent (org.eclipse.core.resources.IResourceChangeEvent)1 IResourceChangeListener (org.eclipse.core.resources.IResourceChangeListener)1 IResourceDelta (org.eclipse.core.resources.IResourceDelta)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 CloudSyncMetadataListener (org.eclipse.flux.core.internal.CloudSyncMetadataListener)1 CloudSyncResourceListener (org.eclipse.flux.core.internal.CloudSyncResourceListener)1