package jetbrains.mps.editor.runtime.impl.cellActions; /*Generated by MPS */ import jetbrains.mps.editor.runtime.cells.AbstractCellAction; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.nodeEditor.selection.NodeRangeSelection; import jetbrains.mps.openapi.editor.cells.EditorCell; public class CellAction_CreateChildRangeSelection extends AbstractCellAction { private SNode myNode; private EditorContext myEditorContext; private NodeRangeSelection.RangeSelectionFilter myFilter; private boolean myNext = false; private String myEmptyCellId; public CellAction_CreateChildRangeSelection(SNode node, NodeRangeSelection.RangeSelectionFilter filter, String emptyCellId, EditorContext editorContext, boolean next) { super(false); myNode = node; myFilter = filter; myEditorContext = editorContext; myEmptyCellId = emptyCellId; myNext = next; } @Override public boolean canExecute(EditorContext context) { EditorCell selectedCell = context.getSelectedCell(); return selectedCell != null && selectedCell.getSNode() == myNode; } public void execute(EditorContext context) { EditorCell selectedCell = myEditorContext.getSelectedCell(); NodeRangeSelection newSelection = new NodeRangeSelection(myEditorContext.getEditorComponent(), myNode, myNode, myFilter, myEmptyCellId); if (selectedCell != null && selectedCell.isBig()) { newSelection = newSelection.enlargeSelection(myNext); } if (newSelection != null) { myEditorContext.getSelectionManager().pushSelection(newSelection); newSelection.ensureVisible(); } } }