package jetbrains.mps.core.xml.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.editor.runtime.cells.BigCellUtil; import jetbrains.mps.core.xml.behavior.XmlBaseAttribute__BehaviorDescriptor; import jetbrains.mps.nodeEditor.cells.EditorCell_Collection; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Indent; 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.core.xml.editor.XmlSS_StyleSheet.xmlAttributeNameStyleClass; import jetbrains.mps.nodeEditor.EditorManager; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.core.xml.editor.XmlSS_StyleSheet.xmlAttributeValueStyleClass; import jetbrains.mps.nodeEditor.cellProviders.AbstractCellListHandler; import jetbrains.mps.lang.editor.cellProviders.RefNodeListHandler; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SConceptOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; 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.menus.transformation.DefaultTransformationMenuLookup; import jetbrains.mps.smodel.language.LanguageRegistry; /*package*/ class XmlAttribute_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public XmlAttribute_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createAlternation_1uorir_a(); } private EditorCell createAlternation_1uorir_a() { boolean alternationCondition = true; alternationCondition = nodeCondition_1uorir_a0(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createCollection_1uorir_a0(); } else { editorCell = createCollection_1uorir_a0_0(); } EditorCell bigCell = BigCellUtil.findBigCell(editorCell, getNode()); if (bigCell != null) { bigCell.setBig(true); bigCell.setCellContext(getCellFactory().getCellContext()); } return editorCell; } private boolean nodeCondition_1uorir_a0() { return (boolean) XmlBaseAttribute__BehaviorDescriptor.isMultiline_id2EZ251fZScc.invoke(myNode); } private EditorCell createCollection_1uorir_a0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_1uorir_a0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_ON_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createProperty_1uorir_a0a()); editorCell.addEditorCell(createConstant_1uorir_b0a()); editorCell.addEditorCell(createConstant_1uorir_c0a()); editorCell.addEditorCell(createCollection_1uorir_d0a()); editorCell.addEditorCell(createConstant_1uorir_e0a()); return editorCell; } private EditorCell createProperty_1uorir_a0a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("attrName"); provider.setNoTargetText("<no attrName>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_attrName"); Style style = new StyleImpl(); new xmlAttributeNameStyleClass(getEditorContext(), getNode()).apply(style, editorCell); 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_1uorir_b0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "="); editorCell.setCellId("Constant_1uorir_b0a"); Style style = new StyleImpl(); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_1uorir_c0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "\""); editorCell.setCellId("Constant_1uorir_c0a"); Style style = new StyleImpl(); new xmlAttributeValueStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_1uorir_d0a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_1uorir_d0a"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_INDENT_ANCHOR, true); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createRefNodeList_1uorir_a3a0()); return editorCell; } private EditorCell createRefNodeList_1uorir_a3a0() { AbstractCellListHandler handler = new XmlAttribute_EditorBuilder_a.valueListHandler_1uorir_a3a0(myNode, "value", getEditorContext()); EditorCell_Collection editorCell = handler.createCells(new CellLayout_Indent(), false); editorCell.setCellId("refNodeList_value"); editorCell.setRole(handler.getElementRole()); return editorCell; } private static class valueListHandler_1uorir_a3a0 extends RefNodeListHandler { @NotNull private SNode myNode; public valueListHandler_1uorir_a3a0(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 nodeFactory(); } public SNode nodeFactory() { return SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54cfd1fL, "jetbrains.mps.core.xml.structure.XmlTextValue")); } 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(valueListHandler_1uorir_a3a0.this.getNode(), MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, 0x5c842a42c54cfd1eL, "value"))); try { EditorCell emptyCell = null; emptyCell = createConstant_1uorir_a0d0a(); 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(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, 0x5c842a42c54cfd1eL, "value"), elementNode)); } } } private EditorCell createConstant_1uorir_a0d0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ""); editorCell.setCellId("Constant_1uorir_a0d0a"); Style style = new StyleImpl(); style.set(StyleAttributes.EDITABLE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } } private EditorCell createConstant_1uorir_e0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "\""); editorCell.setCellId("Constant_1uorir_e0a"); Style style = new StyleImpl(); new xmlAttributeValueStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_LEFT, true); editorCell.getStyle().putAll(style); editorCell.setTransformationMenuLookup(new DefaultTransformationMenuLookup(LanguageRegistry.getInstance(getEditorContext().getRepository()), MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, "jetbrains.mps.core.xml.structure.XmlAttribute"))); editorCell.setDefaultText(""); editorCell.setSubstituteInfo(new SChildSubstituteInfo(editorCell)); return editorCell; } private EditorCell createCollection_1uorir_a0_0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_1uorir_a0_0"); editorCell.addEditorCell(createProperty_1uorir_a0a_0()); editorCell.addEditorCell(createConstant_1uorir_b0a_0()); editorCell.addEditorCell(createConstant_1uorir_c0a_0()); editorCell.addEditorCell(createRefNodeList_1uorir_d0a()); editorCell.addEditorCell(createConstant_1uorir_e0a_0()); return editorCell; } private EditorCell createProperty_1uorir_a0a_0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("attrName"); provider.setNoTargetText("<no attrName>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_attrName_1"); Style style = new StyleImpl(); new xmlAttributeNameStyleClass(getEditorContext(), getNode()).apply(style, editorCell); 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_1uorir_b0a_0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "="); editorCell.setCellId("Constant_1uorir_b0a_0"); Style style = new StyleImpl(); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_1uorir_c0a_0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "\""); editorCell.setCellId("Constant_1uorir_c0a_0"); Style style = new StyleImpl(); new xmlAttributeValueStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createRefNodeList_1uorir_d0a() { AbstractCellListHandler handler = new XmlAttribute_EditorBuilder_a.valueListHandler_1uorir_d0a(myNode, "value", getEditorContext()); EditorCell_Collection editorCell = handler.createCells(new CellLayout_Indent(), false); editorCell.setCellId("refNodeList_value_1"); editorCell.setRole(handler.getElementRole()); return editorCell; } private static class valueListHandler_1uorir_d0a extends RefNodeListHandler { @NotNull private SNode myNode; public valueListHandler_1uorir_d0a(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 nodeFactory(); } public SNode nodeFactory() { return SConceptOperations.createNewNode(MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54cfd1fL, "jetbrains.mps.core.xml.structure.XmlTextValue")); } 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(valueListHandler_1uorir_d0a.this.getNode(), MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, 0x5c842a42c54cfd1eL, "value"))); try { EditorCell emptyCell = null; emptyCell = createConstant_1uorir_a3a0(); 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(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, 0x5c842a42c54cfd1eL, "value"), elementNode)); } } } private EditorCell createConstant_1uorir_a3a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ""); editorCell.setCellId("Constant_1uorir_a3a0"); Style style = new StyleImpl(); style.set(StyleAttributes.EDITABLE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } } private EditorCell createConstant_1uorir_e0a_0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "\""); editorCell.setCellId("Constant_1uorir_e0a_0"); Style style = new StyleImpl(); new xmlAttributeValueStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_LEFT, true); editorCell.getStyle().putAll(style); editorCell.setTransformationMenuLookup(new DefaultTransformationMenuLookup(LanguageRegistry.getInstance(getEditorContext().getRepository()), MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x5c842a42c54b8df3L, "jetbrains.mps.core.xml.structure.XmlAttribute"))); editorCell.setDefaultText(""); editorCell.setSubstituteInfo(new SChildSubstituteInfo(editorCell)); return editorCell; } }