Author Topic: EA api doubt  (Read 2293 times)

emiliano.davila

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
EA api doubt
« on: March 12, 2022, 12:41:22 am »
Hi
I am currently developing an addin and I need a button to open the properties window of a specific element.
Is there any function for this in the EA api?
I also need to open the traceability window through the addin, is this possible?

I know it is possible to simulate clicks, but from what I read it is not the most advisable thing to do.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: EA api doubt
« Reply #1 on: March 12, 2022, 03:47:31 am »
Propertieswindow, yes, traceability, no.

For properties you can use Repository.CustomCommand

Code: [Select]
/// <summary>
        /// opens the properties dialog for this item
        /// </summary>
        /// <param name="item">the item to open the properties dialog for</param>
        public void openProperties(UML.Extended.UMLItem item)
        {
            //get the type string
            string typeString = string.Empty;
            int itemID = 0;
            if (item is Package)
            {
                typeString = "PKG";
                itemID = ((Package)item).packageID;
            }
            else if (item is ElementWrapper)
            {
                typeString = "ELM";
                itemID = ((ElementWrapper)item).id;
            }
            else if (item is Attribute)
            {
                typeString = "ATT";
                itemID = ((Attribute)item).id;
            }
            else if (item is Operation)
            {
                typeString = "OP";
                itemID = ((Operation)item).id;
            }
            else if (item is Diagram)
            {
                typeString = "DGM";
                itemID = ((Diagram)item).DiagramID;
            }
            // TODO: figure out how to open the properties dialog for a connector.
            // else if (item is ConnectorWrapper)
            // {
            // //typeString = "CON";
            // typeString = "MSG";
            // itemID = ((ConnectorWrapper)item).id;
            // }
            //open the actual dialog
            if (this.mainEAWindow != null
                && typeString != string.Empty
                && itemID != 0)
            {
                string ret = this.wrappedModel.CustomCommand("CFormCommandHelper", "ProcessCommand", "Dlg=" + typeString + ";id=" + itemID.ToString() + ";hwnd=" + this.mainEAWindow.Handle);
            }
        }

Geert