Book a Demo

Author Topic: Differentiate between an element selected in the browser or a diagram?  (Read 7982 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1403
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Hi,

I have a menu item to show in my C# addin when there is a selected element from the active diagram.
Repository.GetContextItemType() displays otElement object type when I have an element selected from the Browser or a Diagram.
Is there a way to know that my element is selected within the active diagram, and not the browser? (and vice versa i.e. I want to display a menu when my element is selected in the browser, not a diagram).
Guillaume

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


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Differentiate between an element selected in the browser or a diagram?
« Reply #1 on: August 27, 2019, 01:24:22 am »
Use the parameter MenuLocation

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1403
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Differentiate between an element selected in the browser or a diagram?
« Reply #2 on: August 27, 2019, 04:13:29 pm »
Thanks Geert  :D

This is indeed an information available via one of the parameters of EA_GetMenuItems, EA_GetMenuState and EA_MenuClick with one of the following values: Diagram, TreeView, MainMenu.

Guillaume

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


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Differentiate between an element selected in the browser or a diagram?
« Reply #3 on: August 27, 2019, 04:27:52 pm »
Sorry about the short reply and lack of context. I didn't really have time to write a full answer at the time.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Differentiate between an element selected in the browser or a diagram?
« Reply #4 on: August 28, 2019, 03:12:06 pm »
I'll just take this opportunity to recommend EA 15 as it contains a new API which may help.

Repository.CurrentSelection is documented as "Provides information on what is selected, and in what location without making any requests to the database."

EASelection Class

The Location property does what you're asking, and in greater detail than the MenuLocation property. Although I'd encourage where possible it's best to have the same behavior wherever the selection is. (The obvious exception being commands to select it in another place)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1403
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Differentiate between an element selected in the browser or a diagram?
« Reply #5 on: August 30, 2019, 07:41:00 pm »
This new API method looks interesting so I'll test it.

Thanks Eve
Guillaume

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