use of org.jetbrains.plugins.ipnb.format.cells.IpnbCell in project intellij-community by JetBrains.
the class JsonParserTest method testMarkdownCells.
public void testMarkdownCells() throws IOException {
final String fileName = "testData/SymPy.ipynb";
final String fileText = IpnbTestCase.getFileText(fileName);
final IpnbFile ipnbFile = IpnbParser.parseIpnbFile(fileText, new LightVirtualFile());
assertNotNull(ipnbFile);
final List<IpnbCell> cells = ipnbFile.getCells();
Iterables.removeIf(cells, new Predicate<IpnbCell>() {
@Override
public boolean apply(IpnbCell cell) {
return !(cell instanceof IpnbMarkdownCell);
}
});
assertEquals(7, cells.size());
}
use of org.jetbrains.plugins.ipnb.format.cells.IpnbCell 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.IpnbCell 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