/// <summary> /// Method adds the constant fixed definitions into given components defintion collection. /// Currently it adds two definitions, decision and loop. /// </summary> /// <param name="componentsDefinitionCollection">The collection of components definition into which fixed definition are going to be added</param> internal static void LoadConstantDefinitionsIntoLibrary(ObservableComponentDefinitionCollection componentsDefinitionCollection) { DecisionMetadataDefinition decisionMetadataDefinition = BuildDecisionDefinition(); componentsDefinitionCollection.Add(decisionMetadataDefinition); LoopMetadataDefinition loopMetadataDefinition = BuildWhileLoopDefinition(); componentsDefinitionCollection.Add(loopMetadataDefinition); DecisionMetadataDefinition gotoDecisionMetadataDefinition = BuildGoToDecisionDefinition(); componentsDefinitionCollection.Add(gotoDecisionMetadataDefinition); // HERZUM SPRINT 0.0 ScopeMetadataDefinition scopeMetadataDefinition = BuildScopeDefinition(); componentsDefinitionCollection.Add(scopeMetadataDefinition); // HERZUM SPRINT 2.0: TLAB-65 CLASS // ScopeMetadataDefinition challengeScopeMetadataDefinition = BuildChallengeDefinition(); // componentsDefinitionCollection.Add(challengeScopeMetadataDefinition); ChallengeMetadataDefinition challengeMetadataDefinition = BuildChallengeDefinition(); componentsDefinitionCollection.Add(challengeMetadataDefinition); // END HERZUM SPRINT 2.0: TLAB-65 CLASS // END HERZUM 0.0 // HERZUM SPRINT 1.0 CommentMetadataDefinition commentMetadataDefinition = BuildCommentDefinition(); componentsDefinitionCollection.Add(commentMetadataDefinition); // END HERZUM SPRINT 1.0 }
// HERZUM SPRINT 0.0 private static ScopeMetadataDefinition BuildScopeDefinition() { ScopeMetadataDefinition scopeMetadataDefinition = new ScopeMetadataDefinition(ScopeMetadataDefinition.ScopeGuid); scopeMetadataDefinition.Label = "Scope"; scopeMetadataDefinition.Tags.SetTag("Control Structures", false); scopeMetadataDefinition.Description = "Scope provides way of specifying execution paths based on runtime data in the workspace."; return(scopeMetadataDefinition); }
// HERZUM SPRINT 2.0: TLAB-148 internal void AddScopeInDecisionComponent(DecisionNodeControl decisionNodeControl) { double x = 0; IEnumerable<ExperimentNodeConnection> edges = null; IEnumerable<ExperimentNode> vertices = null; if (m_subExperiment != null){ edges = m_subExperiment.Edges; vertices = m_subExperiment.Vertices; } else { edges = m_applicationViewModel.Experiment.Edges; vertices = m_applicationViewModel.Experiment.Vertices; } foreach (ExperimentNodeConnection edge in edges){ if (edge.Source.Equals(decisionNodeControl.ExperimentNode)) if (edge.Target is ScopeNode) if (edge.Target.Data.X > x) x = edge.Target.Data.X; } String label = "Scope"; for (int n=1;; n++) { bool found = false; foreach (ExperimentNodeConnection edge in edges) if (edge.Source.Equals(decisionNodeControl.ExperimentNode)) if (edge.Target is ScopeNode) if (edge.Target.Data.Metadata.Label.Equals("Scope " + n)){ found = true; break; } if (!found){ label = "Scope " + n; break; } } Cairo.PointD translation = m_experimentCanvasWidget.ExperimentCanvas.View.ViewToDrawing(decisionNodeControl.DisplayBox.X, decisionNodeControl.DisplayBox.Y); ScopeMetadataDefinition meta_def = new ScopeMetadataDefinition(ScopeMetadataDefinition.ScopeGuid); meta_def.Label = label; ExperimentNode scopeNode = null; if (m_subExperiment != null) scopeNode = m_subExperiment.AddComponentFromDefinition (meta_def, x + 230, translation.Y + 120); else scopeNode = m_applicationViewModel.Experiment.AddComponentFromDefinition (meta_def, x + 230, translation.Y + 120); TryFixScopeDecisionEntryAndExitNodes (decisionNodeControl.ExperimentNode, scopeNode); m_experimentDrawer.DrawComponent (scopeNode, true); ExperimentNodeConnection new_edge = null; if (m_subExperiment != null) new_edge = m_subExperiment.AddConnection (decisionNodeControl.ExperimentNode, scopeNode); else new_edge = m_applicationViewModel.Experiment.AddConnection (decisionNodeControl.ExperimentNode, scopeNode); m_experimentDrawer.DrawEdge (new_edge, false); ExperimentNode exitNode = null; bool response = false; foreach (ExperimentNode n in vertices) if (n is ExitDecisionNode) { if (m_subExperiment != null) response = m_subExperiment.TryGetEdge (decisionNodeControl.ExperimentNode, n, out new_edge); else response = m_applicationViewModel.Experiment.TryGetEdge (decisionNodeControl.ExperimentNode, n, out new_edge); if (response) { exitNode = n; break; } } if (exitNode != null) { TryFixScopeDecisionEntryAndExitNodes (scopeNode, exitNode); if (m_subExperiment != null) new_edge = m_subExperiment.AddConnection (scopeNode, exitNode); else new_edge = m_applicationViewModel.Experiment.AddConnection (scopeNode, exitNode); m_experimentDrawer.DrawEdge (new_edge, false); } }
// HERZUM SPRINT 0.0 private static ScopeMetadataDefinition BuildScopeDefinition() { ScopeMetadataDefinition scopeMetadataDefinition = new ScopeMetadataDefinition (ScopeMetadataDefinition.ScopeGuid); scopeMetadataDefinition.Label = "Scope"; scopeMetadataDefinition.Tags.SetTag("Control Structures", false); scopeMetadataDefinition.Description = "Scope provides way of specifying execution paths based on runtime data in the workspace."; return scopeMetadataDefinition; }