Search in sources :

Example 11 with IpnbEditablePanel

use of org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel in project intellij-community by JetBrains.

the class IpnbUnresolvedReferenceSkipper method unusedImportShouldBeSkipped.

@Override
public boolean unusedImportShouldBeSkipped(@NotNull final PyImportedNameDefiner importNameDefiner) {
    final PsiFile file = importNameDefiner.getContainingFile();
    if (file instanceof IpnbPyFragment) {
        final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
        final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
        for (IpnbEditablePanel editablePanel : panels) {
            if (!(editablePanel instanceof IpnbCodePanel))
                continue;
            final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
            final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(importNameDefiner.getProject()).getPsiFile(editor.getDocument());
            if (psiFile == null)
                continue;
            final MyVisitor visitor = new MyVisitor(importNameDefiner);
            psiFile.accept(visitor);
            if (visitor.used)
                return true;
        }
    }
    return false;
}
Also used : IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbCodePanel(org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel) Editor(com.intellij.openapi.editor.Editor) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Example 12 with IpnbEditablePanel

use of org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel in project intellij-community by JetBrains.

the class IpnbRunAllCellsAction method runCells.

private static void runCells(List<IpnbEditablePanel> cells, IpnbFilePanel ipnbFilePanel) {
    for (IpnbEditablePanel cell : cells) {
        cell.runCell(true);
        ipnbFilePanel.revalidate();
        ipnbFilePanel.repaint();
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(ipnbFilePanel, true);
        });
    }
}
Also used : IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Aggregations

IpnbEditablePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)12 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)9 DataContext (com.intellij.openapi.actionSystem.DataContext)3 Editor (com.intellij.openapi.editor.Editor)3 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)3 IpnbCodePanel (org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel)3 IpnbCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCell)3 IpnbEditableCell (org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell)3 PsiFile (com.intellij.psi.PsiFile)2 NotNull (org.jetbrains.annotations.NotNull)2 JsonWriter (com.google.gson.stream.JsonWriter)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ResolveResult (com.intellij.psi.ResolveResult)1 Nullable (org.jetbrains.annotations.Nullable)1 IpnbConnectionManager (org.jetbrains.plugins.ipnb.configuration.IpnbConnectionManager)1 IpnbCodeCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCodeCell)1 IpnbHeadingCell (org.jetbrains.plugins.ipnb.format.cells.IpnbHeadingCell)1 IpnbMarkdownCell (org.jetbrains.plugins.ipnb.format.cells.IpnbMarkdownCell)1