extend the on click event of relationship

Started by charbel, October 05, 2014, 02:18:47 AM

Previous topic - Next topic

Phil Beauvoir

You could take a look at how the Nested Relations dialog is implemented. It's not the best way to do it. It hooks into a Command to display a dialog box in this class:

com.archimatetool.editor.diagram.commands.DiagramCommandFactory#createNewNestedRelationCommandWithDialog(IArchimateElement, IArchimateElement[])

It's called from com.archimatetool.editor.diagram.policies.ArchimateContainerLayoutPolicy
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

charbel

Thank you a lot for your support, it helped me. A small question also which is:

As you know the protected IDiagramModelConnection createNewConnection() class is working for all the types of relation ships. Inside this class, I need to write some lines of java code for a specific relationship such as the association relationship and not for the others, so my question is that what is the necessary java code that should be written to detect or recognize the type of the relationship?

Please advise,

Thank you,

Phil Beauvoir

One place to hook into could be in DiagramModelArchimateConnection and the setRelationship() method.

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

charbel

Hello,

I tried to find DiagramModelArchimateConnection and the setRelationship() method but I couldn't catch. What I need is that I need to detect in java code the type of the relationship. In other words, I need to wirte some lines of java code for a specific relationship only and no for the others.
I need to execute this java code when I will use this specific relation ship such as association, assignmenet or any other extended relationship.
The question is where i can put:

if relationship = association then
   write some java code...
else
  work normaly

could you advise plz?

charbel

Iam kindly asking you to answer to my request below

Phil Beauvoir

To be honest, I don't think your approach is the best approach, and I'm still not entirely clear what it is that you are trying to do. Assuming that you are trying to add an additional property and value to a specific relationship type, if I was implementing this (on the Association relationship for example) I would:

Add some code in createAssociationRelationship() in the ArchiMateFactory class:

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated NOT
     */
    public IAssociationRelationship createAssociationRelationship() {
        AssociationRelationship associationRelationship = new AssociationRelationship();
        // Create an IProperty type, add a value and add it to associationRelationship
        return associationRelationship;
    }

Then when the user selected such a relationship this would show in the User Properties table in the Properties window, and they could edit it.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

charbel

mainly I just wanted to add some java code when using a specific realtion ship.
I have added this code in the factory class of this new relation ship and i succeeded.
I still in progress and maybe I will need for your help in the next phases but till now you helped to solve my current problem.

Thank you a lot for your help and support.

charbel

Hello,

I want to create a node element in the technology layer automatically when I create a business actor in the business layer. The method of creation the business actor is below:
                                       public EditPart createEditPart() {
       
                                              TechnologyNodeUIProvider NodeMO = null;
                                          NodeMO.createEditPart();

                                       return new BusinessActorEditPart();             
                                                       }
The code inside this method doesn't call or create automatically the node element in the technology layer. I need to know if I want to change the code   TechnologyNodeUIProvider NodeMO = null;
      NodeMO.createEditPart();

Please advise what I need to change or add to the code in order to call automatically a node in the technology layer according to the creation of each business actor in the business layer.
In case I can call the node element in the technology layer using another scenario please advise.

Thank you,

Phil Beauvoir

You should re-think your approach. Because of the Model-View-Controller structure of the code, you should be adding new elements at the model level. EditParts are created by the framework according to the model, not the other way around. If you are adding a new element to the diagram, then you will have to take a look at the process of what happens when the palette tool creates it - a request is sent which then creates a Creation Command which then creates a model element, which then creates an Edit Part, and so on. Your proposed approach will not work.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

charbel

Maybe I have to explain that in another way.
For example, when I create a business actor, a node should be created automatically in the technology layer. I just need from your side how I can call the creation of the node element in the technology layer I finish creating the Business actor in the business layer. We can say I need a mapping in parallel between the business layer and the technology layer. I need this scenario when the designer is creating the business layer model so automatically each business actor corresponding to a node element in the technology. Please I need from you to tell me where exactly I can call the code of creating the node element when I finish creating the business actor element.

Thank you

charbel

I'm trying to add code (In  bold) to the  BusinessActorUIProvider class such as: public EditPart createEditPart() {
                                                                                                                            TechnologyNodeUIProvider test = new TechnologyNodeUIProvider();
                                                                                                                                  test.createEditPart();

                                                                                                                          return new BusinessActorEditPart();

I didn't get the node element automatically created, even I'm calling the right method of the technology layer.

Could you advise please?

charbel

I don't know if I'm thinking wrong, you can just tell me what are the classes and methods that i want to hook into in order to call the technology layer element (node).

Please it's urgent for me

Phil Beauvoir

Quote from: charbel on February 16, 2015, 19:32:01 PM
Maybe I have to explain that in another way.
For example, when I create a business actor, a node should be created automatically in the technology layer.

Do you mean when you create  business actor using the palette? Do you want to create two objects when you use the palette?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

charbel

Yes exactly, when I create a business actor for example from the palette, I need to call a node in the technology layer. This node should be created automatically once I finish creating the business actor.
you can say it's a direct mapping.
In another way, I need to call elements automatically from technology layer when I create an element in the business layer.

Please you help is highly appreciated.

Thank you  a lot

Phil Beauvoir

Please explain exactly what you are trying to do in the interface. For example:


  • User creates a Business Actor in a View using the palette
  • A node is also created...on the same View? Just in the model? What if the Viewpoint does not support a Node?
  • ?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.