package jetbrains.mps.lang.core.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.nodeEditor.cells.EditorCell_Property;
import jetbrains.mps.nodeEditor.cells.ModelAccessor;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations;
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.Style;
import jetbrains.mps.editor.runtime.style.StyleImpl;
import jetbrains.mps.editor.runtime.style.StyleAttributes;
import jetbrains.mps.nodeEditor.cells.EditorCell_Constant;
import jetbrains.mps.nodeEditor.MPSFonts;
import jetbrains.mps.nodeEditor.EditorManager;
import jetbrains.mps.openapi.editor.update.AttributeKind;
/*package*/ class Attribute_EditorBuilder_a extends AbstractEditorBuilder {
@NotNull
private SNode myNode;
public Attribute_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) {
super(context);
myNode = node;
}
@NotNull
@Override
public SNode getNode() {
return myNode;
}
/*package*/ EditorCell createCell() {
return createCollection_mc4j88_a();
}
private EditorCell createCollection_mc4j88_a() {
EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent());
editorCell.setCellId("Collection_mc4j88_a");
editorCell.setBig(true);
editorCell.setCellContext(getCellFactory().getCellContext());
editorCell.addEditorCell(createReadOnlyModelAccessor_mc4j88_a0());
editorCell.addEditorCell(createConstant_mc4j88_b0());
editorCell.addEditorCell(createAttributedNodeCell_mc4j88_c0());
editorCell.addEditorCell(createConstant_mc4j88_d0());
return editorCell;
}
private EditorCell createReadOnlyModelAccessor_mc4j88_a0() {
EditorCell_Property editorCell = EditorCell_Property.create(getEditorContext(), new ModelAccessor() {
public String getText() {
return SNodeOperations.getConcept(myNode).getName();
}
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_mc4j88_a0");
Style style = new StyleImpl();
style.set(StyleAttributes.EDITABLE, false);
editorCell.getStyle().putAll(style);
return editorCell;
}
private EditorCell createConstant_mc4j88_b0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "{");
editorCell.setCellId("Constant_mc4j88_b0");
Style style = new StyleImpl();
style.set(StyleAttributes.PUNCTUATION_LEFT, true);
style.set(StyleAttributes.MATCHING_LABEL, "attribute_brace");
style.set(StyleAttributes.FONT_STYLE, MPSFonts.PLAIN);
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
private EditorCell createAttributedNodeCell_mc4j88_c0() {
EditorManager manager = EditorManager.getInstanceFromContext(getEditorContext());
EditorCell editorCell = getUpdateSession().getAttributedCell(AttributeKind.NODE, myNode);
return editorCell;
}
private EditorCell createConstant_mc4j88_d0() {
EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "}");
editorCell.setCellId("Constant_mc4j88_d0");
Style style = new StyleImpl();
style.set(StyleAttributes.MATCHING_LABEL, "attribute_brace");
style.set(StyleAttributes.FONT_STYLE, MPSFonts.PLAIN);
editorCell.getStyle().putAll(style);
editorCell.setDefaultText("");
return editorCell;
}
}