Book a Demo

Author Topic: Callback mechanism  (Read 4953 times)

supplyondemand

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Callback mechanism
« on: February 24, 2012, 09:58:00 pm »
Hi!

I am new to EA scripting, so please bear with me.

I want to do two things:

1. Display a custom tooltip.
2. Display a custom window (for example like the predefined "Tagged Values" or "Notes" window) to display information that I can assemble according to the selected element.

Is there some kind of callback mechanism, meaning that the function will be invoked every time I select an element (with a reference to this element) or move the mouse over an element (to display the tooltip)?

Thank you!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Callback mechanism
« Reply #1 on: February 24, 2012, 10:01:08 pm »
No. IIRC Rational Rose had that neat callback which we used for quite a lot of things. But EA hasn't. You only get called if you're actually manipulating elements.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Callback mechanism
« Reply #2 on: February 24, 2012, 10:38:52 pm »
I don't think a custom tooltip is possible, but a custom window certainly is.
I use that feature to for the  EA Navigator.
The complete code can be found here:
https://github.com/GeertBellekens/Enterprise-Architect-Toolpack
https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework
https://github.com/GeertBellekens/UML-Tooling-Framework

Geert
« Last Edit: February 24, 2012, 10:39:22 pm by Geert.Bellekens »

supplyondemand

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Callback mechanism
« Reply #3 on: February 24, 2012, 11:05:29 pm »
Thanks a lot Geert.

Could you however give me some more specific pointers where I can find the "entry point", meaning the function that is called when I select an element and that does the window update? And how I define that this function is actually called?

Like I said I am really new to this.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Callback mechanism
« Reply #4 on: February 24, 2012, 11:12:02 pm »
The starting point is here:
https://github.com/GeertBellekens/Enterprise-Architect-Toolpack/blob/master/EANavigator/EAAddin.cs
On line 345
Code: [Select]
     public override void EA_OnContextItemChanged(global::EA.Repository Repository, string GUID, global::EA.ObjectType ot)
    {
        if (fullyLoaded && this.model != null )
        {      
            if (this.model.selectedItem != null)
            {
                  this.navigate(this.model.selectedItem) ;
            }
        }
    }

      private void navigate(UML.UMLItem item)
      {
            if (fullyLoaded)
        {
            if (this.navigatorControl == null)
            {
                this.navigatorControl = this.model.addWindow("Navigate", "TSF.UmlToolingFramework.EANavigator.NavigatorControl") as NavigatorControl;
                this.navigatorControl.BeforeExpand += new TreeViewCancelEventHandler(this.NavigatorTreeBeforeExpand);
                this.navigatorControl.NodeDoubleClick += new TreeNodeMouseClickEventHandler(this.NavigatorTreeNodeDoubleClick);
            }
            if (this.navigatorControl != null && this.model != null)
            {
                if (item != null)
                {
                    this.navigatorControl.setElement(item);
                }

            }
        }
      }

Geert