Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: emiliano.davila 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.
-
Propertieswindow, yes, traceability, no.
For properties you can use Repository.CustomCommand
/// <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