/// <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);

            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);

            return(scopeNode);
        }
        /// <summary>
        /// Generates the challenge node.
        /// </summary>
        /// <param name="challengeName">Name of the challenge.</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 ChallengeNode CreateChallengeNode(string challengeName, 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 ChallengeMetadata(componentGraph, challengeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

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

            var challengeNode = new ChallengeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(challengeNode);

            return(challengeNode);
        }
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns></returns>
        public override BaseExperiment Clone()
        {
            var clone = new CompositeComponentEditableGraph(this);

            clone.ResetModifiedFlag();
            return(clone);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScopeBaseMetadata"/> class.
 /// </summary>
 /// <param name="compositeComponentGraph">The composite component graph.</param>
 /// <param name="label">The label.</param>
 /// <param name="experimentLocationRoot">The experiment location root.</param>
 internal ScopeBaseMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
     : this()
 {
     m_experimentLocationRoot = experimentLocationRoot;
     m_compositeComponentGraph = compositeComponentGraph;
     Label = label;
 }
Exemple #5
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 LoopScopeNode CreateLoopScopeNode(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);

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

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

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

            var loopScopeNode = new LoopScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(loopScopeNode);

            return(loopScopeNode);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeComponentEditableGraph"/> class.
        /// </summary>
        /// <param name="compositeComponentNode">The composite component node.</param>
        /// <param name="componentGraph">The component graph.</param>
        public CompositeComponentEditableGraph(CompositeComponentNode compositeComponentNode, CompositeComponentEditableGraph componentGraph)
            : base()
        {
            if (componentGraph == null)
            {
                throw new ArgumentException("Component graph cannot be null");
            }

            CopyFrom(componentGraph);
            OwnerNode = compositeComponentNode;
        }
        // ***************************************************
        // HERZUM SPRINT 2.4 TLAB-157
        public void SetApplicationModel(ApplicationViewModel applicationViewModel,  ExperimentCanvasWidget experimentCanvasWidget, CompositeComponentGraph subExperiment) 
        {
            // HERZUM SPRINT 1.0
            // scopeNodeControlCurrent = scopeNodeControl;
            // END HERZUM SPRINT 1.0

            if(m_initialized == false || m_dockFrame.GdkWindow == null) 
            {
                //GdkWindow is for each dock frame is assigned when windowShell calls ShowAll(). See DockContainer.OnRealize method
                throw new InvalidOperationException("ExperimentCanvasPad must be first initialized and dockFrame must have assigned GdkWindow before setting application model.");
            }

            m_applicationViewModel = applicationViewModel;

            if(m_applicationViewModel.Experiment == null) 
            {
                m_experimentPad.Content = new WelcomePageWidget(m_applicationContext);
            } 
            else 
            {
                // CreateExperimentControlToolbar();


                m_subExperiment = new CompositeComponentEditableGraph(subExperiment);
                if (subExperiment.OwnerNode != null)
                    m_subExperiment.OwnerNode = subExperiment.OwnerNode;
                if (subExperiment.GraphIdPath != null)
                    m_subExperiment.GraphIdPath = subExperiment.GraphIdPath;

                m_experimentCanvasWidget = experimentCanvasWidget;


                m_experimentPad.Content = m_experimentCanvasWidget;

                // bool isExperimentEditable = m_applicationViewModel.Experiment is IEditableExperiment;


                m_experimentDrawer = new ExperimentDrawer(m_experimentCanvasWidget, 
                                                          new NodeControlFactory(m_applicationContext),
                                                          new NodeConnectionControlFactory(m_applicationContext));


                m_experimentDrawer.DrawExperiment(m_subExperiment, false);

            }
        }
        // HERZUM SPRINT 2.5 TLAB-157
        /*
        private bool IsInEditableExperiment(CompositeComponentGraph experiment){
            if (experiment == null || experiment.OwnerNode == null)
                return true;

            CompositeComponentGraph fatherExperiment = experiment.OwnerNode.Owner as CompositeComponentGraph ;
            if (fatherExperiment != null && fatherExperiment.OwnerNode!= null){
                CompositeComponentBaseMetadata meta = fatherExperiment.OwnerNode.Data.Metadata as CompositeComponentBaseMetadata;
                if (meta != null && meta.ComponentGraph is CompositeComponentEditableGraph)
                    return IsInEditableExperiment (meta.ComponentGraph);
                else
                    return false;
            } else
                return true;
        }
        */
        // END SPRINT 2.5 TLAB-157

        public void SetScopeApplicationModel(ScopeNodeControl scopeNodeControl, ApplicationViewModel applicationViewModel, CompositeComponentGraph subExperiment) 
        {
            // HERZUM SPRINT 1.0
            // scopeNodeControlCurrent = scopeNodeControl;
            // END HERZUM SPRINT 1.0

                if(m_initialized == false || m_dockFrame.GdkWindow == null) 
            {
                //GdkWindow is for each dock frame is assigned when windowShell calls ShowAll(). See DockContainer.OnRealize method
                throw new InvalidOperationException ("ExperimentCanvasPad must be first initialized and dockFrame must have assigned GdkWindow before setting application model.");
            }

            m_applicationViewModel = applicationViewModel;

            // HERZUM SPRINT 1.0
            // Experiment e = new Experiment ();
            // m_applicationViewModel = ApplicationViewModel.CreateNewApplicationViewModel (applicationViewModel, e);
            // m_applicationContext = new ApplicationContext (m_applicationViewModel);
            // END HERZUM SPRINT 1.0

            if(m_applicationViewModel.Experiment == null) 
            {
                m_experimentPad.Content = new WelcomePageWidget(m_applicationContext);
            } 
            else 
            {
                // CreateExperimentControlToolbar();

                // HERZUM SPRINT 1.0
                m_subExperiment = new CompositeComponentEditableGraph (subExperiment);
                // END HERZUM SPRINT 1.0

                // HERZUM SPRINT 1.0 PROGRESS
                // HERZUM SPRINT 2.4 TLAB-157
                if (subExperiment.OwnerNode != null)
                    // END HERZUM SPRINT 2.4 TLAB-157
                    m_subExperiment.OwnerNode = subExperiment.OwnerNode;
                // HERZUM SPRINT 2.4 TLAB-157
                if (subExperiment.GraphIdPath != null)
                    // END HERZUM SPRINT 2.4 TLAB-157
                    m_subExperiment.GraphIdPath = subExperiment.GraphIdPath;
                // END HERZUM SPRINT 1.0

                // HERZUM SPRINT 4.3: TLAB-238 TLAB-243
                if (m_subExperiment.ExperimentInfo != null)
                    m_subExperiment.ExperimentInfo.FilePath = m_applicationContext.Application.Experiment.ExperimentInfo.FilePath;
                // END HERZUM SPRINT 4.3: TLAB-238 TLAB-243

                // HERZUM SPRINT 1.1 LOOP
                // ScopeMetadata scopeMetadata = scopeNodeControlCurrent.ExperimentNode.Data.Metadata as ScopeMetadata;

                // HERZUM SPRINT 2.1
                // ScopeBaseMetadata scopeMetadata = scopeNodeControlCurrent.ExperimentNode.Data.Metadata as ScopeBaseMetadata;
                ScopeBaseMetadata scopeMetadata = scopeNodeControl.ExperimentNode.Data.Metadata as ScopeBaseMetadata;
                // END HERZUM SPRINT 2.1

                // END HERZUM SPRINT 1.1 LOOP

                scopeMetadata.SetSubExperiment (m_subExperiment);
                m_experimentCanvasWidget = new ExperimentCanvasWidget ();
                m_experimentPad.Content = m_experimentCanvasWidget;

                bool isExperimentEditable = m_applicationViewModel.Experiment is IEditableExperiment;
             //   isExperimentEditable = isChallengePasswordBeenUsed ();

                m_experimentDrawer = new ExperimentDrawer (m_experimentCanvasWidget, m_applicationContext.NodeControlFactory,
                                                           m_applicationContext.NodeConnectionControlFactory);

                //m_experimentDrawer.DrawExperiment(m_applicationViewModel.Experiment, isExperimentEditable);

                // HERZUM SPRINT 2.5 TLAB-157
                // isExperimentEditable = isExperimentEditable && IsInEditableExperiment (m_subExperiment);
                isExperimentEditable = checkEditable (m_subExperiment);
                // END HERZUM SPRINT 2.5 TLAB-157

                if (scopeNodeControl is ChallengeNodeControl)
                    isExperimentEditable = true;

                // HERZUM SPRINT 3.0: TLAB-172
                isExperimentEditable = isExperimentEditable && !isInCompositeCrumb();
                // END HERZUM SPRINT 3.0: TLAB-172

                m_experimentDrawer.DrawExperiment(m_subExperiment, isExperimentEditable);               

                // HERZUM SPRINT 1.0
                m_subExperiment.NodeRemoved += OnNodeRemoved;
                m_subExperiment.EdgeRemoved += OnEdgeRemoved;
                //
                //m_applicationViewModel.Experiment.NodeRemoved += OnNodeRemoved;
                //m_applicationViewModel.Experiment.EdgeRemoved += OnEdgeRemoved;
                // END HERZUM SPRINT 1.0

                if(isExperimentEditable) 
                {
                    //enable drop of components to canvas
                    EnableDrop ();
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ScopeMetadata"/> class.
 /// </summary>
 /// <param name="compositeComponentGraph">The composite component graph.</param>
 /// <param name="label">The label.</param>
 /// <param name="experimentLocationRoot">The experiment location root.</param>
 internal ScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
     : base(compositeComponentGraph, label, experimentLocationRoot)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LoopScopeMetadata"/> class.
 /// </summary>
 /// <param name="compositeComponentGraph">The composite component graph.</param>
 /// <param name="label">The label.</param>
 /// <param name="experimentLocationRoot">The experiment location root.</param>
 internal LoopScopeMetadata(CompositeComponentEditableGraph compositeComponentGraph, string label, string experimentLocationRoot)
     : base(compositeComponentGraph, label, experimentLocationRoot)
 {
     UniqueDecisionID = Guid.NewGuid().ToString();
 }
Exemple #11
0
 // HERZUM SPRINT 1.0
 public void SetSubExperiment(CompositeComponentEditableGraph compositeComponentEditableGraph)
 {
     m_compositeComponentGraph = compositeComponentEditableGraph;
 }
        /// <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 LoopScopeNode CreateLoopScopeNode(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);
            componentGraph.References = new System.Collections.ObjectModel.ObservableCollection<TraceLabSDK.PackageSystem.IPackageReference>(experiment.References);

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

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

            var loopScopeNode = new LoopScopeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(loopScopeNode);

            return loopScopeNode;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompositeComponentEditableGraph"/> class.
        /// </summary>
        /// <param name="compositeComponentNode">The composite component node.</param>
        /// <param name="componentGraph">The component graph.</param>
        public CompositeComponentEditableGraph(CompositeComponentNode compositeComponentNode, CompositeComponentEditableGraph componentGraph)
            : base()
        {
            if (componentGraph == null)
            {
                throw new ArgumentException("Component graph cannot be null");
            }

            CopyFrom(componentGraph);
            OwnerNode = compositeComponentNode;
        }
 /// <summary>
 /// Clones this instance.
 /// </summary>
 /// <returns></returns>
 public override BaseExperiment Clone()
 {
     var clone = new CompositeComponentEditableGraph(this);
     clone.ResetModifiedFlag();
     return clone;
 }
Exemple #15
0
        /// <summary>
        /// Generates the challenge node.
        /// </summary>
        /// <param name="challengeName">Name of the challenge.</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 ChallengeNode CreateChallengeNode(string challengeName, 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 ChallengeMetadata(componentGraph, challengeName, System.IO.Path.GetDirectoryName(experiment.ExperimentInfo.FilePath));

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

            var challengeNode = new ChallengeNode(Guid.NewGuid().ToString(), data);

            experiment.AddVertex(challengeNode);

            return challengeNode;
        }
Exemple #16
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);

            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);
            return scopeNode;
        }