package jetbrains.mps.samples.mindmaps.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_Constant; import jetbrains.mps.nodeEditor.cellProviders.CellProviderWithRole; import jetbrains.mps.lang.editor.cellProviders.PropertyCellProvider; 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.EditorManager; import jetbrains.mps.nodeEditor.cells.jetpad.DiagramCell; import jetbrains.mps.nodeEditor.cellMenu.CompositeSubstituteInfo; import jetbrains.mps.nodeEditor.cellMenu.BasicCellContext; import jetbrains.mps.nodeEditor.cellMenu.SubstituteInfoPartExt; import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory; import jetbrains.mps.baseLanguage.closures.runtime._FunctionTypes; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SNodeOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SPropertyOperations; import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations; import jetbrains.jetpad.mapper.Mapper; import jetbrains.jetpad.projectional.diagram.view.DiagramView; import jetbrains.jetpad.mapper.Synchronizers; import jetbrains.jetpad.mapper.MapperFactory; import jetbrains.jetpad.projectional.view.View; import jetbrains.mps.nodeEditor.cells.jetpad.BlockCell; import jetbrains.jetpad.projectional.diagram.view.Connection; import jetbrains.mps.nodeEditor.cells.jetpad.ConnectorCell; import jetbrains.jetpad.model.property.WritableProperty; import jetbrains.jetpad.projectional.view.ViewContainer; import jetbrains.mps.lang.editor.diagram.runtime.jetpad.views.DiagramDecoratorView; import java.util.Set; import java.util.HashSet; import java.util.ListIterator; import jetbrains.jetpad.projectional.diagram.view.ConnectionRoutingView; import jetbrains.jetpad.projectional.diagram.layout.OrthogonalRouter; import jetbrains.mps.lang.editor.diagram.runtime.jetpad.palette.ui.DiagramPalette; import jetbrains.mps.lang.editor.diagram.runtime.jetpad.palette.impl.PaletteElementsCreationActionGroup; import jetbrains.mps.lang.editor.diagram.runtime.jetpad.palette.impl.DiagramTraitButton; /*package*/ class MindMap_diagram_EditorBuilder_a extends AbstractEditorBuilder { @NotNull private SNode myNode; public MindMap_diagram_EditorBuilder_a(@NotNull EditorContext context, @NotNull SNode node) { super(context); myNode = node; } @NotNull @Override public SNode getNode() { return myNode; } /*package*/ EditorCell createCell() { return createCollection_e8klwn_a(); } private EditorCell createCollection_e8klwn_a() { EditorCell_Collection editorCell = new EditorCell_Collection(getEditorContext(), myNode, new CellLayout_Indent()); editorCell.setCanBeSynchronized(true); editorCell.setCellId("Collection_e8klwn_a"); editorCell.setBig(true); editorCell.setCellContext(getCellFactory().getCellContext()); editorCell.addEditorCell(createConstant_e8klwn_a0()); editorCell.addEditorCell(createProperty_e8klwn_b0()); editorCell.addEditorCell(createConstant_e8klwn_c0()); editorCell.addEditorCell(createDiagram_e8klwn_d0()); return editorCell; } private EditorCell createConstant_e8klwn_a0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, "Mind map"); editorCell.setCellId("Constant_e8klwn_a0"); editorCell.setDefaultText(""); return editorCell; } private EditorCell createProperty_e8klwn_b0() { CellProviderWithRole provider = new PropertyCellProvider(myNode, getEditorContext()); provider.setRole("name"); provider.setNoTargetText("<no name>"); EditorCell editorCell; editorCell = provider.createEditorCell(getEditorContext()); editorCell.setCellId("property_name"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); 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_e8klwn_c0() { EditorCell_Constant editorCell = new EditorCell_Constant(getEditorContext(), myNode, ""); editorCell.setCellId("Constant_e8klwn_c0"); Style style = new StyleImpl(); style.set(StyleAttributes.INDENT_LAYOUT_NEW_LINE, true); editorCell.getStyle().putAll(style); editorCell.setDefaultText(""); return editorCell; } private EditorCell createDiagram_e8klwn_d0() { DiagramCell editorCell = new MindMap_diagram_EditorBuilder_a.DiagramCellImpl_e8klwn_d0(getEditorContext(), myNode); editorCell.setCellId("Diagram_e8klwn_d0"); return editorCell; } private class DiagramCellImpl_e8klwn_d0 extends DiagramCell { private DiagramCellImpl_e8klwn_d0(EditorContext editorContext, SNode node) { super(editorContext, node); setSubstituteInfo(new CompositeSubstituteInfo(editorContext, new BasicCellContext(node), new SubstituteInfoPartExt[]{createNewDiagramNodeActions(getSNode(), MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought"), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5d6L, "thoughts"), new _FunctionTypes._void_P3_E0<SNode, Integer, Integer>() { public void invoke(SNode node, Integer x, Integer y) { SNode thought = SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")); SPropertyOperations.set(thought, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "new thought"); } }), createNewDiagramConnectorActions(getSNode(), MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship"), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5dbL, "relationships"), new _FunctionTypes._return_P4_E0<Boolean, SNode, Object, SNode, Object>() { public Boolean invoke(SNode from, Object fromId, SNode to, Object toId) { return SNodeOperations.isInstanceOf(from, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")) && SNodeOperations.isInstanceOf(to, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")) && neq_5yst3b_a0a0a0a0d1a2a0a1a0n(from, to); } }, new _FunctionTypes._void_P5_E0<SNode, SNode, Object, SNode, Object>() { public void invoke(SNode node, SNode from, Object fromId, SNode to, Object toId) { SLinkOperations.setTarget(SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship")), MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x517b79625769ba9eL, "source"), from); SLinkOperations.setTarget(SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship")), MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x1198689ff14c5dfL, "target"), to); } })})); setPalette(new MindMap_diagram_EditorBuilder_a.DiagramCellImpl_e8klwn_d0.DiagramPaletteImpl_e8klwn_a3a(this)); synchronize(); } protected SubstituteInfoPartExt[] createPaletteBlockSubstituteInfoPartExts() { return new SubstituteInfoPartExt[]{createNewDiagramNodeActions(getSNode(), MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought"), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5d6L, "thoughts"), new _FunctionTypes._void_P3_E0<SNode, Integer, Integer>() { public void invoke(SNode node, Integer x, Integer y) { SNode thought = SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")); SPropertyOperations.set(thought, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "new thought"); } })}; } protected SubstituteInfoPartExt[] createPaletteConnectorSubstituteInfoPartExts() { return new SubstituteInfoPartExt[]{createNewDiagramConnectorActions(getSNode(), MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship"), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5dbL, "relationships"), new _FunctionTypes._return_P4_E0<Boolean, SNode, Object, SNode, Object>() { public Boolean invoke(SNode from, Object fromId, SNode to, Object toId) { return SNodeOperations.isInstanceOf(from, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")) && SNodeOperations.isInstanceOf(to, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")) && neq_5yst3b_a0a0a0a0d0a0a0d31(from, to); } }, new _FunctionTypes._void_P5_E0<SNode, SNode, Object, SNode, Object>() { public void invoke(SNode node, SNode from, Object fromId, SNode to, Object toId) { SLinkOperations.setTarget(SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship")), MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x517b79625769ba9eL, "source"), from); SLinkOperations.setTarget(SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, "jetbrains.mps.samples.mindmaps.structure.Relationship")), MetaAdapterFactory.getReferenceLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bad3L, 0x1198689ff14c5dfL, "target"), to); } })}; } public Mapper<SNode, DiagramView> createMapper(SNode node) { return new Mapper<SNode, DiagramView>(node, createDiagramView()) { @Override protected void registerSynchronizers(Mapper.SynchronizersConfiguration configuration) { super.registerSynchronizers(configuration); configuration.add(Synchronizers.forObservableRole(this, myBlocks, getTarget().itemsView.children(), new MapperFactory<SNode, View>() { public Mapper<? extends SNode, ? extends View> createMapper(SNode node) { return ((BlockCell) getDirectChildCell(node)).createMapper(); } })); configuration.add(Synchronizers.forObservableRole(this, myConnectors, getTarget().connections, new MapperFactory<SNode, Connection>() { public Mapper<? extends SNode, ? extends Connection> createMapper(SNode node) { return ((ConnectorCell) getDirectChildCell(node)).createMapper(); } })); configuration.add(Synchronizers.forProperty(myIsShowingDragFeedBack, new WritableProperty<Boolean>() { public void set(Boolean showDragFeedBack) { if (showDragFeedBack) { getTarget().connections.add(myDragConnection); } else { getTarget().connections.remove(myDragConnection); } } })); configuration.add(Synchronizers.forProperty(mySelectedItem, new WritableProperty<Boolean>() { public void set(Boolean isSelected) { ViewContainer viewContainer = getTarget().container(); if (viewContainer != null) { if (isSelected && !(viewContainer.root().focused().get())) { viewContainer.focusedView().set(viewContainer.root()); } else if (!(isSelected) && viewContainer.root().focused().get()) { viewContainer.focusedView().set(null); } } } })); } }; } public Mapper<SNode, DiagramDecoratorView> createDecorationMapper(SNode node) { return new Mapper<SNode, DiagramDecoratorView>(getSNode(), new DiagramDecoratorView()) { @Override protected void registerSynchronizers(Mapper.SynchronizersConfiguration configuration) { super.registerSynchronizers(configuration); configuration.add(Synchronizers.forObservableRole(this, myBlocks, getTarget().itemsDecotatorView.children(), new MapperFactory<SNode, View>() { public Mapper<? extends SNode, ? extends View> createMapper(SNode node) { return ((BlockCell) getDirectChildCell(node)).createDecorationMapper(); } })); configuration.add(Synchronizers.forObservableRole(this, myConnectors, getTarget().connectorsDecotatorView.children(), new MapperFactory<SNode, View>() { public Mapper<? extends SNode, ? extends View> createMapper(SNode node) { return ((ConnectorCell) getDirectChildCell(node)).createDecorationMapper(); } })); } }; } public void synchronize() { Set<SNode> existingBlocks = new HashSet<SNode>(myBlocks); ListIterator<SNode> blocksIterator = myBlocks.listIterator(); Set<SNode> existingConnectors = new HashSet<SNode>(myConnectors); ListIterator<SNode> connectorsIterator = myConnectors.listIterator(); syncDiagramElements(SLinkOperations.getChildren(getSNode(), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5d6L, "thoughts")), blocksIterator, existingBlocks, connectorsIterator, existingConnectors); syncDiagramElements(SLinkOperations.getChildren(getSNode(), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5dbL, "relationships")), blocksIterator, existingBlocks, connectorsIterator, existingConnectors); purgeTailNodes(blocksIterator); purgeTailNodes(connectorsIterator); } private DiagramView createDiagramView() { ConnectionRoutingView diagramView = new ConnectionRoutingView(new OrthogonalRouter()); return diagramView; } private class DiagramPaletteImpl_e8klwn_a3a extends DiagramPalette { private DiagramPaletteImpl_e8klwn_a3a(DiagramCell diagramCell) { super(diagramCell); addPaletteElement(new PaletteElementsCreationActionGroup(diagramCell, getSNode(), MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought"), MetaAdapterFactory.getContainmentLink(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14758fL, 0x1198689ff14c5d6L, "thoughts"), new _FunctionTypes._void_P3_E0<SNode, Integer, Integer>() { public void invoke(SNode node, Integer x, Integer y) { SNode thought = SNodeOperations.cast(node, MetaAdapterFactory.getConcept(0x33f294fd370a4a40L, 0x999b43f382910018L, 0x1198689ff14bac8L, "jetbrains.mps.samples.mindmaps.structure.Thought")); SPropertyOperations.set(thought, MetaAdapterFactory.getProperty(0xceab519525ea4f22L, 0x9b92103b95ca8c0cL, 0x110396eaaa4L, 0x110396ec041L, "name"), "new thought"); } }) { @Override public String getText() { return "Thought"; } }); addPaletteElement(new DiagramTraitButton(diagramCell)); createPalette(); } } } private static boolean neq_5yst3b_a0a0a0a0d1a2a0a1a0n(Object a, Object b) { return !(((a != null ? a.equals(b) : a == b))); } private static boolean neq_5yst3b_a0a0a0a0d0a0a0d31(Object a, Object b) { return !(((a != null ? a.equals(b) : a == b))); } }