/// <summary> /// Performs a deep copy of the data in this object to another instance of the Metadata. /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(Metadata other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); CompositeComponentMetadata metadata = (CompositeComponentMetadata)other; m_IOSpec = metadata.m_IOSpec.Clone(); m_configWrapper = metadata.m_configWrapper.Clone(); m_experimentLocationRoot = metadata.m_experimentLocationRoot; m_compositeComponentMetadataDefinition = metadata.m_compositeComponentMetadataDefinition; m_componentMetadataDefinitionID = metadata.m_componentMetadataDefinitionID; HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } // if composite component was not present in the library, then corresponding component graph may be null. // the deserialization has already set the corresponding error above, nevertheless subgraph cannot be cloned obviously if (HasDeserializationError == false && metadata.m_compositeComponentGraph != null) { m_compositeComponentGraph = (CompositeComponentGraph)(metadata.m_compositeComponentGraph.Clone()); } m_tempConfigWrapper = metadata.m_tempConfigWrapper; m_tempIoSpec = metadata.m_tempIoSpec; m_tempLabel = metadata.m_tempLabel; }
public void OpenComponentGraphFunc(object param) { CompositeComponentGraph componentGraph = param as CompositeComponentGraph; SubLevelExperimentViewModel componentGraphVM = param as SubLevelExperimentViewModel; CompositeComponentNode node = param as CompositeComponentNode; TopLevelExperimentViewModel topLevel = param as TopLevelExperimentViewModel; if (node != null) { componentGraph = node.CompositeComponentMetadata.ComponentGraph; } else if (componentGraphVM != null) { componentGraph = (CompositeComponentGraph)componentGraphVM.GetExperiment(); } BaseLevelExperimentViewModel view = null; if (componentGraph != null) { view = FindSubLevel(componentGraph.GraphIdPath); } else if (topLevel != null) { view = topLevel; } CurrentView = view; }
// HERZUM SPRINT 3.0: TLAB-176 private bool IncludeChallenge(CompositeComponentGraph experiment) { if (experiment == null) { return(false); } foreach (ExperimentNode node in experiment.Vertices) { ChallengeMetadata ch_meta = node.Data.Metadata as ChallengeMetadata; if (ch_meta != null) { // HERZUM SPRINT 3.0: TLAB-176 ExperimentNodeConnection firstInEdge = experiment.InEdge(node, 0); ExperimentNodeConnection firstOutEdge = experiment.OutEdge(node, 0); if (firstInEdge != null && firstInEdge.Source != null && firstOutEdge != null && firstOutEdge.Target != null) { experiment.AddEdge(new ExperimentNodeConnection(Guid.NewGuid().ToString(), firstInEdge.Source, firstOutEdge.Target)); } // END HERZUM SPRINT 3.0: TLAB-176 experiment.RemoveVertex(node); return(true); } CompositeComponentBaseMetadata meta = node.Data.Metadata as CompositeComponentBaseMetadata; if (meta != null) { return(IncludeChallenge(meta.ComponentGraph)); } } return(false); }
public static void Copy(ApplicationContext applicationContext, BaseExperiment originalExperiment) { clipboardComponentGraph = CompositeComponentGraph.ConstructGraphFromSelectedNodes(originalExperiment); foreach (ExperimentNode node in clipboardComponentGraph.Vertices) { node.IsSelected = false; } BasicNodeControl componentControl; foreach (ExperimentNode originalNode in originalExperiment.Vertices) { foreach (ExperimentNode node in clipboardComponentGraph.Vertices) { if (originalNode.ID.Equals(node.ID)) { if (applicationContext.NodeControlFactory.TryGetNodeControl(originalNode, out componentControl)) { node.Data.X = componentControl.DisplayBox.X; node.Data.Y = componentControl.DisplayBox.Y; } } } } }
/// <summary> /// Finds the owner node in the top level experiment, (at the top of the subgraphs hierarchy) of this sublevel component graph. /// Also it sets the node id full path. It contains the id of all the owners node of the subgraphs all the way to the top. /// </summary> private CompositeComponentNode GetTopOwnerNode() { //if the top owner node has not yet been discovered if (m_topOwnerCompositeComponentNode == null) { if (Owner == null) { throw new InvalidOperationException("Application is at invalid state. Sublevel experiment always need to have an owner."); } // if the owner of this sublevel experiment is the top level experiment TopLevelExperimentViewModel topLevel = Owner as TopLevelExperimentViewModel; if (topLevel != null) { // then return this component graph owner node (which is a part of the top level experiment) CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment(); m_topOwnerCompositeComponentNode = componentGraph.OwnerNode; } else { //otherwise recursive to subgraph above this graph, until it finds top level experiment SubLevelExperimentViewModel levelAbove = (SubLevelExperimentViewModel)Owner; m_topOwnerCompositeComponentNode = levelAbove.GetTopOwnerNode(); //in addition, set this component graph node if path. CompositeComponentGraph componentGraph = (CompositeComponentGraph)GetExperiment(); GraphIdPath = componentGraph.OwnerNode.ID; } } return(m_topOwnerCompositeComponentNode); }
/// <summary> /// The converter method returns the ConfigWrapper object for the calling node info. /// If the node belongs to sub level experiment it will replace the config wrapper with references to /// the ConfigPropertyObjects for the given node in the CompositeComponentNode in the top experiment view. /// If the node is already in the top experiment view, it simply returns original config wrapper. /// </summary> /// <param name="value">The value produced by the binding source.</param> /// <param name="targetType">type ConfigWrapper</param> /// <param name="parameter">not used</param> /// <param name="culture">not used</param> /// <returns> /// ConfigWrapper for the calling node info /// </returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { ExperimentNode node = value as ExperimentNode; if (node == null) { throw new InvalidOperationException("Converter cannot accept value that is not of the ExperimentNode type"); } var metadata = (IConfigurableAndIOSpecifiable)node.Data.Metadata; //the default return value is config wrapper itself ConfigWrapper defaultConfigWrapper = metadata.ConfigWrapper; // the config wrapper that is going to be returned ConfigWrapper retConfigWrapper = defaultConfigWrapper; CompositeComponentGraph ownerGraph = node.Owner as CompositeComponentEditableGraph; bool isNodeInScope = (ownerGraph != null); //if node is not in scope (the check is needed, as scope extends composite component, but unlike composite component, it does not need to override config values) if (isNodeInScope == false) { //check if node is in composite component instead ownerGraph = node.Owner as CompositeComponentGraph; //check if node is in the subgraph, and also check if //ownerGraph.OwnerNode as it the top graph might be a composite component - if it is during the process of creating //the composite component bool isNodeInSubgraph = (ownerGraph != null && ownerGraph.OwnerNode != null); if (isNodeInSubgraph) { CompositeComponentNode topCompositeComponentNode = ownerGraph.OwnerNode; string fullNodeId = String.Empty; GetGraphIdPath(topCompositeComponentNode, ref fullNodeId); if (String.IsNullOrEmpty(fullNodeId)) { fullNodeId = node.ID; } else { //otherwise add to already existing path fullNodeId += ":" + node.ID; } CompositeComponentMetadata compositeComponentMetadata = (CompositeComponentMetadata)topCompositeComponentNode.Data.Metadata; ConfigWrapper topConfig = compositeComponentMetadata.ConfigWrapper; //replace the config wrapper retConfigWrapper = topConfig.CreateViewForId(fullNodeId, true); } } return(retConfigWrapper); }
/// <summary> /// Creates sub level view for the given composite component graph. /// SubLevelViewModel represents the view for the breadcrumbs. /// /// Method also collects the sub level into dictionary of sublevel id to its corresponding view model, /// so that when user opens subgraph it can locate coressponging view model. /// </summary> /// <param name="componentGraph">The component graph.</param> /// <param name="subLevelId">The sub level id.</param> /// <param name="parentLevelViewModel">The parent level view model - it may either top level experiment view model, or another sublevel view model.</param> private void CreateSubLevelViewModel(CompositeComponentGraph componentGraph, string subLevelId, BaseLevelExperimentViewModel parentLevelViewModel) { //if it is null the loading failed... and node should be marked with error already if (componentGraph != null) { var subLevel = new SubLevelExperimentViewModel(componentGraph, parentLevelViewModel); m_subLevels.Add(subLevelId, subLevel); AddSubLevels(subLevelId, subLevel); //if the graph is editable graph listen to added node event if (componentGraph is CompositeComponentEditableGraph) { componentGraph.NodeAdded += OnNodeAdded; } } }
private static void PushParents(CompositeComponentGraph graph, List <Crumb> crumbs) { IExperiment parent = graph.OwnerNode.Owner; CompositeComponentGraph graphAbove = parent as CompositeComponentGraph; if (graphAbove != null) { PushParents(graphAbove, crumbs); ExperimentNode ownerNode = graphAbove.OwnerNode; crumbs.Add(new ExperimentCrumb(ownerNode.Data.Metadata.Label, graphAbove)); } else if (parent is Experiment) { crumbs.Add(new ExperimentCrumb(parent.Title, parent)); } }
/// <summary> /// Process excuted once xml deserialization was completed. /// </summary> /// <param name="library">The library.</param> /// <param name="experimentLocationRoot">The experiment location root.</param> public override void PostProcessReadXml(Components.IComponentsLibrary library, string experimentLocationRoot) { m_experimentLocationRoot = experimentLocationRoot; if (m_experimentXml != null) { using (XmlReader reader = XmlReader.Create(new System.IO.StringReader(m_experimentXml))) { var experiment = TraceLab.Core.Experiments.ExperimentSerializer.DeserializeExperiment(reader, library); m_compositeComponentGraph = new Experiments.CompositeComponentEditableGraph(experiment); } //clear variable m_experimentXml = null; } IsInitialized = true; IsModified = false; }
/// <summary> /// Performs a deep copy of the data in this object to another instance of the Metadata. /// </summary> /// <param name="other">The other.</param> protected override void CopyFrom(Metadata other) { if (other == null) { throw new ArgumentNullException("other"); } base.CopyFrom(other); ScopeBaseMetadata metadata = (ScopeBaseMetadata)other; m_experimentLocationRoot = metadata.m_experimentLocationRoot; m_compositeComponentGraph = (CompositeComponentEditableGraph)(metadata.m_compositeComponentGraph.Clone()); HasDeserializationError = metadata.HasDeserializationError; if (HasDeserializationError) { DeserializationErrorMessage = metadata.DeserializationErrorMessage; } }
private static void PushParents(CompositeComponentGraph graph, List <Crumb> crumbs) { IExperiment parent = graph.OwnerNode.Owner; CompositeComponentGraph graphAbove = parent as CompositeComponentGraph; if (graphAbove != null) { PushParents(graphAbove, crumbs); ExperimentNode ownerNode = graphAbove.OwnerNode; // HERZUM SPRINT 2.5: TLAB-173 if (graphAbove.OwnerNode is ScopeNode || graphAbove.OwnerNode is LoopScopeNode || graphAbove.OwnerNode is ChallengeNode) { return; } // END HERZUM SPRINT 2.5: TLAB-173 crumbs.Add(new ExperimentCrumb(ownerNode.Data.Metadata.Label, graphAbove)); } else if (parent is Experiment) { crumbs.Add(new ExperimentCrumb(parent.Title, parent)); } }
// HERZUM SPRINT 1.0 public void SetSubExperiment(CompositeComponentEditableGraph compositeComponentEditableGraph) { m_compositeComponentGraph = compositeComponentEditableGraph; }
/// <summary> /// Initializes the component graph from ComponentMetadataDefinition graph /// </summary> /// <param name="node">The node.</param> /// <param name="settings">The settings.</param> public override void InitializeComponentGraph(CompositeComponentNode node, TraceLab.Core.Settings.Settings settings) { //each composite node gets its own copy of ComponentMetadataDefinition.ComponentGraph m_compositeComponentGraph = new CompositeComponentGraph(node, ComponentMetadataDefinition.ComponentGraph); m_compositeComponentGraph.Settings = settings; }
/// <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(); } } }
// HERZUM SPRINT 2.4 TLAB-157 public static ExperimentCanvasPad CreateCompositeExperimentCanvasPad(ApplicationContext applicationContext, ExperimentCanvasWidget experimentCanvasWidget, CompositeComponentGraph experiment) { ExperimentCanvasPad experimentCanvasPad = null; if (m_mapPadToNodes.TryGetValue(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id, out experimentCanvasPad)) { return(experimentCanvasPad); } else { experimentCanvasPad = new ExperimentCanvasPad(applicationContext); m_mapPadToNodes.Add(applicationContext.GetHashCode() + experiment.ExperimentInfo.Id, experimentCanvasPad); } 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); experimentCanvasPad.Initialize(m_dockFrame); experimentCanvasPad.SetApplicationModel(applicationContext.Application, experimentCanvasWidget, experiment); return(experimentCanvasPad); }
public SubLevelExperimentViewModel(CompositeComponentGraph componentGraph, BaseLevelExperimentViewModel owner) : base(componentGraph, owner) { }