package jetbrains.mps.lang.editor.forms.runtime; /*Generated by MPS */ import jetbrains.mps.openapi.editor.cells.EditorCell; import jetbrains.mps.nodeEditor.selectionRestoring.RestorableSelection; import jetbrains.mps.openapi.editor.cells.EditorCell_Collection; import jetbrains.mps.util.IterableUtil; import jetbrains.mps.nodeEditor.selectionRestoring.RestorableSelectionByCell; import jetbrains.mps.nodeEditor.selectionRestoring.ChildCellLocator; import jetbrains.mps.nodeEditor.selectionRestoring.CellIdLocator; import jetbrains.mps.nodeEditor.selectionRestoring.CellSelector; /** * * @deprecated AbstractToggleCheckboxAction was created & used by generated code starting from now. This class will be removed after MPS 3.3 */ @Deprecated public abstract class SaveSelectionForCheckbox { private static final int EXPECTED_CHILD_INDEX = 0; protected final EditorCell mySelectedCell; @Deprecated public SaveSelectionForCheckbox(EditorCell selectedCell) { mySelectedCell = selectedCell; } public RestorableSelection save() { if (mySelectedCell == null || mySelectedCell instanceof EditorCell_Collection) { // No need to save selection, it will be restored by normal means return null; } EditorCell_Collection parent = mySelectedCell.getParent(); if (parent.getCellsCount() < EXPECTED_CHILD_INDEX + 1 || IterableUtil.get(parent, EXPECTED_CHILD_INDEX) != mySelectedCell) { // No need to save selection, it will be restored by normal means return null; } return new RestorableSelectionByCell(new ChildCellLocator(new CellIdLocator(parent.getCellId(), parent.getSNode()), EXPECTED_CHILD_INDEX), createCellSelector()); } protected abstract CellSelector createCellSelector(); }