/** {@inheritDoc} */ @Override public void resourceChanged(IResourceChangeEvent pEvent) { if (IResourceChangeEvent.POST_CHANGE == pEvent.getType()) { // Extract all the additions among the changes IResourceDelta delta = pEvent.getDelta(); IResourceDelta[] added = delta.getAffectedChildren(); // In all the added resources, process the projects for (int i = 0, length = added.length; i < length; i++) { IResourceDelta addedi = added[i]; // Get the project IResource resource = addedi.getResource(); IProject project = resource.getProject(); if (ProjectsManager.getProject(project.getName()) == null && project.isOpen()) { ProjectAdderJob job = new ProjectAdderJob(project); job.schedule(); } } } else if (IResourceChangeEvent.PRE_DELETE == pEvent.getType()) { // detect UNO IDL project about to be deleted IResource removed = pEvent.getResource(); if (ProjectsManager.getProject(removed.getName()) != null) { ProjectsManager.removeProject(removed.getName()); } } else if (IResourceChangeEvent.PRE_CLOSE == pEvent.getType()) { IResource res = pEvent.getResource(); if (res != null && ProjectsManager.getProject(res.getName()) != null) { // Project about to be closed: remove for the available uno projects ProjectsManager.removeProject(res.getName()); } } }
/** {@inheritDoc} */ @Override public void earlyStartup() { // Load the projects manager ProjectsManager.load(); // Add a listener to the resources changes of the workspace ResourcesPlugin.getWorkspace().addResourceChangeListener(this); PluginLogger.info("Resources changes are now listened"); // $NON-NLS-1$ }
/** {@inheritDoc} */ @Override public IStatus runInWorkspace(IProgressMonitor pMonitor) throws CoreException { ProjectsManager.addProject(mPrj); return Status.OK_STATUS; }