package jetbrains.mps.samples.StateChart.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_Indent; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.nodeEditor.EditorManager; import jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical; import jetbrains.mps.lang.editor.cellProviders.RefNodeListHandler; import jetbrains.mps.smodel.action.NodeFactoryManager; import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation; import jetbrains.mps.openapi.editor.cells.CellActionType; import jetbrains.mps.nodeEditor.cellActions.CellAction_DeleteNode; import jetbrains.mps.openapi.editor.cells.DefaultSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfo; import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider; import org.jetbrains.mps.openapi.language.SContainmentLink; import jetbrains.mps.editor.runtime.impl.cellActions.CellAction_DeleteSmart; import jetbrains.mps.nodeEditor.cells.EditorCell_Property; import jetbrains.mps.nodeEditor.cells.ModelAccessor; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.util.EqualUtil; import jetbrains.mps.editor.runtime.cells.EmptyCellAction; /*package*/ class State_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public State_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_sjqidp_a(); } private EditorCell createCollection_sjqidp_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_sjqidp_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createConstant_sjqidp_a0()); editorCell.addEditorCell(createProperty_sjqidp_b0()); editorCell.addEditorCell(createConstant_sjqidp_c0()); editorCell.addEditorCell(createProperty_sjqidp_d0()); editorCell.addEditorCell(createConstant_sjqidp_e0()); editorCell.addEditorCell(createProperty_sjqidp_f0()); editorCell.addEditorCell(createRefNodeList_sjqidp_g0()); if (nodeCondition_sjqidp_a7a()) { editorCell.addEditorCell(createCollection_sjqidp_h0()); } if (nodeCondition_sjqidp_a8a()) { editorCell.addEditorCell(createCollection_sjqidp_i0()); } editorCell.addEditorCell(createConstant_sjqidp_j0()); editorCell.addEditorCell(createConstant_sjqidp_k0()); editorCell.addEditorCell(createReadOnlyModelAccessor_sjqidp_l0()); editorCell.addEditorCell(createComponent_sjqidp_m0()); return editorCell; } private boolean nodeCondition_sjqidp_a7a() { return ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry")), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x5e8f0d038ab26ac1L, 0x5e8f0d038ab26ac2L, "operations"))).isNotEmpty(); } private boolean nodeCondition_sjqidp_a8a() { return ListSequence.fromList(SLinkOperations.getChildren(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit")), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x5e8f0d038ab26ac1L, 0x5e8f0d038ab26ac2L, "operations"))).isNotEmpty(); } private EditorCell createConstant_sjqidp_a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "State:"); editorCell.setCellId("Constant_sjqidp_a0"); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_sjqidp_b0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("name"); provider.setNoTargetText("<no name>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_name"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo()); SNode attributeConcept = provider.getRoleAttribute(); if (attributeConcept != null) { EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext()); return manager.createNodeRoleAttributeCell(attributeConcept, provider.getRoleAttributeKind(), editorCell); } else return editorCell; } private EditorCell createConstant_sjqidp_c0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "initial state:"); editorCell.setCellId("Constant_sjqidp_c0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_sjqidp_d0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("isInitial"); provider.setNoTargetText("<no isInitial>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_isInitial"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo()); SNode attributeConcept = provider.getRoleAttribute(); if (attributeConcept != null) { EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext()); return manager.createNodeRoleAttributeCell(attributeConcept, provider.getRoleAttributeKind(), editorCell); } else return editorCell; } private EditorCell createConstant_sjqidp_e0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "final state:"); editorCell.setCellId("Constant_sjqidp_e0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_sjqidp_f0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("isFinal"); provider.setNoTargetText("<no isFinal>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_isFinal"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setSubstituteInfo(provider.createDefaultSubstituteInfo()); SNode attributeConcept = provider.getRoleAttribute(); if (attributeConcept != null) { EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext()); return manager.createNodeRoleAttributeCell(attributeConcept, provider.getRoleAttributeKind(), editorCell); } else return editorCell; } private EditorCell createRefNodeList_sjqidp_g0() { AbstractCellListHandler handler = new State_EditorBuilder_a.transitionsListHandler_sjqidp_g0(myNode, "transitions", getEditorContext()); EditorCell_Collection editorCell = handler.createCells(new CellLayout_Vertical(), false); editorCell.setCellId("refNodeList_transitions"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setRole(handler.getElementRole()); return editorCell; } private static class transitionsListHandler_sjqidp_g0 extends RefNodeListHandler { @NotNull private SNode myNode; public transitionsListHandler_sjqidp_g0(SNode ownerNode, String childRole, EditorContext context) { super(ownerNode, childRole, context, false); myNode = ownerNode; } @Override @NotNull public SNode getNode() { return myNode; } public SNode createNodeToInsert(EditorContext editorContext) { return NodeFactoryManager.createNode(MetaAdapterFactory.getConcept(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a9L, "jetbrains.mps.samples.StateChart.structure.Transition"), null, getNode(), getNode().getModel()); } public EditorCell createNodeCell(SNode elementNode) { EditorCell elementCell = getUpdateSession().updateChildNodeCell(elementNode); installElementCellActions(elementNode, elementCell); return elementCell; } public EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(transitionsListHandler_sjqidp_g0.this.getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x148d06483264e4afL, "transitions"))); try { EditorCell emptyCell = null; emptyCell = super.createEmptyCell(); installElementCellActions(null, emptyCell); setCellContext(emptyCell); return emptyCell; } finally { getCellFactory().popCellContext(); } } public void installElementCellActions(SNode elementNode, EditorCell elementCell) { if (elementCell.getUserObject(AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET) == null) { elementCell.putUserObject(AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET, AbstractCellListHandler.ELEMENT_CELL_ACTIONS_SET); if (elementNode != null) { elementCell.setAction(CellActionType.DELETE, new CellAction_DeleteNode(elementNode, CellAction_DeleteNode.DeleteDirection.FORWARD)); elementCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteNode(elementNode, CellAction_DeleteNode.DeleteDirection.BACKWARD)); } if (elementCell.getSubstituteInfo() == null || elementCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) { elementCell.setSubstituteInfo(new SChildSubstituteInfo(elementCell, getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x148d06483264e4afL, "transitions"), elementNode)); } } } } private EditorCell createCollection_sjqidp_h0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_sjqidp_h0"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createConstant_sjqidp_a7a()); editorCell.addEditorCell(createRefNode_sjqidp_b7a()); editorCell.addEditorCell(createConstant_sjqidp_c7a()); return editorCell; } private EditorCell createConstant_sjqidp_a7a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "on entry do"); editorCell.setCellId("Constant_sjqidp_a7a"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createRefNode_sjqidp_b7a() { SingleRoleCellProvider provider = new State_EditorBuilder_a.onEntrySingleRoleHandler_sjqidp_b7a(myNode, MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry"), getEditorContext()); return provider.createCell(); } private static class onEntrySingleRoleHandler_sjqidp_b7a extends SingleRoleCellProvider { @NotNull private SNode myNode; public onEntrySingleRoleHandler_sjqidp_b7a(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(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry"), 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(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry"), child)); } if (editorCell.getRole() == null) { editorCell.setRole("onEntry"); } Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691b5L, "onEntry"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_onEntry"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return "<no onEntry>"; } } private EditorCell createConstant_sjqidp_c7a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "end"); editorCell.setCellId("Constant_sjqidp_c7a"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_ON_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_sjqidp_i0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_sjqidp_i0"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createConstant_sjqidp_a8a()); editorCell.addEditorCell(createRefNode_sjqidp_b8a()); editorCell.addEditorCell(createConstant_sjqidp_c8a()); return editorCell; } private EditorCell createConstant_sjqidp_a8a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "on exit do"); editorCell.setCellId("Constant_sjqidp_a8a"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createRefNode_sjqidp_b8a() { SingleRoleCellProvider provider = new State_EditorBuilder_a.onExitSingleRoleHandler_sjqidp_b8a(myNode, MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit"), getEditorContext()); return provider.createCell(); } private static class onExitSingleRoleHandler_sjqidp_b8a extends SingleRoleCellProvider { @NotNull private SNode myNode; public onExitSingleRoleHandler_sjqidp_b8a(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(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit"), 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(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit"), child)); } if (editorCell.getRole() == null) { editorCell.setRole("onExit"); } Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xc3b0572e7f864ac7L, 0xac44ef15dc8f5c15L, 0x148d06483264e4a6L, 0x5e8f0d038ab691caL, "onExit"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_onExit"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return "<no onExit>"; } } private EditorCell createConstant_sjqidp_c8a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "end"); editorCell.setCellId("Constant_sjqidp_c8a"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_ON_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_sjqidp_j0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ""); editorCell.setCellId("Constant_sjqidp_j0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_sjqidp_k0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "Nested state chart"); editorCell.setCellId("Constant_sjqidp_k0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createReadOnlyModelAccessor_sjqidp_l0() { EditorCell_Property editorCell = EditorCell_Property.create(getEditorContext(), new ModelAccessor() { public String getText() { return "for state " + SPropertyOperations.getString(myNode, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name")); } 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.setCellId("ReadOnlyModelAccessor_sjqidp_l0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); style.set(StyleAttributes.EDITABLE, false); editorCell.getStyle().putAll(style); return editorCell; } private EditorCell createComponent_sjqidp_m0() { EditorCell editorCell = getCellFactory().createEditorComponentCell(myNode, "jetbrains.mps.samples.StateChart.editor.StateChartContents"); return editorCell; } }