Пример #1
0
        /// <summary>
        /// Adds a docker node to the hive.
        /// </summary>
        /// <param name="node">The new node.</param>
        public void AddNode(NodeDefinition node)
        {
            Covenant.Requires <ArgumentNullException>(node != null);
            Covenant.Requires <ArgumentException>(NeonHelper.DoesNotThrow(() => node.Validate(this)));

            NodeDefinitions.Add(node.Name, node);
        }
Пример #2
0
        /// <summary>
        /// Extracts all nodes from node definitions and loads them into galleries.
        /// </summary>
        private void LoadGalleryItems()
        {
            var categories = NodeDefinitions.OrderBy(x => x.Category).GroupBy(x => x.Category);

            foreach (var category in categories)
            {
                var gallery = new Gallery()
                {
                    Header = category.Key
                };

                if (string.IsNullOrEmpty(gallery.Header))
                {
                    gallery.Header = "General";
                }

                foreach (var item in category.OrderBy(x => x.DisplayName))
                {
                    var galleryItem = new GalleryItem {
                        Header = item.DisplayName
                    };

                    if (item is Definition.ActionNodeDefinition)
                    {
                        galleryItem.Shape = new ActionNodeShape
                        {
                            Name        = item.Name,
                            DataContext = item,
                        };
                    }
                    else
                    {
                        galleryItem.Shape = new EventNodeShape
                        {
                            Name        = item.Name,
                            DataContext = item,
                        };
                    }

                    gallery.Items.Add(galleryItem);
                }
                GalleryItems.Add(gallery);
                GalleryViewSources[gallery]        = CollectionViewSource.GetDefaultView(gallery.Items);
                GalleryViewSources[gallery].Filter = nodeFilter;
            }

            SelectedGallery = GalleryItems.FirstOrDefault();
        }
Пример #3
0
        /// <summary>
        /// Creates a node
        /// </summary>
        /// <param name="shape"></param>
        /// <returns></returns>
        object IObservableGraphSource.CreateNode(IShape shape)
        {
            IsDirty = true;
            if (shape is BaseNodeShape)
            {
                var baseNodeShape = shape as BaseNodeShape;

                var def = NodeDefinitions.FirstOrDefault(x => x.Name == baseNodeShape.Name);

                var nodeConfig = new Configuration.NodeConfiguration
                {
                    Id        = Guid.NewGuid(),
                    ClassName = def.Name,
                    NodeType  = def is ActionNodeDefinition ? "ActionNode" : "EventNode"
                };

                this.flowConfiguration.Nodes.Add(nodeConfig);

                NodeViewModel nodeViewModel = null;

                if (def is ActionNodeDefinition)
                {
                    nodeViewModel             = new ActionNodeViewModel(def, nodeConfig);
                    baseNodeShape.DataContext = nodeViewModel;
                }
                else if (def is EventNodeDefinition)
                {
                    nodeViewModel             = new EventNodeViewModel(def, nodeConfig);
                    baseNodeShape.DataContext = nodeViewModel;
                }

                baseNodeShape.CreateConnectors();
                baseNodeShape.Height = nodeViewModel.Height;
                baseNodeShape.Width  = nodeViewModel.Width;
                return(nodeViewModel);
            }

            return(null);
        }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     nd  = FindObjectOfType <NodeDefinitions>();
     inv = FindObjectOfType <Inventory> ();
 }
Пример #5
0
        /// <summary>
        /// Fills the configuration values
        /// </summary>
        private void FillConfiguration()
        {
            if (!flowConfiguration.Nodes.Any())
            {
                return;
            }

            // create node view models
            foreach (var node in flowConfiguration.Nodes)
            {
                NodeViewModel nodeViewModel  = null;
                var           nodeDefinition = NodeDefinitions.Where(x => x.Name == node.ClassName).FirstOrDefault();

                if (node.NodeType == "ActionNode")
                {
                    nodeViewModel = new ActionNodeViewModel(nodeDefinition, node);
                }
                else if (node.NodeType == "EventNode")
                {
                    nodeViewModel = new EventNodeViewModel(nodeDefinition, node);
                }

                Nodes.Add(nodeViewModel);
            }

            // create flow links
            foreach (var flow in flowConfiguration.Links)
            {
                var sourceNodeViewModel      = Nodes.Where(x => x.Id == flow.From.NodeId).FirstOrDefault();
                var sourceConnectorViewModel = sourceNodeViewModel.FlowPins.Where(x => x.Name == flow.From.PinName).FirstOrDefault();

                var targetNodeViewModel      = Nodes.Where(x => x.Id == flow.To.NodeId).FirstOrDefault();
                var targetConnectorViewModel = targetNodeViewModel.FlowPins.Where(x => x.Name == flow.To.PinName).FirstOrDefault();

                var connectionViewModel = new NodeConnectionViewModel(sourceNodeViewModel, targetNodeViewModel, sourceConnectorViewModel, targetConnectorViewModel);
                Connections.Add(connectionViewModel);
            }

            // create data pins
            foreach (var pin in flowConfiguration.Pins)
            {
                var sourceNodeViewModel      = Nodes.Where(x => x.Id == pin.From.NodeId).FirstOrDefault();
                var sourceConnectorViewModel = sourceNodeViewModel.DataPins.Where(x => x.Name == pin.From.PinName).FirstOrDefault();

                var targetNodeViewModel      = Nodes.Where(x => x.Id == pin.To.NodeId).FirstOrDefault();
                var targetConnectorViewModel = targetNodeViewModel.DataPins.Where(x => x.Name == pin.To.PinName).FirstOrDefault();

                var connectionViewModel = new NodeConnectionViewModel(sourceNodeViewModel, targetNodeViewModel, sourceConnectorViewModel, targetConnectorViewModel);
                Connections.Add(connectionViewModel);

                // if the target connector is a generic data type, update all other generic types to the source data type
                if (targetConnectorViewModel.IsGeneric)
                {
                    (targetNodeViewModel as ActionNodeViewModel).UpdateDataTypes(sourceConnectorViewModel.DataConnectorType);
                }
            }

            // create workflow variables
            foreach (var variable in flowConfiguration.Variables)
            {
                Variables.Add(new FlowVariable
                {
                    Name  = variable.Name,
                    Value = variable.Value,
                    Type  = variable.Type
                });
            }
        }