Author Topic: extend the on click event of relationship  (Read 19265 times)

Phil Beauvoir

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #15 on: December 01, 2014, 19:38:58 PM »
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! https://www.archimatetool.com/donate

charbel

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #16 on: December 02, 2014, 23:04:53 PM »
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

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #17 on: December 03, 2014, 18:05:00 PM »
One place to hook into could be in DiagramModelArchimateConnection and the setRelationship() method.

If you value and use Archi please consider making a donation! https://www.archimatetool.com/donate

charbel

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #18 on: December 05, 2014, 23:36:21 PM »
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

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #19 on: December 08, 2014, 20:03:24 PM »
Iam kindly asking you to answer to my request below

Phil Beauvoir

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #20 on: December 09, 2014, 10:31:02 AM »
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! https://www.archimatetool.com/donate

charbel

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #21 on: December 10, 2014, 00:04:51 AM »
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

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #22 on: December 14, 2014, 11:31:21 AM »
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

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #23 on: December 14, 2014, 16:04:24 PM »
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! https://www.archimatetool.com/donate

charbel

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #24 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. 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

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #25 on: February 17, 2015, 00:09:31 AM »
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

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #26 on: February 17, 2015, 11:17:17 AM »
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

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #27 on: February 18, 2015, 10:32:41 AM »
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! https://www.archimatetool.com/donate

charbel

  • Member
  • **
  • Posts: 24
Re: extend the on click event of relationship
« Reply #28 on: February 18, 2015, 11:31:16 AM »
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

  • Archi Guy
  • Hero Member
  • *****
  • Posts: 1500
  • Archi Guy
    • Archi
Re: extend the on click event of relationship
« Reply #29 on: February 18, 2015, 12:43:36 PM »
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! https://www.archimatetool.com/donate