Search in sources :

Example 1 with IpnbEditableCell

use of org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell in project intellij-community by JetBrains.

the class IpnbMarkdownCellAction method changeTypeToMarkdown.

public void changeTypeToMarkdown(@NotNull final IpnbFileEditor editor) {
    final IpnbFilePanel filePanel = editor.getIpnbFilePanel();
    final IpnbEditablePanel selectedCellPanel = filePanel.getSelectedCellPanel();
    if (selectedCellPanel == null)
        return;
    final IpnbEditableCell cell = selectedCellPanel.getCell();
    final List<IpnbCell> cells = filePanel.getIpnbFile().getCells();
    final int index = cells.indexOf(selectedCellPanel.getCell());
    final IpnbMarkdownCell markdownCell = new IpnbMarkdownCell(cell.getSource(), cell.getMetadata());
    if (index >= 0) {
        cells.set(index, markdownCell);
    }
    filePanel.replaceComponent(selectedCellPanel, markdownCell);
}
Also used : IpnbCell(org.jetbrains.plugins.ipnb.format.cells.IpnbCell) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbEditableCell(org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell) IpnbMarkdownCell(org.jetbrains.plugins.ipnb.format.cells.IpnbMarkdownCell) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Example 2 with IpnbEditableCell

use of org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell in project intellij-community by JetBrains.

the class IpnbCodeCellAction method changeTypeToCode.

public void changeTypeToCode(@NotNull final IpnbFileEditor editor) {
    final IpnbFilePanel filePanel = editor.getIpnbFilePanel();
    final IpnbEditablePanel selectedCellPanel = filePanel.getSelectedCellPanel();
    if (selectedCellPanel == null)
        return;
    final IpnbEditableCell cell = selectedCellPanel.getCell();
    final List<IpnbCell> cells = filePanel.getIpnbFile().getCells();
    final int index = cells.indexOf(selectedCellPanel.getCell());
    final IpnbCodeCell codeCell = new IpnbCodeCell("python", cell.getSource(), null, Lists.newArrayList(), cell.getMetadata());
    if (index >= 0) {
        cells.set(index, codeCell);
    }
    filePanel.replaceComponent(selectedCellPanel, codeCell);
}
Also used : IpnbCell(org.jetbrains.plugins.ipnb.format.cells.IpnbCell) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbEditableCell(org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell) IpnbCodeCell(org.jetbrains.plugins.ipnb.format.cells.IpnbCodeCell) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Example 3 with IpnbEditableCell

use of org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell in project intellij-community by JetBrains.

the class IpnbHeadingCellActionBase method changeTypeToHeading.

public void changeTypeToHeading(@NotNull final IpnbFileEditor editor) {
    final IpnbFilePanel filePanel = editor.getIpnbFilePanel();
    final IpnbEditablePanel selectedCellPanel = filePanel.getSelectedCellPanel();
    if (selectedCellPanel == null)
        return;
    final IpnbEditableCell cell = selectedCellPanel.getCell();
    final List<IpnbCell> cells = filePanel.getIpnbFile().getCells();
    final int index = cells.indexOf(selectedCellPanel.getCell());
    final IpnbHeadingCell heading = new IpnbHeadingCell(cell.getSource(), myLevel, cell.getMetadata());
    if (index >= 0) {
        cells.set(index, heading);
    }
    filePanel.replaceComponent(selectedCellPanel, heading);
}
Also used : IpnbCell(org.jetbrains.plugins.ipnb.format.cells.IpnbCell) IpnbFilePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel) IpnbEditableCell(org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell) IpnbHeadingCell(org.jetbrains.plugins.ipnb.format.cells.IpnbHeadingCell) IpnbEditablePanel(org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)

Aggregations

IpnbEditablePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbEditablePanel)3 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)3 IpnbCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCell)3 IpnbEditableCell (org.jetbrains.plugins.ipnb.format.cells.IpnbEditableCell)3 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