package jetbrains.mps.baseLanguage.collections.editor; /*Generated by MPS */ import jetbrains.mps.editor.runtime.cells.KeyMapImpl; import jetbrains.mps.openapi.editor.cells.KeyMapAction; import jetbrains.mps.editor.runtime.cells.KeyMapActionImpl; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.openapi.editor.cells.EditorCell; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import java.util.List; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.action.SNodeFactoryOperations; public class SequenceCreator_add_initializer extends KeyMapImpl { public SequenceCreator_add_initializer() { this.setApplicableToEveryModel(false); KeyMapAction action; action = new SequenceCreator_add_initializer.SequenceCreator_add_initializer_Action0(); this.putAction("any", "VK_ENTER", action); } public static class SequenceCreator_add_initializer_Action0 extends KeyMapActionImpl { public SequenceCreator_add_initializer_Action0() { this.setShownInPopupMenu(true); } public String getDescriptionText() { return "Add initializer"; } public boolean isMenuAlwaysShown() { return false; } public boolean canExecute(final EditorContext editorContext) { EditorCell contextCell = editorContext.getContextCell(); if ((contextCell == null)) { return false; } SNode contextNode = contextCell.getSNode(); if (contextNode == null) { return false; } if (!(SNodeOperations.isInstanceOf(contextNode, MetaAdapterFactory.getConcept(0x8388864671ce4f1cL, 0x9c53c54016f6ad4fL, 0x11d14c97b16L, "jetbrains.mps.baseLanguage.collections.structure.SequenceCreator")))) { return false; } return this.canExecute_internal(editorContext, contextNode, this.getSelectedNodes(editorContext)); } public void execute(final EditorContext editorContext) { EditorCell contextCell = editorContext.getContextCell(); this.execute_internal(editorContext, contextCell.getSNode(), this.getSelectedNodes(editorContext)); } private boolean canExecute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { return (SLinkOperations.getTarget(node, MetaAdapterFactory.getContainmentLink(0x8388864671ce4f1cL, 0x9c53c54016f6ad4fL, 0x11d14c97b16L, 0x11d14ca1317L, "initializer")) == null); } private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { SNodeFactoryOperations.setNewChild(node, MetaAdapterFactory.getContainmentLink(0x8388864671ce4f1cL, 0x9c53c54016f6ad4fL, 0x11d14c97b16L, 0x11d14ca1317L, "initializer"), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0xfd3920347849419dL, 0x907112563d152375L, 0x1174bed3125L, "jetbrains.mps.baseLanguage.closures.structure.ClosureLiteral"))); } public String getKeyStroke() { return " ENTER"; } } }