package jetbrains.mps.build.editor; /*Generated by MPS */ import jetbrains.mps.openapi.editor.cells.EditorCell; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.openapi.editor.cells.CellActionType; import jetbrains.mps.editor.runtime.cells.AbstractCellAction; import jetbrains.mps.ide.editor.actions.EditorActionUtils; public class forbid_Insert { public static void setCellActions(EditorCell editorCell, SNode node, EditorContext context) { editorCell.setAction(CellActionType.INSERT_BEFORE, new forbid_Insert.forbid_Insert_INSERT_BEFORE(node)); editorCell.setAction(CellActionType.INSERT, new forbid_Insert.forbid_Insert_INSERT(node)); } public static class forbid_Insert_INSERT_BEFORE extends AbstractCellAction { /*package*/ SNode myNode; public forbid_Insert_INSERT_BEFORE(SNode node) { this.myNode = node; } public void execute(EditorContext editorContext) { this.execute_internal(editorContext, this.myNode); } public void execute_internal(EditorContext editorContext, SNode node) { EditorCell cell = editorContext.getEditorComponent().findNodeCell(node); EditorCell outerCollection = (cell != null ? EditorActionUtils.getSiblingCollectionForInsert(cell, false) : null); if (outerCollection != null) { cell = outerCollection; } else { while (cell != null) { if (cell.getSNode() != node) { break; } if (neq_pledwy_a0b0a0a2a3b(cell.getRole(), "parts")) { break; } cell = cell.getParent(); } } if (cell != null) { EditorActionUtils.callInsertBeforeAction(cell); } } private static boolean neq_pledwy_a0b0a0a2a3b(Object a, Object b) { return !(((a != null ? a.equals(b) : a == b))); } } public static class forbid_Insert_INSERT extends AbstractCellAction { /*package*/ SNode myNode; public forbid_Insert_INSERT(SNode node) { this.myNode = node; } public void execute(EditorContext editorContext) { this.execute_internal(editorContext, this.myNode); } public void execute_internal(EditorContext editorContext, SNode node) { EditorCell cell = editorContext.getEditorComponent().findNodeCell(node); EditorCell outerCollection = (cell != null ? EditorActionUtils.getSiblingCollectionForInsert(cell, true) : null); if (outerCollection != null) { cell = outerCollection; } else { while (cell != null) { if (cell.getSNode() != node) { break; } if (neq_pledwy_a0b0a0a2a3c(cell.getRole(), "parts")) { break; } cell = cell.getParent(); } } if (cell != null) { EditorActionUtils.callInsertAction(cell); } } private static boolean neq_pledwy_a0b0a0a2a3c(Object a, Object b) { return !(((a != null ? a.equals(b) : a == b))); } } }