Author Topic: GetContextItem returns false object  (Read 4817 times)

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
GetContextItem returns false object
« on: July 18, 2012, 12:52:46 am »
Hello,

I have a Composite Structure Diagram with a class and two parts inside the enclosing class. The two parts are connected by a flow or a connector. The flow is selected and the addin should return the flow after calling GetContextItem. It returns the enclosing class instead.

Without the enclosing task everything works as expected.

Thanks,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: GetContextItem returns false object
« Reply #1 on: July 18, 2012, 04:00:15 am »
Helmut,
GetContextItem returns an element. If you want to get hold of the connector try the diagram's SelectedConnector method.

q.

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: GetContextItem returns false object
« Reply #2 on: July 18, 2012, 04:02:51 am »
Hi,

thanks a lot. Looks simple but I wasn't aware of it.

Kind regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: GetContextItem returns false object
« Reply #3 on: July 18, 2012, 02:49:14 pm »
Quote
Helmut,
GetContextItem returns an element. If you want to get hold of the connector try the diagram's SelectedConnector method.

q.
q.

I think you are wrong here. I use GetContextItem to get whatever is selected (including connectors) and according to the documentation of of the method GetContextItemType it should:
Quote
Returns the ObjectType of an item in context within Enterprise Architect. A ContextItem is defined as an item selected anywhere within the Enterprise Architect GUI including:

· An item selected in the Project Browser  

· An item selected in an open diagram

· An item selected in certain dialogs, such as the attribute Properties dialog
  

The supported ObjectTypes can be any one of the following values:

· otElement

· otPackage

· otDiagram

· otAttribute

· otMethod

· otConnector

So if it returns the containing Element i.s.o. the selected connector then I guess you can call it a bug and report it to Sparx.

Geert
  

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: GetContextItem returns false object
« Reply #4 on: July 19, 2012, 12:34:06 am »
You're right. But obviously Helmut needed the fallback as the official method did not work. How did I call that? Ah! Geert-around....

q.

P.S. I have tried Helmut's configuration and for me it returned the connector correctly.
« Last Edit: July 19, 2012, 12:39:17 am by qwerty »

Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: GetContextItem returns false object
« Reply #5 on: July 19, 2012, 12:41:54 am »
Hello Thomas, Hello Geert,

thanks a lot!

I have my workaround and I will post a bug report.

Kind regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)