Book a Demo

Author Topic: Add'in menu condition on Diagrams, Project Browser  (Read 5104 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1401
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Add'in menu condition on Diagrams, Project Browser
« on: July 11, 2014, 04:38:13 pm »
Hi,

I'm moving a number of VB scripts (normal, project browser, diagram) into an EA add'in.
I'm looking for a set of conditions to display menus based on the selection context, e.g.
Menu1 : displayed if Extension accessed via a right click from a diagram
Menu2 : displayed if Extension accessed via a right click from the project browser
Menu3 : always displayed

Have you got any recommendation? The current template only checks if an EA Project is opened to enable/disable the whole menu.

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


ZuluTen

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: Add'in menu condition on Diagrams, Project Bro
« Reply #1 on: July 14, 2014, 04:52:24 am »
The GetMenuState instruction includes a value for Location which can be TreeView, MainMenu or Diagram.
You can use a Case statement to determine which and then display sub menus accordingly.
There’s a simple example in the current version of the EA Manual on Page 2566.
What I haven’t yet figure out is whether I can use the Add In to change the native EA Main Menu: for example to remove features that are superfluous to my user.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Add'in menu condition on Diagrams, Project Bro
« Reply #2 on: July 14, 2014, 10:41:44 am »
Both EA_GetMenuItems and EA_GetMenuState have a Location parameter.  Possible values: "MainMenu", "Diagram", "TreeView".

You could either test the Location value in EA_GetMenuItems to decide whether or not to show each menu item at all, or test the Location value in EA_GetMenuState to disable (i.e. grey out) your menu options.

The add-in cannot change any native menus outside of it's own submenu below Extensions.  If you wish to show/hide other EA menu options, please see the help regarding the "Command Sets" feature.
http://www.sparxsystems.com/enterprise_architect_user_guide/10/getting_started/customize_command_sets.html