///-------------------------------------------------------------------------------- /// <summary>This method processes the new spectemplate command.</summary> ///-------------------------------------------------------------------------------- public void ProcessNewSpecTemplateCommand() { SpecTemplateEventArgs message = new SpecTemplateEventArgs(); message.SpecTemplate = new SpecTemplate(); message.SpecTemplate.TemplateID = Guid.NewGuid(); message.SpecTemplate.SolutionID = Solution.SolutionID; message.SpecTemplate.Solution = Solution; message.SolutionID = Solution.SolutionID; message.SpecTemplate.Solution = Solution; message.Solution = Solution; message.WorkspaceID = WorkspaceID; #region protected message.SpecTemplate.SpecificationDirectory = SpecificationDirectory; if (String.IsNullOrEmpty(message.SpecTemplate.SpecificationDirectory)) { message.SpecTemplate.SpecificationDirectory = Solution.SpecTemplatesDirectory; } if (TemplateModelNode == ModelContextTypeCode.Solution.ToString()) { message.SpecTemplate.NodeName = SpecModelContextTypeCode.SpecificationSource.ToString(); } else { ModelContextTypeCode modelContextType = ModelContextTypeCode.None; Enum.TryParse <ModelContextTypeCode>(TemplateModelNode, out modelContextType); if (modelContextType != ModelContextTypeCode.None) { message.SpecTemplate.NodeName = modelContextType.ToString(); } else { SpecModelContextTypeCode specModelContextType = SpecModelContextTypeCode.None; Enum.TryParse <SpecModelContextTypeCode>(TemplateModelNode, out specModelContextType); if (specModelContextType != SpecModelContextTypeCode.None) { message.SpecTemplate.NodeName = specModelContextType.ToString(); } } } #endregion protected Mediator.NotifyColleagues <SpecTemplateEventArgs>(MediatorMessages.Command_EditSpecTemplateRequested, message); }
///-------------------------------------------------------------------------------- /// <summary>This method adds a template to the view models (and tree).</summary> /// /// <param name="template">The template to add.</param> /// <param name="refresh">Flag whether to refresh view.</param> ///-------------------------------------------------------------------------------- public void AddSpecTemplate(SpecTemplateViewModel template, bool refresh = true) { string templateName = String.Empty; ModelContextTypeCode modelContextTypeEnum = ModelContextTypeCode.None; Enum.TryParse <ModelContextTypeCode>(template.SpecTemplate.TemplateType, out modelContextTypeEnum); switch (modelContextTypeEnum) { case ModelContextTypeCode.AuditProperty: templateName = Resources.DisplayValues.NodeName_Templates_AuditProperty; break; case ModelContextTypeCode.Collection: templateName = Resources.DisplayValues.NodeName_Templates_Collection; break; case ModelContextTypeCode.Entity: templateName = Resources.DisplayValues.NodeName_Templates_Entity; break; case ModelContextTypeCode.EntityReference: templateName = Resources.DisplayValues.NodeName_Templates_EntityReference; break; case ModelContextTypeCode.Feature: templateName = Resources.DisplayValues.NodeName_Templates_Feature; break; case ModelContextTypeCode.Index: templateName = Resources.DisplayValues.NodeName_Templates_Index; break; case ModelContextTypeCode.IndexProperty: templateName = Resources.DisplayValues.NodeName_Templates_IndexProperty; break; case ModelContextTypeCode.Method: templateName = Resources.DisplayValues.NodeName_Templates_Method; break; case ModelContextTypeCode.Parameter: templateName = Resources.DisplayValues.NodeName_Templates_Parameter; break; case ModelContextTypeCode.Property: templateName = Resources.DisplayValues.NodeName_Templates_Property; break; case ModelContextTypeCode.PropertyReference: templateName = Resources.DisplayValues.NodeName_Templates_PropertyReference; break; case ModelContextTypeCode.Relationship: templateName = Resources.DisplayValues.NodeName_Templates_Relationship; break; case ModelContextTypeCode.RelationshipProperty: templateName = Resources.DisplayValues.NodeName_Templates_RelationshipProperty; break; case ModelContextTypeCode.Workflow: templateName = Resources.DisplayValues.NodeName_Templates_Workflow; break; case ModelContextTypeCode.Stage: templateName = Resources.DisplayValues.NodeName_Templates_Stage; break; case ModelContextTypeCode.StageTransition: templateName = Resources.DisplayValues.NodeName_Templates_StageTransition; break; case ModelContextTypeCode.Step: templateName = Resources.DisplayValues.NodeName_Templates_Step; break; case ModelContextTypeCode.StepTransition: templateName = Resources.DisplayValues.NodeName_Templates_StepTransition; break; case ModelContextTypeCode.StateModel: templateName = Resources.DisplayValues.NodeName_Templates_StateModel; break; case ModelContextTypeCode.State: templateName = Resources.DisplayValues.NodeName_Templates_State; break; case ModelContextTypeCode.StateTransition: templateName = Resources.DisplayValues.NodeName_Templates_StateTransition; break; default: SpecModelContextTypeCode specModelContextTypeEnum = SpecModelContextTypeCode.None; Enum.TryParse <SpecModelContextTypeCode>(template.SpecTemplate.TemplateType, out specModelContextTypeEnum); switch (specModelContextTypeEnum) { case SpecModelContextTypeCode.SqlColumn: templateName = Resources.DisplayValues.NodeName_Templates_SqlColumn; break; case SpecModelContextTypeCode.SqlDatabase: Name = Resources.DisplayValues.NodeName_Templates_SqlDatabase; break; case SpecModelContextTypeCode.SqlExtendedProperty: templateName = Resources.DisplayValues.NodeName_Templates_SqlExtendedProperty; break; case SpecModelContextTypeCode.SqlForeignKey: templateName = Resources.DisplayValues.NodeName_Templates_SqlForeignKey; break; case SpecModelContextTypeCode.SqlForeignKeyColumn: templateName = Resources.DisplayValues.NodeName_Templates_SqlForeignKeyColumn; break; case SpecModelContextTypeCode.SqlIndex: templateName = Resources.DisplayValues.NodeName_Templates_SqlIndex; break; case SpecModelContextTypeCode.SqlIndexedColumn: templateName = Resources.DisplayValues.NodeName_Templates_SqlIndexedColumn; break; case SpecModelContextTypeCode.SqlProperty: templateName = Resources.DisplayValues.NodeName_Templates_SqlProperty; break; case SpecModelContextTypeCode.SqlTable: templateName = Resources.DisplayValues.NodeName_Templates_SqlTable; break; case SpecModelContextTypeCode.SqlView: templateName = Resources.DisplayValues.NodeName_Templates_SqlView; break; case SpecModelContextTypeCode.SqlViewProperty: templateName = Resources.DisplayValues.NodeName_Templates_SqlViewProperty; break; case SpecModelContextTypeCode.XmlAttribute: templateName = Resources.DisplayValues.NodeName_Templates_XmlAttribute; break; case SpecModelContextTypeCode.XmlDocument: templateName = Resources.DisplayValues.NodeName_Templates_XmlDocument; break; case SpecModelContextTypeCode.XmlNode: templateName = Resources.DisplayValues.NodeName_Templates_XmlNode; break; default: templateName = Resources.DisplayValues.NodeName_SpecTemplates; break; } break; } if (template.SpecTemplate.TemplateType == SpecModelContextTypeCode.SpecificationSource.ToString()) { if (String.IsNullOrEmpty(template.SpecTemplate.CategoryName)) { Items.Add(template); template.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } else { bool foundCategory = false; foreach (SpecTemplatesViewModel folder in Items.OfType <SpecTemplatesViewModel>()) { if (folder.Name == template.SpecTemplate.CategoryName) { folder.AddTemplate(template, refresh); foundCategory = true; } } if (foundCategory == false) { SpecTemplatesViewModel folder = new SpecTemplatesViewModel(Solution, ModelContextTypeCode.None.ToString(), SpecificationDirectory); folder.Name = template.SpecTemplate.CategoryName; folder.AddTemplate(template, refresh); Items.Add(folder); folder.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } } } else { bool foundFolder = false; foreach (SpecTemplatesViewModel folder in Items.OfType <SpecTemplatesViewModel>()) { if (folder.Name == templateName) { folder.AddTemplate(template, refresh); foundFolder = true; } } if (foundFolder == false) { SpecTemplatesViewModel folder = new SpecTemplatesViewModel(Solution, template.SpecTemplate.TemplateType, SpecificationDirectory); folder.Name = templateName; folder.AddTemplate(template, refresh); Items.Add(folder); folder.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } } }
///-------------------------------------------------------------------------------- /// <summary>This method adds a template to the view models (and tree).</summary> /// /// <param name="template">The template to add.</param> /// <param name="refresh">Flag whether to refresh view.</param> ///-------------------------------------------------------------------------------- public void AddTemplate(CodeTemplateViewModel template, bool refresh = true) { ModelContextTypeCode modelContextTypeEnum = ModelContextTypeCode.None; Enum.TryParse <ModelContextTypeCode>(template.CodeTemplate.TemplateType, out modelContextTypeEnum); switch (TemplateModelNode) { case "Solution": string templateName = String.Empty; switch (modelContextTypeEnum) { case ModelContextTypeCode.AuditProperty: templateName = Resources.DisplayValues.NodeName_Templates_AuditProperty; break; case ModelContextTypeCode.Collection: templateName = Resources.DisplayValues.NodeName_Templates_Collection; break; case ModelContextTypeCode.Entity: templateName = Resources.DisplayValues.NodeName_Templates_Entity; break; case ModelContextTypeCode.EntityReference: templateName = Resources.DisplayValues.NodeName_Templates_EntityReference; break; case ModelContextTypeCode.Feature: templateName = Resources.DisplayValues.NodeName_Templates_Feature; break; case ModelContextTypeCode.Index: templateName = Resources.DisplayValues.NodeName_Templates_Index; break; case ModelContextTypeCode.IndexProperty: templateName = Resources.DisplayValues.NodeName_Templates_IndexProperty; break; case ModelContextTypeCode.Method: templateName = Resources.DisplayValues.NodeName_Templates_Method; break; case ModelContextTypeCode.Parameter: templateName = Resources.DisplayValues.NodeName_Templates_Parameter; break; case ModelContextTypeCode.Project: templateName = Resources.DisplayValues.NodeName_Templates_Project; break; case ModelContextTypeCode.Property: templateName = Resources.DisplayValues.NodeName_Templates_Property; break; case ModelContextTypeCode.PropertyReference: templateName = Resources.DisplayValues.NodeName_Templates_PropertyReference; break; case ModelContextTypeCode.Relationship: templateName = Resources.DisplayValues.NodeName_Templates_Relationship; break; case ModelContextTypeCode.RelationshipProperty: templateName = Resources.DisplayValues.NodeName_Templates_RelationshipProperty; break; case ModelContextTypeCode.Workflow: templateName = Resources.DisplayValues.NodeName_Templates_Workflow; break; case ModelContextTypeCode.View: templateName = Resources.DisplayValues.NodeName_Templates_View; break; case ModelContextTypeCode.ViewProperty: templateName = Resources.DisplayValues.NodeName_Templates_ViewProperty; break; case ModelContextTypeCode.Stage: templateName = Resources.DisplayValues.NodeName_Templates_Stage; break; case ModelContextTypeCode.StageTransition: templateName = Resources.DisplayValues.NodeName_Templates_StageTransition; break; case ModelContextTypeCode.Step: templateName = Resources.DisplayValues.NodeName_Templates_Step; break; case ModelContextTypeCode.StepTransition: templateName = Resources.DisplayValues.NodeName_Templates_StepTransition; break; case ModelContextTypeCode.StateModel: templateName = Resources.DisplayValues.NodeName_Templates_StateModel; break; case ModelContextTypeCode.State: templateName = Resources.DisplayValues.NodeName_Templates_State; break; case ModelContextTypeCode.StateTransition: templateName = Resources.DisplayValues.NodeName_Templates_StateTransition; break; case ModelContextTypeCode.Model: templateName = Resources.DisplayValues.NodeName_Templates_Model; break; case ModelContextTypeCode.ModelObject: templateName = Resources.DisplayValues.NodeName_Templates_ModelObject; break; case ModelContextTypeCode.ModelProperty: templateName = Resources.DisplayValues.NodeName_Templates_ModelProperty; break; case ModelContextTypeCode.Enumeration: templateName = Resources.DisplayValues.NodeName_Templates_Enumeration; break; case ModelContextTypeCode.Value: templateName = Resources.DisplayValues.NodeName_Templates_Value; break; case ModelContextTypeCode.ObjectInstance: templateName = Resources.DisplayValues.NodeName_Templates_ObjectInstance; break; case ModelContextTypeCode.PropertyInstance: templateName = Resources.DisplayValues.NodeName_Templates_PropertyInstance; break; default: templateName = Resources.DisplayValues.NodeName_CodeTemplates; break; } if (modelContextTypeEnum == ModelContextTypeCode.Solution) { if (String.IsNullOrEmpty(template.CodeTemplate.CategoryName)) { Items.Add(template); template.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } else { bool foundCategory = false; foreach (CodeTemplatesViewModel folder in Items.OfType <CodeTemplatesViewModel>()) { if (folder.Name == template.CodeTemplate.CategoryName) { folder.AddTemplate(template, refresh); foundCategory = true; } } if (foundCategory == false) { CodeTemplatesViewModel folder = new CodeTemplatesViewModel(Solution, ModelContextTypeCode.None.ToString()); folder.Name = template.CodeTemplate.CategoryName; folder.AddTemplate(template); Items.Add(folder); folder.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } } } else { bool foundFolder = false; foreach (CodeTemplatesViewModel folder in Items.OfType <CodeTemplatesViewModel>()) { if (folder.Name == templateName) { folder.AddTemplate(template, refresh); foundFolder = true; } } if (foundFolder == false) { CodeTemplatesViewModel folder = new CodeTemplatesViewModel(Solution, modelContextTypeEnum.ToString()); folder.Name = templateName; folder.AddTemplate(template); Items.Add(folder); folder.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } } break; default: if (String.IsNullOrEmpty(template.CodeTemplate.CategoryName) || template.CodeTemplate.CategoryName == Name) { Items.Add(template); template.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } else { bool foundCategory = false; foreach (CodeTemplatesViewModel folder in Items.OfType <CodeTemplatesViewModel>()) { if (folder.Name == template.CodeTemplate.CategoryName) { folder.AddTemplate(template, refresh); foundCategory = true; } } if (foundCategory == false) { CodeTemplatesViewModel folder = new CodeTemplatesViewModel(Solution, modelContextTypeEnum.ToString()); folder.Name = template.CodeTemplate.CategoryName; folder.AddTemplate(template); Items.Add(folder); folder.Updated += new EventHandler(Children_Updated); if (refresh == true) { Items.Sort("Name", SortDirection.Ascending); } } } break; } }