///-------------------------------------------------------------------------------- /// <summary>This method loads specification sources into the view model.</summary> /// /// <param name="solution">The solution to load.</param> ///-------------------------------------------------------------------------------- public void LoadSpecificationSources(Solution solution) { // attach the specification sources Items.Clear(); if (DatabaseSources == null) { DatabaseSources = new EnterpriseDataObjectList <DatabaseSourceViewModel>(); } if (XmlSources == null) { XmlSources = new EnterpriseDataObjectList <XmlSourceViewModel>(); } foreach (DatabaseSource source in solution.DatabaseSourceList) { DatabaseSourceViewModel sourceView = new DatabaseSourceViewModel(source, solution); sourceView.Updated += new EventHandler(Children_Updated); DatabaseSources.Add(sourceView); Items.Add(sourceView); } foreach (XmlSource source in solution.XmlSourceList) { XmlSourceViewModel sourceView = new XmlSourceViewModel(source, solution); sourceView.Updated += new EventHandler(Children_Updated); XmlSources.Add(sourceView); Items.Add(sourceView); } }
///-------------------------------------------------------------------------------- /// <summary>Create the instance with the designer view and other data.</summary> /// /// <param name="solution">The solution to load.</param> /// <param name="node">The node in the model the template is associated with.</param> ///-------------------------------------------------------------------------------- public SpecTemplatesViewModel(Solution solution, string node, string specificationDirectory = null, string folderName = null) { TemplateModelNode = node; SpecificationDirectory = specificationDirectory; Solution = solution; if (SpecTemplates == null) { SpecTemplates = new EnterpriseDataObjectList <SpecTemplateViewModel>(); } switch (TemplateModelNode) { case "Solution": Name = Resources.DisplayValues.NodeName_SpecTemplates; // load templates from each unique specification directory LoadSpecDirectories(); break; case "SpecificationSource": if (!String.IsNullOrEmpty(folderName)) { Name = folderName; } else { Name = Resources.DisplayValues.NodeName_SpecTemplates; } LoadTemplateDirectories(); break; default: Name = Resources.DisplayValues.NodeName_SpecTemplates; break; } }
///-------------------------------------------------------------------------------- /// <summary>Create the instance with the designer view and other data.</summary> /// /// <param name="solutionDiagram">The solution diagram to load.</param> /// <param name="entities">The solution entities that could be added to the diagram.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating if child information should be loaded.</param> ///-------------------------------------------------------------------------------- public DiagramViewModel(Diagram solutionDiagram, EnterpriseDataObjectList <EntityViewModel> entities, Solution solution, bool loadChildren = true) { Entities = new EnterpriseDataObjectList <EntityViewModel>(); if (entities != null) { foreach (EntityViewModel entity in entities) { if (loadChildren == true) { Entities.Add(new EntityViewModel(entity.Entity, solution, loadChildren)); } else { Entities.Add(entity); } } } else { foreach (Entity entity in solution.EntityList) { Entities.Add(new EntityViewModel(entity, solution, loadChildren)); } } WorkspaceID = Guid.NewGuid(); Solution = solution; DiagramEntities = new EnterpriseDataObjectList <DiagramEntityViewModel>(); DiagramRelationships = new EnterpriseDataObjectList <DiagramRelationshipViewModel>(); LoadDiagram(solutionDiagram); DiagramEntities.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(DiagramEntities_CollectionChanged); DiagramRelationships.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(DiagramRelationships_CollectionChanged); }
///-------------------------------------------------------------------------------- /// <summary>This method loads an item of Feature into the view model.</summary> /// /// <param name="feature">The Feature to load.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadFeature(Feature feature, bool loadChildren = true) { // attach the Feature Feature = feature; ItemID = Feature.FeatureID; Items.Clear(); // initialize Entities if (Entities == null) { Entities = new EnterpriseDataObjectList <EntityViewModel>(); } if (loadChildren == true) { // attach Entities foreach (Entity item in feature.EntityList) { EntityViewModel itemView = new EntityViewModel(item, Solution); itemView.Updated += new EventHandler(Children_Updated); Entities.Add(itemView); Items.Add(itemView); } #region protected #endregion protected Refresh(false); } }
///-------------------------------------------------------------------------------- /// <summary>This method loads an item of ModelData into the view model.</summary> /// /// <param name="model">The Model to load.</param> /// <param name="solution">The Solution to load.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadModelData(Model model, Solution solution, bool loadChildren = true) { // attach the model data Model = model; Solution = solution; ItemID = Model.ModelID; Items.Clear(); if (loadChildren == true) { // attach ModelObjectDataItems if (ModelObjectDataItems == null) { ModelObjectDataItems = new EnterpriseDataObjectList <ModelObjectDataViewModel>(); foreach (ModelObject loopObject in model.ModelObjectList) { if (loopObject.ParentModelObjectID == null) { ModelObjectDataViewModel modelObjectDataViewModel = new ModelObjectDataViewModel(model, loopObject, null, solution, loadChildren); modelObjectDataViewModel.Updated += new EventHandler(Children_Updated); ModelObjectDataItems.Add(modelObjectDataViewModel); Items.Add(modelObjectDataViewModel); } } } #region protected #endregion protected Refresh(false); } }
///-------------------------------------------------------------------------------- /// <summary>Create the instance with the designer view and other data.</summary> /// /// <param name="propertyInstances">The PropertyInstance items to load.</param> /// <param name="modelProperty">The model property.</param> /// <param name="objectInstanceViewModel">The associated object instance view model.</param> /// <param name="solution">The associated solution.</param> ///-------------------------------------------------------------------------------- public PropertyCollectionItemViewModel(EnterpriseDataObjectList <PropertyInstanceViewModel> propertyInstances, ModelProperty modelProperty, ObjectInstanceViewModel objectInstanceViewModel, Solution solution) { WorkspaceID = Guid.NewGuid(); Solution = solution; PropertyInstances = propertyInstances; ObjectInstanceViewModel = objectInstanceViewModel; ModelProperty = modelProperty; }
///-------------------------------------------------------------------------------- /// <summary>This method loads Solutions into the view model.</summary> /// ///-------------------------------------------------------------------------------- public void LoadSolutions() { // attach the items Items.Clear(); if (Solutions == null) { Solutions = new EnterpriseDataObjectList <SolutionViewModel>(); } }
///-------------------------------------------------------------------------------- /// <summary>The default constructor (for reflection, etc.).</summary> /// /// <param name="entities">The solution entities that could be added to the diagram.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether child information should be loaded.</param> ///-------------------------------------------------------------------------------- public DiagramsViewModel(EnterpriseDataObjectList <EntityViewModel> entities, Solution solution, bool loadChildren = true) { Name = Resources.DisplayValues.NodeName_SolutionDiagrams; Entities = entities; Solution = solution; if (loadChildren == true) { LoadDiagrams(entities, solution, loadChildren); } }
///-------------------------------------------------------------------------------- /// <summary>This method refreshes the set of Properties.</summary> ///-------------------------------------------------------------------------------- public void RefreshProperties() { if (Solution != null) { ReferencedPropertyIDItems = new EnterpriseDataObjectList <Property>((from p in Solution.PropertyList where p.EntityID == ReferencedEntityID select p).ToList <Property>()); OnPropertyChanged("ReferencedPropertyIDItems"); OnPropertyChanged("ReferencedPropertyID"); } }
///-------------------------------------------------------------------------------- /// <summary>This method refreshes the set of Properties.</summary> ///-------------------------------------------------------------------------------- public void RefreshValues() { if (Solution != null) { DefinedByValueIDItems = new EnterpriseDataObjectList <Value>((from v in Solution.ValueList where v.EnumerationID == DefinedByEnumerationID select v).ToList <Value>(), false); DefinedByValueIDItems.Insert(0, new Value()); OnPropertyChanged("DefinedByValueIDItems"); OnPropertyChanged("DefinedByValueID"); } }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Solutions != null) { foreach (SolutionViewModel itemView in Solutions) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Solutions.Clear(); Solutions = null; } base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Diagrams != null) { foreach (DiagramViewModel itemView in Diagrams) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Diagrams.Clear(); Diagrams = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Projects != null) { foreach (ProjectViewModel itemView in Projects) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Projects.Clear(); Projects = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (AuditProperties != null) { foreach (AuditPropertyViewModel itemView in AuditProperties) { itemView.Updated -= Children_Updated; itemView.Dispose(); } AuditProperties.Clear(); AuditProperties = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Models != null) { foreach (ModelViewModel itemView in Models) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Models.Clear(); Models = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Features != null) { foreach (FeatureViewModel itemView in Features) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Features.Clear(); Features = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (XmlSources != null) { foreach (XmlSourceViewModel itemView in XmlSources) { itemView.Updated -= Children_Updated; itemView.Dispose(); } XmlSources.Clear(); XmlSources = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (CodeTemplates != null) { foreach (CodeTemplateViewModel itemView in CodeTemplates) { itemView.Updated -= Children_Updated; itemView.Dispose(); } CodeTemplates.Clear(); CodeTemplates = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method disposes of resources in the view model.</summary> ///-------------------------------------------------------------------------------- protected override void OnDispose() { if (Workflows != null) { foreach (WorkflowViewModel itemView in Workflows) { itemView.Updated -= Children_Updated; itemView.Dispose(); } Workflows.Clear(); Workflows = null; } Solution = null; base.OnDispose(); }
///-------------------------------------------------------------------------------- /// <summary>This method loads Properties into the view model.</summary> /// /// <param name="entity">The entity to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadProperties(Entity entity, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Properties == null) { Properties = new EnterpriseDataObjectList <PropertyViewModel>(); } if (loadChildren == true) { foreach (Property item in entity.PropertyList) { PropertyViewModel itemView = new PropertyViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Properties.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads ModelObjects into the view model.</summary> /// /// <param name="model">The model to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadModelObjects(Model model, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (ModelObjects == null) { ModelObjects = new EnterpriseDataObjectList <ModelObjectViewModel>(); } if (loadChildren == true) { foreach (ModelObject item in model.ModelObjectList) { ModelObjectViewModel itemView = new ModelObjectViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); ModelObjects.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads CodeTemplates into the view model.</summary> /// /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadCodeTemplates(Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (CodeTemplates == null) { CodeTemplates = new EnterpriseDataObjectList <CodeTemplateViewModel>(); } if (loadChildren == true) { foreach (CodeTemplate item in solution.CodeTemplateList) { CodeTemplateViewModel itemView = new CodeTemplateViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); CodeTemplates.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads Diagrams into the view model.</summary> /// /// <param name="entities">The solution entities that could be added to the diagram.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadDiagrams(EnterpriseDataObjectList <EntityViewModel> entities, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Diagrams == null) { Diagrams = new EnterpriseDataObjectList <DiagramViewModel>(); } if (loadChildren == true) { foreach (Diagram item in solution.DiagramList) { DiagramViewModel itemView = new DiagramViewModel(item, entities, solution); itemView.Updated += new EventHandler(Children_Updated); Diagrams.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads XmlSources into the view model.</summary> /// /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadXmlSources(Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (XmlSources == null) { XmlSources = new EnterpriseDataObjectList <XmlSourceViewModel>(); } if (loadChildren == true) { foreach (XmlSource item in solution.XmlSourceList) { XmlSourceViewModel itemView = new XmlSourceViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); XmlSources.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads Methods into the view model.</summary> /// /// <param name="entity">The entity to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadMethods(Entity entity, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Methods == null) { Methods = new EnterpriseDataObjectList <MethodViewModel>(); } if (loadChildren == true) { foreach (Method item in entity.MethodList) { MethodViewModel itemView = new MethodViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Methods.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads Steps into the view model.</summary> /// /// <param name="stage">The stage to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadSteps(Stage stage, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Steps == null) { Steps = new EnterpriseDataObjectList <StepViewModel>(); } if (loadChildren == true) { foreach (Step item in stage.StepList) { StepViewModel itemView = new StepViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Steps.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads Workflows into the view model.</summary> /// /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadWorkflows(Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Workflows == null) { Workflows = new EnterpriseDataObjectList <WorkflowViewModel>(); } if (loadChildren == true) { foreach (Workflow item in solution.WorkflowList) { WorkflowViewModel itemView = new WorkflowViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Workflows.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads EntityReferences into the view model.</summary> /// /// <param name="entity">The entity to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadEntityReferences(Entity entity, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (EntityReferences == null) { EntityReferences = new EnterpriseDataObjectList <EntityReferenceViewModel>(); } if (loadChildren == true) { foreach (EntityReference item in entity.EntityReferenceList) { EntityReferenceViewModel itemView = new EntityReferenceViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); EntityReferences.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads Relationships into the view model.</summary> /// /// <param name="entity">The entity to load.</param> /// <param name="solution">The associated solution.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadRelationships(Entity entity, Solution solution, bool loadChildren = true) { // attach the items Items.Clear(); if (Relationships == null) { Relationships = new EnterpriseDataObjectList <RelationshipViewModel>(); } if (loadChildren == true) { foreach (Relationship item in entity.RelationshipList) { RelationshipViewModel itemView = new RelationshipViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); Relationships.Add(itemView); Items.Add(itemView); } } }
///-------------------------------------------------------------------------------- /// <summary>This method loads an item of ModelObjectData into the view model.</summary> /// /// <param name="model">The Model to load.</param> /// <param name="modelObject">The ModelObject to load.</param> /// <param name="modelProperty">The ModelProperty to load.</param> /// <param name="objectInstance">The ObjectInstance to load.</param> /// <param name="solution">The Solution to load.</param> /// <param name="loadChildren">Flag indicating whether to perform a deeper load.</param> ///-------------------------------------------------------------------------------- public void LoadModelPropertyData(Model model, ModelObject modelObject, ModelProperty modelProperty, ObjectInstance objectInstance, Solution solution, bool loadChildren = true) { // attach the ModelObject Model = model; ModelObject = modelObject; ModelProperty = modelProperty; ObjectInstance = objectInstance; Solution = solution; ItemID = ModelProperty.ModelPropertyID; Items.Clear(); if (loadChildren == true) { // attach PropertyInstances if (PropertyInstances == null) { PropertyInstances = new EnterpriseDataObjectList <PropertyInstanceViewModel>(); foreach (PropertyInstance item in objectInstance.PropertyInstanceList) { if (item.Solution == null) { // TODO: this is a hack item.Solution = solution; } if (objectInstance == null || item.ModelPropertyID == modelProperty.ModelPropertyID) { PropertyInstanceViewModel itemView = new PropertyInstanceViewModel(item, solution); itemView.Updated += new EventHandler(Children_Updated); PropertyInstances.Add(itemView); Items.Add(itemView); } } } #region protected #endregion protected Refresh(false); } }