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.openapi.editor.style.Style;
import jetbrains.mps.editor.runtime.style.StyleImpl;
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.EditorManager;
import jetbrains.mps.nodeEditor.cells.EditorCell_Constant;
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.nodeEditor.cellMenu.SChildSubstituteInfo;
import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.KeyWordStyleClass;
import jetbrains.mps.openapi.editor.style.StyleRegistry;
import jetbrains.mps.nodeEditor.MPSColors;
import jetbrains.mps.lang.editor.menus.transformation.NamedTransformationMenuLookup;
import jetbrains.mps.smodel.language.LanguageRegistry;
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.lang.editor.generator.internal.AbstractCellMenuPart_ReplaceNode_CustomNodeConcept;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.LeftBraceStyleClass;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.RightBraceStyleClass;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.LeftParenStyleClass;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.RightParenStyleClass;
import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.SemicolonStyleClass;
/*package*/ class DoWhileStatement_EditorBuilder_a extends AbstractEditorBuilder {
@NotNull
private SNode myNode;
public DoWhileStatement_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) {
super(context);
myNode = node;
}
@NotNull
@Override
public SNode getNode() {
return myNode;
}
/*package*/ EditorCell createCell() {
return createCollection_q3zjs1_a();
}
private EditorCell createCollection_q3zjs1_a() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent());
editorCell.setCellId("Collection_q3zjs1_a");
editorCell.setBig(true);
editorCell.setCellContext(getCellFactory().getCellContext());
if (nodeCondition_q3zjs1_a0a()) {
editorCell.addEditorCell(createCollection_q3zjs1_a0());
}
if (nodeCondition_q3zjs1_a1a()) {
editorCell.addEditorCell(createCollection_q3zjs1_b0());
}
editorCell.addEditorCell(createConstant_q3zjs1_c0());
editorCell.addEditorCell(createConstant_q3zjs1_d0());
editorCell.addEditorCell(createRefNode_q3zjs1_e0());
editorCell.addEditorCell(createConstant_q3zjs1_f0());
editorCell.addEditorCell(createConstant_q3zjs1_g0());
editorCell.addEditorCell(createConstant_q3zjs1_h0());
editorCell.addEditorCell(createRefNode_q3zjs1_i0());
editorCell.addEditorCell(createConstant_q3zjs1_j0());
editorCell.addEditorCell(createConstant_q3zjs1_k0());
return editorCell;
}
private boolean nodeCondition_q3zjs1_a0a() {
return !(SPropertyOperations.hasValue(myNode, MetaAdapterFactory.getProperty(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x11745b5371dL, "label"), null));
}
private boolean nodeCondition_q3zjs1_a1a() {
return Sequence.fromIterable(AttributeOperations.getChildNodesAndAttributes(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"))).isNotEmpty();
}
private EditorCell createCollection_q3zjs1_a0() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent());
editorCell.setCellId("Collection_q3zjs1_a0");
Style style = new StyleImpl();
style.set(StyleAttributes.SELECTABLE, false);
editorCell.getStyle().putAll(style);
editorCell.addEditorCell(createProperty_q3zjs1_a0a());
editorCell.addEditorCell(createConstant_q3zjs1_b0a());
return editorCell;
}
private EditorCell createProperty_q3zjs1_a0a() {
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);
editorCell.getStyle().putAll(style);
AbstractLoopStatement_Label_Actions.setCellActions(editorCell, myNode, getEditorContext());
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_q3zjs1_b0a() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ":");
editorCell.setCellId("Constant_q3zjs1_b0a");
Style style = new StyleImpl();
style.set(StyleAttributes.SELECTABLE, false);
style.set(StyleAttributes.EDITABLE, false);
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createCollection_q3zjs1_b0() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent());
editorCell.setCellId("Collection_q3zjs1_b0");
Style style = new StyleImpl();
style.set(StyleAttributes.SELECTABLE, false);
editorCell.getStyle().putAll(style);
editorCell.addEditorCell(createRefNode_q3zjs1_a1a());
editorCell.addEditorCell(createConstant_q3zjs1_b1a());
return editorCell;
}
private EditorCell createRefNode_q3zjs1_a1a() {
SingleRoleCellProvider provider = new DoWhileStatement_EditorBuilder_a.loopLabelSingleRoleHandler_q3zjs1_a1a(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"), getEditorContext());
return provider.createCell();
}
private static class loopLabelSingleRoleHandler_q3zjs1_a1a extends SingleRoleCellProvider {
@NotNull
private SNode myNode;
public loopLabelSingleRoleHandler_q3zjs1_a1a(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, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"), child));
editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"), 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, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel"), child));
}
if (editorCell.getRole() == null) {
editorCell.setRole("loopLabel");
}
}
@Override
protected EditorCell createEmptyCell() {
getCellFactory().pushCellContext();
getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x50c493bf9555131L, "loopLabel")));
try {
EditorCell editorCell = super.createEmptyCell();
editorCell.setCellId("empty_loopLabel");
installCellInfo(null, editorCell);
setCellContext(editorCell);
return editorCell;
} finally {
getCellFactory().popCellContext();
}
}
protected String getNoTargetText() {
return "<no loopLabel>";
}
}
private EditorCell createConstant_q3zjs1_b1a() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ":");
editorCell.setCellId("Constant_q3zjs1_b1a");
Style style = new StyleImpl();
style.set(StyleAttributes.SELECTABLE, false);
style.set(StyleAttributes.EDITABLE, false);
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_q3zjs1_c0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "do");
editorCell.setCellId("Constant_q3zjs1_c0");
Style style = new StyleImpl();
new KeyWordStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
style.set(StyleAttributes.EDITABLE, true);
style.set(StyleAttributes.TEXT_COLOR, StyleRegistry.getInstance().getSimpleColor(MPSColors.DARK_BLUE));
editorCell.getStyle().putAll(style);
Delete_Loop.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setTransformationMenuLookup(new NamedTransformationMenuLookup(LanguageRegistry.getInstance(getEditorContext().getRepository()), MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, "jetbrains.mps.baseLanguage.structure.AbstractLoopStatement"), "jetbrains.mps.baseLanguage.editor.loopLabelsAndIfStatement"));
editorCell.setDefaultText("");
editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), new BasicCellContext(myNode), new SubstituteInfoPartExt[]{new DoWhileStatement_EditorBuilder_a.ReplaceWith_WhileStatement_cellMenu_q3zjs1_a0c0(), new DoWhileStatement_EditorBuilder_a.ReplaceWith_ForStatement_cellMenu_q3zjs1_b0c0(), new DoWhileStatement_EditorBuilder_a.ReplaceWith_ForeachStatement_cellMenu_q3zjs1_c0c0(), new SChildSubstituteInfoPartEx(editorCell)}));
return editorCell;
}
public static class ReplaceWith_WhileStatement_cellMenu_q3zjs1_a0c0 extends AbstractCellMenuPart_ReplaceNode_CustomNodeConcept {
public ReplaceWith_WhileStatement_cellMenu_q3zjs1_a0c0() {
}
public SAbstractConcept getReplacementConcept() {
return MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0xfaa4bf0f2fL, "jetbrains.mps.baseLanguage.structure.WhileStatement");
}
}
public static class ReplaceWith_ForStatement_cellMenu_q3zjs1_b0c0 extends AbstractCellMenuPart_ReplaceNode_CustomNodeConcept {
public ReplaceWith_ForStatement_cellMenu_q3zjs1_b0c0() {
}
public SAbstractConcept getReplacementConcept() {
return MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a698082feL, "jetbrains.mps.baseLanguage.structure.ForStatement");
}
}
public static class ReplaceWith_ForeachStatement_cellMenu_q3zjs1_c0c0 extends AbstractCellMenuPart_ReplaceNode_CustomNodeConcept {
public ReplaceWith_ForeachStatement_cellMenu_q3zjs1_c0c0() {
}
public SAbstractConcept getReplacementConcept() {
return MetaAdapterFactory.getConcept(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10a6933ce33L, "jetbrains.mps.baseLanguage.structure.ForeachStatement");
}
}
private EditorCell createConstant_q3zjs1_d0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "{");
editorCell.setCellId("Constant_q3zjs1_d0");
Style style = new StyleImpl();
new LeftBraceStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true);
editorCell.getStyle().putAll(style);
Delete_Loop.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createRefNode_q3zjs1_e0() {
SingleRoleCellProvider provider = new DoWhileStatement_EditorBuilder_a.bodySingleRoleHandler_q3zjs1_e0(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), getEditorContext());
return provider.createCell();
}
private static class bodySingleRoleHandler_q3zjs1_e0 extends SingleRoleCellProvider {
@NotNull
private SNode myNode;
public bodySingleRoleHandler_q3zjs1_e0(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, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), child));
editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), 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, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body"), child));
}
if (editorCell.getRole() == null) {
editorCell.setRole("body");
}
Style style = new StyleImpl();
style.set(StyleAttributes.INDENT_LAYOUT_INDENT, true);
style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true);
editorCell.getStyle().putAll(style);
}
@Override
protected EditorCell createEmptyCell() {
getCellFactory().pushCellContext();
getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x10cb1ac5adeL, 0x10cb1ada6e8L, "body")));
try {
EditorCell editorCell = super.createEmptyCell();
editorCell.setCellId("empty_body");
installCellInfo(null, editorCell);
setCellContext(editorCell);
return editorCell;
} finally {
getCellFactory().popCellContext();
}
}
protected String getNoTargetText() {
return "<no body>";
}
}
private EditorCell createConstant_q3zjs1_f0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "}");
editorCell.setCellId("Constant_q3zjs1_f0");
Style style = new StyleImpl();
new RightBraceStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
Delete_Loop.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_q3zjs1_g0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "while");
editorCell.setCellId("Constant_q3zjs1_g0");
Style style = new StyleImpl();
new KeyWordStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
style.set(StyleAttributes.TEXT_COLOR, StyleRegistry.getInstance().getSimpleColor(MPSColors.DARK_BLUE));
editorCell.getStyle().putAll(style);
Delete_Loop.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_q3zjs1_h0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "(");
editorCell.setCellId("Constant_q3zjs1_h0");
Style style = new StyleImpl();
new LeftParenStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
DeleteCondition.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createRefNode_q3zjs1_i0() {
SingleRoleCellProvider provider = new DoWhileStatement_EditorBuilder_a.conditionSingleRoleHandler_q3zjs1_i0(myNode, MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, 0x11232679422L, "condition"), getEditorContext());
return provider.createCell();
}
private static class conditionSingleRoleHandler_q3zjs1_i0 extends SingleRoleCellProvider {
@NotNull
private SNode myNode;
public conditionSingleRoleHandler_q3zjs1_i0(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, 0x11232674988L, 0x11232679422L, "condition"), child));
editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, 0x11232679422L, "condition"), 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, 0x11232674988L, 0x11232679422L, "condition"), child));
}
if (editorCell.getRole() == null) {
editorCell.setRole("condition");
}
}
@Override
protected EditorCell createEmptyCell() {
getCellFactory().pushCellContext();
getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0xf3061a5392264cc5L, 0xa443f952ceaf5816L, 0x11232674988L, 0x11232679422L, "condition")));
try {
EditorCell editorCell = super.createEmptyCell();
editorCell.setCellId("empty_condition");
installCellInfo(null, editorCell);
setCellContext(editorCell);
return editorCell;
} finally {
getCellFactory().popCellContext();
}
}
protected String getNoTargetText() {
return "<no condition>";
}
}
private EditorCell createConstant_q3zjs1_j0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ")");
editorCell.setCellId("Constant_q3zjs1_j0");
Style style = new StyleImpl();
new RightParenStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
DeleteCondition.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createConstant_q3zjs1_k0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ";");
editorCell.setCellId("Constant_q3zjs1_k0");
Style style = new StyleImpl();
new SemicolonStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
Delete_Loop.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
}