Attaching nested visual objects to 'parent', in a composition-relationship

Started by LapizLazuli, March 08, 2023, 08:10:03 AM

Previous topic - Next topic

LapizLazuli

Hi,

Context:
- Visual object 'ComposedElement' in a view.
- Two other objects 'Component1' and 'Component2', are linked by a composition-relationship to ComposedElement: they are both components of the ComposedElement.
- Size of ComposedElement is large enough to accommodate its two components
- Initial state: the two components are located 'outside' the parent 'ComposedElement' object.
- When, from the UI, Component1 and Component2 are dragged into ComposedComponent:
    - The appear *on top*, not behind, ComposedElement
    - They become part of ComposedElement, so when moving ComposedElement, the ComponentsX objects move with it.

Attempt:
- In order to help organizing a view with hierarchical elements (eg. Business Processes level 1, 2, 3, 4, etc.), I wrote a jArchi script which, when selecting an element:
  - increases its size, so that it holds all its ComponentX elements
  - position ComponentsX *within* the boundaries of ComposedElement.

My expectation was that, then, they become 'part' of the parent component, so that they appear on top of it, and are moved when the parent component moves.

In reality:
- Some of them appear on top, some other behind, the parent ComposedComponent
- When moving ComposedComponent, they don't move with it.

Question:
- Is there a way, in jArchi, to actually nest ComposedElementX into the parent ComposedElement?

If not quite clear, and needed, I'll try to post a sample model, and attach the scripts.

Thank you for your help.

Jean-Baptiste Sarrodie

Hi,

For this to work you have to remove the elements from the view and add them again either directly inside 'ComposedElement' (using object.add(element)), or to the view with autonest set to true.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

As JB says, remove and re-add. I was just looking at the jArchi code and there is no "move" command for view objects (remove from existing parent and add to target object). Perhaps this is something for the "to do" list.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Quote from: Phil Beauvoir on March 08, 2023, 09:53:40 AMAs JB says, remove and re-add. I was just looking at the jArchi code and there is no "move" command for view objects (remove from existing parent and add to target object). Perhaps this is something for the "to do" list.

Maybe we could extend object.add(element, x, y, width, height) so that it accepts also a visual object (and in such case, change its parent).
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

Quote from: Jean-Baptiste Sarrodie on March 08, 2023, 11:09:15 AM
Quote from: Phil Beauvoir on March 08, 2023, 09:53:40 AMAs JB says, remove and re-add. I was just looking at the jArchi code and there is no "move" command for view objects (remove from existing parent and add to target object). Perhaps this is something for the "to do" list.

Maybe we could extend object.add(element, x, y, width, height) so that it accepts also a visual object (and in such case, change its parent).

Yes, that makes more sense.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.


LapizLazuli

Quote from: Jean-Baptiste Sarrodie on March 08, 2023, 09:42:11 AMFor this to work you have to remove the elements from the view and add them again  [...] to the view with autonest set to true.

Hi,

I attempted the above, and it failed. What am I doing wrong?

- View name : TestView
- Elements name : BizFuncParent and BizFuncChild
- Composition relation (BizFuncChild > BizFuncParent)
- BizFuncParent in view
- BizFuncChild not in view
Please also see attached screenshot

// Get view object
var oView = $(".TestView").first()
console.log(oView.name)   // Got view name. Object ok.

// Get oChild object from model. Not displayed in View
var oChild = $(".Child").first()
console.log(oChild.name)  // Got child object name. Object ok.

// Now try to add object from model to view
oView.add(oChild, 30, 30,-1,-1, true)

// Fails:
// Script Error: javax.script.ScriptException: java.lang.Exception: java.lang.NoClassDefFoundError: com/archimatetool/editor/preferences/Preferences


Thanks for your help.


Phil Beauvoir

Hi,

you need to delete oChild first.

Something like this:

// Store the undlerying concept from the child visual object
concept = oChild.concept;

// Store any features like fill color...
fillColor = oChild.fillColor;

// Delete the visual object
oChild.delete();

// Add the stored concept back to parent view
oChild = oView.add(concept, 30, 30,-1,-1, true);

// Restore any features in visual object
oChild.fillColor = fillColor;
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Quote from: LapizLazuli on March 09, 2023, 02:14:34 AMI attempted the above, and it failed. What am I doing wrong?
- View name : TestView
- Elements name : BizFuncParent and BizFuncChild
- Composition relation (BizFuncChild > BizFuncParent)
- BizFuncParent in view
- BizFuncChild not in view

Works ok on my side...

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

LapizLazuli

Thanks @Phil for your reply.

Quote from: Phil Beauvoir on March 09, 2023, 08:51:58 AMyou need to delete oChild first.
There must be something I don't understand. How can I delete oChild [from view], since in the example, it is already not in view?

Quote from: Jean-Baptiste SarrodieWorks on my side...
Thanks too. So the code seems correct. I need now then to investigate why it's not working on my configuration...

Phil Beauvoir

> There must be something I don't understand. How can I delete oChild [from view], since in the example, it is already not in view?

I thought you were trying to "move" an object from one parent to another.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

LapizLazuli

@Phil - Thanks, fine then :)

@All - The cause was purely on my side: the scripts were in a OneDrive folder, which just got a sync issue. Moving the scripts in the Document/Archi folder sorted things out. Apologies.