Author Topic: Can't drop elements on a diagram  (Read 3694 times)

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Can't drop elements on a diagram
« on: August 31, 2020, 08:43:24 pm »
I created a BPMN2.0::StartEvent through a script and add it to a pool. In my project browser the StartEvent is created within the pool, but when I try to drag it to my diagram, I got the following error message:

Quote
When dropping embedded elements (Ports, Object Nodes, etc.) on to a diagram, you must drop them on their correct owner. For embedded elements fixed to a parent edge, drop them near the desired edge

The activities that I created in the same way, are perfectly possible to drop onto the diagram in and outside the pool.

The StartEvent is only dropable on the edge of the pool, and then appears a blue startEvent right on the border/edge of the pool element. Very strange...
« Last Edit: August 31, 2020, 08:47:10 pm by MatthiasVDE »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Can't drop elements on a diagram
« Reply #1 on: September 01, 2020, 09:17:23 am »
The BPMN events extend two different UML metaclasses, it sounds like your script has created one using the other one from what you normally use.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Can't drop elements on a diagram
« Reply #2 on: September 01, 2020, 02:11:43 pm »
The BPMN events extend two different UML metaclasses, it sounds like your script has created one using the other one from what you normally use.

I queried the element object type with an external database viewer, and it seems I created a 'Node' instead of an 'Event'. When I query the element with the model search, the event is an 'Event'.

Quote
         dim startEvent as EA.Element
      set startEvent = poolElement.Elements.AddNew("Start", "BPMN2.0::StartEvent")
      startEvent.Stereotype = "StartEvent"
      startEvent.Update()
      poolElement.Elements.Refresh()



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Can't drop elements on a diagram
« Reply #3 on: September 01, 2020, 03:58:27 pm »
Mathias,

You might need to create the object type explicitly and then set the stereotype

Code: [Select]
dim startEvent as EA.Element
set startEvent = poolElement.Elements.AddNew("Start", "Event")
startEvent.StereotypeEx = "BPMN2.0::StartEvent"
startEvent.Update()

Geert

PS. The lines in your current to set the stereotype, and to Refresh() are probably not needed.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Can't drop elements on a diagram
« Reply #4 on: September 01, 2020, 04:16:11 pm »
Mathias,

You might need to create the object type explicitly and then set the stereotype

Code: [Select]
dim startEvent as EA.Element
set startEvent = poolElement.Elements.AddNew("Start", "Event")
startEvent.StereotypeEx = "BPMN2.0::StartEvent"
startEvent.Update()

Geert

PS. The lines in your current to set the stereotype, and to Refresh() are probably not needed.

Tanks Geert,

I always read that is was necessary to refresh the parent where you create the element, this can be a package or another element. But this is not necessary? even if you create (child) diagrams?
 

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Can't drop elements on a diagram
« Reply #5 on: September 01, 2020, 05:06:00 pm »
The Refresh is only needed it you want to re-iterate the collection later on. In almost all cases you won't do that. So Refresh is a rather superfluous operation.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Can't drop elements on a diagram
« Reply #6 on: September 01, 2020, 05:07:51 pm »
Not sure where you read that about the Refresh()

What it does is reload the EA.Collection from the database.
Not needed, unless you want to iterate the same collection after adding or removing items.

Geert

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Can't drop elements on a diagram
« Reply #7 on: September 01, 2020, 05:14:10 pm »
Not sure where you read that about the Refresh()

What it does is reload the EA.Collection from the database.
Not needed, unless you want to iterate the same collection after adding or removing items.

Geert

In the example scripts:

Quote
      dim testElement as EA.Element
      set testElement = elements.AddNew( "Login to Website", "UseCase" )
      testElement.Stereotype = "testcase"
      testElement.Update()
      thePackage.Elements.Refresh()

But I thought that is was necessary to put the changes to the database or refresh the project browser
« Last Edit: September 01, 2020, 05:16:07 pm by MatthiasVDE »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Can't drop elements on a diagram
« Reply #8 on: September 01, 2020, 08:29:58 pm »
Nope. Update is doing everything to get changes to the database (except where I remember some weirdness with operations/attributes and stereotypes).

q.

MatthiasVDE

  • EA User
  • **
  • Posts: 196
  • Karma: +1/-0
    • View Profile
Re: Can't drop elements on a diagram
« Reply #9 on: September 02, 2020, 04:00:53 am »
Thanks Geert and Qwerty to make this clear.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Can't drop elements on a diagram
« Reply #10 on: September 02, 2020, 06:06:43 am »
Just an update regarding the weirdness. Operation/Attribute seem to be ok (at least with a quick test). But it was a package which showed its Janus face. In order to apply a stereotype you first need to create (and Update) the package before you can access it's Element backside where the stereotype is stored. So you need a two-phase-commit (haha).

q.