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;
 }
 @Override
 public String getText() {
   AbstractMapping<RESULT> _mapping = this.mappingCall.getMapping();
   String _displayName = _mapping.getDisplayName();
   String _plus = (_displayName + " (");
   AbstractMapping<RESULT> _mapping_1 = this.mappingCall.getMapping();
   XDiagramConfig _config = _mapping_1.getConfig();
   String _label = _config.getLabel();
   String _plus_1 = (_plus + _label);
   return (_plus_1 + ")");
 }
 protected <T extends Object> XLabel createLabel(
     final T labelObject, final AbstractLabelMapping<T> labelMapping) {
   boolean _isApplicable = labelMapping.isApplicable(labelObject);
   if (_isApplicable) {
     final IMappedElementDescriptor<T> descriptor =
         this.<T>getDescriptor(labelObject, labelMapping);
     boolean _notEquals = (!Objects.equal(descriptor, null));
     if (_notEquals) {
       final XLabel label = labelMapping.createLabel(descriptor, labelObject);
       XDiagramConfig _config = labelMapping.getConfig();
       _config.initialize(label);
       return label;
     }
   }
   return null;
 }
Пример #4
0
 protected <T extends Object, U extends Object> IMappedElementDescriptor<T> createMappedDescriptor(
     final T domainObject) {
   IMappedElementDescriptor<T> _xblockexpression = null;
   {
     XDiagramConfig.Registry _instance = XDiagramConfig.Registry.getInstance();
     Iterable<? extends XDiagramConfig> _configurations = _instance.getConfigurations();
     final Function1<XDiagramConfig, Iterable<? extends AbstractMapping<T>>> _function =
         (XDiagramConfig it) -> {
           return it.<T>getMappings(domainObject);
         };
     Iterable<Iterable<? extends AbstractMapping<T>>> _map =
         IterableExtensions.map(_configurations, _function);
     Iterable<AbstractMapping<T>> _flatten = Iterables.<AbstractMapping<T>>concat(_map);
     final AbstractMapping<T> mapping = IterableExtensions.<AbstractMapping<T>>head(_flatten);
     XDiagramConfig _config = mapping.getConfig();
     IMappedElementDescriptorProvider _domainObjectProvider = _config.getDomainObjectProvider();
     _xblockexpression =
         _domainObjectProvider.<T>createMappedElementDescriptor(domainObject, mapping);
   }
   return _xblockexpression;
 }
 public <T extends Object> IMappedElementDescriptor<T> getDescriptor(
     final T domainObject, final AbstractMapping<T> mapping) {
   XDiagramConfig _config = mapping.getConfig();
   IMappedElementDescriptorProvider _domainObjectProvider = _config.getDomainObjectProvider();
   return _domainObjectProvider.<T>createMappedElementDescriptor(domainObject, mapping);
 }
 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;
   }
 }