package jetbrains.mps.lang.resources.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.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.nodeEditor.cells.EditorCell_Constant; import jetbrains.mps.openapi.editor.style.Style; import jetbrains.mps.editor.runtime.style.StyleImpl; import jetbrains.mps.editor.runtime.style.StyleAttributes; import jetbrains.mps.openapi.editor.style.StyleRegistry; import jetbrains.mps.nodeEditor.MPSColors; import jetbrains.mps.lang.resources.behavior.FileIcon__BehaviorDescriptor; import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Horizontal; import org.jetbrains.mps.openapi.module.SModule; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import jetbrains.mps.util.MacrosFactory; import jetbrains.mps.project.AbstractModule; import jetbrains.mps.nodeEditor.cells.EditorCell_Image; import jetbrains.mps.nodeEditor.cells.EditorCell_Component; import javax.swing.JComponent; import jetbrains.mps.editor.runtime.EditorUtil; import jetbrains.mps.lang.editor.cellProviders.SingleRoleCellProvider; 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.SChildSubstituteInfo; import jetbrains.mps.openapi.editor.menus.transformation.SNodeLocation; import jetbrains.mps.editor.runtime.EditorCell_Empty; import jetbrains.mps.nodeEditor.cellActions.CellAction_DeleteNode; /*package*/ class FileIcon_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public FileIcon_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_tl1n57_a(); } private EditorCell createCollection_tl1n57_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_tl1n57_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createCollection_tl1n57_a0()); if (nodeCondition_tl1n57_a1a()) { editorCell.addEditorCell(createAlternation_tl1n57_b0()); } return editorCell; } private boolean nodeCondition_tl1n57_a1a() { return (SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression")) != null); } private EditorCell createCollection_tl1n57_a0() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCellId("Collection_tl1n57_a0"); editorCell.addEditorCell(createAlternation_tl1n57_a0a()); editorCell.addEditorCell(createJComponent_tl1n57_b0a()); return editorCell; } private EditorCell createAlternation_tl1n57_a0a() { boolean alternationCondition = true; alternationCondition = nodeCondition_tl1n57_a0a0(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createConstant_tl1n57_a0a0(); } else { editorCell = createAlternation_tl1n57_a0a0(); } return editorCell; } private boolean nodeCondition_tl1n57_a0a0() { return isEmptyString(SPropertyOperations.getString(myNode, MetaAdapterFactory.getProperty(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x26417c377428f6b3L, "file"))); } private EditorCell createConstant_tl1n57_a0a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "<no icon>"); editorCell.setCellId("Constant_tl1n57_a0a0"); Style style = new StyleImpl(); style.set(StyleAttributes.TEXT_COLOR, StyleRegistry.getInstance().getSimpleColor(MPSColors.lightGray)); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createAlternation_tl1n57_a0a0() { boolean alternationCondition = true; alternationCondition = nodeCondition_tl1n57_a0a0a(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createCollection_tl1n57_a0a0a(); } else { editorCell = createConstant_tl1n57_a0a0a(); } return editorCell; } private boolean nodeCondition_tl1n57_a0a0a() { return (boolean) FileIcon__BehaviorDescriptor.isValid_id7Mb2akaestJ.invoke(myNode); } private EditorCell createCollection_tl1n57_a0a0a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Horizontal()); editorCell.setCellId("Collection_tl1n57_a0a0a"); Style style = new StyleImpl(); style.set(StyleAttributes.SELECTABLE, false); editorCell.getStyle().putAll(style); editorCell.addEditorCell(createImage_tl1n57_a0a0a0()); return editorCell; } private EditorCell createImage_tl1n57_a0a0a0() { SModule imageModule; String imagePath; imageModule = SNodeOperations.getModel(myNode).getModule(); imagePath = (new _FunctionTypes._return_P0_E0<String>() { public String invoke() { return MacrosFactory.forModule(((AbstractModule) SNodeOperations.getModel(myNode).getModule())).expandPath(SPropertyOperations.getString(myNode, MetaAdapterFactory.getProperty(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x26417c377428f6b3L, "file"))); } }).invoke(); EditorCell_Image editorCell = EditorCell_Image.createImageCell(getEditorContext(), myNode, imageModule, imagePath); editorCell.setCellId("Image_tl1n57_a0a0a0"); editorCell.setDescent(0); return editorCell; } private EditorCell createConstant_tl1n57_a0a0a() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "<invalid path>"); editorCell.setCellId("Constant_tl1n57_a0a0a"); Style style = new StyleImpl(); style.set(StyleAttributes.TEXT_COLOR, StyleRegistry.getInstance().getSimpleColor(MPSColors.red)); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createJComponent_tl1n57_b0a() { EditorCell editorCell = EditorCell_Component.createComponentCell(getEditorContext(), myNode, _QueryFunction_JComponent_tl1n57_a1a0(), "_tl1n57_b0a"); editorCell.setCellId("JComponent_tl1n57_b0a"); return editorCell; } private JComponent _QueryFunction_JComponent_tl1n57_a1a0() { return EditorUtil.createSelectIconButton(myNode, MetaAdapterFactory.getProperty(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x26417c377428f6b3L, "file"), getEditorContext(), false); } private EditorCell createAlternation_tl1n57_b0() { boolean alternationCondition = true; alternationCondition = nodeCondition_tl1n57_a1a_0(); EditorCell editorCell = null; if (alternationCondition) { editorCell = createRefNode_tl1n57_a1a(); } else { editorCell = createEmpty_tl1n57_a1a(); } return editorCell; } private boolean nodeCondition_tl1n57_a1a_0() { return (SLinkOperations.getTarget(myNode, MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression")) != null); } private EditorCell createRefNode_tl1n57_a1a() { SingleRoleCellProvider provider = new FileIcon_EditorBuilder_a.iconExpressionSingleRoleHandler_tl1n57_a1a(myNode, MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression"), getEditorContext()); return provider.createCell(); } private static class iconExpressionSingleRoleHandler_tl1n57_a1a extends SingleRoleCellProvider { @NotNull private SNode myNode; public iconExpressionSingleRoleHandler_tl1n57_a1a(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(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression"), child)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteSmart(getNode(), MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression"), child)); installCellInfo(child, editorCell); return editorCell; } private void installCellInfo(SNode child, EditorCell editorCell) { if (editorCell.getSubstituteInfo() == null || editorCell.getSubstituteInfo() instanceof DefaultSubstituteInfo) { editorCell.setSubstituteInfo(new SChildSubstituteInfo(editorCell, myNode, MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression"), child)); } if (editorCell.getRole() == null) { editorCell.setRole("iconExpression"); } } @Override protected EditorCell createEmptyCell() { getCellFactory().pushCellContext(); getCellFactory().setNodeLocation(new SNodeLocation.FromParentAndLink(getNode(), MetaAdapterFactory.getContainmentLink(0x982eb8df2c964bd7L, 0x996311712ea622e5L, 0x7c8b08a50a39c6bbL, 0x60d1cf8c81faea09L, "iconExpression"))); try { EditorCell editorCell = super.createEmptyCell(); editorCell.setCellId("empty_iconExpression"); installCellInfo(null, editorCell); setCellContext(editorCell); return editorCell; } finally { getCellFactory().popCellContext(); } } protected String getNoTargetText() { return "<no iconExpression>"; } } private EditorCell createEmpty_tl1n57_a1a() { EditorCell_Empty editorCell = new EditorCell_Empty(getEditorContext(), myNode); editorCell.setAction(CellActionType.DELETE, new CellAction_DeleteNode(editorCell.getSNode(), CellAction_DeleteNode.DeleteDirection.FORWARD)); editorCell.setAction(CellActionType.BACKSPACE, new CellAction_DeleteNode(editorCell.getSNode(), CellAction_DeleteNode.DeleteDirection.BACKWARD)); editorCell.setCellId("Empty_tl1n57_a1a"); return editorCell; } private static boolean isEmptyString(String str) { return str == null || str.length() == 0; } }