private boolean processSideDeletes(CellActionType type) { // TODO: review this logic - it was originally copied from EditorComponentKeyboardHandler final EditorCell selectedCell = getEditorCell(); if (type == CellActionType.DELETE && selectedCell.isLastPositionInBigCell() && !selectedCell.isFirstPositionInBigCell()) { final EditorCell target; if (selectedCell.isLastPositionInBigCell() && selectedCell.getContainingBigCell().getNextSibling() != null) { target = selectedCell.getContainingBigCell().getNextSibling(); } else if (selectedCell.getNextSibling() != null) { target = selectedCell.getNextSibling(); } else { target = selectedCell.getNextLeaf(CellConditions.SELECTABLE); } if (target == null || ModelAccess.instance() .runReadAction( new Computable<Boolean>() { public Boolean compute() { return target.getSNode().isAncestorOf(selectedCell.getSNode()); } })) return false; return target.executeAction(CellActionType.DELETE); } if (type == CellActionType.BACKSPACE && selectedCell.isFirstPositionInBigCell() && !selectedCell.isLastPositionInBigCell()) { final EditorCell target; if (selectedCell.isFirstPositionInBigCell() && selectedCell.getContainingBigCell().getPrevSibling() != null) { target = selectedCell.getContainingBigCell().getPrevSibling(); } else if (selectedCell.getPrevSibling() != null) { target = selectedCell.getPrevSibling(); } else { target = selectedCell.getPrevLeaf(CellConditions.SELECTABLE); } if (target == null) return false; /* if (ModelAccess.instance().runReadAction(new Computable<Boolean>() { public Boolean compute() { return target.getSNode().isAncestorOf(selectedCell.getSNode()); } })) return false; */ return target.executeAction(CellActionType.DELETE); } return false; }
private boolean canPasteBefore(EditorCell selectedCell, List<SNode> pasteNodes) { if (!selectedCell.isFirstPositionInBigCell()) return false; SNode anchor = selectedCell.getSNode(); if (anchor.getParent() == null) return false; NodeAndRole nodeAndRole = new NodePaster(pasteNodes).getActualAnchorNode(anchor, anchor.getRoleInParent()); if (nodeAndRole == null) return false; EditorCell targetCell = selectedCell.getEditor().findNodeCell(nodeAndRole.myNode); return targetCell != null && targetCell.getFirstLeaf(CellConditions.SELECTABLE) == selectedCell && new NodePaster(pasteNodes).canPasteRelative(nodeAndRole.myNode); }