Merge "Issue #2441 Initialize python interpreter asynchronously when opening localization perspective." into development

Former-commit-id: 97ac5b996bc54d949f03e6ea0f0952207e10366c
This commit is contained in:
Nate Jensen 2013-10-14 11:42:23 -05:00 committed by Gerrit Code Review
commit 93c67d2d8c

View file

@ -23,7 +23,11 @@ import java.io.File;
import java.io.IOException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.IPreferenceStore;
import org.python.pydev.core.IInterpreterInfo;
import org.python.pydev.core.IInterpreterManager;
@ -48,9 +52,10 @@ import com.raytheon.uf.common.util.FileUtil;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* May 1, 2013 1967 njensen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* May 01, 2013 1967 njensen Initial creation
* Oct 11, 2013 2441 bsteffen Make initialize async.
*
* </pre>
*
@ -69,7 +74,18 @@ public class PydevSetup {
*/
public static void preparePydev() {
preventFundingPopup();
initializeInterpreter();
initializeInterpreterAsync();
}
public static void initializeInterpreterAsync() {
new Job("Preparing python interpreter.") {
@Override
protected IStatus run(IProgressMonitor monitor) {
initializeInterpreter(monitor);
return Status.OK_STATUS;
}
}.schedule();
}
/**
@ -77,7 +93,7 @@ public class PydevSetup {
* environment, saving the user the trouble of initializing it through the
* preference page.
*/
public static void initializeInterpreter() {
public static void initializeInterpreter(IProgressMonitor monitor) {
try {
// Attempt the initialization twice before reporting errors,
// sometimes it can fail unexpectedly and recover a second time.
@ -132,7 +148,15 @@ public class PydevSetup {
}
IInterpreterInfo[] infoList = new IInterpreterInfo[] { iinfo };
setupStupidFile(mgr, iinfo);
mgr.setInfos(infoList, null, null);
/*
* Calling setInfo will not begin a task, but it will
* complete work. There isn't any way to get the amount
* of work that will be completed so this is an
* estimate. 3832 is the amount of work was being done
* at the time of this writing.
*/
monitor.beginTask("Examining python path.", 3832);
mgr.setInfos(infoList, null, monitor);
} else {
if (retry) {
throw new Exception(