Search in sources :

Example 1 with IpnbConnectionManager

use of org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager in project intellij-community by JetBrains.

the class IpnbCodePanel method runCell.

@Override
public void runCell(boolean selectNext) {
    mySelectNext = selectNext;
    updateCellSource();
    updatePrompt();
    final IpnbConnectionManager connectionManager = IpnbConnectionManager.getInstance(myProject);
    connectionManager.executeCell(this);
    setEditing(false);
}
Also used : IpnbConnectionManager(org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager)

Example 2 with IpnbConnectionManager

use of org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager in project intellij-community by JetBrains.

the class IpnbRunAllCellsAction method actionPerformed.

@Override
public void actionPerformed(@NotNull AnActionEvent event) {
    final DataContext context = event.getDataContext();
    final IpnbFileEditor ipnbEditor = IpnbFileEditor.DATA_KEY.getData(context);
    if (ipnbEditor != null) {
        final IpnbFilePanel ipnbFilePanel = ipnbEditor.getIpnbFilePanel();
        final List<IpnbEditablePanel> cells = ipnbFilePanel.getIpnbPanels();
        final Project project = ipnbFilePanel.getProject();
        final IpnbConnectionManager connectionManager = IpnbConnectionManager.getInstance(project);
        final VirtualFile virtualFile = ipnbEditor.getVirtualFile();
        final String path = virtualFile.getPath();
        if (!connectionManager.hasConnection(path)) {
            String url = IpnbSettings.getInstance(project).getURL();
            if (StringUtil.isEmptyOrSpaces(url)) {
                url = IpnbConnectionManager.showDialogUrl(url);
            }
            if (url == null)
                return;
            IpnbSettings.getInstance(project).setURL(url);
            final String finalUrl = url;
            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                final boolean serverStarted = connectionManager.startIpythonServer(finalUrl, ipnbEditor);
                if (!serverStarted) {
                    return;
                }
                UIUtil.invokeLaterIfNeeded(() -> connectionManager.startConnection(null, path, finalUrl, false));
                runCells(cells, ipnbFilePanel);
            });
        } else {
            runCells(cells, ipnbFilePanel);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) IpnbConnectionManager(org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbFileEditor(org.jetbrains.plugins.ipnb.editor.IpnbFileEditor) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Aggregations

IpnbConnectionManager (org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager)2 DataContext (com.intellij.openapi.actionSystem.DataContext)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)1 IpnbEditablePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)1 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)1