package jetbrains.mps.lang.smodel.query.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.internal.collections.runtime.Sequence; import jetbrains.mps.lang.smodel.query.behavior.QueryExpression__BehaviorDescriptor; import jetbrains.mps.smodel.action.SNodeFactoryOperations; public class QueryExpression_KeyMap extends KeyMapImpl { public QueryExpression_KeyMap() { this.setApplicableToEveryModel(false); KeyMapAction action; action = new QueryExpression_KeyMap.QueryExpression_KeyMap_Action0(); this.putAction("any", "<", action); } public static class QueryExpression_KeyMap_Action0 extends KeyMapActionImpl { public QueryExpression_KeyMap_Action0() { this.setShownInPopupMenu(false); } 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(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3bc64421760bacfdL, "jetbrains.mps.lang.smodel.query.structure.QueryExpression")))) { 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(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3bc64421760bacfdL, 0x3bc644217616e548L, "parameter")) == null) && Sequence.fromIterable(QueryExpression__BehaviorDescriptor.getSupportedParameters_id3J6h25QXCDW.invoke(SNodeOperations.asSConcept(SNodeOperations.getConcept(node)))).isNotEmpty(); } private void execute_internal(final EditorContext editorContext, final SNode node, final List<SNode> selectedNodes) { SNodeFactoryOperations.setNewChild(node, MetaAdapterFactory.getContainmentLink(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3bc64421760bacfdL, 0x3bc644217616e548L, "parameter"), SNodeFactoryOperations.asInstanceConcept(MetaAdapterFactory.getConcept(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3bc644217616ddf9L, "jetbrains.mps.lang.smodel.query.structure.QueryParameterList"))); } public String getKeyStroke() { return " <"; } } }