package jetbrains.mps.baseLanguage.math.editor; /*Generated by MPS */ import jetbrains.mps.editor.runtime.descriptor.AbstractEditorBuilder; import org.jetbrains.annotations.NotNull; import org.jetbrains.mps.openapi.model.SNode; import jetbrains.mps.openapi.editor.EditorContext; import jetbrains.mps.openapi.editor.cells.EditorCell; import jetbrains.mps.nodeEditor.cells.EditorCell_Collection; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Superscript; import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import org.jetbrains.mps.openapi.language.SContainmentLink; import jetbrains.mps.openapi.editor.cells.CellActionType; import jetbrains.mps.editor.runtime.impl.cellActions.CellAction_DeleteSmart; import jetbrains.mps.openapi.editor.cells.DefaultSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfo; import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation; import jetbrains.mps.nodeEditor.cells.EditorCell_Property; import jetbrains.mps.nodeEditor.cells.ModelAccessor; import jetbrains.mps.baseLanguage.math.behavior.ExponentialOperation__BehaviorDescriptor; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.util.EqualUtil; import jetbrains.mps.editor.runtime.cells.EmptyCellAction; import jetbrains.mps.nodeEditor.cellMenu.CompositeSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.BasicCellContext; import jetbrains.mps.nodeEditor.cellMenu.SubstituteInfoPartExt; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfoPartEx; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.editor.runtime.style.ScriptKind; import jetbrains.mps.lang.editor.generator.internal.AbstractCellMenuPart_Generic_Group; import java.util.List; import jetbrains.mps.smodel.IOperationContext; import org.jetbrains.mps.openapi.language.SConcept; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import org.jetbrains.mps.openapi.language.SAbstractConcept; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import org.jetbrains.mps.openapi.model.SModel; import jetbrains.mps.smodel.action.SNodeFactoryOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.editor.runtime.EditorCell_Empty; import jetbrains.mps.nodeEditor.cellActions.CellAction_DeleteNode; /*package*/ class ExponentOperation_Component_ComponentBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public ExponentOperation_Component_ComponentBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_spngij_a(); } private EditorCell createCollection_spngij_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Superscript()); editorCell.setCellId("Collection_spngij_a"); editorCell.addEditorCell(createRefNode_spngij_a0()); editorCell.addEditorCell(createReadOnlyModelAccessor_spngij_b0()); editorCell.addEditorCell(createEmpty_spngij_c0()); return editorCell; } private EditorCell createRefNode_spngij_a0() { SingleRoleCellProvider provider = new ExponentOperation_Component_ComponentBuilder_a.exprSingleRoleHandler_spngij_a0(myNode, MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr"), getEditorContext()); return provider.createCell(); } private static class exprSingleRoleHandler_spngij_a0 extends SingleRoleCellProvider { @NotNull private SNode myNode; public exprSingleRoleHandler_spngij_a0(SNode ownerNode, SContainmentLink containmentLink, EditorContext context) { super(containmentLink, context); myNode = ownerNode; } @Override @NotNull public SNode getNode() { return myNode; } protected EditorCell createChildCell(SNode child) { EditorCell editorCell = getUpdateSession().updateChildNodeCell(child); editorCell.setAction(CellActionType.DELETE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr"), child)); installCellInfo(child, editorCell); return editorCell; } private void installCellInfo(SNode child, EditorCell editorCell) { if (editorCell.getSubstituteInfo() == null || editorCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) { editorCell.setSubstituteInfo(new SChildSubstituteInfo(editorCell, myNode, MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr"), child)); } if (editorCell.getRole() == null) { editorCell.setRole("expr"); } } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_expr"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return "<no expr>"; } } private EditorCell createReadOnlyModelAccessor_spngij_b0() { EditorCell_Property editorCell = EditorCell_Property.create(getEditorContext(), new ModelAccessor() { public String getText() { return (String) ExponentialOperation__BehaviorDescriptor.getOperationSymbol_id1653mnvAgnB.invoke(SNodeOperations.asSConcept(SNodeOperations.getConcept(myNode))); } public void setText(String s) { } public boolean isValidText(String s) { return EqualUtil.equals(s, getText()); } }, myNode); editorCell.setAction(CellActionType.DELETE, EmptyCellAction.getInstance()); editorCell.setAction(CellActionType.BACKSPACE, EmptyCellAction.getInstance()); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), new BasicCellContext(myNode), new SubstituteInfoPartExt[]{new ExponentOperation_Component_ComponentBuilder_a.ExponentialOperation_generic_cellMenu_spngij_a0b0(), new SChildSubstituteInfoPartEx(editorCell)})); editorCell.setCellId("ReadOnlyModelAccessor_spngij_b0"); Style style = new StyleImpl(); style.set(StyleAttributes.SCRIPT_KIND, ScriptKind.SUPERSCRIPT); style.set(StyleAttributes.EDITABLE, true); editorCell.getStyle().putAll(style); deleteUpperIndex.setCellActions(editorCell, myNode, getEditorContext()); return editorCell; } public static class ExponentialOperation_generic_cellMenu_spngij_a0b0 extends AbstractCellMenuPart_Generic_Group { public ExponentialOperation_generic_cellMenu_spngij_a0b0() { } public List<?> createParameterObjects(SNode node, IOperationContext operationContext, EditorContext editorContext) { List<SConcept> result = ListSequence.fromList(new ArrayList<SConcept>()); for (SAbstractConcept a : ListSequence.fromList(SConceptOperations.getAllSubConcepts(SNodeOperations.asSConcept(ListSequence.fromList(ExponentialOperation__BehaviorDescriptor.getAllowedSubstituends_id2D1PBM_bxH0.invoke(SNodeOperations.asSConcept(SNodeOperations.getConcept(node)))).first()), SNodeOperations.getModel(node)))) { if (!(a.isAbstract()) && SConceptOperations.isSubConceptOf(SNodeOperations.asSConcept(a), MetaAdapterFactory.getConcept(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, "jetbrains.mps.baseLanguage.math.structure.ExponentialOperation"))) { ListSequence.fromList(result).addElement((SConcept) a); } } return result; } protected void handleAction(Object parameterObject, SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) { this.handleAction_impl((SConcept) parameterObject, node, model, operationContext, editorContext); } public void handleAction_impl(SConcept parameterObject, SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) { SNodeOperations.replaceWithAnother(node, SNodeFactoryOperations.createNewNode(SNodeFactoryOperations.asInstanceConcept(parameterObject), SLinkOperations.getTarget(node, MetaAdapterFactory.getContainmentLink(0x3304fc6e7c6b401eL, 0xa016b944934bb21fL, 0x64b1e972e6443a20L, 0x64b1e972e6443a22L, "expr")))); } public boolean isReferentPresentation() { return false; } public String getMatchingText(Object parameterObject) { return this.getMatchingText_internal((SConcept) parameterObject); } public String getMatchingText_internal(SConcept parameterObject) { return (String) ExponentialOperation__BehaviorDescriptor.getOperationSymbol_id1653mnvAgnB.invoke(SNodeOperations.asSConcept(parameterObject)); } public String getDescriptionText(Object parameterObject) { return this.getDescriptionText_internal((SConcept) parameterObject); } public String getDescriptionText_internal(SConcept parameterObject) { return SConceptOperations.shortDescription(parameterObject); } } private EditorCell createEmpty_spngij_c0() { EditorCell_Empty editorCell = new EditorCell_Empty(getEditorContext(), myNode); editorCell.setAction(CellActionType.DELETE, new CellAction_DeleteNode(editorCell.getSNode(), CellAction_DeleteNode.DeleteDirection.FORWARD)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteNode(editorCell.getSNode(), CellAction_DeleteNode.DeleteDirection.BACKWARD)); editorCell.setCellId("Empty_spngij_c0"); Style style = new StyleImpl(); style.set(StyleAttributes.PUNCTUATION_LEFT, true); editorCell.getStyle().putAll(style); return editorCell; } }