Book a Demo

Author Topic: Change element parent to diagram package  (Read 4148 times)

Paul W

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Change element parent to diagram package
« on: September 17, 2008, 01:07:10 am »
This one is a hang over from my Rose days.
When in a diagram highlight one or more elements and have a locate to current package option. The elements would then be moved into the current package and the browser refreshed.
Use it lots to organise models

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Change element parent to diagram package
« Reply #1 on: September 17, 2008, 01:39:09 am »
What a nice feature!

I suggest you fire this in to Sparx. Use the Feature Request link below the Support link near the bottom of any forum page.
No, you can't have it!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Change element parent to diagram package
« Reply #2 on: September 17, 2008, 08:10:26 am »
I have an add-in command for this purpose if it helps.

Code: [Select]
       int CountDiagramSelectionInOtherPackage(EA.Repository r)
        {
            EA.Diagram d = r.GetCurrentDiagram();
            if(d == null)
                return 0;

            int count = 0;
            EA.Collection c = d.SelectedObjects;
            foreach (EA.DiagramObject o in d.SelectedObjects)
            {
                EA.Element e = r.GetElementByID(o.ElementID);
                if (e.PackageID != d.PackageID)
                    count++;
            }
            return count;
        }

        void MoveDiagramSelectionToThisPackage(EA.Repository r)
        {
            EA.Diagram d = r.GetCurrentDiagram();
            if (d == null)
                return;

            EA.Collection c = d.SelectedObjects;
            foreach (EA.DiagramObject o in d.SelectedObjects)
            {
                EA.Element e = r.GetElementByID(o.ElementID);
                if (e.PackageID != d.PackageID)
                {
                    e.PackageID = d.PackageID;
                    e.Update();
                    r.AdviseElementChange(e.ElementID);
                }
            }
        }

Paul W

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
Re: Change element parent to diagram package
« Reply #3 on: September 19, 2008, 09:00:13 pm »
Thats great but how do I get this into EA?
:-?