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.nodeEditor.cells.EditorCell_Collection; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Indent; import jetbrains.mps.core.xml.behavior.XmlPart__BehaviorDescriptor; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.core.xml.editor.XmlSS_StyleSheet.xmlTagPunctuationStyleClass; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.core.xml.editor.XmlSS_StyleSheet.xmlTagNameStyleClass; import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; import jetbrains.mps.core.xml.editor.XmlSS_StyleSheet.xmlAttributeValueStyleClass; import jetbrains.mps.nodeEditor.EditorManager; import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; 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.CompositeSubstituteInfo; import jetbrains.mps.lang.editor.cellProviders.AggregationCellContext; import jetbrains.mps.nodeEditor.cellMenu.SubstituteInfoPartExt; import jetbrains.mps.nodeEditor.cellMenu.SChildSubstituteInfoPartEx; import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation; import jetbrains.mps.lang.editor.generator.internal.AbstractCellMenuPart_ReplaceChild_Item; import org.jetbrains.mps.openapi.language.SAbstractConcept; import org.jetbrains.mps.openapi.model.SModel; import jetbrains.mps.smodel.IOperationContext; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; /*package*/ class XmlDoctypeDeclaration_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public XmlDoctypeDeclaration_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_kqvvq_a(); } private EditorCell createCollection_kqvvq_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_kqvvq_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createAlternation_kqvvq_a0()); editorCell.addEditorCell(createCollection_kqvvq_b0()); editorCell.addEditorCell(createAlternation_kqvvq_c0()); return editorCell; } private EditorCell createAlternation_kqvvq_a0() { boolean alternationCondition = true; alternationCondition = nodeCondition_kqvvq_a0a(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createConstant_kqvvq_a0a(); } else { editorCell = createConstant_kqvvq_a0a_0(); } return editorCell; } private boolean nodeCondition_kqvvq_a0a() { return (boolean) XmlPart__BehaviorDescriptor.isFirstPositionAllowed_id1Qs9WekVZ7m.invoke(myNode); } private EditorCell createConstant_kqvvq_a0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "<!"); editorCell.setCellId("Constant_kqvvq_a0a"); Style style = new StyleImpl(); new xmlTagPunctuationStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.MATCHING_LABEL, "openTag"); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_kqvvq_a0a_0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "<!"); editorCell.setCellId("Constant_kqvvq_a0a_0"); Style style = new StyleImpl(); new xmlTagPunctuationStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.MATCHING_LABEL, "openTag"); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_kqvvq_b0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_kqvvq_b0"); editorCell.addEditorCell(createConstant_kqvvq_a1a()); editorCell.addEditorCell(createProperty_kqvvq_b1a()); editorCell.addEditorCell(createRefNode_kqvvq_c1a()); return editorCell; } private EditorCell createConstant_kqvvq_a1a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "DOCTYPE"); editorCell.setCellId("Constant_kqvvq_a1a"); Style style = new StyleImpl(); new xmlTagNameStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_kqvvq_b1a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("doctypeName"); provider.setNoTargetText("<no doctypeName>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_doctypeName"); Style style = new StyleImpl(); new xmlAttributeValueStyleClass(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 createRefNode_kqvvq_c1a() { SingleRoleCellProvider provider = new XmlDoctypeDeclaration_EditorBuilder_a.externalIdSingleRoleHandler_kqvvq_c1a(myNode, MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), getEditorContext()); return provider.createCell(); } private static class externalIdSingleRoleHandler_kqvvq_c1a extends SingleRoleCellProvider { @NotNull private SNode myNode; public externalIdSingleRoleHandler_kqvvq_c1a(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(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), child)); installCellInfo(child, editorCell); return editorCell; } private void installCellInfo(SNode child, EditorCell editorCell) { if (editorCell.getSubstituteInfo() == null || editorCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) { editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), new AggregationCellContext(myNode, child, MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f6033fL, "jetbrains.mps.core.xml.structure.XmlExternalId")), new SubstituteInfoPartExt[]{new XmlDoctypeDeclaration_EditorBuilder_a.externalIdSingleRoleHandler_kqvvq_c1a.XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_a0c1a(), new XmlDoctypeDeclaration_EditorBuilder_a.externalIdSingleRoleHandler_kqvvq_c1a.XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_b0c1a(), new SChildSubstituteInfoPartEx(editorCell)})); } if (editorCell.getRole() == null) { editorCell.setRole("externalId"); } } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_externalId"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return ""; } public static class XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_a0c1a extends AbstractCellMenuPart_ReplaceChild_Item { public XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_a0c1a() { } public String getMatchingText() { return "PUBLIC"; } public boolean isCustomCreateChildNode() { return true; } public SNode customCreateChildNode(SNode node, SNode currentChild, SAbstractConcept defaultChildConcept, SModel model, IOperationContext operationContext, EditorContext editorContext) { return customCreateChildNode_impl(node, currentChild, defaultChildConcept.getDeclarationNode(), defaultChildConcept, model, operationContext, editorContext); } private SNode customCreateChildNode_impl(SNode node, SNode currentChild, SNode defaultConceptOfChild, SAbstractConcept defaultChildConcept, SModel model, IOperationContext operationContext, EditorContext editorContext) { SNode newId = SLinkOperations.setNewChild(node, MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f6033fL, "jetbrains.mps.core.xml.structure.XmlExternalId")); SPropertyOperations.set(newId, MetaAdapterFactory.getProperty(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f6033fL, 0x1d9c27c394f60345L, "isPublic"), "" + (true)); return newId; } } public static class XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_b0c1a extends AbstractCellMenuPart_ReplaceChild_Item { public XmlDoctypeDeclaration_externalId_cellMenu_kqvvq_b0c1a() { } public String getMatchingText() { return "SYSTEM"; } public boolean isCustomCreateChildNode() { return true; } public SNode customCreateChildNode(SNode node, SNode currentChild, SAbstractConcept defaultChildConcept, SModel model, IOperationContext operationContext, EditorContext editorContext) { return customCreateChildNode_impl(node, currentChild, defaultChildConcept.getDeclarationNode(), defaultChildConcept, model, operationContext, editorContext); } private SNode customCreateChildNode_impl(SNode node, SNode currentChild, SNode defaultConceptOfChild, SAbstractConcept defaultChildConcept, SModel model, IOperationContext operationContext, EditorContext editorContext) { SNode newId = SLinkOperations.setNewChild(node, MetaAdapterFactory.getContainmentLink(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f4069bL, 0x1d9c27c394f60340L, "externalId"), MetaAdapterFactory.getConcept(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f6033fL, "jetbrains.mps.core.xml.structure.XmlExternalId")); SPropertyOperations.set(newId, MetaAdapterFactory.getProperty(0x479c7a8c02f943b5L, 0x9139d910cb22f298L, 0x1d9c27c394f6033fL, 0x1d9c27c394f60345L, "isPublic"), "" + (false)); return newId; } } } private EditorCell createAlternation_kqvvq_c0() { boolean alternationCondition = true; alternationCondition = nodeCondition_kqvvq_a2a(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createConstant_kqvvq_a2a(); } else { editorCell = createConstant_kqvvq_a2a_0(); } return editorCell; } private boolean nodeCondition_kqvvq_a2a() { return (boolean) XmlPart__BehaviorDescriptor.isLastPositionAllowed_id1Qs9WekVZ8v.invoke(myNode); } private EditorCell createConstant_kqvvq_a2a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ">"); editorCell.setCellId("Constant_kqvvq_a2a"); Style style = new StyleImpl(); new xmlTagPunctuationStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.MATCHING_LABEL, "openTag"); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createConstant_kqvvq_a2a_0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ">"); editorCell.setCellId("Constant_kqvvq_a2a_0"); Style style = new StyleImpl(); new xmlTagPunctuationStyleClass(getEditorContext(), getNode()).apply(style, editorCell); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.MATCHING_LABEL, "openTag"); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } }