public <T extends Object> XConnection createConnection( final T connectionObject, final ConnectionMapping<T> connectionMapping, final Procedure1<? super XConnection> initializer, final InterpreterContext context) { boolean _isApplicable = connectionMapping.isApplicable(connectionObject); if (_isApplicable) { final ConnectionMapping<T> connectionMappingCasted = ((ConnectionMapping<T>) connectionMapping); final IMappedElementDescriptor<T> descriptor = this.<T>getDescriptor(connectionObject, connectionMappingCasted); boolean _equals = Objects.equal(descriptor, null); if (_equals) { return null; } final XConnection existingConnection = context.getConnection(descriptor); boolean _or = false; boolean _notEquals = (!Objects.equal(existingConnection, null)); if (_notEquals) { _or = true; } else { boolean _isCreateConnections = context.isCreateConnections(); boolean _not = (!_isCreateConnections); _or = _not; } if (_or) { return existingConnection; } final XConnection connection = connectionMappingCasted.createConnection(descriptor); XDiagramConfig _config = connectionMappingCasted.getConfig(); _config.initialize(connection); List<AbstractLabelMappingCall<?, T>> _labels = connectionMapping.getLabels(); final Consumer<AbstractLabelMappingCall<?, T>> _function = (AbstractLabelMappingCall<?, T> it) -> { ObservableList<XConnectionLabel> _labels_1 = connection.getLabels(); Iterable<? extends XLabel> _execute = this.execute(it, connectionObject); Iterable<XConnectionLabel> _filter = Iterables.<XConnectionLabel>filter(_execute, XConnectionLabel.class); Iterables.<XConnectionLabel>addAll(_labels_1, _filter); }; _labels.forEach(_function); initializer.apply(connection); this.<T>createEndpoints(connectionMapping, connectionObject, connection, context); boolean _and = false; XNode _source = connection.getSource(); boolean _notEquals_1 = (!Objects.equal(_source, null)); if (!_notEquals_1) { _and = false; } else { XNode _target = connection.getTarget(); boolean _notEquals_2 = (!Objects.equal(_target, null)); _and = _notEquals_2; } if (_and) { context.addConnection(connection); return connection; } } return null; }
protected <T extends Object> void populateDiagram( final DiagramMapping<T> diagramMapping, final T diagramObject, final InterpreterContext context) { List<AbstractNodeMappingCall<?, T>> _nodes = diagramMapping.getNodes(); final Consumer<AbstractNodeMappingCall<?, T>> _function = (AbstractNodeMappingCall<?, T> it) -> { this.execute(it, diagramObject, context); }; _nodes.forEach(_function); List<AbstractConnectionMappingCall<?, T>> _connections = diagramMapping.getConnections(); final Consumer<AbstractConnectionMappingCall<?, T>> _function_1 = (AbstractConnectionMappingCall<?, T> it) -> { final Procedure1<XConnection> _function_2 = (XConnection it_1) -> {}; this.execute(it, diagramObject, _function_2, context); }; _connections.forEach(_function_1); context.setIsCreateNodes(false); List<ConnectionMapping<?>> _eagerConnections = diagramMapping.getEagerConnections(); boolean _isEmpty = _eagerConnections.isEmpty(); boolean _not = (!_isEmpty); if (_not) { List<ConnectionMapping<?>> _eagerConnections_1 = diagramMapping.getEagerConnections(); final HashSet<ConnectionMapping<?>> eagerConnections = new HashSet<ConnectionMapping<?>>(_eagerConnections_1); List<AbstractNodeMappingCall<?, T>> _nodes_1 = diagramMapping.getNodes(); final Consumer<AbstractNodeMappingCall<?, T>> _function_2 = (AbstractNodeMappingCall<?, T> it) -> { this.<T>connectNodesEagerly(it, diagramObject, eagerConnections, context); }; _nodes_1.forEach(_function_2); } context.setIsCreateNodes(true); }
protected <T extends Object> void doRevealElement( final T element, final EntryCall<? super T> entryCall, final IEditorPart editor) { XDiagram _diagram = this.root.getDiagram(); final InterpreterContext interpreterContext = new InterpreterContext(_diagram); entryCall.execute(element, this.configInterpreter, interpreterContext); CommandStack _commandStack = this.root.getCommandStack(); interpreterContext.executeCommands(_commandStack); final IMappedElementDescriptor<T> descriptor = this.<T, Object>createMappedDescriptor(element); XDiagram _diagram_1 = interpreterContext.getDiagram(); ObservableList<XNode> _nodes = _diagram_1.getNodes(); XDiagram _diagram_2 = interpreterContext.getDiagram(); ObservableList<XConnection> _connections = _diagram_2.getConnections(); Iterable<XDomainObjectShape> _plus = Iterables.<XDomainObjectShape>concat(_nodes, _connections); final Function1<XDomainObjectShape, Boolean> _function = (XDomainObjectShape it) -> { DomainObjectDescriptor _domainObjectDescriptor = it.getDomainObjectDescriptor(); return Boolean.valueOf(Objects.equal(_domainObjectDescriptor, descriptor)); }; final XDomainObjectShape centerShape = IterableExtensions.<XDomainObjectShape>findFirst(_plus, _function); CommandStack _commandStack_1 = this.root.getCommandStack(); ParallelAnimationCommand _parallelAnimationCommand = new ParallelAnimationCommand(); final Procedure1<ParallelAnimationCommand> _function_1 = (ParallelAnimationCommand it) -> { boolean _needsLayoutCommand = interpreterContext.needsLayoutCommand(); if (_needsLayoutCommand) { Layouter _layouter = new Layouter(); XDiagram _diagram_3 = interpreterContext.getDiagram(); Duration _millis = DurationExtensions.millis(500); LazyCommand _createLayoutCommand = _layouter.createLayoutCommand(LayoutType.DOT, _diagram_3, _millis, centerShape); it.operator_add(_createLayoutCommand); } final Function1<XShape, Boolean> _function_2 = (XShape it_1) -> { return Boolean.valueOf(Objects.equal(it_1, centerShape)); }; SelectAndRevealCommand _selectAndRevealCommand = new SelectAndRevealCommand(this.root, _function_2); it.operator_add(_selectAndRevealCommand); }; ParallelAnimationCommand _doubleArrow = ObjectExtensions.<ParallelAnimationCommand>operator_doubleArrow( _parallelAnimationCommand, _function_1); _commandStack_1.execute(_doubleArrow); }
public <T extends Object, U extends Object> XDiagram createDiagram( final T diagramObject, final DiagramMapping<T> diagramMapping, final boolean isOnDemand, final InterpreterContext context) { XDiagram _xblockexpression = null; { boolean _isApplicable = diagramMapping.isApplicable(diagramObject); boolean _not = (!_isApplicable); if (_not) { return null; } final IMappedElementDescriptor<T> descriptor = this.<T>getDescriptor(diagramObject, diagramMapping); boolean _equals = Objects.equal(descriptor, null); if (_equals) { return null; } XDiagram _diagram = context.getDiagram(); DomainObjectDescriptor _domainObjectDescriptor = _diagram.getDomainObjectDescriptor(); final boolean replaceDiagram = (!Objects.equal(_domainObjectDescriptor, descriptor)); context.setIsReplaceRootDiagram(replaceDiagram); XDiagram _xifexpression = null; if (replaceDiagram) { _xifexpression = diagramMapping.createDiagram(descriptor); } else { _xifexpression = context.getDiagram(); } final XDiagram diagram = _xifexpression; InterpreterContext _xifexpression_1 = null; if (replaceDiagram) { _xifexpression_1 = new InterpreterContext(diagram, context); } else { _xifexpression_1 = context; } final InterpreterContext newContext = _xifexpression_1; if (isOnDemand) { diagram.setLayoutOnActivate(true); final Procedure1<XDiagram> _function = (XDiagram it) -> { final Function1<T, Object> _function_1 = (T domainObject) -> { Object _xblockexpression_1 = null; { this.<T>populateDiagram(diagramMapping, domainObject, newContext); newContext.directlyApplyChanges(); XRoot _root = CoreExtensions.getRoot(diagram); final CommandStack commandStack = _root.getCommandStack(); newContext.executeCommands(commandStack); _xblockexpression_1 = null; } return _xblockexpression_1; }; descriptor.<Object>withDomainObject(_function_1); }; diagram.setContentsInitializer(_function); } else { this.<T>populateDiagram(diagramMapping, diagramObject, newContext); } _xblockexpression = diagram; } return _xblockexpression; }
public <T extends Object> XNode createNode( final T nodeObject, final NodeMapping<T> nodeMapping, final InterpreterContext context) { boolean _isApplicable = nodeMapping.isApplicable(nodeObject); if (_isApplicable) { final IMappedElementDescriptor<T> descriptor = this.<T>getDescriptor(nodeObject, nodeMapping); boolean _equals = Objects.equal(descriptor, null); if (_equals) { return null; } boolean _isCreateDuplicateNodes = context.isCreateDuplicateNodes(); boolean _not = (!_isCreateDuplicateNodes); if (_not) { final XNode existingNode = context.getNode(descriptor); boolean _or = false; boolean _notEquals = (!Objects.equal(existingNode, null)); if (_notEquals) { _or = true; } else { boolean _isCreateNodes = context.isCreateNodes(); boolean _not_1 = (!_isCreateNodes); _or = _not_1; } if (_or) { return existingNode; } } final XNode node = nodeMapping.createNode(descriptor); XDiagramConfig _config = nodeMapping.getConfig(); _config.initialize(node); context.addNode(node); boolean _isCreateConnections = context.isCreateConnections(); if (_isCreateConnections) { List<AbstractConnectionMappingCall<?, T>> _incoming = nodeMapping.getIncoming(); final Consumer<AbstractConnectionMappingCall<?, T>> _function = (AbstractConnectionMappingCall<?, T> it) -> { boolean _isOnDemand = it.isOnDemand(); boolean _not_2 = (!_isOnDemand); if (_not_2) { final Procedure1<XConnection> _function_1 = (XConnection it_1) -> { it_1.setTarget(node); }; this.execute(it, nodeObject, _function_1, context); } }; _incoming.forEach(_function); List<AbstractConnectionMappingCall<?, T>> _outgoing = nodeMapping.getOutgoing(); final Consumer<AbstractConnectionMappingCall<?, T>> _function_1 = (AbstractConnectionMappingCall<?, T> it) -> { boolean _isOnDemand = it.isOnDemand(); boolean _not_2 = (!_isOnDemand); if (_not_2) { final Procedure1<XConnection> _function_2 = (XConnection it_1) -> { it_1.setSource(node); }; this.execute(it, nodeObject, _function_2, context); } }; _outgoing.forEach(_function_1); } List<AbstractLabelMappingCall<?, T>> _labels = nodeMapping.getLabels(); final Consumer<AbstractLabelMappingCall<?, T>> _function_2 = (AbstractLabelMappingCall<?, T> it) -> { ObservableList<XLabel> _labels_1 = node.getLabels(); Iterable<? extends XLabel> _execute = this.execute(it, nodeObject); Iterables.<XLabel>addAll(_labels_1, _execute); }; _labels.forEach(_function_2); if ((node instanceof XDiagramContainer)) { DiagramMappingCall<?, T> _nestedDiagram = nodeMapping.getNestedDiagram(); XDiagram _execute = null; if (_nestedDiagram != null) { XDiagram _xDiagram = new XDiagram(); InterpreterContext _interpreterContext = new InterpreterContext(_xDiagram, context); _execute = this.execute(_nestedDiagram, nodeObject, _interpreterContext); } ((XDiagramContainer) node).setInnerDiagram(_execute); } return node; } else { return null; } }
protected <T extends Object> void connectNodesEagerly( final AbstractNodeMappingCall<?, T> it, final T diagramObject, final Set<ConnectionMapping<?>> eagerConnections, final InterpreterContext context) { final Iterable<?> nodeObjects = this.select(it, diagramObject); NodeMapping<?> _nodeMapping = it.getNodeMapping(); final NodeMapping<Object> nodeMappingCasted = ((NodeMapping<Object>) _nodeMapping); for (final Object nodeObject : nodeObjects) { { final IMappedElementDescriptor<Object> descriptor = this.<Object>getDescriptor(nodeObject, nodeMappingCasted); final XNode node = context.getNode(descriptor); boolean _notEquals = (!Objects.equal(node, null)); if (_notEquals) { List<AbstractConnectionMappingCall<?, Object>> _incoming = nodeMappingCasted.getIncoming(); final Function1<AbstractConnectionMappingCall<?, Object>, Boolean> _function = (AbstractConnectionMappingCall<?, Object> it_1) -> { boolean _and = false; boolean _isOnDemand = it_1.isOnDemand(); if (!_isOnDemand) { _and = false; } else { AbstractMapping<?> _mapping = it_1.getMapping(); boolean _contains = eagerConnections.contains(_mapping); _and = _contains; } return Boolean.valueOf(_and); }; Iterable<AbstractConnectionMappingCall<?, Object>> _filter = IterableExtensions.<AbstractConnectionMappingCall<?, Object>>filter( _incoming, _function); final Consumer<AbstractConnectionMappingCall<?, Object>> _function_1 = (AbstractConnectionMappingCall<?, Object> it_1) -> { final Procedure1<XConnection> _function_2 = (XConnection it_2) -> { it_2.setTarget(node); }; this.execute(it_1, nodeObject, _function_2, context); }; _filter.forEach(_function_1); List<AbstractConnectionMappingCall<?, Object>> _outgoing = nodeMappingCasted.getOutgoing(); final Function1<AbstractConnectionMappingCall<?, Object>, Boolean> _function_2 = (AbstractConnectionMappingCall<?, Object> it_1) -> { boolean _and = false; boolean _isOnDemand = it_1.isOnDemand(); if (!_isOnDemand) { _and = false; } else { AbstractMapping<?> _mapping = it_1.getMapping(); boolean _contains = eagerConnections.contains(_mapping); _and = _contains; } return Boolean.valueOf(_and); }; Iterable<AbstractConnectionMappingCall<?, Object>> _filter_1 = IterableExtensions.<AbstractConnectionMappingCall<?, Object>>filter( _outgoing, _function_2); final Consumer<AbstractConnectionMappingCall<?, Object>> _function_3 = (AbstractConnectionMappingCall<?, Object> it_1) -> { final Procedure1<XConnection> _function_4 = (XConnection it_2) -> { it_2.setSource(node); }; this.execute(it_1, nodeObject, _function_4, context); }; _filter_1.forEach(_function_3); } } } }