Пример #1
0
        public int CreateDiagram(int parentDiagramID)
        {
            EAAPI.Diagram lifeCycleDiagram;
            EAAPI.Element parentElement;
            String        lifeCycleAlias;

            parentElement  = eaRepo.GetElementByID(parentDiagramID);
            lifeCycleAlias = FormatLifeCycleDiagramName(parentElement.Name, diagramConfig.Configuration.LifeCycleAlias);


            // Create the child diagram that will contain the Life Cycle information.
            lifeCycleDiagram = (EAAPI.Diagram)parentElement.Diagrams.AddNew(
                lifeCycleAlias,
                diagramConfig.Configuration.EAStereotype);
            lifeCycleDiagram.Stereotype = diagramConfig.Configuration.LifeCycleAlias;

            // Attach it to the parent
            lifeCycleDiagram.ParentID = parentDiagramID;

            parentElement.Update();
            parentElement.Refresh();

            lifeCycleDiagram.Update();

            return(lifeCycleDiagram.DiagramID);
        }
Пример #2
0
        //DIAGRAM CONTENT
        public void Generate_otDiagram_content(EA.Repository m_Repository, string TOI_GUID, string SP_BaseURL,
                                               out List <string> listOfElements,
                                               out List <string> listOfElementsNames,
                                               out List <string> listOfLinks,
                                               out List <string> listOfLinkNames,
                                               out Dictionary <string, string> DiagramDictionary)
        {
            listOfElements      = new List <string>();
            listOfElementsNames = new List <string>();
            listOfLinks         = new List <string>();
            listOfLinkNames     = new List <string>();

            EA.Diagram DiagramToShow = (EA.Diagram)m_Repository.GetDiagramByGuid(TOI_GUID);



            //STORE DIAGRAM ELEMENTS
            for (short iDO = 0; iDO < DiagramToShow.DiagramObjects.Count; iDO++)
            {
                EA.DiagramObject MyDO = (EA.DiagramObject)DiagramToShow.DiagramObjects.GetAt(iDO);
                int        ID         = m_Repository.GetElementByID(MyDO.ElementID).ElementID;
                EA.Element MyEle      = (EA.Element)m_Repository.GetElementByID(ID);
                listOfElements.Add(MyEle.Name + "|" + MyEle.ObjectType + "|" + MyEle.ElementGUID);
                listOfElementsNames.Add(MyEle.Name);
            }



            //STORE DIAGRAM LINKS
            for (short iDO = 0; iDO < DiagramToShow.DiagramLinks.Count; iDO++)
            {
                EA.DiagramLink MyLink = (EA.DiagramLink)DiagramToShow.DiagramLinks.GetAt(iDO);
                int            ID     = m_Repository.GetConnectorByID(MyLink.ConnectorID).ConnectorID;

                EA.Connector con;

                try //Try and get the connector object from the repository
                {
                    con = (EA.Connector)m_Repository.GetConnectorByID(ID);
                    listOfLinks.Add(con.Name + "|" + con.ObjectType + "|" + con.ConnectorGUID);
                    listOfLinkNames.Add(con.Name);
                }
                catch { }
            }



            //JSON Content
            string DiagramURL = SP_BaseURL + "/" + DiagramToShow.Name + "|otDiagram|" + TOI_GUID;


            DiagramDictionary = new Dictionary <string, string>();
            DiagramDictionary.Add("Diagram Name", DiagramToShow.Name);
            DiagramDictionary.Add("Created Data", DiagramToShow.CreatedDate.ToString());
            DiagramDictionary.Add("Meta Type", DiagramToShow.MetaType);
            DiagramDictionary.Add("Notes", DiagramToShow.Notes);
            DiagramDictionary.Add("Package ID", DiagramToShow.PackageID.ToString());
            DiagramDictionary.Add("Big Preview", DiagramURL + "/BigPreview");
            DiagramDictionary.Add("Small Preview", DiagramURL + "/SmallPreview");
        }
        /// <summary>
        /// Returns the edge an embedded element is bound to (left, right, top, bottom)
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="rep"></param>
        /// <returns></returns>
        public static EmbeddedPosition Edge(this EA.DiagramObject obj, EA.Repository rep)
        {
            EA.Element el = rep.GetElementByID(obj.ElementID);


            EA.Element elParent = el.GetParentOfEmbedded(rep);
            if (elParent == null)
            {
                return(EmbeddedPosition.Undefined);
            }
            // for Required/Required Interface use the owning Port for the position
            if (el.Type == "ProvidedInterface" ||
                el.Type == "RequiredInterface")
            {
                if (el.ParentID == 0)
                {
                    return(EmbeddedPosition.Undefined);
                }
                el = rep.GetElementByID(el.ParentID);
            }


            EA.Diagram       dia              = rep.GetDiagramByID(obj.DiagramID);
            EA.DiagramObject objParent        = dia.GetDiagramObjectByID(elParent.ElementID, "");
            EA.DiagramObject objFirstEmbedded = dia.GetDiagramObjectByID(el.ElementID, "");
            if (objParent == null)
            {
                return(EmbeddedPosition.Undefined);
            }

            int horicontalCenter = objFirstEmbedded.left + (objFirstEmbedded.right - objFirstEmbedded.left) / 2;
            int verticalCenter   = objFirstEmbedded.top - (objFirstEmbedded.top - objFirstEmbedded.bottom) / 2;

            if (horicontalCenter < objParent.left + 10 && horicontalCenter > objParent.left - 10)
            {
                return(EmbeddedPosition.Left);
            }
            if (horicontalCenter < objParent.right + 10 && horicontalCenter > objParent.right - 10)
            {
                return(EmbeddedPosition.Right);
            }


            if (verticalCenter < objParent.top + 10 && verticalCenter > objParent.top - 10)
            {
                return(EmbeddedPosition.Top);
            }
            if (verticalCenter < objParent.bottom + 10 && verticalCenter > objParent.bottom - 10)
            {
                return(EmbeddedPosition.Bottom);
            }
            return(EmbeddedPosition.Undefined);
        }
        public bool GetElement(out EA.Element element)
        {
            element = null;
            int elementId;

            if (GetEAObjectId(ElementID, out elementId))
            {
                element = repository.GetElementByID(elementId);
                return(element != null);
            }
            return(false);
        }
        private async void ExecuteAddSpecificationToSpecIfAsync()
        {
            EAAPI.Package treeSelectedPackage = _repository.GetTreeSelectedPackage();

            if (treeSelectedPackage.Element.Stereotype == "specification")
            {
                CachedDataProvider eaCacheDataProvider = new CachedDataProvider(_repository);

                EADM.Element cachedSpecification = eaCacheDataProvider.GetCachedSpecification(treeSelectedPackage);

                List <EADM.Element> linearElementList = eaCacheDataProvider.GetSpecificationElementList(cachedSpecification);

                List <EADM.Element> cachedRequirements = linearElementList.FindAll(el => el.Type == "Requirement" &&
                                                                                   !el.TaggedValues.Exists(tv => tv.Name == "specifId"));

                if (cachedRequirements.Count > 0)
                {
                    ProjectDescriptor project = ExecuteSelectProject();

                    if (project != null)
                    {
                        await Task.Run(() =>
                        {
                            bool error = false;

                            foreach (EADM.Element cachedElement in cachedRequirements)
                            {
                                EAAPI.Element element = _repository.GetElementByID(cachedElement.ElementID);

                                if (element != null)
                                {
                                    logger.Info("Integrating requirement " + cachedElement.Name + "...");
                                    Resource repositoryResource = _projectIntegrator.AddRequirementToSpecIF(_requirementMasterDataWriter, element, project.ID);
                                    if (repositoryResource == null)
                                    {
                                        logger.Error("Error integrating requirement. Abort.");
                                        error = true;
                                        break;
                                    }
                                }
                            }

                            if (!error)
                            {
                                logger.Info("Integration finished.");
                            }
                        });
                    }
                }
            }
        }
Пример #6
0
        // 図から必要な要素を取得し、リストを作成する
        internal void LoadDeployDiagramObjectsInformation(EA.Repository Repository)
        {
            // ノードの配置に関するモデルの作成,親をたどることにより必要な情報を入手
            // 配置図の要素を環境、デバイス、ノード、コンポーネントのリストに格納
            EA.Diagram diagram = Repository.GetCurrentDiagram();
            var        TmpCommunicationList = new List <Communication>();

            for (short i = 0; i < diagram.DiagramObjects.Count; i++)
            {
                DiagramObject diagramObject = diagram.DiagramObjects.GetAt(i);
                Element       element       = Repository.GetElementByID(diagramObject.ElementID);
                var           ConnectorList = new List <Connector>();
                var           xdoc          = element.Notes.ToXDocument();
                switch (element.MetaType)
                {
                case "ExecutionEnvironment":
                    ExecutionEnvironmentList.Add(new ExecutionEnvironment(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Device":
                    // デバイスが保持している接続を取得
                    for (short j = 0; j < element.Connectors.Count; j++)
                    {
                        Connector connector = element.Connectors.GetAt(j);
                        ConnectorList.Add(connector);
                        TmpCommunicationList.Add(new Communication(connector.Name, connector.ConnectorID, connector.DiagramID, connector.Notes.ToXDocument()));
                    }

                    DeviceList.Add(new Device(element.Name, element.ElementID, element.ParentID, xdoc, element.Stereotype, ConnectorList));
                    break;

                case "Node":
                    NodeList.Add(new Node(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;

                case "Component":
                    ComponentList.Add(new Component(element.Name, element.ElementID, element.ParentID, xdoc));
                    break;
                }
            }

            TmpCommunicationList.GroupBy(communication => communication.Name)
            .Select(x => x.FirstOrDefault())
            .ToList()
            .ForEach(Communication => CommunicationList.Add(Communication));
        }
        /// <summary>
        /// Get parent Element of an Embedded Element which isn't an embedded element. Returns null if not found
        /// </summary>
        /// <param name="el"></param>
        /// <param name="rep"></param>
        /// <returns></returns>

        public static EA.Element GetParentOfEmbedded(this EA.Element el, EA.Repository rep)
        {
            if (!el.IsEmbeddedElement(rep, true))
            {
                return(el);
            }
            if (el.ParentID == 0)
            {
                return(null);
            }
            EA.Element elParent = rep.GetElementByID(el.ParentID);
            if (elParent.IsEmbeddedElement(rep, true))
            {
                return(elParent.GetParentOfEmbedded(rep));
            }
            return(elParent);
        }
Пример #8
0
        private void ExecuteSynchronizeReference()
        {
            EAAPI.Diagram diagram = _repository.GetCurrentDiagram();

            if (diagram != null)
            {
                if (diagram.SelectedObjects.Count == 1)
                {
                    EAAPI.DiagramObject diagramObject = (EAAPI.DiagramObject)diagram.SelectedObjects.GetAt(0);

                    EAAPI.Element referenceElement = _repository.GetElementByID(diagramObject.ElementID);

                    ReferenceSynchronizer referenceSynchronizer = new ReferenceSynchronizer(_repository, referenceElement);

                    referenceSynchronizer.SynchronizeReferenceWithOriginal();

                    MessageBox.Show("Synchronization finished.", "Reference Synchronization");
                }
            }
        }
Пример #9
0
        /// <summary>
        ///  Create/Update an Activity Diagram for the operation
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="m"></param>
        /// <param name="treePos">If a new package is created the new tree position to show the package in the correct order</param>
        /// <returns></returns>
        public static bool CreateActivityForOperation(EA.Repository rep, EA.Method m, int treePos = 100)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            EA.Package pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // Check if update behavior, behavior exists
            string behaviorGuid = m.Behavior;

            // Check if update Activity or Create a new one
            if (behaviorGuid.StartsWith("{") && behaviorGuid.EndsWith("}"))
            {
                //behaviorGuid = behaviorGuid.Substring(1, behaviorGuid.Length-2);
                EA.Element actForUpdate = rep.GetElementByGuid(behaviorGuid);
                if (actForUpdate == null)
                {
                    var res = MessageBox.Show($@"Can't update Activity for Operation, invalid link to Activity found

Behavior GUID =GUID of expected Activity:
{behaviorGuid}

Unable to find Activity for this GUID",
                                              @"Invalid link to Activity found, Create a new one?",
                                              MessageBoxButtons.OKCancel);
                    if (res != DialogResult.OK)
                    {
                        return(false);
                    }
                    CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass);
                }
                else
                {
                    UpdateParameterFromOperation(rep, actForUpdate, m); // update parameters from Operation for Activity
                }
                return(true);
            }
            CreateActivityFromOperation(rep, m, treePos, pkgSrc, elClass);
            return(true);
        }
Пример #10
0
        public bool EA_OnPostNewElement(EAAPI.Repository repository, EAAPI.EventProperties info)
        {
            bool result = true;

            int elementId = Convert.ToInt32(info.Get(0).Value.ToString());

            EAAPI.Element newElement = repository.GetElementByID(elementId);

            bool knownType = true;

            ViewModelBase viewModel = null;

            viewModel = GetEditorViewModel(repository, newElement);

            if (viewModel != null)
            {
                repository.SuppressEADialogs = true;
                FMCElementPropertyWindow newAgentWindow = new FMCElementPropertyWindow();
                newAgentWindow.DataContext = viewModel;
                newAgentWindow.ShowDialog();
            }

            return(result);
        }
Пример #11
0
        /// <summary>
        /// Set attributes and tags of supplier port when port is created or connected.
        /// </summary>
        /// <param name="connectorId">The created item flow connector.</param>
        /// <param name="portStereotype">The stereotype of the port.</param>
        /// <param name="connectorStereotype">The stereotype of the port connectiong flow connector.</param>
        /// <param name="supplierName">The EA default name for the new created supplier port.</param>
        public void SetPropertyTypeAndDirectionOnFlowPortCreation(int connectorId,
                                                                  string portStereotype,
                                                                  string connectorStereotype,
                                                                  string supplierName)
        {
            EAShared.Connector connector = Rep.GetConnectorByID(connectorId);

            EAShared.Element client   = Rep.GetElementByID(connector.ClientID);
            EAShared.Element supplier = Rep.GetElementByID(connector.SupplierID);

            if ((supplier.Stereotype == portStereotype) &&
                (connector.Stereotype == connectorStereotype))
            {
                CopyTaggedValuesFromClientToSupplierPort(client, supplier);

                if (supplier.PropertyType == 0)
                {
                    supplier.PropertyType = client.PropertyType;
                    if (supplier.Alias == "")
                    {
                        supplier.Alias = client.Alias;
                    }

                    if (supplier.Multiplicity == "")
                    {
                        supplier.Multiplicity = client.Multiplicity;
                    }

                    // Copy notes text from client to supplier
                    if (supplier.Notes == "")
                    {
                        supplier.Notes = client.Notes;
                    }
                }
                else if (supplier.PropertyType == client.PropertyType)
                {
                    if (supplier.Alias == "")
                    {
                        supplier.Alias = client.Alias;
                    }

                    if (supplier.Multiplicity == "")
                    {
                        supplier.Multiplicity = client.Multiplicity;
                    }

                    // Copy notes text from client to supplier
                    if (supplier.Notes == "")
                    {
                        supplier.Notes = client.Notes;
                    }
                }

                if (supplier.Name.StartsWith(supplierName) || supplier.Name == "")
                {
                    supplier.Name = client.Name;
                }


                supplier.Update();
                supplier.Refresh();
            } // if
        }
Пример #12
0
        public void SynchronizeReferenceWithOriginal()
        {
            List <EAAPI.Element> originals = new List <EAAPI.Element>();

            EAAPI.Element original = null;

            // search for originals
            for (short connectorCount = 0; connectorCount < _referenceElement.Connectors.Count; connectorCount++)
            {
                EAAPI.Connector connector = (EAAPI.Connector)_referenceElement.Connectors.GetAt(connectorCount);

                if (connector.ClientID == _referenceElement.ElementID && connector.SupplierID != _referenceElement.ElementID)
                {
                    if (connector.Type == "Dependency" && connector.Stereotype == "referenceOf")
                    {
                        original = _repository.GetElementByID(connector.SupplierID);

                        if (original.Type == "Object" && original.ClassifierID == _referenceElement.ClassifierID)
                        {
                            originals.Add(original);
                        }
                    }
                }
            }

            if (originals.Count == 1)
            {
                original = originals[0];

                if (original.ClassifierID != _referenceElement.ClassfierID)
                {
                    logger.Info("Synchronizing element type.");
                    _referenceElement.ClassifierID = _referenceElement.ClassifierID;
                    _referenceElement.Update();
                }

                DeleteWrongPortReferenceOfConnections(original.ElementID);

                SynchronizePortsOfReferenceElement(original);

                // synchronize descriptional notes
                logger.Info("Synchronizing descriptional notes.");
                _referenceElement.Notes = original.Notes;
                _referenceElement.Update();

                _referenceElement.Stereotype = original.Stereotype;
                _referenceElement.Update();

                SynchronizeTaggedValues(original, _referenceElement);

                logger.Info("Port synchoronization finished.");
            }
            else if (originals.Count == 0)
            {
                // return if no original was found
                logger.Info("No original element found.");
                return;
            }
            else
            {
                logger.Error("Error: Reference is not unique.");
            }
        }
 /// <summary>
 /// Get parent DiagramObject from DiagramObject
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="rep"></param>
 /// <param name="dia"></param>
 /// <returns></returns>
 public static EA.DiagramObject GetParentOfEmbedded(this EA.DiagramObject obj, EA.Repository rep, EA.Diagram dia)
 {
     EA.Element elParent = rep.GetElementByID(obj.ElementID).GetParentOfEmbedded(rep);
     return(dia.GetDiagramObjectByID(elParent.ElementID, ""));
 }
Пример #14
0
        /// <summary>
        /// Import and update Requirements. You can set EA ObjectType like "Requirement" or EA Stereotype like "FunctionalRequirement"
        /// </summary>
        /// async Task
        public virtual bool ImportForFile(string eaObjectType = "Requirement",
                                          string eaStereotype = "",
                                          string stateNew     = "",
                                          string stateChanged = "")
        {
            _rep.BatchAppend     = true;
            _rep.EnableUIUpdates = false;

            // Prepare
            _dtRequirements = ExpImp.MakeDataTableFromCsvFile(_importModuleFile, ',');

            ReadEaPackageRequirements();
            CreateEaPackageDeletedObjects();

            _count        = 0;
            _countAll     = 0;
            _countChanged = 0;
            _countNew     = 0;
            List <int> parentElementIdsPerLevel = new List <int> {
                0
            };
            int parentElementId = 0;
            int lastElementId   = 0;

            int oldLevel = 0;

            foreach (DataRow row in _dtRequirements.Rows)
            {
                _count += 1;
                string objectId      = row["Id"].ToString();
                string reqAbsNumber  = GetAbsoluteNumerFromDoorsId(objectId);
                int    objectLevel   = Int32.Parse(row["Object Level"].ToString()) - 1;
                string objectNumber  = row["Object Number"].ToString();
                string objectType    = row["ObjectType"].ToString();
                string objectHeading = row["Object Heading"].ToString();


                // Maintain parent ids of level
                // get parent id
                if (objectLevel > oldLevel)
                {
                    if (parentElementIdsPerLevel.Count <= objectLevel)
                    {
                        parentElementIdsPerLevel.Add(lastElementId);
                    }
                    else
                    {
                        parentElementIdsPerLevel[objectLevel] = lastElementId;
                    }
                    parentElementId = lastElementId;
                }
                if (objectLevel < oldLevel)
                {
                    parentElementId = parentElementIdsPerLevel[objectLevel];
                }

                oldLevel = objectLevel;
                string name;
                string notes;

                // Estimate if header
                if (objectType == "headline" || !String.IsNullOrWhiteSpace(objectHeading))
                {
                    name  = $"{objectNumber} {objectHeading}";
                    notes = row["Object Heading"].ToString();
                }
                else
                {
                    notes = row["Object Text"].ToString();
                    string objectShorttext = GetTextExtract(notes);
                    objectShorttext = objectShorttext.Length > ShortNameLength?objectShorttext.Substring(0, ShortNameLength) : objectShorttext;

                    name = $"{reqAbsNumber.PadRight(7)} {objectShorttext}";
                }
                // Check if requirement with Doors ID already exists
                bool isExistingRequirement = DictPackageRequirements.TryGetValue(reqAbsNumber, out int elId);


                EA.Element el;
                if (isExistingRequirement)
                {
                    el = _rep.GetElementByID(elId);
                    if (el.Alias != objectId ||
                        el.Name != name ||
                        el.Notes != notes ||
                        el.Type != eaObjectType ||
                        el.Stereotype != eaStereotype)
                    {
                        if (stateChanged != "")
                        {
                            el.Status = stateChanged;
                        }
                        _countChanged += 1;
                    }
                }
                else
                {
                    el = (EA.Element)_pkg.Elements.AddNew(name, "Requirement");
                    if (stateNew != "")
                    {
                        el.Status = stateNew;
                    }
                    _countChanged += 1;
                }


                el.Alias        = objectId;
                el.Name         = name;
                el.Multiplicity = reqAbsNumber;
                el.Notes        = notes;
                el.TreePos      = _count * 10;
                el.PackageID    = _pkg.PackageID;
                el.ParentID     = parentElementId;
                el.Type         = eaObjectType;
                el.Stereotype   = eaStereotype;

                el.Update();
                _pkg.Elements.Refresh();
                lastElementId = el.ElementID;

                // handle the remaining columns/ tagged values
                var cols = from c in _dtRequirements.Columns.Cast <DataColumn>()
                           where !ColumnNamesNoTaggedValues.Any(n => n == c.ColumnName)
                           select new
                {
                    Name  = c.ColumnName,
                    Value = row[c].ToString()
                }

                ;
                // Update/Create Tagged value
                foreach (var c in cols)
                {
                    TaggedValue.SetUpdate(el, c.Name, c.Value);
                }
            }

            MoveDeletedRequirements();
            UpdatePackage();

            _rep.BatchAppend     = false;
            _rep.EnableUIUpdates = true;
            _rep.ReloadPackage(_pkg.PackageID);
            return(true);
        }
Пример #15
0
        public static bool CreateInteractionForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            Package    pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");

            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class Sequence Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Sequence");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in Sequence diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create Interaction with the name of the operation
            EA.Element seq = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "Interaction");
            seq.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            seq.Update();
            pkgTrg.Elements.Refresh();

            // create sequence diagram beneath Interaction
            EA.Diagram seqDia = (EA.Diagram)seq.Diagrams.AddNew(m.Name, "Sequence");
            seqDia.Update();
            seq.Diagrams.Refresh();

            // create instance from class beneath Interaction
            EA.Element obj = (EA.Element)seq.Elements.AddNew("", "Object");
            seq.Elements.Refresh();
            obj.ClassfierID = elClass.ElementID;
            obj.Update();

            // add node object to Sequence Diagram
            EA.DiagramObject node = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=100;r=180;t=50;b=70", "");
            node.ElementID = obj.ElementID;
            node.Update();


            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)seqDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            seqDia.DiagramObjects.Refresh();


            // Link Operation to activity
            HoUtil.SetBehaviorForOperation(rep, m, seq);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, seqDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }
Пример #16
0
        //-----------------------------------------------------------------------------------------
        // Create StateMachine for Operation
        //----------------------------------------------------------------------------------
        public static bool CreateStateMachineForOperation(EA.Repository rep, EA.Method m)
        {
            // get class
            EA.Element elClass = rep.GetElementByID(m.ParentID);
            EA.Package pkgSrc  = rep.GetPackageByID(elClass.PackageID);

            // create a package with the name of the operation
            EA.Package pkgTrg = (Package)pkgSrc.Packages.AddNew(m.Name, "");
            pkgTrg.Update();
            pkgSrc.Packages.Refresh();

            // create Class StateMachine Diagram in target package
            EA.Diagram pkgSeqDia = (EA.Diagram)pkgTrg.Diagrams.AddNew("Operation:" + m.Name + " Content", "Statechart");
            pkgSeqDia.Update();
            pkgTrg.Diagrams.Refresh();

            // add frame in StateMachine diagram
            EA.DiagramObject frmObj = (EA.DiagramObject)pkgSeqDia.DiagramObjects.AddNew("l=100;r=400;t=25;b=50", "");
            EA.Element       frm    = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "UMLDiagram");
            frm.Update();
            frmObj.ElementID = frm.ElementID;
            //frmObj.Style = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            frmObj.Update();
            pkgTrg.Elements.Refresh();
            pkgSeqDia.DiagramObjects.Refresh();


            // create StateMachine with the name of the operation
            EA.Element stateMachine = (EA.Element)pkgTrg.Elements.AddNew(m.Name, "StateMachine");
            stateMachine.Notes = "Generated from Operation:\r\n" + m.Visibility + " " + m.Name + ":" + m.ReturnType + ";\r\nDetails see Operation definition!!";
            stateMachine.Update();
            pkgTrg.Elements.Refresh();

            // create Statechart diagram beneath State Machine
            EA.Diagram chartDia = (EA.Diagram)stateMachine.Diagrams.AddNew(m.Name, "Statechart");
            chartDia.Update();
            stateMachine.Diagrams.Refresh();

            // put the state machine on the diagram
            EA.DiagramObject chartObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=50;r=600;t=100;b=800", "");
            chartObj.ElementID = stateMachine.ElementID;
            chartObj.Update();
            chartDia.DiagramObjects.Refresh();

            // add default nodes (init/final)
            CreateDefaultElementsForStateDiagram(rep, chartDia, stateMachine);

            // Add Heading to diagram
            EA.DiagramObject noteObj = (EA.DiagramObject)chartDia.DiagramObjects.AddNew("l=40;r=700;t=10;b=25", "");
            EA.Element       note    = (EA.Element)pkgTrg.Elements.AddNew("Text", "Text");

            note.Notes = m.Visibility + " " + elClass.Name + "_" + m.Name + ":" + m.ReturnType;
            note.Update();
            noteObj.ElementID = note.ElementID;
            noteObj.Style     = "fontsz=200;pitch=34;DUID=265D32D5;font=Arial Narrow;bold=0;italic=0;ul=0;charset=0;";
            noteObj.Update();
            pkgTrg.Elements.Refresh();
            chartDia.DiagramObjects.Refresh();


            // Link Operation to StateMachine
            HoUtil.SetBehaviorForOperation(rep, m, stateMachine);

            // Set show behavior
            HoUtil.SetShowBehaviorInDiagram(rep, m);



            HoUtil.SetFrameLinksToDiagram(rep, frm, chartDia); // link Overview frame to diagram
            frm.Update();
            //rep.ReloadDiagram(actDia.DiagramID);


            return(true);
        }