Book a Demo

Author Topic: removing connector after EA_OnPostNewConnector  (Read 5389 times)

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
removing connector after EA_OnPostNewConnector
« on: February 21, 2013, 11:02:27 pm »
Hi

After (in) the EA_OnPostNewConnector the add-in can decide the connector should not be created.

How to proceed to remove the connector (apparently) already created ??

- this is a 'stateflow' connector on a FinalStateMachine diagram

- simply returning 'false' from EA_OnPostNewConnector doesn't suffice

As always : all and any help greatly appreciated.




Reg.

Danny

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: removing connector after EA_OnPostNewConnector
« Reply #1 on: February 22, 2013, 12:08:52 am »
Danny,

If you want to prevent the creation of the connector then you have to use EA_OnPreNewConnector.
Otherwise, I guess you need to get one of the two ends, get its collection of connectors, loop that until you find the connector you need, and use Collection.DeleteAt() to delete it.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: removing connector after EA_OnPostNewConnector
« Reply #2 on: February 22, 2013, 12:14:51 am »
However, it should be possible to control whether the properties dialog shall close after completion instead of just telling something has changed. I guess the "usual" use case is that you check some consistency and the user can choose to change or cancel. This applies to all On_Post events.

q.

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: removing connector after EA_OnPostNewConnector
« Reply #3 on: February 22, 2013, 12:30:43 am »
Thanks guys........but

I seem to run into 'special cases' all the time  ;)

@ Geert : that technique works, but not for a stateflow connector  
it 'automagically' re-appears !
I have even deleted the entry myself in t_connector and it gets created again !! with a connectorID+1  :-?

@ Querty, a stateflow connector doesn't present a properties dialog

I wanted a challenge - seems like I got me one  ;D



Reg.

Danny

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: removing connector after EA_OnPostNewConnector
« Reply #4 on: February 22, 2013, 12:38:43 am »
Quote
Thanks guys........but

I seem to run into 'special cases' all the time  ;)

@ Geert : that technique works, but not for a stateflow connector  
it 'automagically' re-appears !
I have even deleted the entry myself in t_connector and it gets created again !! with a connectorID+1  :-?


Are you still using the OnPostNew connector?
I can imagine that, depending on the return value of this operation, EA will save the connector again.

If not it must be a bug.

Anyway, as a workaround you could save the details of the 'connector to delete' in your add-in, and then in the next event delete it (like OnContextItemChanged)


Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: removing connector after EA_OnPostNewConnector
« Reply #5 on: February 22, 2013, 01:33:14 am »
Quote
@ Querty, a stateflow connector doesn't present a properties dialog
Connector properties only pop up if Tools/Options/Links/Edit Connector on New is checked. So indeed connector treatment is even more complicated since the GUI behaves different to other elements.

q.

Danny F

  • EA User
  • **
  • Posts: 60
  • Karma: +0/-0
    • View Profile
Re: removing connector after EA_OnPostNewConnector
« Reply #6 on: February 22, 2013, 01:57:09 am »
Thanks Querty for this tip (and all help you tirelessly provide, same goes for Geert)

but it doesn't change anything

indeed, when Tools/Options/Links/Edit Connector on New is checked  the dialog pops up

Cancel on this dialog
or (hardcoded) returning false on the EA_OnPostNewConnector event

all to no avail - the connector (stateflow) stays where it is

Reg.

Danny

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: removing connector after EA_OnPostNewConnector
« Reply #7 on: February 22, 2013, 02:49:20 am »
That sucks, I know. There was a recent similar thread where someone suggested to trigger a timer and do the job a bit later. Geert also posted there.

q.