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);
}
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);
}
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);
}
Aggregations