Book a Demo

Author Topic: Weird behavior while creating elements in add-in  (Read 4080 times)

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Weird behavior while creating elements in add-in
« on: September 11, 2013, 06:36:38 pm »
Hi Folks,

I have a stereotype extending metaclass Component and set Composite Structure Diagram as _defaultDiagramType. Both are placed in a MDG technology.

I am creating elements of the stereotype with this code:

Code: [Select]
       public static EA.IDualElement addNewElementToPackage(EA.IDualRepository rep, EA.IDualPackage package, string compName, string qualifiedStereotype)
        {
            EA.IDualCollection collectionSubElems = package.Elements;
            EA.IDualElement newComponent = (EA.IDualElement)collectionSubElems.AddNew(compName, qualifiedStereotype);
            newComponent.Update();
            collectionSubElems.Refresh();
            EA.Diagram compositeDiagram = rep.GetDiagramByID(newComponent.CompositeDiagram.diagramID);
            compositeDiagram.Name = compName;
            compositeDiagram.Update();
            return newComponent;
        }

By now, this worked perfectly in all cases, but now I discovered a weird behavior:
I create a new empty view with the context menu. The result looks like this.

Note the little arrow before classView, although the view is still empty. If I invoke the function above the component is obviously created, but no diagram is nor created neither associated to the component.
The whole procedure works perfectly, if I click once on the empty view before invoking the function. The arrow disappears and the setting looks like this:

Could anyone imagine what the click on the package induces internally?

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Weird behavior while creating elements in add-
« Reply #1 on: September 11, 2013, 06:43:29 pm »
OK, I don't know what causes this issue inside EA, but a
Code: [Select]
rep.RefreshModelView(package.PackageID); helped once again.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Weird behavior while creating elements in add-
« Reply #2 on: September 11, 2013, 07:48:12 pm »
I also find the triangle appear when creating packages manually (don't remember the exact circumstances). But as it's EA I simply ignore that since I know it vanishes once clicked. EAUI.

q.
« Last Edit: September 11, 2013, 07:49:25 pm by qwerty »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Weird behavior while creating elements in add-
« Reply #3 on: September 12, 2013, 08:58:25 am »
The 'arrow' is just the normal tree collapsed indication.

You'll see that behavior any time a package is visible but its contents haven't been loaded. (Because it only tries to load the contents when you expand)

EA could be smarter about this when creating a new package, but it appears that in this circumstance it isn't.