Esempio n. 1
0
        // HERZUM SPRINT 2.3 TLAB-60
        private ScopeNodeBase GetScopeUp(ExperimentNode experimentNode, BaseExperiment experiment, double x, double y)
        {
            BasicNodeControl componentControl;

            foreach (ExperimentNode node in experiment.Vertices)
            {
                if (node is ScopeNodeBase && !node.Equals(experimentNode))
                {
                    if (m_applicationContext.NodeControlFactory.TryGetNodeControl(node, out componentControl))
                    {
                        ScopeNodeControl scopeNodeControl = componentControl as ScopeNodeControl;
                        if (scopeNodeControl.ContainsPoint(x, y))
                        {
                            return(node as ScopeNodeBase);
                        }
                    }
                }
            }
            return(null);
        }
Esempio n. 2
0
 internal void SetScopeNodeControlCurrent(ScopeNodeControl scopeNodeControl)
 {
     scopeNodeControlCurrent = scopeNodeControl;
 }
Esempio n. 3
0
        /// <summary>
        /// Sets the application model on the given pad.
        /// Pad refreshes its information according to the given application model.
        /// </summary>
        /// <param name='applicationViewModel'>
        /// Application model.
        /// </param>
        /// <param name='subExperiment'>
        /// Scope SubExperiment
        /// </param>
        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
                m_subExperiment.OwnerNode   = subExperiment.OwnerNode;
                m_subExperiment.GraphIdPath = subExperiment.GraphIdPath;
                // END HERZUM SPRINT 1.0

                // HERZUM SPRINT 1.1 LOOP
                // ScopeMetadata scopeMetadata = scopeNodeControlCurrent.ExperimentNode.Data.Metadata as ScopeMetadata;
                ScopeBaseMetadata scopeMetadata = scopeNodeControlCurrent.ExperimentNode.Data.Metadata as ScopeBaseMetadata;
                // 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;


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


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


                m_scopeDrawer.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();
                }
            }
        }
Esempio n. 4
0
        // 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 ();
                }
            }
        }
Esempio n. 5
0
 internal void SetScopeNodeControlCurrent(ScopeNodeControl scopeNodeControl)
 { 
     scopeNodeControlCurrent = scopeNodeControl;
 }
Esempio n. 6
0
        public BasicNodeControl CreateNodeControl(ExperimentNode node) 
        {
            BasicNodeControl control;

            if (node is ComponentNode) 
            {
                control = new ComponentControl(node, m_applicationContext);
            } 
            else if (node is ExperimentStartNode) 
            {
                control = new StartNodeControl(node, m_applicationContext);
            } 
            else if (node is ExperimentEndNode) 
            { 
                control = new EndNodeControl(node, m_applicationContext);
            }
            else if (node is ExperimentDecisionNode) 
            { 
                control = new DecisionNodeControl(node, m_applicationContext);
            }
            else if (node is ExitDecisionNode)
            {
                // HERZUM  SPRINT 0.0
                // control = null;
                // throw new NotImplementedException();
                // HERZUM SPRINT 1.1 IF
                // control = new EndNodeControl(node, m_applicationContext);
                control = new ExitDecisionControl(node, m_applicationContext);
                // END HERZUM SPRINT 1.1 IF
                // END HERZUM 
            }
            else if (node is LoopScopeNode)
            {
                // HERZUM SPRINT 1.1 LOOP
                // control = null;
                // throw new NotImplementedException();
                control = new LoopNodeControl(node, m_applicationContext);
                // END HERZUM SPRINT 1.1 LOOP
            }
            else if (node is ScopeNode)
            {
                // HERZUM  SPRINT 0.0
                //control = null;
                //throw new NotImplementedException();
                control = new ScopeNodeControl(node, m_applicationContext);
                // END HERZUM 
            }
            // HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (node is ChallengeNode)
            {
                control = new ChallengeNodeControl(node, m_applicationContext);
            }
            // END HERZUM SPRINT 2.0: TLAB-65 CLASS
            else if (node is CompositeComponentNode)
            {
                control = new CompositeComponentControl(node, m_applicationContext);
            }
            // HERZUM SPRINT 1.0
            else if (node is CommentNode)
            {
                control = new CommentNodeControl(node, m_applicationContext);
            }
            // END HERZUM SPRINT 1.0
            else 
            {
                control = new BasicNodeControl(node, m_applicationContext);
            }

            m_mapNodesToControls.Add(node, control);

            return control;
        }