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.SPropertyOperations;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
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.nodeEditor.cellProviders.CellProviderWithRole;
import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider;
import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.macroDescriptionTextStyleClass;
import jetbrains.mps.nodeEditor.EditorManager;
import jetbrains.mps.openapi.editor.update.AttributeKind;
import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.nodeUnderMacroStyleClass;
/*package*/ class PropertyMacro_EditorBuilder_a extends AbstractEditorBuilder {
@NotNull
private SNode myNode;
public PropertyMacro_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) {
super(context);
myNode = node;
}
@NotNull
@Override
public SNode getNode() {
return myNode;
}
/*package*/ EditorCell createCell() {
return createCollection_y5igai_a();
}
private EditorCell createCollection_y5igai_a() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal());
editorCell.setCellId("Collection_y5igai_a");
editorCell.setBig(true);
editorCell.setCellContext(getCellFactory().getCellContext());
editorCell.addEditorCell(createConstant_y5igai_a0());
if (nodeCondition_y5igai_a1a()) {
editorCell.addEditorCell(createProperty_y5igai_b0());
}
editorCell.addEditorCell(createAttributedPropertyCell_y5igai_c0());
return editorCell;
}
private boolean nodeCondition_y5igai_a1a() {
return SPropertyOperations.getString(myNode, MetaAdapterFactory.getProperty(0xb401a68083254110L, 0x8fd384331ff25befL, 0x11dc0f7933bL, 0x2d521c90e9601e88L, "comment")) != null;
}
private EditorCell createConstant_y5igai_a0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "$");
editorCell.setCellId("Constant_y5igai_a0");
Style style = new StyleImpl();
new macroStartStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
style.set(StyleAttributes.EDITABLE, false);
style.set(StyleAttributes.LAST_POSITION_ALLOWED, true);
editorCell.getStyle().putAll(style);
PropertyMacroActions.setCellActions(editorCell, myNode, getEditorContext());
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createProperty_y5igai_b0() {
CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext());
provider.setRole("comment");
provider.setNoTargetText("<no comment>");
provider.setAllowsEmptyTarget(true);
EditorCell editorCell;
editorCell = provider.createEditorCell(getEditorContext());
editorCell.setCellId("property_comment");
Style style = new StyleImpl();
new macroDescriptionTextStyleClass(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 createAttributedPropertyCell_y5igai_c0() {
EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext());
EditorCell editorCell = getUpdateSession().getAttributedCell(AttributeKind.PROPERTY, myNode);
Style style = new StyleImpl();
new nodeUnderMacroStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
return editorCell;
}
}