Exemplo n.º 1
0
        /// <summary>
        /// Add a new force for each concern if the combination not exists already
        /// </summary>
        /// <param name="force"></param>
        private void AddForceConcerns(IEAElement force)
        {
            IEARepository repository  = EAFacade.EA.Repository;
            string        diagramGuid = _controller.Model.DiagramGUID;
            IEADiagram    diagram     = repository.GetDiagramByGuid(diagramGuid);

            //Add the force for each selected concern
            foreach (var item in _lbConcern.SelectedItems)
            {
                var        selectedItem = (KeyValuePair <string, string>)item;
                IEAElement concern      = repository.GetElementByGUID(selectedItem.Key);

                diagram.AddElement(concern);

                IEAConnector connector = force.ConnectTo(concern, EAConstants.ForcesConnectorType, EAConstants.RelationClassifiedBy);
                if (!connector.TaggedValueExists(EATaggedValueKeys.IsForceConnector, diagramGuid))
                {
                    // Add TaggedValue for new force and concern (having multiple TaggedValues of the same name/data is possible).
                    // The amount of TaggedValues with the same name and data is the amount of forces/concerns in the table.
                    force.AddTaggedValue(EATaggedValueKeys.IsForceElement, diagramGuid);
                    concern.AddTaggedValue(EATaggedValueKeys.IsConcernElement, diagramGuid);

                    // Add the diagramGuid as a TaggedValue (ConnectorTag) to the connector
                    connector.AddTaggedValue(EATaggedValueKeys.IsForceConnector, diagramGuid);
                    _closeWindow = true;
                }
                else //Force concern combination (connector) already exists
                {
                    MessageBox.Show(string.Format(Messages.ForcesViewForceExists, force.Name, concern.Name),
                                    "Force already exists", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the forces and concerns that are selected in the TreeView and ListBox to the forces diagram
        /// </summary>
        public void AddForceToForcesDiagram()
        {
            TreeNode selectedNode = _tvForce.SelectedNode;

            // Cannot add force if no force or concern is selected
            if (selectedNode == null || _lbConcern.SelectedItems.Count < 1)
            {
                return;
            }

            IEARepository repository  = EAFacade.EA.Repository;
            string        diagramGuid = _controller.Model.DiagramGUID;
            IEADiagram    diagram     = repository.GetDiagramByGuid(diagramGuid);

            IEAElement force = repository.GetElementByGUID(selectedNode.ImageKey);

//            if (force.Type.Equals("Package")) return; // User cannot add packages as a force
            diagram.AddElement(force); //Will not be added if already exists

            AddForceConcerns(force);

            //Window does not have to be closed and no update needed
            if (!_closeWindow)
            {
                return;
            }

            _controller.SetDiagramModel(repository.GetDiagramByGuid(_controller.Model.DiagramGUID));
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
 private void GenerateDiagram(IEADiagram chronologicalViewpoint, IEnumerable <IEAElement> elements)
 {
     foreach (IEAElement element in elements)
     {
         chronologicalViewpoint.AddElement(element);
     }
 }
        /// <summary>
        ///     Add deicsion to the diagram and TaggedValue to the decision if it doesn't exist already
        /// </summary>
        /// <param name="element"></param>
        private void AddDecisionToDiagram(IEAElement element)
        {
            if (_listener != null)
            {
                _listener.OnDecisionSelected(element);
                return;
            }

            IEARepository repository = EAMain.Repository;

            string     diagramGuid = _controller.Model.DiagramGUID;
            IEADiagram diagram     = repository.GetDiagramByGuid(diagramGuid);

            diagram.AddElement(element);

            // Only add the TaggedValue once, because the element is already a decision
            if (!element.TaggedValueExists(EATaggedValueKeys.IsDecisionElement, diagramGuid))
            {
                element.AddTaggedValue(EATaggedValueKeys.IsDecisionElement, diagramGuid);
                _closeWindow = true;
            }
            else
            {
                MessageBox.Show(string.Format(Messages.ForcesViewDecisionExists, element.Name),
                                Messages.ForcesViewDecisionExistsTitle,
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 5
0
        public void EA_DiagramTests()
        {
            // Properties

            {
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                Assert.IsTrue(DateTime.Now > diagram.Created);
                Assert.IsTrue(EANativeType.Diagram == diagram.EANativeType);
                Assert.IsTrue("" != diagram.GUID);
                Assert.IsTrue(0 < diagram.ID);
                Assert.IsTrue("" != diagram.Metatype);
                Assert.IsTrue(DateTime.Now > diagram.Modified);
                Assert.IsTrue("" != diagram.Name);
                Assert.IsTrue("" == diagram.Notes);
                Assert.IsNotNull(diagram.ParentElement);
                Assert.IsNotNull(diagram.ParentPackage);
                Assert.IsTrue("" != diagram.Version);
            }

            // Operations

            {
                // IsForcesView / AddElement / Contains / OpenAndSelectElement / HideConnectors / RemoveElement
                IEAPackage package = _e.GetDecisionPackage();
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                IEAElement element = package.CreateElement("MyNote", "MyStereotype", "Note");
                package.RefreshElements();
                diagram.AddElement(element);
                Assert.IsTrue(diagram.Contains(element));
                diagram.OpenAndSelectElement(element);
                diagram.HideConnectors(new[]
                {
                    EAConstants.RelationAlternativeFor, EAConstants.RelationCausedBy,
                    EAConstants.RelationDependsOn,
                    EAConstants.RelationExcludedBy, EAConstants.RelationReplaces, EAConstants.RelationFollowedBy
                });
                diagram.RemoveElement(element);
                Assert.IsFalse(diagram.Contains(element));
                Assert.IsTrue(deleteElementFromPackage(package, element));
            }

            {
                // ShowInProjectView / DiagramToStream
                IEAPackage package = _e.GetDecisionPackage();
                IEADiagram diagram = _e.GetDecisionForcesDiagram();
                diagram.ShowInProjectView();
                FileStream fs = diagram.DiagramToStream();
                Assert.IsNotNull(fs);
                Assert.IsTrue(fs.Name.Contains(".emf"));
            }

            {
                // GetElements
                IEAPackage package           = _e.GetDecisionPackage();
                IEADiagram diagram           = _e.GetDecisionForcesDiagram();
                List <IEADiagramObject> objs = diagram.GetElements();
                Assert.IsNotNull(objs);
                Assert.IsTrue(0 < objs.Count);
            }

            /* TODO: adjust for Decision Architect MDG
             * {  // IsChronologicalView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionChronologicalDiagram();
             * }
             *
             * {  // IsRelationshipView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionRelationshipDiagram();
             * }
             *
             * {  // IsStakeholderInvolvementView
             *  IEAPackage package = _e.GetDecisionPackage();
             *  IEADiagram diagram = _e.GetDecisionStakeholderDiagram();
             * }
             */
        }