示例#1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method is used to copy/paste a new item.</summary>
        ///
        /// <param name="copyItem">The item to copy/paste.</param>
        /// <param name="savePaste">Flag to determine whether to save the results of the paste.</param>
        ///--------------------------------------------------------------------------------
        public XmlSourceViewModel PasteXmlSource(XmlSourceViewModel copyItem, bool savePaste = true)
        {
            XmlSource newItem = new XmlSource();

            newItem.ReverseInstance = new XmlSource();
            newItem.TransformDataFromObject(copyItem.XmlSource, null, false);
            newItem.SpecificationSourceID = Guid.NewGuid();
            newItem.IsAutoUpdated         = false;

            newItem.Solution = Solution;
            newItem.Solution = Solution;
            XmlSourceViewModel newView = new XmlSourceViewModel(newItem, Solution);

            newView.ResetModified(true);
            AddXmlSource(newView);

            // paste children
            if (savePaste == true)
            {
                Solution.XmlSourceList.Add(newItem);
                newView.OnUpdated(this, null);
                Solution.ResetModified(true);
            }
            return(newView);
        }
示例#2
0
 ///--------------------------------------------------------------------------------
 /// <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);
     }
 }
示例#3
0
 ///--------------------------------------------------------------------------------
 /// <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);
         }
     }
 }
示例#4
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method applies xmlsource updates.</summary>
 ///--------------------------------------------------------------------------------
 public void ProcessEditXmlSourcePerformed(XmlSourceEventArgs data)
 {
     try
     {
         bool isItemMatch = false;
         if (data != null && data.XmlSource != null)
         {
             foreach (XmlSourceViewModel item in XmlSources)
             {
                 if (item.XmlSource.SpecificationSourceID == data.XmlSource.SpecificationSourceID)
                 {
                     isItemMatch = true;
                     item.XmlSource.TransformDataFromObject(data.XmlSource, null, false);
                     item.OnUpdated(item, null);
                     item.ShowInTreeView();
                     break;
                 }
             }
             if (isItemMatch == false)
             {
                 // add new XmlSource
                 data.XmlSource.Solution = Solution;
                 XmlSourceViewModel newItem = new XmlSourceViewModel(data.XmlSource, Solution);
                 newItem.Updated += new EventHandler(Children_Updated);
                 XmlSources.Add(newItem);
                 Solution.XmlSourceList.Add(newItem.XmlSource);
                 Items.Add(newItem);
                 OnUpdated(this, null);
                 newItem.ShowInTreeView();
             }
         }
     }
     catch (Exception ex)
     {
         ShowIssue(ex.Message + ex.StackTrace);
     }
 }
示例#5
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method deletes an instance of XmlSource from the view model.</summary>
 ///
 /// <param name="itemView">The XmlSource to delete.</param>
 ///--------------------------------------------------------------------------------
 public void DeleteXmlSource(XmlSourceViewModel itemView)
 {
     itemView.Updated -= Children_Updated;
     XmlSources.Remove(itemView);
     Delete(itemView);
 }
示例#6
0
 ///--------------------------------------------------------------------------------
 /// <summary>This method adds an instance of XmlSource to the view model.</summary>
 ///
 /// <param name="itemView">The XmlSource to add.</param>
 ///--------------------------------------------------------------------------------
 public void AddXmlSource(XmlSourceViewModel itemView)
 {
     itemView.Updated += new EventHandler(Children_Updated);
     XmlSources.Add(itemView);
     Add(itemView);
 }
示例#7
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method applies solution deletes.</summary>
        ///--------------------------------------------------------------------------------
        public void ProcessDeleteSolutionPerformed(SolutionEventArgs data)
        {
            try
            {
                bool isItemMatch = false;
                if (data != null && data.Solution != null)
                {
                    foreach (SolutionViewModel item in Solutions.ToList <SolutionViewModel>())
                    {
                        if (item.Solution.SolutionID == data.Solution.SolutionID)
                        {
                            // remove item from tabs, if present
                            WorkspaceEventArgs message = new WorkspaceEventArgs();
                            message.ItemID = item.Solution.SolutionID;
                            Mediator.NotifyColleagues <WorkspaceEventArgs>(MediatorMessages.Command_CloseItemRequested, message);

                            // delete children
                            for (int i = item.Items.Count - 1; i >= 0; i--)
                            {
                                if (item.Items[i] is ViewViewModel)
                                {
                                    ViewViewModel child        = item.Items[i] as ViewViewModel;
                                    ViewEventArgs childMessage = new ViewEventArgs();
                                    childMessage.View        = child.View;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.ViewsFolder.ProcessDeleteViewPerformed(childMessage);
                                }
                                if (item.Items[i] is DatabaseSourceViewModel)
                                {
                                    DatabaseSourceViewModel child        = item.Items[i] as DatabaseSourceViewModel;
                                    DatabaseSourceEventArgs childMessage = new DatabaseSourceEventArgs();
                                    childMessage.DatabaseSource = child.DatabaseSource;
                                    childMessage.SolutionID     = item.Solution.SolutionID;
                                    childMessage.Solution       = Solution;
                                    childMessage.WorkspaceID    = child.WorkspaceID;
                                    item.SpecificationSourcesFolder.ProcessDeleteDatabaseSourcePerformed(childMessage);
                                }
                                if (item.Items[i] is XmlSourceViewModel)
                                {
                                    XmlSourceViewModel child        = item.Items[i] as XmlSourceViewModel;
                                    XmlSourceEventArgs childMessage = new XmlSourceEventArgs();
                                    childMessage.XmlSource   = child.XmlSource;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.SpecificationSourcesFolder.ProcessDeleteXmlSourcePerformed(childMessage);
                                }
                                if (item.Items[i] is ProjectViewModel)
                                {
                                    ProjectViewModel child        = item.Items[i] as ProjectViewModel;
                                    ProjectEventArgs childMessage = new ProjectEventArgs();
                                    childMessage.Project     = child.Project;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.ProjectsFolder.ProcessDeleteProjectPerformed(childMessage);
                                }
                                if (item.Items[i] is FeatureViewModel)
                                {
                                    FeatureViewModel child        = item.Items[i] as FeatureViewModel;
                                    FeatureEventArgs childMessage = new FeatureEventArgs();
                                    childMessage.Feature     = child.Feature;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.FeaturesFolder.ProcessDeleteFeaturePerformed(childMessage);
                                }
                                if (item.Items[i] is WorkflowViewModel)
                                {
                                    WorkflowViewModel child        = item.Items[i] as WorkflowViewModel;
                                    WorkflowEventArgs childMessage = new WorkflowEventArgs();
                                    childMessage.Workflow    = child.Workflow;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.WorkflowsFolder.ProcessDeleteWorkflowPerformed(childMessage);
                                }
                                if (item.Items[i] is ModelViewModel)
                                {
                                    ModelViewModel child        = item.Items[i] as ModelViewModel;
                                    ModelEventArgs childMessage = new ModelEventArgs();
                                    childMessage.Model       = child.Model;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.ModelsFolder.ProcessDeleteModelPerformed(childMessage);
                                }
                                if (item.Items[i] is DiagramViewModel)
                                {
                                    DiagramViewModel child        = item.Items[i] as DiagramViewModel;
                                    DiagramEventArgs childMessage = new DiagramEventArgs();
                                    childMessage.Diagram     = child.Diagram;
                                    childMessage.SolutionID  = item.Solution.SolutionID;
                                    childMessage.Solution    = Solution;
                                    childMessage.WorkspaceID = child.WorkspaceID;
                                    item.DiagramsFolder.ProcessDeleteDiagramPerformed(childMessage);
                                }
                                if (item.Items[i] is AuditPropertyViewModel)
                                {
                                    AuditPropertyViewModel child        = item.Items[i] as AuditPropertyViewModel;
                                    AuditPropertyEventArgs childMessage = new AuditPropertyEventArgs();
                                    childMessage.AuditProperty = child.AuditProperty;
                                    childMessage.SolutionID    = item.Solution.SolutionID;
                                    childMessage.Solution      = Solution;
                                    childMessage.WorkspaceID   = child.WorkspaceID;
                                    item.AuditPropertiesFolder.ProcessDeleteAuditPropertyPerformed(childMessage);
                                }
                                if (item.Items[i] is SpecTemplateViewModel)
                                {
                                    SpecTemplateViewModel child        = item.Items[i] as SpecTemplateViewModel;
                                    SpecTemplateEventArgs childMessage = new SpecTemplateEventArgs();
                                    childMessage.SpecTemplate = child.SpecTemplate;
                                    childMessage.SolutionID   = item.Solution.SolutionID;
                                    childMessage.Solution     = Solution;
                                    childMessage.WorkspaceID  = child.WorkspaceID;
                                    item.SpecTemplatesFolder.ProcessDeleteSpecTemplatePerformed(childMessage);
                                }
                                if (item.Items[i] is CodeTemplateViewModel)
                                {
                                    CodeTemplateViewModel child        = item.Items[i] as CodeTemplateViewModel;
                                    CodeTemplateEventArgs childMessage = new CodeTemplateEventArgs();
                                    childMessage.CodeTemplate = child.CodeTemplate;
                                    childMessage.SolutionID   = item.Solution.SolutionID;
                                    childMessage.Solution     = Solution;
                                    childMessage.WorkspaceID  = child.WorkspaceID;
                                    item.CodeTemplatesFolder.ProcessDeleteCodeTemplatePerformed(childMessage);
                                }
                            }

                            // delete item
                            isItemMatch = true;
                            Solutions.Remove(item);
                            Items.Remove(item);
                            OnUpdated(this, null);
                            break;
                        }
                    }
                    if (isItemMatch == false)
                    {
                        ShowIssue(DisplayValues.Issue_DeleteItemNotFound);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowIssue(ex.Message + ex.StackTrace);
            }
        }