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.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.lang.generator.generationContext.editor.Styles_StyleSheet.deprecatedStyleClass;
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.cellProviders.CellProviderWithRole;
import jetbrains.mps.lang.editor.cellProviders.RefCellCellProvider;
import jetbrains.mps.util.Computable;
import jetbrains.mps.editor.runtime.impl.CellUtil;
import jetbrains.mps.nodeEditor.EditorManager;
import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider;
import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.mappingLabelReferenceStyleClass;
import jetbrains.mps.openapi.editor.update.AttributeKind;
import jetbrains.mps.lang.generator.editor.Styles_StyleSheet.nodeUnderMacroStyleClass;
/*package*/ class ExportMacro_EditorBuilder_a extends AbstractEditorBuilder {
@NotNull
private SNode myNode;
public ExportMacro_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) {
super(context);
myNode = node;
}
@NotNull
@Override
public SNode getNode() {
return myNode;
}
/*package*/ EditorCell createCell() {
return createCollection_gzv99m_a();
}
private EditorCell createCollection_gzv99m_a() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal());
editorCell.setCellId("Collection_gzv99m_a");
editorCell.setBig(true);
editorCell.setCellContext(getCellFactory().getCellContext());
editorCell.addEditorCell(createConstant_gzv99m_a0());
editorCell.addEditorCell(createRefCell_gzv99m_b0());
editorCell.addEditorCell(createAttributedNodeCell_gzv99m_c0());
return editorCell;
}
private EditorCell createConstant_gzv99m_a0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "$EXPORT$");
editorCell.setCellId("Constant_gzv99m_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);
new deprecatedStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
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 ExportMacro_EditorBuilder_a.ExportMacro_component_cellMenu_gzv99m_a0a0(), new SChildSubstituteInfoPartEx(editorCell)}));
return editorCell;
}
public static class ExportMacro_component_cellMenu_gzv99m_a0a0 implements SubstituteInfoPartExt {
private replace_node_macro myComponent;
public ExportMacro_component_cellMenu_gzv99m_a0a0() {
this.myComponent = new replace_node_macro();
}
public List<SubstituteAction> createActions(CellContext cellContext, EditorContext editorContext) {
return this.myComponent.createSubstituteActions(cellContext, editorContext);
}
}
private EditorCell createRefCell_gzv99m_b0() {
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 ExportMacro_EditorBuilder_a.Inline_Builder_gzv99m_a1a(getEditorContext(), myNode, effectiveNode).createCell();
}
}, effectiveNode, "label");
CellUtil.setupIDeprecatableStyles(effectiveNode, cell);
setSemanticNodeToCells(cell, myNode);
installDeleteActions_atLeastOne(cell);
return cell;
}
};
provider.setRole("label");
provider.setNoTargetText("<no label>");
EditorCell editorCell;
editorCell = provider.createEditorCell(getEditorContext());
if (editorCell.getRole() == null) {
editorCell.setReferenceCell(true);
editorCell.setRole("label");
}
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_gzv99m_a1a extends AbstractEditorBuilder {
@NotNull
private SNode myNode;
private SNode myReferencingNode;
/*package*/ Inline_Builder_gzv99m_a1a(@NotNull EditorContext context, SNode referencingNode, @NotNull SNode node) {
super(context);
myReferencingNode = referencingNode;
myNode = node;
}
/*package*/ EditorCell createCell() {
return createProperty_gzv99m_a0b0();
}
@NotNull
@Override
public SNode getNode() {
return myNode;
}
private EditorCell createProperty_gzv99m_a0b0() {
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 mappingLabelReferenceStyleClass(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 createAttributedNodeCell_gzv99m_c0() {
EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext());
EditorCell editorCell = getUpdateSession().getAttributedCell(AttributeKind.NODE, myNode);
Style style = new StyleImpl();
new nodeUnderMacroStyleClass(getEditorContext(), getNode()).apply(style, editorCell);
editorCell.getStyle().putAll(style);
return editorCell;
}
}