package jetbrains.mps.lang.actions.testLanguage.editor; /*Generated by MPS */ import jetbrains.mps.nodeEditor.menus.substitute.SubstituteMenuBase; import org.jetbrains.annotations.NotNull; import java.util.List; import jetbrains.mps.lang.editor.menus.MenuPart; import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuItem; import jetbrains.mps.openapi.editor.menus.substitute.SubstituteMenuContext; import java.util.ArrayList; import jetbrains.mps.lang.editor.menus.GroupMenuPart; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import java.util.Arrays; import jetbrains.mps.lang.editor.menus.substitute.ConstraintsFilteringSubstituteMenuPartDecorator; import jetbrains.mps.lang.editor.menus.ParameterizedMenuPart; import org.jetbrains.mps.openapi.language.SConcept; import org.jetbrains.annotations.Nullable; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.lang.editor.menus.substitute.SingleItemSubstituteMenuPart; import jetbrains.mps.lang.editor.menus.substitute.DefaultSubstituteMenuItem; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.runtime.IconResource; import jetbrains.mps.smodel.runtime.IconResourceUtil; import jetbrains.mps.openapi.editor.cells.EditorCell; import jetbrains.mps.openapi.editor.cells.CellTraversalUtil; import jetbrains.mps.nodeEditor.cells.EditorCell_Label; import jetbrains.mps.editor.runtime.selection.SelectionUtil; import jetbrains.mps.openapi.editor.selection.SelectionManager; import org.jetbrains.mps.openapi.persistence.PersistenceFacade; import jetbrains.mps.smodel.SModelUtil_new; import org.jetbrains.mps.openapi.model.SNodeAccessUtil; public class AddMenuPart_ParameterizedSubstitute extends SubstituteMenuBase { @NotNull @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts(final SubstituteMenuContext _context) { List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> result = new ArrayList<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>(); result.add(new AddMenuPart_ParameterizedSubstitute.SMP_Group_qp9nsj_a()); return result; } public class SMP_Group_qp9nsj_a extends GroupMenuPart<SubstituteMenuItem, SubstituteMenuContext> { @Override protected boolean isApplicable(SubstituteMenuContext _context) { return _context.getLink() == MetaAdapterFactory.getContainmentLink(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1671696fL, 0x2d9c6017d86af8c9L, "addMenu_parameterizedSubstitute"); } @Override protected List<MenuPart<SubstituteMenuItem, SubstituteMenuContext>> getParts() { return Arrays.<MenuPart<SubstituteMenuItem, SubstituteMenuContext>>asList(new ConstraintsFilteringSubstituteMenuPartDecorator(new AddMenuPart_ParameterizedSubstitute.SMP_Group_qp9nsj_a.SMP_Param_qp9nsj_a0(), MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1671a9caL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestAbstractChild"))); } private class SMP_Param_qp9nsj_a0 extends ParameterizedMenuPart<SConcept, SubstituteMenuItem, SubstituteMenuContext> { @NotNull @Override protected List<SubstituteMenuItem> createItems(SConcept parameter, SubstituteMenuContext context) { return new AddMenuPart_ParameterizedSubstitute.SMP_Group_qp9nsj_a.SMP_Param_qp9nsj_a0.SMP_Action_qp9nsj_a0a(parameter).createItems(context); } @Nullable @Override protected Iterable<? extends SConcept> getParameters(SubstituteMenuContext _context) { // additional compilation test for all passed parameters boolean tmpVar = _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getEditorContext() != null; tmpVar = tmpVar && _context.getModel() != null; return ListSequence.fromList(SConceptOperations.getAllSubConcepts2(MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1671a9caL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestAbstractChild"), _context.getModel())).where(new IWhereFilter<SConcept>() { public boolean accept(SConcept it) { return neq_qp9nsj_a0a0a0a0a0h0b3b(it, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1671a9caL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestAbstractChild")); } }); } private class SMP_Action_qp9nsj_a0a extends SingleItemSubstituteMenuPart { private final SConcept myParameterObject; public SMP_Action_qp9nsj_a0a(SConcept parameterObject) { myParameterObject = parameterObject; } @Nullable @Override protected SubstituteMenuItem createItem(SubstituteMenuContext _context) { return new AddMenuPart_ParameterizedSubstitute.SMP_Group_qp9nsj_a.SMP_Param_qp9nsj_a0.SMP_Action_qp9nsj_a0a.Item(_context); } private class Item extends DefaultSubstituteMenuItem { private final SubstituteMenuContext _context; public Item(SubstituteMenuContext context) { super(MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1671a9caL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestAbstractChild"), context.getParentNode(), context.getCurrentTargetNode(), context.getEditorContext()); _context = context; } @Nullable @Override public SNode createNode(@NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; SNode result = SConceptOperations.createNewNode(SNodeOperations.asInstanceConcept(myParameterObject)); if (eq_qp9nsj_a0j0d4c3b(myParameterObject, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1"))) { SLinkOperations.addNewChild(SNodeOperations.cast(result, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1")), MetaAdapterFactory.getContainmentLink(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, 0x7f805f0c2dd46343L, "child1"), MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x7f805f0c2dd45b4eL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1Child")); } return result; } @Nullable @Override public String getMatchingText(@NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; return myParameterObject.getName(); } @Nullable @Override public String getDescriptionText(@NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; return "Create new instance of concept: " + myParameterObject.getName(); } @Nullable @Override public SNode getType(@NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; boolean useNodeType = eq_qp9nsj_a0a8a6e2d1(myParameterObject, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2c99ba4dd5ff2533L, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1SubConcept")); return (useNodeType ? _quotation_createNode_qp9nsj_a0j0a2a0a_0() : _quotation_createNode_qp9nsj_a0j0a2a0a((SNode) SNodeOperations.asNode(myParameterObject))); } @Nullable @Override public IconResource getIcon(@NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && _context.getCurrentTargetNode() != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; return IconResourceUtil.getIconResourceForConcept(myParameterObject); } @Override public void select(@NotNull SNode createdNode, @NotNull String pattern) { // compilation test for all passed parameters boolean tmpVar = pattern != null; tmpVar = tmpVar && myParameterObject != null; tmpVar = tmpVar && _context.getParentNode() != null; tmpVar = tmpVar && createdNode != null; tmpVar = tmpVar && _context.getLink() != null; tmpVar = tmpVar && _context.getModel() != null; tmpVar = tmpVar && _context.getEditorContext() != null; if (eq_qp9nsj_a0j0i4c3b(myParameterObject, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e1672224dL, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild2"))) { // selecting a custom cell _context.getEditorContext().flushEvents(); EditorCell createdNodeCell = _context.getEditorContext().getEditorComponent().findNodeCell(createdNode); if (createdNodeCell != null) { EditorCell firstLeaf = CellTraversalUtil.getFirstLeaf(createdNodeCell); _context.getEditorContext().getEditorComponent().changeSelection(firstLeaf); if (firstLeaf instanceof EditorCell_Label) { ((EditorCell_Label) firstLeaf).setCaretPosition(3); } return; } } if (eq_qp9nsj_a0k0i4c3b(myParameterObject, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1"))) { // returning node to select SelectionUtil.selectLabelCellAnSetCaret(_context.getEditorContext(), ListSequence.fromList(SLinkOperations.getChildren(SNodeOperations.cast(createdNode, MetaAdapterFactory.getConcept(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, "jetbrains.mps.lang.actions.testLanguage.structure.ActionTestChild1")), MetaAdapterFactory.getContainmentLink(0x737ed1fffa634ebcL, 0xa834435499b23c64L, 0x2365c14e167220f9L, 0x7f805f0c2dd46343L, "child1"))).first(), SelectionManager.FIRST_ERROR_CELL + "|" + SelectionManager.FOCUS_POLICY_CELL + "|" + SelectionManager.FIRST_EDITABLE_CELL + "|" + SelectionManager.FIRST_CELL, -1); return; } SelectionUtil.selectLabelCellAnSetCaret(_context.getEditorContext(), createdNode, SelectionManager.FIRST_ERROR_CELL + "|" + SelectionManager.FOCUS_POLICY_CELL + "|" + SelectionManager.FIRST_EDITABLE_CELL + "|" + SelectionManager.FIRST_CELL, -1); } } } } } private static boolean neq_qp9nsj_a0a0a0a0a0h0b3b(Object a, Object b) { return !(((a != null ? a.equals(b) : a == b))); } private static boolean eq_qp9nsj_a0j0d4c3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_qp9nsj_a0a8a6e2d1(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static SNode _quotation_createNode_qp9nsj_a0j0a2a0a(Object parameter_1) { PersistenceFacade facade = PersistenceFacade.getInstance(); SNode quotedNode_2 = null; quotedNode_2 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0x7866978ea0f04cc7L, 0x81bc4d213d9375e1L, "jetbrains.mps.lang.smodel"), 0x108f968b3caL, "SNodeType"), null, null, false); SNodeAccessUtil.setReferenceTarget(quotedNode_2, MetaAdapterFactory.getReferenceLink(0x7866978ea0f04cc7L, 0x81bc4d213d9375e1L, 0x108f968b3caL, 0x1090e46ca51L, "concept"), (SNode) parameter_1); return quotedNode_2; } private static SNode _quotation_createNode_qp9nsj_a0j0a2a0a_0() { PersistenceFacade facade = PersistenceFacade.getInstance(); SNode quotedNode_1 = null; quotedNode_1 = SModelUtil_new.instantiateConceptDeclaration(MetaAdapterFactory.getConcept(MetaAdapterFactory.getLanguage(0x7866978ea0f04cc7L, 0x81bc4d213d9375e1L, "jetbrains.mps.lang.smodel"), 0x108f968b3caL, "SNodeType"), null, null, false); return quotedNode_1; } private static boolean eq_qp9nsj_a0j0i4c3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } private static boolean eq_qp9nsj_a0k0i4c3b(Object a, Object b) { return (a != null ? a.equals(b) : a == b); } }