Esempio n. 1
0
        //HERZUM END SPRINT 2: TLAB-156

        public static ExperimentCanvasPad CreateExperimentCanvasPad(ApplicationContext applicationContext, BasicNodeControl basicNodeControl)
        {
            IExperiment       experiment    = null;
            ScopeBaseMetadata scopeMetadata = basicNodeControl.ExperimentNode.Data.Metadata as ScopeBaseMetadata;

            if (scopeMetadata != null)
            {
                experiment = scopeMetadata.ComponentGraph.GetExperiment();
            }
            else
            {
                return(applicationContext.MainWindow.ExperimentCanvasPad);
            }

            ExperimentCanvasPad experimentCanvasPad = new  ExperimentCanvasPad(applicationContext);

            if (!m_mapPadToNodes.ContainsKey(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id))
            //HERZUM SPRINT 2: TLAB-156
            {
                // HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59
                // m_mapPadToNodes.Add(experiment.ExperimentInfo.Id, experimentCanvasPad);
                // m_mapIdToNodes.Add (experiment.ExperimentInfo.Id, basicNodeControl);
                m_mapPadToNodes.Add(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id, experimentCanvasPad);
                m_mapIdToNodes.Add(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id, basicNodeControl);
                // END HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59
            }
            //HERZUM END SPRINT 2: TLAB-156
            return(experimentCanvasPad);
        }
Esempio n. 2
0
        // HERZUM SPRINT 4: TLAB-215
        public bool ThereAreNodeErrors(out string message)
        {
            bool   wrong        = false;
            string localMessage = "";
            string subMessage   = "";

            // HERZUM SPRINT 4.2: TLAB-215
            // if (this.Errors.Count > 0){
            // END HERZUM SPRINT 4.2: TLAB-215
            foreach (ExperimentNode node in Vertices)
            {
                if (node.Error != null && node.Error.ErrorMessage != null)
                {
                    localMessage = localMessage + "\r\n" + node.Data.Metadata.Label + " Component: " + node.Error.ErrorMessage + "\r\n";
                }
                ScopeBaseMetadata meta = node.Data.Metadata as ScopeBaseMetadata;
                if (meta != null && meta.ComponentGraph != null)
                {
                    wrong        = meta.ComponentGraph.ThereAreNodeErrors(out subMessage);
                    localMessage = localMessage + subMessage;
                }
            }
            // HERZUM SPRINT 4.2: TLAB-215
            // }
            // END HERZUM SPRINT 4.2: TLAB-215
            message = localMessage;
            return((this.Errors.Count > 0) || wrong);
        }
Esempio n. 3
0
        /// <summary>
        /// Creates the Runnable node with a specific id based on the given metadata.
        /// </summary>
        /// <param name="nodeId">The node id.</param>
        /// <param name="metadata">The component metadata.</param>
        /// <param name="loggerNameRoot">The logger name root - needed so that the logs are specific per experiment and experiment window.</param>
        /// <param name="library">The library of components.</param>
        /// <param name="componentsAppDomain">The components app domain is the app domain which components assemblies are going to be loaded into.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The event that allows signalling termination of the experiment;
        /// Needed for the composite components sublevel experiments, so that they hold the referance to the same termination event as top level experiment.</param>
        /// <returns>
        /// Created node
        /// </returns>
        public virtual RunnableNode CreateNode(String nodeId, Metadata metadata, LoggerNameRoot loggerNameRoot,
                                               ComponentsLibrary library, AppDomain componentsAppDomain, System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            RunnableNode retNode;

            ComponentMetadata          componentMetadata          = metadata as ComponentMetadata;
            DecisionMetadata           decisionMetadata           = metadata as DecisionMetadata;
            StartNodeMetadata          startNodeMetadata          = metadata as StartNodeMetadata;
            EndNodeMetadata            endNodeMetadata            = metadata as EndNodeMetadata;
            ScopeBaseMetadata          scopeMetadata              = metadata as ScopeBaseMetadata;
            LoopScopeMetadata          loopMetadata               = metadata as LoopScopeMetadata;
            CompositeComponentMetadata compositeComponentMetadata = metadata as CompositeComponentMetadata;
            ExitDecisionMetadata       exitDecisionMetadata       = metadata as ExitDecisionMetadata;

            if (componentMetadata != null)
            {
                TraceLabSDK.ComponentLogger logger = TraceLab.Core.Components.LoggerFactory.CreateLogger(loggerNameRoot, nodeId, componentMetadata);
                IComponent component = library.LoadComponent(componentMetadata, Workspace, logger, componentsAppDomain);
                retNode = new RunnableComponentNode(nodeId, componentMetadata.Label, component, logger, library, componentMetadata.WaitsForAllPredecessors);
            }
            else if (decisionMetadata != null)
            {
                IDecisionModule decisionModule = DecisionModuleFactory.LoadDecisionModule(decisionMetadata, Workspace, componentsAppDomain);
                retNode = new RunnableDecisionNode(nodeId, decisionMetadata.Label, decisionModule, library, decisionMetadata.WaitsForAllPredecessors);
            }
            else if (startNodeMetadata != null)
            {
                retNode = new RunnableStartNode(nodeId);
            }
            else if (endNodeMetadata != null)
            {
                retNode = new RunnableEndNode(nodeId, endNodeMetadata.WaitsForAllPredecessors);
            }
            else if (loopMetadata != null)
            {
                retNode = CreateLoopNode(nodeId, loopMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (scopeMetadata != null)
            {
                retNode = CreateScopeCompositeComponentNode(nodeId, scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (compositeComponentMetadata != null)
            {
                retNode = CreateCompositeComponentNode(nodeId, compositeComponentMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent);
            }
            else if (exitDecisionMetadata != null)
            {
                retNode = new RunnablePrimitiveNode(nodeId, exitDecisionMetadata.WaitsForAllPredecessors);
            }
            else
            {
                throw new Exceptions.InconsistentTemplateException("Could not identify node type.");
            }

            return(retNode);
        }
Esempio n. 4
0
 public override void ResetModifiedFlag()
 {
     base.ResetModifiedFlag();
     if (Data != null)
     {
         ScopeBaseMetadata meta = Data.Metadata as ScopeBaseMetadata;
         if (meta.ComponentGraph != null)
         {
             meta.ComponentGraph.ResetModifiedFlag();
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Creates the scope composite component node. It actually returns the composite component, but with different nested workspace wrapper.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="scopeMetadata">The scope metadata.</param>
        /// <param name="loggerNameRoot">The logger name root.</param>
        /// <param name="library">The library.</param>
        /// <param name="componentsAppDomain">The components app domain.</param>
        /// <param name="terminateExperimentExecutionResetEvent">The terminate experiment execution reset event.</param>
        /// <returns></returns>
        protected RunnableNode CreateScopeCompositeComponentNode(string id, ScopeBaseMetadata scopeMetadata, LoggerNameRoot loggerNameRoot,
                                                                 ComponentsLibrary library, AppDomain componentsAppDomain,
                                                                 System.Threading.ManualResetEvent terminateExperimentExecutionResetEvent)
        {
            ScopeNestedWorkspaceWrapper workspaceWrapper = WorkspaceWrapperFactory.CreateCompositeComponentWorkspaceWrapper(scopeMetadata, Workspace, id, componentsAppDomain);

            //scope can standard runnable factory, unlike the composite component
            IRunnableNodeFactory nodesFactory = new RunnableNodeFactory(workspaceWrapper);

            RunnableExperimentBase subExperiment = ConstructSubExperiment(scopeMetadata, loggerNameRoot, library, componentsAppDomain, terminateExperimentExecutionResetEvent, nodesFactory);

            return(new RunnableCompositeComponentNode(id, scopeMetadata, subExperiment, workspaceWrapper, library, scopeMetadata.WaitsForAllPredecessors));
        }
Esempio n. 6
0
        /*
         * private ScopeNodeBase GetScopeUp(ExperimentNode experimentNode, BaseExperiment experiment, double x, double y){
         *  BasicNodeControl componentControl;
         *  ScopeNodeBase scopeUp = null;
         *  ExperimentCanvasPad pad = null;
         *  if (experiment == null)
         *      return null;
         *  foreach (ExperimentNode node in experiment.Vertices)
         *      if (node is ScopeNodeBase && !node.Equals(experimentNode))
         *          if(m_applicationContext.NodeControlFactory.TryGetNodeControl(node, out componentControl)){
         *              ScopeBaseMetadata  scopeBaseMetadata  = node.Data.Metadata as ScopeBaseMetadata;
         *              int xMouse = 0;
         *              int yMouse = 0;
         *              BasicNodeControl internalComponentControl = null;
         *              foreach (ExperimentNode internalNode in scopeBaseMetadata.ComponentGraph.Vertices){
         *                  m_applicationContext.NodeControlFactory.TryGetNodeControl(internalNode, out internalComponentControl) ;
         *                  break;
         *              }
         *              if (internalComponentControl == null)
         *                  return null;
         *                  pad = ExperimentCanvasPadFactory.GetExperimentCanvasPad (m_applicationContext, componentControl);
         *              if (pad == null)
         *                  return null;
         *              pad.ExperimentCanvasWidget.GetPointer(out xMouse, out yMouse);
         *              scopeUp = GetScopeUp(experimentNode, scopeBaseMetadata.ComponentGraph as BaseExperiment, xMouse, yMouse);
         *              if (scopeUp != null)
         *                  return scopeUp;
         *              ScopeNodeControl scopeNodeControl = componentControl as ScopeNodeControl;
         *              if (scopeNodeControl.ContainsPoint (x, y))
         *                  return node as ScopeNodeBase;
         *          }
         *  return null;
         * }
         */
        // END HERZUM SPRINT 2.3 TLAB-60


        public override ITool CreateFigureTool(IPrimaryToolDelegator mainTool, IDrawingEditor editor,
                                               ITool defaultTool, MouseEvent ev)
        {
            DragTool dragTool = defaultTool as DragTool;

            if (dragTool != null)
            {
                //when drag is completed update model data
                dragTool.DragCompleted += (object sender, EventArgs e) =>
                {
                    this.ExperimentNode.Data.X = this.DisplayBox.X;
                    this.ExperimentNode.Data.Y = this.DisplayBox.Y;

                    // HERZUM SPRINT 2.3 TLAB-60
                    int           xMouse    = 0;
                    int           yMouse    = 0;
                    ScopeNodeBase scopeNode = GetScopeUp(ExperimentNode, ExperimentNode.Owner as BaseExperiment, ExperimentNode.Data.X, ExperimentNode.Data.Y);
                    if (scopeNode != null)
                    {
                        ScopeBaseMetadata   scopeBaseMetadata = scopeNode.Data.Metadata as ScopeBaseMetadata;
                        BaseExperiment      experimentTarget  = scopeBaseMetadata.ComponentGraph;
                        BasicNodeControl    componentControl  = null;
                        ExperimentCanvasPad pad = null;
                        foreach (ExperimentNode node in scopeBaseMetadata.ComponentGraph.Vertices)
                        {
                            m_applicationContext.NodeControlFactory.TryGetNodeControl(node, out componentControl);
                            break;
                        }
                        if (componentControl != null)
                        {
                            pad = ExperimentCanvasPadFactory.GetExperimentCanvasPad(m_applicationContext, componentControl);
                        }

                        if (pad != null)
                        {
                            pad.ExperimentCanvasWidget.GetPointer(out xMouse, out yMouse);
                            // HERZUM SPRINT 2.4 TLAB-56 TLAB-57 TLAB-58 TLAB-59 CLASS
                            //TraceLab.Core.Experiments.Clipboard.Cut(ExperimentNode.Owner as BaseExperiment);
                            //TraceLab.Core.Experiments.Clipboard.Paste(experimentTarget,xMouse,yMouse);

                            DragClipboard.Cut(m_applicationContext, ExperimentNode.Owner as BaseExperiment);
                            DragClipboard.Paste(m_applicationContext, experimentTarget, xMouse, yMouse);
                            // END HERZUM SPRINT 2.4 TLAB-56 TLAB-57 TLAB-58 TLAB-59 CLASS
                            pad.DisplayAddedSubgraph(experimentTarget);
                        }
                    }
                    // END HERZUM SPRINT 2.3 TLAB-60
                };
            }
            return(base.CreateFigureTool(mainTool, editor, defaultTool, ev));
        }
Esempio n. 7
0
 private void ConstructGraphFromSelectedScopeNodes(CompositeComponentGraph experiment)
 {
     if (experiment == null)
     {
         return;
     }
     CompositeComponentGraph.CopyAndAdd(CompositeComponentGraph.ConstructGraphFromSelectedNodes(experiment), 200.0, 200.0);
     foreach (ExperimentNode node in experiment.Vertices)
     {
         if (!node.IsSelected)
         {
             ScopeBaseMetadata scopeBaseMetadata = node.Data.Metadata as ScopeBaseMetadata;
             if (scopeBaseMetadata != null && scopeBaseMetadata.ComponentGraph != null)
             {
                 ConstructGraphFromSelectedScopeNodes(scopeBaseMetadata.ComponentGraph);
             }
         }
     }
 }
Esempio n. 8
0
        private void SetComboBoxAction()
        {
            fillSelectComboBox();
            fillLoadComboBox();

            DecisionControl.ExperimentNode.Owner.EdgeAdded += (ExperimentNodeConnection e) => {
                fillSelectComboBox();
                fillLoadComboBox();
            };

            DecisionControl.ExperimentNode.Owner.EdgeRemoved += (ExperimentNodeConnection e) => {
                fillSelectComboBox();
                fillLoadComboBox();
            };

            m_applicationContext.Application.Experiment.VertexAdded += (ExperimentNode vertex) => {
                fillSelectComboBox();
                fillLoadComboBox();
            };

            m_applicationContext.Application.Experiment.VertexRemoved += (ExperimentNode vertex) => {
                fillSelectComboBox();
                fillLoadComboBox();
            };

            foreach (ExperimentNode node in m_applicationContext.Application.Experiment.Vertices)
            {
                ScopeNodeBase scopeNode = node as ScopeNodeBase;
                if (scopeNode != null)
                {
                    ScopeBaseMetadata scopeMetadata = scopeNode.Data.Metadata as ScopeBaseMetadata;
                    scopeMetadata.ComponentGraph.VertexAdded += (ExperimentNode vertex) => {
                        fillLoadComboBox();
                        fillSelectComboBox();
                    };

                    scopeMetadata.ComponentGraph.VertexRemoved += (ExperimentNode vertex) => {
                        fillLoadComboBox();
                        fillSelectComboBox();
                    };
                }
            }
        }
Esempio n. 9
0
        // HERZUM SPRINT 1.0
        // HERZUM SPRINT 1.0 CANVAS da commentare la routine
        public override void CompositeComponentNoSelected(BasicNodeControl focusControl)  {

            base.CompositeComponentNoSelected (focusControl);
            var metadata = this.ExperimentNode.Data.Metadata;
            ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata;          
            if(scopeMetadata.ComponentGraph != null)
            {
                BasicNodeControl componentControl;
                foreach (ExperimentNode node in scopeMetadata.ComponentGraph.Vertices)
                    if (m_applicationContext.NodeControlFactory.TryGetNodeControl (node, out componentControl)){
                        // HERZUM SPRINT 2.0 TLAB-136-2
                        // if (!componentControl.Equals(focusControl)){                            
                            // m_scopeCanvasWidget.ExperimentCanvas.View.RemoveFromSelection(componentControl);
                        componentControl.CompositeComponentNoSelected (focusControl);                            
                        // }
                    // END HERZUM SPRINT 2.0 TLAB-136-2TLAB-136-2
                        
                     }
             }

         }
Esempio n. 10
0
        // END HERZUM SPRINT 2.3 TLAB-56 TLAB-57 TLAB-58 TLAB-59

        // HERZUM SPRINT 2.5: TLAB-173
        public static void RemoveSubExperimentCanvasPad(ApplicationContext applicationContext, BasicNodeControl basicNodeControl)
        {
            IExperiment       experiment    = null;
            ScopeBaseMetadata scopeMetadata = basicNodeControl.ExperimentNode.Data.Metadata as ScopeBaseMetadata;

            if (scopeMetadata != null)
            {
                experiment = scopeMetadata.ComponentGraph.GetExperiment();
            }

            if (basicNodeControl is CommentNodeControl)
            {
                if (m_mapIdToNodes.ContainsKey(applicationContext.GetHashCode() + basicNodeControl.ExperimentNode.Owner.ExperimentInfo.Id))
                {
                    m_mapIdToNodes.Remove(applicationContext.GetHashCode() + basicNodeControl.ExperimentNode.Owner.ExperimentInfo.Id);
                }
                return;
            }
            m_mapPadToNodes.Remove(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id);
            m_mapIdToNodes.Remove(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id);
        }
Esempio n. 11
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. 12
0
        // END HERZUM SPRINT 5.0: TLAB-235

        // HERZUM SPRINT 1.1 LOOP
        protected void DrawScope (String start, String end){

            var metadata = this.ExperimentNode.Data.Metadata;
            ScopeBaseMetadata scopeMetadata = metadata as ScopeBaseMetadata;

            //componentGraph might be null if component metadata definition is not existing in the library 
            if(scopeMetadata.ComponentGraph != null)
            {
                // HERZUM SPRINT 1.1 CANVAS
                // return;
                // END HERZUM SPRINT 1.1 CANVAS

                if (m_scopeCanvasWidget == null)
                {
                    // HERZUM SPRINT 1.0
                    //scopeCanvasPad = new ExperimentCanvasPad(m_applicationContext);
                    //scopeCanvasPad = new  ScopeCanvasPad(m_applicationContext);
                    // END HERZUM SPRINT 1.0

                    //HERZUM SPRINT 2.0 TLAB-136
                    scopeCanvasPad = ExperimentCanvasPadFactory.CreateExperimentCanvasPad (m_applicationContext,this);
                    //END HERZUM SPRINT 2.0 TLAB-136

                    DockFrame m_dockFrame = new DockFrame();
                    Gdk.WindowAttr attributes = new Gdk.WindowAttr();
                    attributes.WindowType = Gdk.WindowType.Child;

                    attributes.X = 100;
                    attributes.Y = 100;
                    attributes.Width = 100;
                    attributes.Height = 100;    

                    Gdk.WindowAttributesType mask = WindowAttributesType.X | WindowAttributesType.Y;
                    m_dockFrame.GdkWindow = new Gdk.Window(null, attributes, (int) mask);
                    scopeCanvasPad.Initialize (m_dockFrame);

                    
                    // HERZUM SPRINT 2.2 TLAB-101 TLAB-102
                    foreach (ExperimentNode node in scopeMetadata.ComponentGraph.GetExperiment().Vertices)
                    {
                        if (node is ExperimentStartNode)
                            // HERZUM SPRINT 5.0: TLAB-235
                            // node.Data.Metadata.Label = "Start";
                            node.Data.Metadata.Label = start;
                        // END HERZUM SPRINT 5.0: TLAB-235

                        if (node is ExperimentEndNode)
                        {
                            // HERZUM SPRINT 5.0: TLAB-235
                            // node.Data.Metadata.Label = "End";
                            node.Data.Metadata.Label = end;
                            // END HERZUM SPRINT 5.0: TLAB-235

                            //HERZUM SPRINT 2.4 TLAB-158
                            // HERZUM SPRINT 5.0: TLAB-235
                            if (scopeMetadata.ComponentGraph.GetExperiment().StartNode.Data.X == 0 && 
                                scopeMetadata.ComponentGraph.GetExperiment().StartNode.Data.Y == 0 &&
                                scopeMetadata.ComponentGraph.GetExperiment().EndNode.Data.X == 0 && 
                                scopeMetadata.ComponentGraph.GetExperiment().EndNode.Data.Y == 0)
                            // END HERZUM SPRINT 5.0: TLAB-235
                                //HERZUM SPRINT 5.3 TLAB-185
                                    node.Data.Y =+ 110;
                               //END HERZUM SPRINT 5.3 TLAB-185
                            //END HERZUM SPRINT 2.4 TLAB-158
                        }
                    }
                    // END HERZUM SPRINT 2.2 TLAB-101 TLAB-102

                    // HERZUM SPRINT 1.0
                    scopeCanvasPad.SetScopeApplicationModel(this, m_applicationContext.Application, scopeMetadata.ComponentGraph);
                    // scopeCanvasPad.SetScopeApplicationModel(m_applicationContext.Application, scopeMetadata.ComponentGraph);
                    // END HERZUM SPRINT 1.0


                    // HERZUM SPRINT 1.0
                    //m_scopeCanvasWidget = scopeCanvasPad.ScopeCanvasWidget;
                    m_scopeCanvasWidget = scopeCanvasPad.ExperimentCanvasWidget;
                    m_scopeCanvasWidget.DestroyVbox1();
                    // END HERZUM SPRINT 1.0

                }

                // HERZUM SPRINT 2.1
                // m_applicationContext.MainWindow.ExperimentCanvasPad.ScopeNodeControlCurrent = this;
                // END HERZUM SPRINT 2.1


                
                //HERZUM SPRINT 2.0 TLAB-136
                ecp = ExperimentCanvasPadFactory.GetExperimentCanvasPad (m_applicationContext, this);
                //END HERZUM SPRINT 2.0 TLAB-136

                valueZoom = ecp.ExperimentCanvasWidget.ExperimentCanvas.View.Scale;

                if (!nodeCreated)
                {

                    xCur=rect.X;
                    yCur=rect.Y;

                    //PRINT 1.2 TLAB-133
                    //HERZUM SPRINT 2.0 TLAB-136
                    // HERZUM SPRINT 2.4: TLAB-156
                    offsetPanX =  ecp.ExperimentCanvasWidget.OffsetPanX;
                    offsetPanY= ecp.ExperimentCanvasWidget.OffsetPanY;

                    // HERZUM SPRINT 5.3: TLAB-185
                    //ecp.DisplayScope (m_scopeCanvasWidget, rect.X+1+offsetPanX, rect2.Y2+1+offsetPanY); 
                    //ecp.DisplayScope (m_scopeCanvasWidget, rect.X+edgeBorder+offsetPanX, rect2.Y2+edgeBorder+offsetPanY); 
                    ecp.DisplayScope (m_scopeCanvasWidget, (int)((rect.X+edgeBorder+offsetPanX)*valueZoom), (int)((rect2.Y2+edgeBorder+offsetPanY)*valueZoom)); 
                    // END HERZUM SPRINT 5.3: TLAB-185

                    // END HERZUM SPRINT 2.4: TLAB-156
                    //END HERZUM SPRINT 2.0 TLAB-136
                    //END HERZUM SPRINT 1.2 TLAB-133

                    m_scopeCanvasWidget.Show();
                    nodeCreated=true;
                } 

                else if (xCur!=rect.X  ||  yCur!=rect.Y) 
                { 
                    //HERZUM SPRINT 1.2 TLAB-133
                    //HERZUM SPRINT 2.0 TLAB-136

                    //HERZUM SPRINT 2: TLAB-156
                    if (valueZoom==zoomPrevious && valueZoom==1)
                        // HERZUM SPRINT 2.4: TLAB-156
                        // HERZUM SPRINT 5.3: TLAB-185
                        //ecp.MoveScope (m_scopeCanvasWidget, rect.X+1+offsetPanX, rect2.Y2+1+offsetPanY);
                        ecp.MoveScope (m_scopeCanvasWidget, rect.X+edgeBorder+offsetPanX, rect2.Y2+edgeBorder+offsetPanY);
                        // END HERZUM SPRINT 5.3: TLAB-185
                        // END HERZUM SPRINT 2.4: TLAB-156
                    //END HERZUM SPRINT 2: TLAB-156

                    //END HERZUM SPRINT 2.0 TLAB-136

                    xCur=rect.X;
                    yCur=rect.Y;

                    //HERZUM SPRINT 2.0 TLAB-135
                    if (IconisationForced)
                    { 
                        NormalizeScope ();
                        IconisationForced = false;
                    } 

                    OverlayScope (m_applicationContext);
                    //END HERZUM SPRINT 2.0 TLAB-135

                } 


                //HERZUM SPRINT 1.2 TLAB-133
                ResizeCanvasWidget ();
                //END HERZUM SPRINT 1.2 TLAB-133

            }

            if (firstDrawScope)
                if (stateWidget=="max")
                { 
                    MaximizeScope();
                    PaddingBottom = PaddingBottom - 20;
                }
                else if (stateWidget=="iconized")
                    IconizeScope();

            if (stateWidget=="iconized")
                m_scopeCanvasWidget.Hide();

            //HERZUM SPRINT 2.0 TLAB-135
            if (firstDrawScope)
            { 
                OverlayScope (m_applicationContext);
                firstDrawScope=false;
            }
            //END HERZUM SPRINT 2.0 TLAB-135


            //HERZUM SPRINT 2.0 TLAB-135
            if (IsResize)
            { 
                OverlayScope (m_applicationContext);
                IsResize=false;
            }
            //END HERZUM SPRINT 2.0 TLAB-135   


            //HERZUM SPRINT 2: TLAB-156
            valueZoom = ecp.ExperimentCanvasWidget.ExperimentCanvas.View.Scale;
            m_scopeCanvasWidget.ExperimentCanvas.View.Scale = valueZoom;   
            SetZoom (valueZoom);
            //HERZUM END SPRINT 2: TLAB-156

            
            // HERZUM SPRINT 2.4: TLAB-156
            //HERZUM SPRINT 5.5 TLAB-216
            point = ecp.ExperimentCanvasWidget.ExperimentCanvas.View.DrawingToView ((int)rect.X / valueZoom, (int)rect2.Y2 / valueZoom);
            offsetPanX = (point.X - rect.X) / valueZoom;
            offsetPanY = (point.Y - rect2.Y - 30) / valueZoom;
            //END HERZUM SPRINT 5.5 TLAB-216 
            if (ecp.ExperimentCanvasWidget.IsPanToolButtonActive ()) {
                //point = ecp.ExperimentCanvasWidget.ExperimentCanvas.View.DrawingToView ((int)rect.X / valueZoom, (int)rect2.Y2 / valueZoom);
                //offsetPanX = (point.X - rect.X) / valueZoom;
                //offsetPanY = (point.Y - rect2.Y - 30) / valueZoom;
                if (valueZoom == 1)
                    // HERZUM SPRINT 5.3: TLAB-185
                    //ecp.MoveScope (m_scopeCanvasWidget, point.X + 1, point.Y);
                    ecp.MoveScope (m_scopeCanvasWidget, point.X + edgeBorder, point.Y + edgeBorder);              
                   // END HERZUM SPRINT 5.3: TLAB-185
            } 
            // END HERZUM SPRINT 2.4: TLAB-156
              

        }
Esempio n. 13
0
        public void CopyAndAdd(CompositeComponentGraph subExperiment, double x, double y, bool first)
        {
            if (subExperiment == null)
            {
                return;
            }

            if (subExperiment.IsVerticesEmpty)
            {
                return;
            }

            bool   firstNode = true;
            double minX      = 0;
            double minY      = 0;
            double offsetX   = 0;
            double offsetY   = 0;

            if (first)
            {
                foreach (ExperimentNode node in subExperiment.Vertices)
                {
                    // HERZUM SPRINT 2.6 TLAB-175
                    // if (node.ID != "Start" && node.ID != "End"){
                    if ((node.ID != "Start" && node.ID != "End") && !(first && (node is ExperimentStartNode || node is ExperimentEndNode)))
                    {
                        // END HERZUM SPRINT 2.6 TLAB-175
                        if (firstNode)
                        {
                            minX      = node.Data.X;
                            minY      = node.Data.Y;
                            firstNode = false;
                        }
                        else
                        {
                            if (node.Data.X < minX)
                            {
                                minX = node.Data.X;
                            }
                            if (node.Data.Y < minY)
                            {
                                minY = node.Data.Y;
                            }
                        }
                    }
                }
            }

            offsetX = x - minX;
            offsetY = y - minY;

            //keep lookup from original node to its clone for later edge reproduction
            Dictionary <ExperimentNode, ExperimentNode> clonedNodeLookup = new Dictionary <ExperimentNode, ExperimentNode>();

            // Clone vertices and add them to the composite component graph
            foreach (ExperimentNode node in subExperiment.Vertices)
            {
                // HERZUM SPRINT 2.6 TLAB-175
                // if (node.ID != "Start" && node.ID != "End")
                if ((node.ID != "Start" && node.ID != "End") && !(first && (node is ExperimentStartNode || node is ExperimentEndNode)))
                // END HERZUM SPRINT 2.6 TLAB-175
                {
                    var clonedNode = node.Clone();
                    clonedNode.ID = Guid.NewGuid().ToString();
                    SetLogLevelSettings(clonedNode, Settings);
                    clonedNodeLookup[node] = clonedNode;

                    clonedNode.Owner = this;

                    if (first)
                    {
                        clonedNode.Data.X = clonedNode.Data.X + offsetX;
                        clonedNode.Data.Y = clonedNode.Data.Y + offsetY;
                    }

                    AddVertex(clonedNode);

                    ScopeBaseMetadata scopeBaseMetadata       = node.Data.Metadata as ScopeBaseMetadata;
                    ScopeBaseMetadata clonedScopeBaseMetadata = clonedNode.Data.Metadata as ScopeBaseMetadata;
                    if ((scopeBaseMetadata != null && clonedScopeBaseMetadata != null) &&
                        (scopeBaseMetadata.ComponentGraph != null))
                    {
                        clonedScopeBaseMetadata.ComponentGraph.Clear();
                        clonedScopeBaseMetadata.ComponentGraph.GetExperiment().ExperimentInfo = clonedScopeBaseMetadata.ComponentGraph.GetExperiment().ExperimentInfo.CloneWithNewId();
                        clonedScopeBaseMetadata.ComponentGraph.CopyAndAdd(scopeBaseMetadata.ComponentGraph, x, y, false);
                    }
                }
            }

            // Clone edges
            foreach (ExperimentNodeConnection connection in subExperiment.Edges)
            {
                ExperimentNode cloneSourceNode, cloneTargetNode;

                //add edges only if both source and target nodes has been found in clones lookup
                bool foundSourceNode = clonedNodeLookup.TryGetValue(connection.Source, out cloneSourceNode);
                bool foundTargetNode = clonedNodeLookup.TryGetValue(connection.Target, out cloneTargetNode);
                if (foundSourceNode && foundTargetNode)
                {
                    ExperimentNodeConnection clonedConnection = new ExperimentNodeConnection(Guid.NewGuid().ToString(), cloneSourceNode, cloneTargetNode, connection.IsFixed, connection.IsVisible);
                    //copy also all route points
                    clonedConnection.RoutePoints.CopyPointsFrom(connection.RoutePoints);
                    AddEdge(clonedConnection);

                    //special case - fix scope node references
                    ScopeNodeHelper.TryFixScopeDecisionEntryAndExitNodes(cloneSourceNode, cloneTargetNode);
                }
            }

            // HERZUM SPRINT 2.4 TLAB-56 TLAB-57 TLAB-58 TLAB-59
            if (first)
            {
                if (subExperiment.References != null)
                {
                    References = subExperiment.References.CopyCollection();
                }
            }
            // HERZUM SPRINT 2.4 TLAB-56 TLAB-57 TLAB-58 TLAB-59

            // Do deep copy of errors.
            this.m_errors = new ObservableDictionary <ExperimentNode, ExperimentNodeError>();
            foreach (KeyValuePair <ExperimentNode, ExperimentNodeError> pair in m_errors)
            {
                m_errors[clonedNodeLookup[pair.Key]] = new ExperimentNodeError(pair.Value.ErrorMessage, pair.Value.ErrorType);
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Creates the scope nested workspace wrapper.
        /// It is specifc workspace wrapper, that uses the composite node namespace to store and load items. It pass loading and storing to its
        /// workspace instance, but with added namespace.
        /// It also has method to setup and teardown workspace units from and to nested workspace.
        /// </summary>
        /// <param name="compositeComponentMetadata">The composite component metadata.</param>
        /// <param name="workspaceInstance">The workspace instance.</param>
        /// <param name="workspaceNamespaceId">The workspace namespace id.</param>
        /// <returns></returns>
        public static ScopeNestedWorkspaceWrapper CreateCompositeComponentWorkspaceWrapper(ScopeBaseMetadata scopeMetadata, IWorkspaceInternal workspaceInstance, string workspaceNamespaceId, AppDomain componentsAppDomain)
        {
            var type = typeof(ScopeNestedWorkspaceWrapper);

            var scopeNestedWorkspaceWrapper = (ScopeNestedWorkspaceWrapper)componentsAppDomain.CreateInstanceAndUnwrap(
                type.Assembly.FullName, type.FullName, false,
                BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.CreateInstance | BindingFlags.Instance, null,
                new object[] { workspaceInstance, workspaceNamespaceId },
                System.Globalization.CultureInfo.CurrentCulture, new object[] { });

            return(scopeNestedWorkspaceWrapper);
        }