use of org.python.pydev.core.IInterpreterManagerListener in project Pydev by fabioz.
the class AbstractInterpreterManager method setInfos.
/* (non-Javadoc)
* @see org.python.pydev.core.IInterpreterManager#setInfos(org.python.pydev.core.IInterpreterInfo[], java.util.Set, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void setInfos(IInterpreterInfo[] infos, Set<String> interpreterNamesToRestore, IProgressMonitor monitor) {
// Set the string to persist!
String s = AbstractInterpreterManager.getStringToPersist(infos);
prefs.put(getPreferenceName(), s);
try {
prefs.flush();
} catch (BackingStoreException e) {
String message = e.getMessage();
if (message == null || message.indexOf("File name not specified") == -1) {
Log.log(e);
}
}
IInterpreterInfo[] interpreterInfos;
try {
synchronized (this.lock) {
modificationStamp += 1;
clearInterpretersFromPersistedString();
persistedString = s;
// After setting the preference, get the actual infos (will be recreated).
interpreterInfos = internalRecreateCacheGetInterpreterInfos();
this.restorePythopathForInterpreters(monitor, interpreterNamesToRestore);
for (InterpreterInfo info : this.exeToInfo.values()) {
try {
ISystemModulesManager modulesManager = info.getModulesManager();
Object pythonPathHelper = modulesManager.getPythonPathHelper();
if (!(pythonPathHelper instanceof PythonPathHelper)) {
continue;
}
PythonPathHelper pathHelper = (PythonPathHelper) pythonPathHelper;
List<String> pythonpath = pathHelper.getPythonpath();
if (pythonpath == null || pythonpath.size() == 0) {
continue;
}
modulesManager.save();
} catch (Throwable e) {
Log.log(e);
}
}
}
// Now, last step is updating the natures (the call must NOT be locked in this case).
this.restorePythopathForNatures(monitor);
// And in jython, changing the classpath also needs to restore it.
for (IInterpreterInfo interpreter : interpreterInfos) {
for (ShellId id : AbstractShell.getAllShellIds()) {
AbstractShell.stopServerShell(interpreter, id);
}
}
IInterpreterManagerListener[] managerListeners = listeners.getListeners();
for (IInterpreterManagerListener iInterpreterManagerListener : managerListeners) {
iInterpreterManagerListener.afterSetInfos(this, interpreterInfos);
}
} finally {
AbstractShell.restartAllShells();
}
// In the regular process we do not create the global indexing for forced builtins, thus, we schedule a process
// now which will be able to do that when checking if things are correct in the configuration.
SyncSystemModulesManagerScheduler syncScheduler = DefaultSyncSystemModulesManagerScheduler.get();
if (syncScheduler != null && interpreterNamesToRestore != null && interpreterNamesToRestore.size() > 0) {
ArrayList<IInterpreterInfo> lst = new ArrayList<>(interpreterNamesToRestore.size());
for (IInterpreterInfo info : interpreterInfos) {
if (interpreterNamesToRestore.contains(info.getExecutableOrJar())) {
lst.add(info);
}
}
syncScheduler.addToCheck(this, lst.toArray(new IInterpreterInfo[lst.size()]));
}
}
Aggregations