package jetbrains.mps.lang.structure.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.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; import jetbrains.mps.nodeEditor.cells.EditorCell_Property; import jetbrains.mps.nodeEditor.cells.ModelAccessor; import jetbrains.mps.nodeEditor.cells.TransactionalPropertyAccessor; import jetbrains.mps.internal.collections.runtime.Sequence; import jetbrains.mps.smodel.structure.ExtensionPoint; import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import jetbrains.mps.internal.collections.runtime.IWhereFilter; import jetbrains.mps.nodeEditor.cells.ChangePropertyEditorCommand; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.FieldStyleClass; 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_PropertyPostfixHints; import java.util.List; import jetbrains.mps.smodel.IOperationContext; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.util.NameUtil; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Indent; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.lang.editor.cellProviders.RefCellCellProvider; import jetbrains.mps.util.Computable; import jetbrains.mps.editor.runtime.impl.CellUtil; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.ConceptNameStyleClass; import jetbrains.mps.nodeEditor.MPSFonts; import jetbrains.mps.baseLanguage.editor.BaseLanguageStyle_StyleSheet.NumericLiteralStyleClass; import jetbrains.mps.lang.editor.generator.internal.AbstractCellMenuPart_PropertyValues; import org.jetbrains.mps.openapi.language.SEnumerationLiteral; import jetbrains.mps.internal.collections.runtime.CollectionSequence; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SEnumOperations; import jetbrains.mps.kernel.model.SModelUtil; import jetbrains.mps.util.EqualUtil; import jetbrains.mps.openapi.editor.cells.CellActionType; import jetbrains.mps.editor.runtime.cells.EmptyCellAction; import jetbrains.mps.openapi.editor.style.StyleRegistry; import jetbrains.mps.nodeEditor.MPSColors; import jetbrains.mps.lang.structure.editor.structure_StyleSheet.KeywordStyleClass; /*package*/ class LinkDeclaration_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public LinkDeclaration_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_6h6dhy_a(); } private EditorCell createCollection_6h6dhy_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal()); editorCell.setCellId("Collection_6h6dhy_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createTransactionalProperty_6h6dhy_a0()); editorCell.addEditorCell(createConstant_6h6dhy_b0()); editorCell.addEditorCell(createCollection_6h6dhy_c0()); return editorCell; } private EditorCell createTransactionalProperty_6h6dhy_a0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("role"); EditorCell_Property editorCell = null; { ModelAccessor modelAccessor = new TransactionalPropertyAccessor(myNode, "role", false, false, getEditorContext()) { public void doCommit(final String oldValue, final String newValue) { doCommitImpl(oldValue, newValue); } public void doCommitImpl(final String oldValue, final String newValue) { if (!(Sequence.fromIterable(new ExtensionPoint<_FunctionTypes._return_P4_E0<? extends Boolean, ? super EditorContext, ? super SNode, ? super String, ? super String>>("jetbrains.mps.lang.structure.NodeRenamer").getObjects()).any(new IWhereFilter<_FunctionTypes._return_P4_E0<? extends Boolean, ? super EditorContext, ? super SNode, ? super String, ? super String>>() { public boolean accept(_FunctionTypes._return_P4_E0<? extends Boolean, ? super EditorContext, ? super SNode, ? super String, ? super String> it) { return it.invoke(getEditorContext(), myNode, oldValue, newValue); } }))) { getEditorContext().getRepository().getModelAccess().executeCommand(new ChangePropertyEditorCommand(getEditorContext(), "role_" + myNode.getNodeId().toString()) { protected void doExecute() { SPropertyOperations.set(myNode, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98052f333L, "role"), newValue); } }); } } }; editorCell = EditorCell_Property.create(getEditorContext(), modelAccessor, myNode); editorCell.setCellId("role"); Style style = new StyleImpl(); new FieldStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setDefaultText("<no role>"); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), provider.getCellContext(), new SubstituteInfoPartExt[]{new LinkDeclaration_EditorBuilder_a.LinkDeclaration_null_postfixCellMenu_6h6dhy_a0a0(), new SChildSubstituteInfoPartEx(editorCell)})); editorCell.setCommitInCommand(false); } 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 LinkDeclaration_null_postfixCellMenu_6h6dhy_a0a0 extends AbstractCellMenuPart_PropertyPostfixHints { public LinkDeclaration_null_postfixCellMenu_6h6dhy_a0a0() { } public List<String> getPostfixes(SNode node, IOperationContext operationContext, EditorContext editorContext) { List<String> postfixes = ListSequence.fromList(new ArrayList<String>()); if ((SLinkOperations.getTarget(node, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98055fef0L, "target")) != null)) { String name = NameUtil.decapitalize(SPropertyOperations.getString(SLinkOperations.getTarget(node, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98055fef0L, "target")), MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"))); ListSequence.fromList(postfixes).addSequence(ListSequence.fromList(NameUtil.splitByCamels(name))); } return postfixes; } } private EditorCell createConstant_6h6dhy_b0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ":"); editorCell.setCellId("Constant_6h6dhy_b0"); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_6h6dhy_c0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_6h6dhy_c0"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createRefCell_6h6dhy_a2a()); editorCell.addEditorCell(createConstant_6h6dhy_b2a()); if (nodeCondition_6h6dhy_a2c0()) { editorCell.addEditorCell(createProperty_6h6dhy_c2a()); } if (nodeCondition_6h6dhy_a3c0()) { editorCell.addEditorCell(createReadOnlyModelAccessor_6h6dhy_d2a()); } editorCell.addEditorCell(createConstant_6h6dhy_e2a()); if (nodeCondition_6h6dhy_a5c0()) { editorCell.addEditorCell(createCollection_6h6dhy_f2a()); } if (nodeCondition_6h6dhy_a6c0()) { editorCell.addEditorCell(createConstant_6h6dhy_g2a()); } if (nodeCondition_6h6dhy_a7c0()) { editorCell.addEditorCell(createCollection_6h6dhy_h2a()); } return editorCell; } private boolean nodeCondition_6h6dhy_a2c0() { return SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98051c244L, "specializedLink")) == null; } private boolean nodeCondition_6h6dhy_a3c0() { return SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98051c244L, "specializedLink")) != null; } private boolean nodeCondition_6h6dhy_a5c0() { return (SLinkOperations.getTarget(myNode, MetaAdapterFactory.getReferenceLink(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf98051c244L, "specializedLink")) != null); } private boolean nodeCondition_6h6dhy_a6c0() { return SPropertyOperations.getBoolean(myNode, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0x213ed46fe94fc232L, "unordered")); } private boolean nodeCondition_6h6dhy_a7c0() { return IdEditorHelper.shownInEditor(myNode); } private EditorCell createRefCell_6h6dhy_a2a() { CellProviderWithRole provider = new RefCellCellProvider(myNode, getEditorContext()) { @Override protected EditorCell createRefCell(EditorContext context, final SNode effectiveNode, SNode node) { EditorCell cell = getUpdateSession().updateReferencedNodeCell(new Computable<EditorCell>() { public EditorCell compute() { return new LinkDeclaration_EditorBuilder_a.Inline_Builder_6h6dhy_a0c0(getEditorContext(), myNode, effectiveNode).createCell(); } }, effectiveNode, "target"); CellUtil.setupIDeprecatableStyles(effectiveNode, cell); setSemanticNodeToCells(cell, myNode); installDeleteActions_atLeastOne(cell); return cell; } }; provider.setRole("target"); provider.setNoTargetText("<no target>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); if (editorCell.getRole() == null) { editorCell.setReferenceCell(true); editorCell.setRole("target"); } LinkDeclarationDeleteActions.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; } /*package*/ static class Inline_Builder_6h6dhy_a0c0 extends AbstractEditorBuilder { @NotNull private SNode myNode; private SNode myReferencingNode; /*package*/ Inline_Builder_6h6dhy_a0c0(@NotNull EditorContext context, SNode referencingNode, @NotNull SNode node) { super(context); myReferencingNode = referencingNode; myNode = node; } /*package*/ EditorCell createCell() { return createProperty_6h6dhy_a0a2a(); } @NotNull @Override public SNode getNode() { return myNode; } private EditorCell createProperty_6h6dhy_a0a2a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("name"); provider.setNoTargetText("<no name>"); provider.setReadOnly(true); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_name"); Style style = new StyleImpl(); new ConceptNameStyleClass(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_6h6dhy_b2a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "["); editorCell.setCellId("Constant_6h6dhy_b2a"); Style style = new StyleImpl(); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.PUNCTUATION_RIGHT, true); style.set(StyleAttributes.MATCHING_LABEL, "card"); style.set(StyleAttributes.FONT_STYLE, MPSFonts.PLAIN); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_6h6dhy_c2a() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("sourceCardinality"); provider.setNoTargetText("<no sourceCardinality>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_sourceCardinality"); Style style = new StyleImpl(); new NumericLiteralStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setSubstituteInfo(new CompositeSubstituteInfo(getEditorContext(), provider.getCellContext(), new SubstituteInfoPartExt[]{new LinkDeclaration_EditorBuilder_a.LinkDeclaration_sourceCardinality_cellMenu_6h6dhy_a0c2a(), 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 LinkDeclaration_sourceCardinality_cellMenu_6h6dhy_a0c2a extends AbstractCellMenuPart_PropertyValues { public LinkDeclaration_sourceCardinality_cellMenu_6h6dhy_a0c2a() { } public List<String> getPropertyValues(SNode node, IOperationContext operationContext, EditorContext editorContext) { List<String> result = ListSequence.fromList(new ArrayList<String>()); if (SPropertyOperations.hasValue(node, MetaAdapterFactory.getProperty(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, 0xf979bd086aL, 0xf980556927L, "metaClass"), "aggregation", "reference")) { for (SEnumerationLiteral member : CollectionSequence.fromCollection(SEnumOperations.getMembers(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure", 0xfc6f3944c2L, "Cardinality"))) { ListSequence.fromList(result).addElement(SEnumOperations.getMemberValue(member)); } } else { ListSequence.fromList(result).addElement(SEnumOperations.getMemberValue(SEnumOperations.getMember(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure", 0xfc6f3944c2L, "Cardinality", 0xfc6f3944c3L, "0..1"))); ListSequence.fromList(result).addElement(SEnumOperations.getMemberValue(SEnumOperations.getMember(0xc72da2b97cce4447L, 0x8389f407dc1158b7L, "jetbrains.mps.lang.structure", 0xfc6f3944c2L, "Cardinality", 0xfc6f3944c4L, "1"))); } return result; } } private EditorCell createReadOnlyModelAccessor_6h6dhy_d2a() { EditorCell_Property editorCell = EditorCell_Property.create(getEditorContext(), new ModelAccessor() { public String getText() { return SEnumOperations.getMemberName(SModelUtil.getGenuineLinkSourceCardinality(myNode)); } 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_6h6dhy_d2a"); Style style = new StyleImpl(); style.set(StyleAttributes.TEXT_BACKGROUND_COLOR, StyleRegistry.getInstance().getSimpleColor(MPSColors.lightGray)); style.set(StyleAttributes.EDITABLE, false); editorCell.getStyle().putAll(style); return editorCell; } private EditorCell createConstant_6h6dhy_e2a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "]"); editorCell.setCellId("Constant_6h6dhy_e2a"); Style style = new StyleImpl(); style.set(StyleAttributes.PUNCTUATION_LEFT, true); style.set(StyleAttributes.MATCHING_LABEL, "card"); style.set(StyleAttributes.FONT_STYLE, MPSFonts.PLAIN); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_6h6dhy_f2a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_6h6dhy_f2a"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createConstant_6h6dhy_a5c0()); editorCell.addEditorCell(createRefCell_6h6dhy_b5c0()); return editorCell; } private EditorCell createConstant_6h6dhy_a5c0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "specializes:"); editorCell.setCellId("Constant_6h6dhy_a5c0"); Style style = new StyleImpl(); new KeywordStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createRefCell_6h6dhy_b5c0() { CellProviderWithRole provider = new RefCellCellProvider(myNode, getEditorContext()) { @Override protected EditorCell createRefCell(EditorContext context, final SNode effectiveNode, SNode node) { EditorCell cell = getUpdateSession().updateReferencedNodeCell(new Computable<EditorCell>() { public EditorCell compute() { return new LinkDeclaration_EditorBuilder_a.Inline_Builder_6h6dhy_a1f2a(getEditorContext(), myNode, effectiveNode).createCell(); } }, effectiveNode, "specializedLink"); CellUtil.setupIDeprecatableStyles(effectiveNode, cell); setSemanticNodeToCells(cell, myNode); installDeleteActions_nullable_reference(cell); return cell; } }; provider.setRole("specializedLink"); provider.setNoTargetText("<none>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); if (editorCell.getRole() == null) { editorCell.setReferenceCell(true); editorCell.setRole("specializedLink"); } 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; } /*package*/ static class Inline_Builder_6h6dhy_a1f2a extends AbstractEditorBuilder { @NotNull private SNode myNode; private SNode myReferencingNode; /*package*/ Inline_Builder_6h6dhy_a1f2a(@NotNull EditorContext context, SNode referencingNode, @NotNull SNode node) { super(context); myReferencingNode = referencingNode; myNode = node; } /*package*/ EditorCell createCell() { return createProperty_6h6dhy_a0b5c0(); } @NotNull @Override public SNode getNode() { return myNode; } private EditorCell createProperty_6h6dhy_a0b5c0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("role"); provider.setNoTargetText("<no role>"); provider.setReadOnly(true); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_role"); 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_6h6dhy_g2a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "unordered"); editorCell.setCellId("Constant_6h6dhy_g2a"); Style style = new StyleImpl(); new KeywordStyleClass(getEditorContext(), getNode()).apply(style, editorCell); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createCollection_6h6dhy_h2a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal()); editorCell.setCellId("Collection_6h6dhy_h2a"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createConstant_6h6dhy_a7c0()); editorCell.addEditorCell(createProperty_6h6dhy_b7c0()); return editorCell; } private EditorCell createConstant_6h6dhy_a7c0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "ID: "); editorCell.setCellId("Constant_6h6dhy_a7c0"); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_6h6dhy_b7c0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("linkId"); provider.setNoTargetText("<no id>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_linkId"); 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; } }