Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Geert Bellekens

Pages: 1 ... 475 476 [477] 478 479 ... 576
7141
Automation Interface, Add-Ins and Tools / Re: Change Stereotypes
« on: December 04, 2013, 07:17:57 pm »
Some sources for info:


- the help file: there a whole automation section in the help file
- Thomas Kilians scripting book
- The examples in the installation folder (on my machine on C:\Program Files (x86)\Sparx Systems\EA\Scripts)
- The community site
- this forum (there are a lot of posts with code snippets)
- My blog Tutorial: Create your first C# Enterprise Architect addin in 10 minutes
-  My open source repositories (C#)

Geert

7142
Here's what I use in my ElementWrapper.cs

Code: [Select]
   //returns a list of diagrams that somehow use this element.
    public override HashSet<T> getUsingDiagrams<T>()
    {
        string sqlGetDiagrams = @"select distinct d.Diagram_ID from t_DiagramObjects d
                                  where d.Object_ID = " + this.wrappedElement.ElementID;
        List<UML.Diagrams.Diagram> allDiagrams = this.model.getDiagramsByQuery(sqlGetDiagrams).Cast<UML.Diagrams.Diagram>().ToList(); ; ;
        HashSet<T> returnedDiagrams = new HashSet<T>();
        foreach (UML.Diagrams.Diagram diagram in allDiagrams)
        {
            if (diagram is T)
            {
                T typedDiagram = (T)diagram;
                if (!returnedDiagrams.Contains(typedDiagram))
                {
                    returnedDiagrams.Add(typedDiagram);
                }
            }
        }
        return returnedDiagrams;
    }

Geert

7143
I always consider the API as a very thin layer around the actual database. So not much different to actually working with the database directly.

And don't forget, there's hardly any constraint defined on that database :'(

Geert

7144
EA doesn't do much automatically when using the API.

Geert

7145
There is a subtle difference between Repository.SaveDiagram() and Diagram.Update().
Repository.SaveDiagram() will the save the unsaved changes in an opened diagram.
Diagram.Update() will save the changes you have made to the EA.Diagram object in memory (and thus ignore all unsaved changes on the opened diagram)
So since you are calling Repository.SaveDiagram() it it saving the object in the memory of the EA GUI, and not the object your are working with in your add-in.

But in this particular case you don't even need to save the diagram because you are not changing anything to the diagram, only to a DiagramObject.

Geert

7146
Automation Interface, Add-Ins and Tools / Re: package.update() exception
« on: November 19, 2013, 06:05:45 pm »
Also make sure you run the Project Integrity Check to make sure there are not inconsistencies in the package you are trying to update.

Geert

7147
Check the package class.
There's all kinds of version control operations that you can do from there.

Geert

7148
Just to be clear, you can only do the checkbox thing with menu's.
No icons or radio buttons or anything else fancy.

Geert

7149
Automation Interface, Add-Ins and Tools / Re: SQL Update in a C# addin
« on: November 06, 2013, 06:30:14 pm »
Guillaume,

Repository.SQLQuery only allows read-only queries.
For other types of SQL commands use Repository.Execute().

Geert

7150
Could be a 32/64 bit issue.
EA only plays with 32 bit buddies.

Geert

7151
Automation Interface, Add-Ins and Tools / Re: Remove elements in script
« on: October 18, 2013, 04:49:49 pm »
What I do in my tooling framework is write wrapper classes for all the EA classes in the API.
On such a wrapper class you can write a delete() operation and implement is such that it first retrieves the owner and then deletes itself from the owners .Elements collection.

In my add-ins and tools I only use the wrapper classes, not the actual API classes. That sort of shields me from most of the madness ;D

Geert

7152
What I usually do in such circumstances is use Repository.SQLQuery to get the ID(s) of the things I need, and then use Repository.Get<thing>ByID to actually retrieve the object.

Geert

7153
Here's the interesting bit from the code in my framework, from the class Model.cs

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.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);
            }
        }

And the bit to get to the main EA windows handle:
Code: [Select]
   /// <summary>
    /// the main EA window to use when opening properties dialogs
    /// </summary>
    public IWin32Window mainEAWindow
    {
            get
            {
                    if //(true)
                            (this._mainEAWindow == null)
                    {
                            List<Process> allProcesses = new List<Process>( Process.GetProcesses());
                                   Process proc = allProcesses.Find(pr => pr.ProcessName == "EA");
                             //if we don't find the process then we set the mainwindow to null
                                   if (proc == null
                                       || proc.MainWindowHandle == null)
                             {
                                     this._mainEAWindow = null;
                             }
                             else
                             {
                                     //found it. Create new WindowWrapper
                                     this._mainEAWindow  = new WindowWrapper(proc.MainWindowHandle);
                             }
                    }
                     return this._mainEAWindow;
            }
    }

This code is used by the EA Navigator to open the properties of an item.

Geert

7154
It shows the name of the key in the registry.
So, yes in theory you could add things like the version in the name of the key, but it would be a bit of a hassle to maintain that.

Geert

7155
I'm not sure (since I don't use scripting) but I think I've seen some topics go by that suggested it should be possible somehow.

Have you tried searching the forum (using the top left search button)

Geert

Pages: 1 ... 475 476 [477] 478 479 ... 576