Example #1
0
        /// <summary>
        /// Helper method, that sets the scope decision entry and exit nodes.
        /// If source vertex is scope and target vertex is exit decision node, it sets that source scope vertex ExitDecisionNode property to the given target exit node.
        /// Similarly, if target vertex is a scope node, and source vertex is decision, it sets that target scope vertex Decision property to the given source decision node.
        /// </summary>
        /// <param name="sourceVert">The source vert.</param>
        /// <param name="targetVert">The target vert.</param>
        public static void TryFixScopeDecisionEntryAndExitNodes(ExperimentNode sourceVert, ExperimentNode targetVert)
        {
            //case 1: sourceVert is ScopeNode, and target is ExitDecisionNode
            ScopeNode scopeNode = sourceVert as ScopeNode;

            if (scopeNode != null)
            {
                ExitDecisionNode exitDecisionNode = targetVert as ExitDecisionNode;
                if (exitDecisionNode != null)
                {
                    scopeNode.ExitDecisionNode = exitDecisionNode;
                }
            }
            else
            {
                //case 2: targetNode is ScopeNode, and source is DecisionNode
                scopeNode = targetVert as ScopeNode;
                if (scopeNode != null)
                {
                    ExperimentDecisionNode decisionNode = sourceVert as ExperimentDecisionNode;
                    if (decisionNode != null)
                    {
                        scopeNode.DecisionNode = decisionNode;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public override ExperimentNode Clone()
        {
            var clone = new ScopeNode();

            clone.CopyFrom(this);
            return(clone);
        }
 /// <summary>
 /// Assures that all decision are selected with their scopes.
 /// If decision has been partially selected, meaning only decision with not all scopes was selected,
 /// or only some scopes were selected without decision node, this method will select all nodes
 /// to assure completeness of selection.
 /// </summary>
 /// <param name="originalExperiment">The original experiment.</param>
 private static void AssureCompleteDecisionSelection(BaseExperiment originalExperiment)
 {
     foreach (ExperimentNode node in originalExperiment.Vertices)
     {
         if (node.IsSelected)
         {
             //case 1. node is ExperimentDecisionNode
             if (node is ExperimentDecisionNode)
             {
                 SelectDecisionsScopes(originalExperiment, node);
             }
             else if (node is ExitDecisionNode)
             {
                 SelectDecisionsScopesConnectedToExitNode(originalExperiment, node);
             }
             else
             {
                 //case 2. node is a scope node
                 ScopeNode scopeNode = node as ScopeNode;
                 if (scopeNode != null)
                 {
                     if (!scopeNode.DecisionNode.IsSelected)
                     {
                         scopeNode.DecisionNode.IsSelected = true;
                         SelectDecisionsScopes(originalExperiment, scopeNode.DecisionNode);
                     }
                 }
             }
         }
     }
 }
Example #4
0
        /// <summary>
        /// Generates the scope node.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ScopeNode CreateScopeNode(string scopeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();

            data.X      = positionX;
            data.Y      = positionY;
            data.Width  = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            if (componentGraph.References != null)
            {
                componentGraph.References = experiment.References.CopyCollection();
            }

            data.Metadata = new ScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName   = data.Metadata.Label;

            var scopeNode = new ScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(scopeNode);

            return(scopeNode);
        }
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
Example #6
0
        /// <summary>
        /// Adds the scope to decision.
        /// Default scope size is 160 by 160
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="positionX">The center X position of the scope.</param>
        /// <param name="positionY">The center Y position of the scope.</param>
        /// <param name="decisionNode">The decision node.</param>
        /// <param name="exitDecisionNode">The exit decision node.</param>
        /// <param name="experiment">The experiment.</param>
        public static void AddScopeToDecision(string label, double positionX, double positionY, ExperimentDecisionNode decisionNode, ExitDecisionNode exitDecisionNode, IEditableExperiment experiment, double width = 160, double height = 160)
        {
            ScopeNode scopeNode = GenerateScopeNode(label, experiment, positionX, positionY, width, height);

            //set decision and exit decision references
            //(also note that ExperimentFactory also sets it when deseralizing experiment)
            scopeNode.DecisionNode     = decisionNode;
            scopeNode.ExitDecisionNode = exitDecisionNode;

            experiment.AddVertex(scopeNode);
            experiment.AddFixedConnection(decisionNode, scopeNode, true);
            experiment.AddFixedConnection(scopeNode, exitDecisionNode, true);

            experiment.SetLogLevelSettings(scopeNode);
        }
        /// <summary>
        /// When overridden in a derived class, is invoked whenever application code or internal processes call <see cref="M:System.Windows.FrameworkElement.ApplyTemplate"/>.
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            var vertexControl = (GraphSharp.Controls.VertexControl)DataContext;
            m_enterScopeNode = (ExperimentStartNode)vertexControl.Vertex;

            //listen to property changed of the parent scope node, and update exit node x and y, if scope size is changing. 
            ScopeNodeControl scope = this.GetParent<ScopeNodeControl>(null);

            //find node label border - needed border height to adjust node move inside the canvas
            Border labelBorder = (Border)scope.Template.FindName("labelBorder", scope);
            m_labelHeight = labelBorder.ActualHeight;

            m_scopeNode = (ScopeNode)scope.VertexControl.Vertex;

            //listen to scope node size change and decision node position changes
            m_scopeNode.DataWithSize.PropertyChanged += ScopeNodeData_PropertyChanged;
            m_scopeNode.DecisionNode.Data.PropertyChanged += DecisionNodeData_PropertyChanged;

            //intially move node to the border
            MoveNodeAlongScopeBorder();
        }
Example #8
0
        /// <summary>
        /// Generates the scope node at the given position.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ScopeNode GenerateScopeNode(string scopeName, IExperiment experiment, double positionX, double positionY, double width, double height)
        {
            var data = new SerializedVertexDataWithSize();

            data.X      = positionX;
            data.Y      = positionY;
            data.Width  = width;
            data.Height = height;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            componentGraph.References = new System.Collections.ObjectModel.ObservableCollection <TraceLabSDK.PackageSystem.IPackageReference>(experiment.References);

            data.Metadata = new ScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName   = data.Metadata.Label;

            var scopeNode = new ScopeNode(Guid.NewGuid().ToString(), data);

            return(scopeNode);
        }
 /// <summary>
 /// Clones this instance.
 /// </summary>
 /// <returns></returns>
 public override ExperimentNode Clone()
 {
     var clone = new ScopeNode();
     clone.CopyFrom(this);
     return clone;
 }
Example #10
0
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize) nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize) nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            if (nodeData == null)
            {
                throw new ArgumentNullException("nodeData");
            }

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            // HERZUM SPRINT 1.0
            else if (nodeData.Metadata is CommentMetadata)
            {
                // HERZUM SPRINT 1.2
                // node = new CommentNode(id, nodeData);
                node = new CommentNode(id, (SerializedVertexDataWithSize)nodeData);
                // END HERZUM SPRINT 1.2
            }
            // END HERZUM SPRINT 1.0
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (nodeData.Metadata is ChallengeMetadata)
            {
                node = new ChallengeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return(node);
        }
        /// <summary>
        /// Generates the scope node at the given position.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ScopeNode GenerateScopeNode(string scopeName, IExperiment experiment, double positionX, double positionY, double width, double height)
        {
            var data = new SerializedVertexDataWithSize();
            data.X = positionX;
            data.Y = positionY;
            data.Width = width;
            data.Height = height;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);
            componentGraph.References = new System.Collections.ObjectModel.ObservableCollection<TraceLabSDK.PackageSystem.IPackageReference>(experiment.References);

            data.Metadata = new ScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));
            
            string componentNodeId = Guid.NewGuid().ToString();
            string componentName = data.Metadata.Label;

            var scopeNode = new ScopeNode(Guid.NewGuid().ToString(), data);
            return scopeNode;
        }
        /// <summary>
        /// Generates the correct node based on metadata contained in serialized vertex data
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="nodeData">The node data.</param>
        /// <returns>Experiment node</returns>
        private ExperimentNode NodeGenerator(string id, SerializedVertexData nodeData)
        {
            if (id == null)
                throw new ArgumentNullException("id");
            if (nodeData == null)
                throw new ArgumentNullException("nodeData");

            ExperimentNode node;

            if (nodeData.Metadata is StartNodeMetadata)
            {
                node = new ExperimentStartNode(id, nodeData);
            }
            else if (nodeData.Metadata is EndNodeMetadata)
            {
                node = new ExperimentEndNode(id, nodeData);
            }
            else if (nodeData.Metadata is DecisionMetadata)
            {
                node = new ExperimentDecisionNode(id, nodeData);
            }
            else if (nodeData.Metadata is ScopeMetadata)
            {
                node = new ScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is LoopScopeMetadata)
            {
                node = new LoopScopeNode(id, (SerializedVertexDataWithSize)nodeData);
            }
            else if (nodeData.Metadata is CompositeComponentMetadata)
            {
                node = new CompositeComponentNode(id, nodeData);
            }
            else if (nodeData.Metadata is ExitDecisionMetadata)
            {
                node = new ExitDecisionNode(id, nodeData);
            }
            else
            {
                ComponentNode componentNode = new ComponentNode(id, nodeData);
                node = componentNode;
            }

            return node;
        }
Example #14
0
        /// <summary>
        /// Generates the scope node.
        /// </summary>
        /// <param name="scopeName">Name of the scope.</param>
        /// <param name="experiment">The experiment to which new component is added.</param>
        /// <param name="positionX">The position X.</param>
        /// <param name="positionY">The position Y.</param>
        /// <returns></returns>
        private static ScopeNode CreateScopeNode(string scopeName, IEditableExperiment experiment, double positionX, double positionY)
        {
            var data = new SerializedVertexDataWithSize();
            data.X = positionX;
            data.Y = positionY;
            data.Width = 160;
            data.Height = 160;

            string componentId = Guid.NewGuid().ToString();

            var componentGraph = new CompositeComponentEditableGraph(true);

            if (componentGraph.References != null)
            {
                componentGraph.References = experiment.References.CopyCollection();
            }

            data.Metadata = new ScopeMetadata(componentGraph, scopeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

            string componentNodeId = Guid.NewGuid().ToString();
            string componentName = data.Metadata.Label;

            var scopeNode = new ScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(scopeNode);

            return scopeNode;
        }