コード例 #1
0
  public boolean canExecute(EditorContext context) {
    EditorCell selectedCell = getCellToPasteTo((EditorCell) context.getSelectedCell());
    if (selectedCell == null) {
      return false;
    }
    SNode selectedNode = selectedCell.getSNode();
    if (selectedNode == null || jetbrains.mps.util.SNodeOperations.isDisposed(selectedNode)) {
      return false;
    }
    List<SNode> pasteNodes = CopyPasteUtil.getNodesFromClipboard(selectedNode.getModel());
    if (pasteNodes == null || pasteNodes.isEmpty()) {
      return CopyPasteUtil.isConversionAvailable(selectedNode.getModel(), selectedNode);
    }

    if (!new NodePaster(pasteNodes).canPaste(selectedCell)) {
      LOG.debug("Couldn't paste node here");
      return false;
    }
    return true;
  }
コード例 #2
0
  @Override
  public boolean canExecute(EditorContext context) {
    EditorCell selectedCell = (EditorCell) context.getSelectedCell();
    if (selectedCell == null) {
      return false;
    }
    SNode anchorNode = selectedCell.getSNode();
    if (anchorNode == null) {
      return false;
    }
    List<SNode> pasteNodes = CopyPasteUtil.getNodesFromClipboard(anchorNode.getModel());
    if (pasteNodes == null || pasteNodes.isEmpty()) {
      return CopyPasteUtil.isConversionAvailable(anchorNode.getModel(), anchorNode);
    }

    if (!new NodePaster(pasteNodes).canPasteRelative(anchorNode)) {
      LOG.debug("Couldn't paste node relative");
      return false;
    }
    return true;
  }