コード例 #1
0
        /********************************************************************************************
        ** Invoke View Change methods
        ********************************************************************************************/

        internal static void InvokeViewChange(string elementGUID, EANativeType eANativeType)
        {
            if (eANativeType == EANativeType.Diagram)
            {
                IEAElement   element  = EAMain.Repository.GetElementByGUID(elementGUID);
                IEADiagram[] diagrams = element.GetDiagrams();
                if (diagrams.Length == 1)
                {
                    IEADiagram diagram = diagrams[0];
                    diagram.OpenAndSelectElement(element);
                }
                else if (diagrams.Length >= 2)
                {
                    var selectForm = new SelectDiagramDialog(diagrams);
                    if (selectForm.ShowDialog() == DialogResult.OK)
                    {
                        IEADiagram diagram = selectForm.GetSelectedDiagram();
                        diagram.OpenAndSelectElement(element);
                    }
                }
            }
            else if (eANativeType == EANativeType.Element)
            {
                Instance.OnContextItemDoubleClicked(elementGUID, eANativeType);
            }
        }
コード例 #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();
 }
コード例 #4
0
        public override bool OnPreDeleteElement(IEAElement element)
        {
            if (!element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement) &&
                !element.TaggedValueExists(EATaggedValueKeys.IsConcernElement) &&
                !element.TaggedValueExists(EATaggedValueKeys.IsForceElement))
            {
                return(true);
            }

            var diagrams = new List <IEADiagram>();

            diagrams.AddRange(element.GetDiagrams().Where(eaDiagram => eaDiagram.IsForcesView()));
            if (diagrams.Count == 0)
            {
                return(true);
            }
            IEARepository repository = EAMain.Repository;

            foreach (
                IForcesController forcesController in
                from diagram in diagrams
                where repository.IsTabOpen(ForcesModel.CreateForcesTabName(diagram.Name)) > 0
                select _controllers[diagram.GUID])
            {
                string diagramGuid = forcesController.Model.DiagramGUID;
                // we cannot update the view with a new diagram model here, as the diagram changes are applied
                // after the deletion event is successful
                if (element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, diagramGuid))
                {
                    forcesController.RemoveDecision(element);
                }
                if (element.TaggedValueExists(EATaggedValueKeys.IsConcernElement, diagramGuid))
                {
                    forcesController.RemoveConcern(element);
                }
                if (element.TaggedValueExists(EATaggedValueKeys.IsForceElement, diagramGuid))
                {
                    forcesController.RemoveForce(element);
                }
            }
            return(true);
        }
コード例 #5
0
        public IEADiagram GetDecisionForcesDiagram()
        {
            IEADiagram         diagram = null;
            IEAPackage         folder  = GetDecisionPackageFolder();
            IList <IEAElement> topics  = folder.Elements;

            Assert.IsTrue(topics.Any());
            // Use the first topic
            IEAElement topic = topics.First();
            IEnumerable <IEADiagram> diagrams = topic.GetDiagrams();

            Assert.IsNotNull(diagrams);
            // Find a forces viewpoint
            foreach (IEADiagram d in diagrams)
            {
                if (d.IsStakeholderInvolvementView())
                {
                    diagram = d;
                    break;
                }
            }
            Assert.IsNotNull(diagram);
            return(diagram);
        }
コード例 #6
0
        public void EA_ElementTests()
        {
            // Properties
            {
                Element element = _e.GetDecisionPackageElement();
                Assert.IsTrue("" != element.Abstract);
                Assert.IsTrue("" == element.ActionFlags);
                Assert.IsTrue("" == element.Alias);
                Assert.IsTrue(0 == element.AssociationClassConnectorID);
                Assert.IsTrue(0 == element.Attributes.Count);
                Assert.IsTrue(0 == element.AttributesEx.Count);
                Assert.IsTrue("" != element.Author);
                Assert.IsTrue(0 == element.BaseClasses.Count);
                Assert.IsTrue(0 == element.ClassfierID);
                Assert.IsTrue(0 == element.ClassifierID);
                Assert.IsTrue("" == element.ClassifierName);
                Assert.IsTrue("" == element.ClassifierType);
                Assert.IsTrue("" != element.Complexity);
                Assert.IsNull(element.CompositeDiagram);
                Assert.IsTrue(0 < element.Connectors.Count);
                Assert.IsTrue(0 == element.Constraints.Count);
                Assert.IsTrue(0 == element.ConstraintsEx.Count);
                Assert.IsTrue(DateTime.Now > element.Created);
                Assert.IsTrue(0 < element.CustomProperties.Count);
                Assert.IsTrue(0 < element.Diagrams.Count);
                Assert.IsTrue("" == element.Difficulty);
                Assert.IsTrue(0 == element.Efforts.Count);
                Assert.IsTrue("" != element.ElementGUID);
                Assert.IsTrue(0 < element.ElementID);
                Assert.IsTrue(0 < element.Elements.Count);
                Assert.IsTrue(0 == element.EmbeddedElements.Count);
                Assert.IsTrue("" == element.EventFlags);
                Assert.IsTrue("" == element.ExtensionPoints);
                Assert.IsTrue(0 == element.Files.Count);
                Assert.IsTrue("" == element.Genfile);
                Assert.IsTrue("" == element.Genlinks);
                Assert.IsTrue("" != element.Gentype);
                Assert.IsTrue("" == element.Header1);
                Assert.IsTrue("" == element.Header2);
                Assert.IsFalse(element.IsActive);
                Assert.IsFalse(element.IsComposite);
                Assert.IsFalse(element.IsLeaf);
                Assert.IsTrue(element.IsNew);
                Assert.IsFalse(element.IsSpec);
                Assert.IsTrue(0 == element.Issues.Count);
                Assert.IsFalse(element.Locked);
                Assert.IsTrue("" != element.MetaType);
                Assert.IsTrue(0 == element.Methods.Count);
                Assert.IsTrue(0 == element.MethodsEx.Count);
                Assert.IsTrue(0 == element.Metrics.Count);
                Assert.IsTrue("" == element.MiscData[0]);
                Assert.IsTrue(DateTime.Now > element.Modified);
                Assert.IsTrue("" == element.Multiplicity);
                Assert.IsTrue("" != element.Name);
                Assert.IsTrue("" == element.Notes);
                Assert.IsTrue(ObjectType.otElement == element.ObjectType);
                Assert.IsTrue(0 < element.PackageID);
                Assert.IsTrue(0 == element.ParentID);
                Assert.IsTrue(0 == element.Partitions.Count);
                Assert.IsTrue("" == element.Persistence);
                Assert.IsTrue("" != element.Phase);
                Assert.IsTrue("" == element.Priority);
                Assert.IsNotNull(element.Properties);
                Assert.IsTrue(0 == element.PropertyType);
                Assert.IsTrue(0 == element.Realizes.Count);
                Assert.IsTrue(0 == element.Requirements.Count);
                Assert.IsTrue(0 == element.RequirementsEx.Count);
                Assert.IsTrue(0 == element.Resources.Count);
                Assert.IsTrue(0 == element.Risks.Count);
                Assert.IsTrue("" == element.RunState);
                Assert.IsTrue(0 == element.Scenarios.Count);
                Assert.IsTrue(0 == element.StateTransitions.Count);
                Assert.IsTrue("" != element.Status);
                Assert.IsTrue("" != element.Stereotype);
                Assert.IsTrue("" != element.StereotypeEx);
                Assert.IsTrue("" == element.StyleEx);
                Assert.IsTrue(0 == element.Subtype);
                Assert.IsTrue("" == element.Tablespace);
                Assert.IsTrue("" == element.Tag);
                Assert.IsTrue(0 < element.TaggedValues.Count);
                Assert.IsTrue(0 < element.TaggedValuesEx.Count);
                Assert.IsTrue(0 == element.Tests.Count);
                Assert.IsTrue(1 == element.TreePos);
                Assert.IsTrue("" != element.Type);
                Assert.IsTrue("" != element.Version);
                Assert.IsTrue("" != element.Visibility);
            }

            // Operations

            {
                // GetTracedElements (no traced elements in example model)
                IEAElement element = _e.GetForcesDecisionElement();
                IEnumerable <IEAElement> elements = element.GetTracedElements();
                Assert.IsTrue(!elements.Any());
            }

            {
                // GetDiagrams
                IEAElement   element  = _e.GetForcesDecisionElement();
                IEADiagram[] diagrams = element.GetDiagrams();
                Assert.IsTrue(diagrams.Any());
            }

            {
                // GetConnectors / ConnectTo / Update / Refresh / FindConnectors / RemoveConnector
                IEAElement          element     = _e.GetForcesDecisionElement();
                const string        myType      = "Dependency";
                const string        mySterotype = "my stereotype";
                List <IEAConnector> connectors  = element.GetConnectors();
                Assert.IsTrue(connectors.Any());
                IEAConnector c      = connectors.ElementAt(0);
                IEAElement   client = c.GetClient();
                IEAConnector nc     = client.ConnectTo(element, myType, mySterotype);
                Assert.IsTrue(element.Update());
                element.Refresh();
                IList <IEAConnector> flows = client.FindConnectors(element, mySterotype, myType);
                Assert.IsNotNull(flows);
                Assert.IsTrue(flows.Any());
                element.RemoveConnector(nc);
                Assert.IsTrue(element.Update());
                element.Refresh();
                flows = client.FindConnectors(element, mySterotype, myType);
                Assert.IsNotNull(flows);
                Assert.IsFalse(flows.Any());
            }

            /* Disabled pending better understanding of Chronological view
             * {  // GetElements
             *  IEAElement element = _e.GetChronologyTopicElement();
             *  List<IEAElement> children = element.GetElements();
             *  Assert.IsTrue(0 < children.Count());
             * }
             *
             * {  // AddTaggedValue / TaggedValueExists / GetTaggedValue / RemoveTaggedValue
             *  string taggedValueLabel = "MyTaggedValue";
             *  string taggedValueData = "my data";
             *  IEAElement element = _e.GetChronologyDecisionElement();
             *  Assert.IsFalse(element.TaggedValueExists(taggedValueLabel));
             *  element.AddTaggedValue(taggedValueLabel, taggedValueData);
             *  Assert.IsTrue(element.TaggedValueExists(taggedValueLabel));
             *  Assert.IsTrue(element.TaggedValueExists(taggedValueLabel, taggedValueData));
             *  string myData = element.GetTaggedValueByName(taggedValueLabel);
             *  Assert.IsTrue(myData == taggedValueData);
             *  element.RemoveTaggedValue(taggedValueLabel, taggedValueData);
             *  Assert.IsFalse(element.TaggedValueExists(taggedValueLabel));
             * }
             */
        }
コード例 #7
0
        public override void OnNotifyContextItemModified(string guid, EANativeType type)
        {
            IEARepository     repository = EAMain.Repository;
            IForcesController forcesController;

            switch (type)
            {
            // the diagram is modified when we remove an element or a connector from it
            case EANativeType.Diagram:
                IEADiagram diagram = repository.GetDiagramByGuid(guid);
                if (!diagram.IsForcesView())
                {
                    return;
                }
                // if the name of a diagram changed and the forces tab is open then close it to avoid conflicts
                if (repository.IsTabOpen(ForcesModel.CreateForcesTabName(diagram.Name)) <= 0)
                {
                    if (!_controllers.ContainsKey(diagram.GUID))
                    {
                        break;
                    }
                    forcesController = _controllers[diagram.GUID];
                    if (repository.IsTabOpen(forcesController.Model.Name) > 0)
                    {
                        repository.RemoveTab(forcesController.Model.Name);
                    }
                    break;
                }
                if (!_controllers.ContainsKey(diagram.GUID))
                {
                    break;
                }
                forcesController = _controllers[diagram.GUID];
                forcesController.SetDiagramModel(diagram);
                break;

            case EANativeType.Element:
                IEAElement element = repository.GetElementByGUID(guid);
                foreach (
                    IEADiagram eaDiagram in
                    element.GetDiagrams()
                    .Where(eaDiagram => eaDiagram.IsForcesView())
                    .Where(eaDiagram => _controllers.ContainsKey(eaDiagram.GUID)))
                {
                    forcesController = _controllers[eaDiagram.GUID];
                    // An element can be of multiple types:
                    if (element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateDecision(element);
                    }
                    if (element.TaggedValueExists(EATaggedValueKeys.IsConcernElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateConcern(element);
                    }
                    if (element.TaggedValueExists(EATaggedValueKeys.IsForceElement, eaDiagram.GUID))
                    {
                        forcesController.UpdateForce(element);
                    }
                }
                break;
            }
        }