mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-06 06:21:16 +07:00
do not ask for url in case there are no jupyter installed
This commit is contained in:
+13
-11
@@ -94,29 +94,22 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
}
|
||||
|
||||
private void startConnection(@NotNull final IpnbCodePanel codePanel, final IpnbFileEditor fileEditor, final String path) {
|
||||
String url = IpnbSettings.getInstance(myProject).getURL();
|
||||
if (StringUtil.isEmptyOrSpaces(url)) {
|
||||
url = IpnbSettings.DEFAULT_URL;
|
||||
}
|
||||
String url = getURL();
|
||||
|
||||
boolean connectionStarted = startConnection(codePanel, path, url, false);
|
||||
if (!connectionStarted) {
|
||||
final String finalUrl = url;
|
||||
url = showDialogUrl(url);
|
||||
if (url == null) return;
|
||||
IpnbSettings.getInstance(myProject).setURL(url);
|
||||
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final boolean serverStarted = startIpythonServer(finalUrl, fileEditor);
|
||||
final boolean serverStarted = startIpythonServer(url, fileEditor);
|
||||
if (!serverStarted) {
|
||||
return;
|
||||
}
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startConnection(codePanel, path, finalUrl, true);
|
||||
startConnection(codePanel, path, url, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -124,6 +117,11 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private String getURL() {
|
||||
String url = IpnbSettings.getInstance(myProject).getURL();
|
||||
return StringUtil.isEmptyOrSpaces(url) ? IpnbSettings.DEFAULT_URL : url;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String showDialogUrl(@NotNull final String initialUrl) {
|
||||
final String url = Messages.showInputDialog("Jupyter Notebook URL:", "Start Jupyter Notebook", null, initialUrl,
|
||||
@@ -258,7 +256,7 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
});
|
||||
}
|
||||
|
||||
public boolean startIpythonServer(@NotNull final String url, @NotNull final IpnbFileEditor fileEditor) {
|
||||
public boolean startIpythonServer(@NotNull final String initUrl, @NotNull final IpnbFileEditor fileEditor) {
|
||||
final Module module = ProjectFileIndex.SERVICE.getInstance(myProject).getModuleForFile(fileEditor.getVirtualFile());
|
||||
if (module == null) return false;
|
||||
final Sdk sdk = PythonSdkType.findPythonSdk(module);
|
||||
@@ -276,6 +274,10 @@ public final class IpnbConnectionManager implements ProjectComponent {
|
||||
catch (ExecutionException ignored) {
|
||||
}
|
||||
|
||||
String url = showDialogUrl(initUrl);
|
||||
if (url == null) return false;
|
||||
IpnbSettings.getInstance(myProject).setURL(url);
|
||||
|
||||
final Pair<String, String> hostPort = getHostPortFromUrl(url);
|
||||
if (hostPort == null) {
|
||||
showWarning(fileEditor, "Please, check Jupyter Notebook URL in <a href=\"\">Settings->Tools->Jupyter Notebook</a>",
|
||||
|
||||
Reference in New Issue
Block a user