package jetbrains.mps.samples.mindmaps.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.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.internal.collections.runtime.IVisitor; public class DeleteThought { public static void setCellActions(EditorCell editorCell, SNode node, EditorContext context) { editorCell.setAction(CellActionType.DELETE, new DeleteThought.DeleteThought_DELETE(node)); editorCell.setAction(CellActionType.BACKSPACE, new DeleteThought.DeleteThought_BACKSPACE(node)); } public static class DeleteThought_DELETE extends AbstractCellAction { /*package*/ SNode myNode; public DeleteThought_DELETE(SNode node) { this.myNode = node; } public void execute(EditorContext editorContext) { this.execute_internal(editorContext, this.myNode); } public void execute_internal(EditorContext editorContext, final SNode node) { SNode mindMap = SNodeOperations.getNodeAncestor(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, "jetbrains.mps.samples.mindmaps.structure.MindMap"), false, false); ListSequence.fromList(SLinkOperations.getChildren(mindMap, MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5dbL, "relationships"))).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_tcgyjr_a0a0a0a0a0a0c0d1_0(SLinkOperations.getTarget(it, MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x1198689ff14c5dfL, "target")), node) || eq_tcgyjr_a0a0a0a0a0a0c0d1(SLinkOperations.getTarget(it, MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x517b79625769ba9eL, "source")), node); } }).visitAll(new IVisitor<SNode>() { public void visit(SNode it) { SNodeOperations.deleteNode(it); } }); SNodeOperations.deleteNode(node); } private static boolean eq_tcgyjr_a0a0a0a0a0a0c0d1(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_tcgyjr_a0a0a0a0a0a0c0d1_0(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } } public static class DeleteThought_BACKSPACE extends AbstractCellAction { /*package*/ SNode myNode; public DeleteThought_BACKSPACE(SNode node) { this.myNode = node; } public void execute(EditorContext editorContext) { this.execute_internal(editorContext, this.myNode); } public void execute_internal(EditorContext editorContext, final SNode node) { SNode mindMap = SNodeOperations.getNodeAncestor(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, "jetbrains.mps.samples.mindmaps.structure.MindMap"), false, false); ListSequence.fromList(SLinkOperations.getChildren(mindMap, MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5dbL, "relationships"))).where(new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_tcgyjr_a0a0a0a0a0a0c0d2_0(SLinkOperations.getTarget(it, MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x1198689ff14c5dfL, "target")), node) || eq_tcgyjr_a0a0a0a0a0a0c0d2(SLinkOperations.getTarget(it, MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x517b79625769ba9eL, "source")), node); } }).visitAll(new IVisitor<SNode>() { public void visit(SNode it) { SNodeOperations.deleteNode(it); } }); SNodeOperations.deleteNode(node); } private static boolean eq_tcgyjr_a0a0a0a0a0a0c0d2(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_tcgyjr_a0a0a0a0a0a0c0d2_0(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } } }