package jetbrains.mps.lang.generator.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_Horizontal; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.macroStartStyleClass; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.editor.runtime.style.FocusPolicy; 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 java.util.List; import jetbrains.mps.openapi.editor.cells.SubstituteAction; import jetbrains.mps.nodeEditor.cellMenu.CellContext; import jetbrains.mps.nodeEditor.cells.EditorCell_Property; import jetbrains.mps.nodeEditor.cells.ModelAccessor; import jetbrains.mps.util.EqualUtil; import jetbrains.mps.openapi.editor.cells.CellActionType; import jetbrains.mps.editor.runtime.cells.EmptyCellAction; import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.referenceStyleClass; /*package*/ class TemplateSwitchMacro_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public TemplateSwitchMacro_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_84vp13_a(); } private EditorCell createCollection_84vp13_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal()); editorCell.setCellId("Collection_84vp13_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createConstant_84vp13_a0()); if (nodeCondition_84vp13_a1a()) { editorCell.addEditorCell(createReadOnlyModelAccessor_84vp13_b0()); } editorCell.addEditorCell(createComponent_84vp13_c0()); return editorCell; } private boolean nodeCondition_84vp13_a1a() { return (SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xb401a68083254110L, 0x8fd384331ff25befL, 0x17e941d108ce3120L, 0x17e941d108ce3173L, "template")) != null) && isNotEmptyString(SPropertyOperations.getString(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xb401a68083254110L, 0x8fd384331ff25befL, 0x17e941d108ce3120L, 0x17e941d108ce3173L, "template")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))); } private EditorCell createConstant_84vp13_a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "$SWITCH$"); editorCell.setCellId("Constant_84vp13_a0"); Style style = new StyleImpl(); new macroStartStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_RIGHT, false); style.set(StyleAttributes.LAST_POSITION_ALLOWED, false); editorCell.getStyle().putAll(style); if (true) { editorCell.getStyle().set(StyleAttributes.FOCUS_POLICY, FocusPolicy.ATTRACTS_FOCUS); } MacroSymbol_Actions.setCellActions(editorCell, myNode, getEditorContext()); editorCell.setDefaultText(""); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), new BasicCellContext(myNode), new SubstituteInfoPartExt[]{new TemplateSwitchMacro_EditorBuilder_a.TemplateSwitchMacro_component_cellMenu_84vp13_a0a0(), new SChildSubstituteInfoPartEx(editorCell)})); return editorCell; } public static class TemplateSwitchMacro_component_cellMenu_84vp13_a0a0 implements SubstituteInfoPartExt { private replace_node_macro myComponent; public TemplateSwitchMacro_component_cellMenu_84vp13_a0a0() { this.myComponent = new replace_node_macro(); } public List<SubstituteAction> createActions(CellContext cellContext, EditorContext editorContext) { return this.myComponent.createSubstituteActions(cellContext, editorContext); } } private EditorCell createReadOnlyModelAccessor_84vp13_b0() { EditorCell_Property editorCell = EditorCell_Property.create(getEditorContext(), new ModelAccessor() { public String getText() { return SPropertyOperations.getString(SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xb401a68083254110L, 0x8fd384331ff25befL, 0x17e941d108ce3120L, 0x17e941d108ce3173L, "template")), 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_84vp13_b0"); Style style = new StyleImpl(); new referenceStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.NAVIGATABLE_REFERENCE, "template"); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); style.set(StyleAttributes.LAST_POSITION_ALLOWED, true); style.set(StyleAttributes.EDITABLE, false); editorCell.getStyle().putAll(style); return editorCell; } private EditorCell createComponent_84vp13_c0() { EditorCell editorCell = getCellFactory().createEditorComponentCell(myNode, "jetbrains.mps.lang.generator.editor.NodeMacro_postfix"); return editorCell; } private static boolean isNotEmptyString(String str) { return str != null && str.length() > 0; } }