package jetbrains.mps.baseLanguage.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.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.AttributeOperations; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.KeyWordStyleClass; import jetbrains.mps.lang.editor.menus.transformation.DefaultTransformationMenuLookup; import jetbrains.mps.smodel.language.LanguageRegistry; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfo; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.LabelStyleClass; import jetbrains.mps.nodeEditor.cellMenu.CompositeSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.SubstituteInfoPartExt; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfoPartEx; import jetbrains.mps.nodeEditor.EditorManager; import jetbrains.mps.lang.editor.generator.internal.AbstractCellMenuPart_Generic_Group; import java.util.List; import jetbrains.mps.smodel.IOperationContext; import jetbrains.mps.internal.collections.runtime.ListSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.internal.collections.runtime.ITranslator2; import java.util.Iterator; import jetbrains.mps.baseLanguage.closures.runtime.YieldingIterator; import org.jetbrains.mps.openapi.model.SModel; import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider; 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.baseLanguage.editor.BaseLanguageStyle_StyleSheet.VariableNameStyleClass; import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.SemicolonStyleClass; /*package*/ class BreakStatement_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public BreakStatement_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_xk0l2m_a(); } private EditorCell createCollection_xk0l2m_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_xk0l2m_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createConstant_xk0l2m_a0()); if (nodeCondition_xk0l2m_a1a()) { editorCell.addEditorCell(createCollection_xk0l2m_b0()); } if (nodeCondition_xk0l2m_a2a()) { editorCell.addEditorCell(createCollection_xk0l2m_c0()); } editorCell.addEditorCell(createConstant_xk0l2m_d0()); return editorCell; } private boolean nodeCondition_xk0l2m_a1a() { return !(SPropertyOperations.hasValue(myNode, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x11745bfb2d8L, "label"), null)); } private boolean nodeCondition_xk0l2m_a2a() { return Sequence.fromIterable(AttributeOperations.getChildNodesAndAttributes(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"))).isNotEmpty(); } private EditorCell createConstant_xk0l2m_a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "break"); editorCell.setCellId("Constant_xk0l2m_a0"); Style style = new StyleImpl(); new KeyWordStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setTransformationMenuLookup(new DefaultTransformationMenuLookup(LanguageRegistry.getInstance(getEditorContext().getRepository()), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, "jetbrains.mps.baseLanguage.structure.BreakStatement"))); editorCell.setDefaultText(""); editorCell.setSubstituteInfo(new SChildSubstituteInfo(editorCell)); return editorCell; } private EditorCell createCollection_xk0l2m_b0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_xk0l2m_b0"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createProperty_xk0l2m_a1a()); return editorCell; } private EditorCell createProperty_xk0l2m_a1a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("label"); provider.setNoTargetText("<no label>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_label"); Style style = new StyleImpl(); new LabelStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.SELECTABLE, true); style.set(StyleAttributes.EDITABLE, true); editorCell.getStyle().putAll(style); BreakStatement_Actions.setCellActions(editorCell, myNode, getEditorContext()); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), provider.getCellContext(), new SubstituteInfoPartExt[]{new BreakStatement_EditorBuilder_a.BreakStatement_generic_cellMenu_xk0l2m_a0a1a(), new SChildSubstituteInfoPartEx(editorCell)})); SNode attributeConcept = provider.getRoleAttribute(); if (attributeConcept != null) { EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext()); return manager.createNodeRoleAttributeCell(attributeConcept, provider.getRoleAttributeKind(), editorCell); } else return editorCell; } public static class BreakStatement_generic_cellMenu_xk0l2m_a0a1a extends AbstractCellMenuPart_Generic_Group { public BreakStatement_generic_cellMenu_xk0l2m_a0a1a() { } public List<?> createParameterObjects(SNode node, IOperationContext operationContext, EditorContext editorContext) { return ListSequence.fromList(SNodeOperations.getNodeAncestors(node, MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, "jetbrains.mps.baseLanguage.structure.AbstractLoopStatement"), false)).translate(new ITranslator2<SNode, String>() { public Iterable<String> translate(final SNode it) { return new Iterable<String>() { public Iterator<String> iterator() { return new YieldingIterator<String>() { private int __CP__ = 0; protected boolean moveToNext() { __loop__: do { __switch__: switch (this.__CP__) { case -1: assert false : "Internal error"; return false; case 2: if (!(SPropertyOperations.hasValue(it, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x11745b5371dL, "label"), null))) { this.__CP__ = 3; break; } this.__CP__ = 1; break; case 4: this.__CP__ = 1; this.yield(SPropertyOperations.getString(it, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x11745b5371dL, "label"))); return true; case 0: this.__CP__ = 2; break; case 3: this.__CP__ = 4; break; default: break __loop__; } } while (true); return false; } }; } }; } }).toListSequence(); } protected void handleAction(Object parameterObject, SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) { this.handleAction_impl((String) parameterObject, node, model, operationContext, editorContext); } public void handleAction_impl(String parameterObject, SNode node, SModel model, IOperationContext operationContext, EditorContext editorContext) { SPropertyOperations.set(node, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x11745bfb2d8L, "label"), parameterObject); } public boolean isReferentPresentation() { return false; } } private EditorCell createCollection_xk0l2m_c0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_xk0l2m_c0"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createRefNode_xk0l2m_a2a()); return editorCell; } private EditorCell createRefNode_xk0l2m_a2a() { SingleRoleCellProvider provider = new BreakStatement_EditorBuilder_a.loopLabelReferenceSingleRoleHandler_xk0l2m_a2a(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"), getEditorContext()); return provider.createCell(); } private static class loopLabelReferenceSingleRoleHandler_xk0l2m_a2a extends SingleRoleCellProvider { @NotNull private SNode myNode; public loopLabelReferenceSingleRoleHandler_xk0l2m_a2a(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(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"), 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(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"), child)); } if (editorCell.getRole() == null) { editorCell.setRole("loopLabelReference"); } Style style = new StyleImpl(); new VariableNameStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfbe39a867fL, 0x7dae85d6eb42f8c4L, "loopLabelReference"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_loopLabelReference"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return "<no loopLabelReference>"; } } private EditorCell createConstant_xk0l2m_d0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ";"); editorCell.setCellId("Constant_xk0l2m_d0"); Style style = new StyleImpl(); new SemicolonStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } }