public static void CreateAndTraceTopic()
        {
            IEARepository repository = EAMain.Repository;

            if (repository.GetContextItemType() == EANativeType.Element)
            {
                var eaelement = repository.GetContextObject <IEAElement>();
                if (eaelement != null && !EAMain.IsDecision(eaelement) && !EAMain.IsTopic(eaelement))
                {
                    string nameSuggestion  = string.Format(Messages.NameSuggestionTopic, eaelement.Name);
                    var    createTopicView = new CreateTopicDialog(nameSuggestion);
                    if (createTopicView.ShowDialog() == DialogResult.OK)
                    {
                        IEAPackage dvPackage = createTopicView.GetDecisionViewPackage();
                        IEAElement topic     = dvPackage.CreateElement(createTopicView.GetName(),
                                                                       EAConstants.TopicStereoType,
                                                                       EAConstants.ActivityMetaType);
                        topic.MetaType = EAConstants.TopicMetaType;
                        topic.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                             DateTime.Now.ToString(CultureInfo.InvariantCulture));
                        eaelement.ConnectTo(topic, EAConstants.AbstractionMetaType, EAConstants.RelationTrace);
                        topic.Update();

                        dvPackage.RefreshElements();
                        repository.RefreshModelView(dvPackage.ID);
                        topic.ShowInProjectView();
                    }
                }
            }
        }
        /********************************************************************************************
        ** EAMain Callbacks
        ********************************************************************************************/

        /// <summary>
        ///     This method is called when double clicking an element in the view pane. It opens the respective View.
        /// </summary>
        /// <param name="guid">
        ///     A string holding the GUID of the EAElement clicked by the user.
        /// </param>
        /// <param name="type">
        ///     The EANativeType of the element clicked by the user.
        /// </param>
        /// <returns></returns>
        public override bool OnContextItemDoubleClicked(string guid, EANativeType type)
        {
            // If the type is not an Element
            if (type != EANativeType.Element)
            {
                return(false);
            }
            // Get the element
            IEAElement element = EAMain.Repository.GetElementByGUID(guid);

            // If it is not a decision or a topic, leave!
            if (!(EAMain.IsDecision(element) || EAMain.IsTopic(element)))
            {
                return(false);
            }

            // Check if the tab is already open.
            if (EAMain.IsDecision(element))
            {
                OpenDecisionDetailView(Decision.Load(element));
                return(true);
            }

            if (EAMain.IsTopic(element))
            {
                OpenTopicDetailView(Topic.Load(element));
                return(true);
            }
            return(false);
        }
        private static bool ContextItemAreDecisions()
        {
            IEnumerable <IEAElement> selectedTopicsAndDecisions =
                (from IEAElement element in EAMain.Repository.GetSelectedItems()
                 where (EAMain.IsDecision(element) || EAMain.IsTopic(element)) && !EAMain.IsHistoryDecision(element)
                 select element);

            return(selectedTopicsAndDecisions.Any());
        }
Beispiel #4
0
        public IEnumerable <IEAElement> GetDecisionsForTopic()
        {
            IEAElement element = EAMain.Repository.GetElementByGUID(GUID);

            if (!EAMain.IsTopic(element))
            {
                throw new Exception("EAElementImpl is not a topic");
            }

            return(from IEAElement e in element.GetElements() where EAMain.IsDecision(e) select e);
        }
Beispiel #5
0
 public override bool OnPostNewElement(IEAElement element)
 {
     if (EAMain.IsDecision(element))
     {
         element.AddTaggedValue(EATaggedValueKeys.DecisionState, element.Stereotype);
         element.AddTaggedValue(EATaggedValueKeys.IsHistoryDecision, false.ToString());
     }
     if (EAMain.IsDecision(element) || EAMain.IsTopic(element))
     {
         element.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                element.Modified.ToString(CultureInfo.InvariantCulture));
     }
     return(true);
 }
        /// <summary>
        ///     Colours the header of a row according to the state of the element in the row if it is a decision
        /// </summary>
        /// <param name="i"></param>
        private void ColourForceHeader(int i)
        {
            DataGridViewRow row  = _forcesTable.Rows[i];
            string          guid = row.Cells[ForcesTableContext.ForceGUIDColumnIndex].Value.ToString();

            if (guid.Equals(ForcesTableContext.EmptyCellValue))
            {
                return;
            }
            IEARepository repository = EAMain.Repository;
            IEAElement    element    = repository.GetElementByGUID(guid);

            if (element == null || row.HeaderCell == null || !EAMain.IsDecision(element))
            {
                return;
            }
            row.HeaderCell.Style.BackColor = RetrieveColorByState(element.Stereotype);
        }
Beispiel #7
0
        /// <summary>
        ///     Adds an element and its children to the node
        /// </summary>
        /// <param name="node">Node to be added to</param>
        /// <param name="element"></param>
        /// <returns>A node with element information and its children</returns>
        private TreeNode AddElementToNode(TreeNode node, IEAElement element)
        {
            node.ImageKey = element.GUID;
            node.Text     = element.Name;

            foreach (IEAElement el in element.GetElements())
            {
                if (el.Name.Equals("") || EAMain.IsHistoryDecision(el))
                {
                    continue;
                }
                if (_decision && (!EAMain.IsDecision(el) && !EAMain.IsTopic(el)))
                {
                    continue;
                }
                node.Nodes.Add((AddElementToNode(new TreeNode(), el)));
            }
            return(node);
        }
 /// <summary>
 ///     Add all elements that do not contain children
 /// </summary>
 /// <param name="node"></param>
 private void AddFromNode(TreeNode node)
 {
     if (node.Nodes.Count > 0)
     {
         foreach (TreeNode n in node.Nodes)
         {
             AddFromNode(n);
         }
     }
     else
     {
         IEARepository repository = EAMain.Repository;
         IEAElement    element    = repository.GetElementByGUID(node.ImageKey);
         if (EAMain.IsDecision(element))
         {
             AddDecisionToDiagram(element);
         }
     }
 }
Beispiel #9
0
        /// <summary>
        ///     Adds a package and its children to the node
        /// </summary>
        /// <param name="node">Node to be added to</param>
        /// <param name="package">Package to be added</param>
        /// <returns>A node with the package information and its children</returns>
        private TreeNode AddPackageNode(TreeNode node, IEAPackage package)
        {
            node.ImageKey = package.GUID;
            node.Text     = package.Name;

            foreach (IEAPackage subPackage in package.Packages)
            {
                //Skip history package and packages without elements
                if (subPackage.Stereotype.Equals(EAConstants.ChronologicalStereoType) ||
                    !subPackage.GetAllElementsOfSubTree().Any())
                {
                    continue;
                }
                TreeNode subPackageNode = AddPackageNode(new TreeNode(), subPackage);
                if (null != subPackageNode)
                {
                    node.Nodes.Add(subPackageNode);
                }
            }

            int count = 0;

            foreach (IEAElement element in package.Elements)
            {
                if (element.Name.Equals("") || EAMain.IsHistoryDecision(element))
                {
                    continue;
                }
                if (_decision && (!EAMain.IsDecision(element) && !EAMain.IsTopic(element)))
                {
                    continue;
                }
                node.Nodes.Add(AddElementToNode(new TreeNode(), element));
                ++count;
            }
            if (node.GetNodeCount(true) == 0)
            {
                return(null);
            }
            return(node);
        }
        private TreeNode CreateTreeNode(IEAPackage package)
        {
            TreeNode packageNode             = null;
            IEnumerable <TreeNode> decisions =
                package.Elements.Where(e => EAMain.IsDecision(e) && !EAMain.IsHistoryDecision(e))
                .Select(e => new TreeNode(Name = e.Name)
            {
                ImageKey = e.GUID
            });
            IEnumerable <TreeNode>        subpackages = package.Packages.Select(CreateTreeNode).Where(node => node != null);
            IOrderedEnumerable <TreeNode> subtree     = decisions.Union(subpackages).OrderBy(node => node.Name);

            if (subtree.Any())
            {
                packageNode = new TreeNode(package.Name, subtree.ToArray())
                {
                    ImageKey = package.GUID
                };
            }
            return(packageNode);
        }
 /// <summary>
 ///     This method is called when dragging in an element. It overrides the standard popup fro EAMain.
 /// </summary>
 /// <param name="element">
 ///     The EAElement dragged into the view pane
 /// </param>
 /// <returns></returns>
 public override bool OnPostNewElement(IEAElement element)
 {
     if (!EAMain.IsDecision(element) && !EAMain.IsTopic(element))
     {
         return(false);
     }
     // suppress properties window
     EAMain.Repository.SuppressDefaultDialogs(true);
     // Check if the tab is already open.
     if (EAMain.IsDecision(element))
     {
         OpenDecisionDetailView(Decision.Load(element));
         return(true);
     }
     if (EAMain.IsTopic(element))
     {
         OpenTopicDetailView(Topic.Load(element));
         return(true);
     }
     return(false);
 }
        static MenuEventHandler()
        {
            var createTraces           = new Model.Menu.Menu(Messages.MenuCreateTraces);
            var createAndTraceDecision = new MenuItem(Messages.MenuTraceToNewDecision,
                                                      CreateTraceMenu.CreateAndTraceDecision)
            {
                UpdateDelegate = menuItem =>
                {
                    if (EANativeType.Element == EAMain.Repository.GetContextItemType())
                    {
                        var eaelement = EAMain.Repository.GetContextObject <IEAElement>();
                        menuItem.IsEnabled = (eaelement != null && !EAMain.IsDecision(eaelement) &&
                                              !EAMain.IsTopic(eaelement));
                        return;
                    }
                    menuItem.IsEnabled = false;
                }
            };

            var createAndTraceTopic = new MenuItem(Messages.MenuTraceToNewTopic, CreateTraceMenu.CreateAndTraceTopic)
            {
                UpdateDelegate = menuItem =>
                {
                    if (EANativeType.Element == EAMain.Repository.GetContextItemType())
                    {
                        var eaelement = EAMain.Repository.GetContextObject <IEAElement>();
                        menuItem.IsEnabled = (eaelement != null && !EAMain.IsDecision(eaelement) &&
                                              !EAMain.IsTopic(eaelement));
                        return;
                    }
                    menuItem.IsEnabled = false;
                }
            };

            var generateChronologicalView = new MenuItem(Messages.MenuGenerateChronologicalVP, ChronologyMenu.Generate)
            {
                UpdateDelegate = self =>
                {
                    if (EANativeType.Package == EAMain.Repository.GetContextItemType())
                    {
                        var eapackage = EAMain.Repository.GetContextObject <IEAPackage>();
                        self.IsEnabled = (eapackage != null);
                        return;
                    }
                    self.IsEnabled = false;
                }
            };

            /*var reportMenu = new Model.Menu.Menu(Messages.MenuExport);
             * var generateWordReport = new MenuItem(Messages.MenuExportWord)
             *  {
             *      ClickDelegate = () => ReportMenu.GenerateReport(SelectedDecisionViewPackage(),"Report.docx", ReportType.Word),
             *      UpdateDelegate = self =>
             *          {
             *              self.IsEnabled = ContextItemIsDecisionViewPackage();
             *          }
             * };
             *
             * var generateExcelAllReport = new MenuItem(Messages.MenuExportExcelForcesAll)
             *  {
             *      ClickDelegate = () => ReportMenu.GenerateReport(SelectedDecisionViewPackage(),"AllForcesReport.xlsx", ReportType.Excel),
             *      UpdateDelegate = self =>
             *          {
             *              self.IsEnabled = ContextItemIsDecisionViewPackage();
             *          }
             *  };
             *
             * var generateExcelReport = new MenuItem(Messages.MenuExportExcelForces)
             *  {
             *      ClickDelegate = () =>
             *          {
             *              if (EANativeType.Diagram == EAFacade.EAMain.Repository.GetContextItemType())
             *              {
             *                  var eadiagram = EAFacade.EAMain.Repository.GetContextObject<IEADiagram>();
             *                  ReportMenu.GenerateForcesReport(eadiagram.Name + "_Report.xlsx", eadiagram);
             *              }
             *          },
             *      UpdateDelegate = self =>
             *          {
             *              if (EANativeType.Diagram == EAFacade.EAMain.Repository.GetContextItemType())
             *              {
             *                  var eadiagram = EAFacade.EAMain.Repository.GetContextObject<IEADiagram>();
             *                  self.IsEnabled = ((eadiagram != null) && eadiagram.IsForcesView());
             *                  return;
             *              }
             *              self.IsEnabled = false;
             *          }
             *  };
             *
             * var generateSelectedDecisionsWordReport = new MenuItem(Messages.MenuExportSelectedDecisionsWord)
             *  {
             *      ClickDelegate = () => ReportMenu.GenerateSelectedDecisionsReport("Report.docx", ReportType.Word),
             *      UpdateDelegate = self => { self.IsEnabled = ContextItemAreDecisions(); }
             *  };
             *
             * var generatePowerpointReport = new MenuItem(Messages.MenuExportPowerPoint)
             *  {
             *      ClickDelegate = () =>
             *                      ReportMenu.GenerateReport(SelectedDecisionViewPackage(),"Report.pptx", ReportType.PowerPoint),
             *      UpdateDelegate = self =>
             *          {
             *              self.IsEnabled = ContextItemIsDecisionViewPackage();
             *          }
             *  };
             *
             * var generateSelectedDecisionsPowerpointReport = new MenuItem(Messages.MenuExportSelectedDecisionsPowerPoint)
             *  {
             *      ClickDelegate = () =>
             *                      ReportMenu.GenerateSelectedDecisionsReport("Report.pptx", ReportType.PowerPoint),
             *      UpdateDelegate = self => { self.IsEnabled = ContextItemAreDecisions();  }
             *  };
             * */

            RootMenu.Add(createTraces);
            createTraces.Add(createAndTraceDecision);
            createTraces.Add(createAndTraceTopic);

            RootMenu.Add(new FollowTraceMenu());
            RootMenu.Add(MenuItem.Separator);
            RootMenu.Add(generateChronologicalView);
            RootMenu.Add(MenuItem.Separator);

            /* RootMenu.Add(reportMenu);
             * reportMenu.Add(generateWordReport);
             * reportMenu.Add(generatePowerpointReport);
             * reportMenu.Add(generateExcelAllReport);
             * reportMenu.Add(MenuItem.Separator);
             * reportMenu.Add(generateSelectedDecisionsWordReport);
             * reportMenu.Add(generateSelectedDecisionsPowerpointReport);
             * reportMenu.Add(generateExcelReport);*/
        }
 public IEnumerable <IEAElement> GetAllDecisions()
 {
     return(GetAllElementsOfSubTree().Where(e => EAMain.IsDecision(e) && !EAMain.IsHistoryDecision(e)));
 }
Beispiel #14
0
        private IEnumerable <IEAElement> GetHistory()
        {
            IEnumerable <IEAElement> allDecisionsInPackage = _decisions;

            IEnumerable <IHistoryEntry> history = allDecisionsInPackage.SelectMany(d => Decision.Load(d).History);

            IEnumerable <IEAElement> exisitingHistoryDecisions = _historyPackage.Elements.Where(e => EAMain.IsDecision(e));

            //create non existing and update existing (name)
            var pastDecisions = new List <IEAElement>();

            foreach (IHistoryEntry item in history.ToList())
            {
                string name = string.Format(Messages.ChronologyDecisionName, item.Decision.Name,
                                            item.Modified.ToShortDateString());
                string       stereotype   = item.State;
                DateTime     modified     = item.Modified;
                const string type         = EAConstants.ActionMetaType;
                string       originalGUID = item.Decision.GUID;

                IEAElement pastDecision =
                    exisitingHistoryDecisions.FirstOrDefault(
                        hd => originalGUID.Equals(hd.GetTaggedValueByName(EATaggedValueKeys.OriginalDecisionGuid)) &&
                        modified.ToString(CultureInfo.InvariantCulture)
                        .Equals(hd.GetTaggedValueByName(EATaggedValueKeys.DecisionStateModifiedDate)) &&
                        stereotype.Equals(hd.Stereotype));
                if (pastDecision == null)
                {
                    pastDecision = _historyPackage.CreateElement(name, stereotype, type);
                }
                pastDecision.MetaType = EAConstants.DecisionMetaType;
                pastDecision.Modified = modified;
                pastDecision.AddTaggedValue(EATaggedValueKeys.DecisionStateModifiedDate,
                                            modified.ToString(CultureInfo.InvariantCulture));
                pastDecision.AddTaggedValue(EATaggedValueKeys.DecisionState, stereotype);
                pastDecision.AddTaggedValue(EATaggedValueKeys.IsHistoryDecision, true.ToString());
                pastDecision.AddTaggedValue(EATaggedValueKeys.OriginalDecisionGuid, originalGUID);

                pastDecisions.Add(pastDecision);
            }


            //add topics  and original decisions

            return
                (pastDecisions.Union(
                     _decisions.Select(d => Decision.Load(d))
                     .Where(d => d.HasTopic())
                     .Select(d => EAMain.Repository.GetElementByGUID(d.Topic.GUID))).Union(_decisions));
        }