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();
                    }
                }
            }
        }
Пример #2
0
        private static MenuItem CreateTraceMenuItem(string uniqueName, IEAElement tracedElement)
        {
            var menuItem = new MenuItem(uniqueName);

            menuItem.Value         = tracedElement;
            menuItem.ClickDelegate = delegate
            {
                IEADiagram[] diagrams = tracedElement.GetDiagrams();
                if (diagrams.Count() == 1)
                {
                    IEADiagram diagram = diagrams[0];
                    diagram.OpenAndSelectElement(tracedElement);
                }
                else if (diagrams.Count() >= 2)
                {
                    var selectForm = new SelectDiagramDialog(diagrams);
                    if (selectForm.ShowDialog() == DialogResult.OK)
                    {
                        IEADiagram diagram = selectForm.GetSelectedDiagram();
                        diagram.OpenAndSelectElement(tracedElement);
                    }
                }
                tracedElement.ShowInProjectView();
            };
            return(menuItem);
        }
Пример #3
0
 private void OpenDecisionInDiagrams(IEAElement decision)
 {
     IEADiagram[] diagrams = decision.GetDiagrams();
     if (diagrams.Count() == 1) // open the diagram with the decision if there is only one diagram
     {
         IEADiagram diagram = diagrams[0];
         diagram.OpenAndSelectElement(decision);
     }
     else if (diagrams.Count() >= 2) // let the user decide which diagram to open
     {
         var selectForm = new SelectDiagram(diagrams);
         if (selectForm.ShowDialog() == DialogResult.OK)
         {
             IEADiagram diagram = selectForm.GetSelectedDiagram();
             diagram.OpenAndSelectElement(decision);
         }
     }
     decision.ShowInProjectView();
 }