Book a Demo

Author Topic: Create multiple elements at once from the Toolbox  (Read 4440 times)

Jamo

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Create multiple elements at once from the Toolbox
« on: July 18, 2020, 12:06:03 am »
Hello all,

I am working on a custom toolbox and was wondering if it's possible to create a toolbox element that, when dragged into a diagram, actually creates two objects that are connected with each other. For example: A requirement and its justification.

I already have a script at hand that can do this, so the question might rather be: Can I trigger such a script when dragging an element from a toolbox into the diagram.

And if you are wondering why I want a toolbox element for this, if I can do this by script: Drag-and-drop is just a bit more convenient then right-click/hover/left-click. ;D
Also I want to learn what else is possible with MDGs

Best,
Jamo

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Create multiple elements at once from the Toolbox
« Reply #1 on: July 18, 2020, 12:31:49 am »
I think you can with patterns yes, but they are a bit awkward to get into an MDG.

Geert

Viking

  • EA User
  • **
  • Posts: 478
  • Karma: +2/-2
    • View Profile
Re: Create multiple elements at once from the Toolbox
« Reply #2 on: July 21, 2020, 12:50:31 am »
I already have a script at hand that can do this, so the question might rather be: Can I trigger such a script when dragging an element from a toolbox into the diagram.

Maybe "Context Item Events" can help to trigger your script.

Jamo

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Create multiple elements at once from the Toolbox
« Reply #3 on: July 23, 2020, 01:02:54 am »
Hey, thanks for both suggestions. I looked into it, but I don't think "Context Item Events" can really help me here.

Patterns however seem to be the way to go. I had success in replicating my script with a pattern, but I struggle to implement it in the MDG.
And I think this is was Geert meant with awkward.

I published the pattern and imported it into my .eapx file with which I build my MDG. Then I followed the instructions (in particular, step 6) here:
https://www.sparxsystems.com/enterprise_architect_user_guide/15.1/modeling/toolbox_profiles.html

Then, I save the updated UML Diagram of my toolbox profile as an .xml file and generate the MDG. In the Contents window of the MDG wizard the box for "Pattern" is checked and all .xml files (Profiles, Patterns, Toolboxes) are selected in the subsequent windows. When I import the MDG file into a new project, my new pattern appears in the toolbox but DOES NOT appear in the Resources/Patterns folder.

If I drag&drop the pattern into a suitable diagram, I get an error message "Pattern not found in model's resources."
If I now manually import the pattern and repeat the drag&drop from the toolbox I get the same error message.
If I drag&drop from the resources window, it works without problem.


Any ideas?

Jamo

  • EA Novice
  • *
  • Posts: 14
  • Karma: +0/-0
    • View Profile
Re: Create multiple elements at once from the Toolbox
« Reply #4 on: July 28, 2020, 10:35:38 pm »
Solved the most important part of it. The problem was (as often) in front of the computer.

1. Typo in the attribute definition of my toolbox
2. Forgot that I had to publish my toolbox diagram as UML profile so that the changes actually take effect.


But still, installing the MDG does not install the pattern although it is selected in the MDG wizard. I have to add the pattern manually to the resources so I can use the toolbox element.