Archi Forum

Archi => Archi Development => Topic started by: charbel on October 05, 2014, 02:18:47 AM

Title: extend the on click event of relationship
Post by: charbel on October 05, 2014, 02:18:47 AM
I'm a PhD student and I published two papers till now, both of them are based on the enterprise architecture and I used ArchiMate and Archi. The latest paper is accepted in the conference sensorcom2014.
I'm working in the context of deep sea observatories and I have succeeded by extending ArchiMate using Archi tool.
My new contribution is requiring to know:
    How can I add some lines of java code on the "on click" event on any extended relation ship
    What are the concerned class to check them?
    Where I can add my java code? on which class or function in Archi?
I really need your help in order to continue my future contribution, I will appreciate my help a lot.
Waiting your kindly reply,
Thank you
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on October 06, 2014, 10:27:22 AM
Hi, welcome to the forums.

Because things are never straightforward in the world of Eclipse and GEF, it might be easier if you could describe your aim - what is it that you are trying to do when a user clicks on a relationship?

Phil
Title: Re: extend the on click event of relationship
Post by: charbel on October 06, 2014, 22:08:54 PM
Hello, Thank you for answering me.
What I need exactly is: when I click on a new extended relationship (I added one), I need to get a dialog box or any field to enter data or value in it.
Once the value is entered by the designer, so the designer will be able to drag and drop this relationship, i another way to use this relationship.
Another concern which is, the value X entered by the designer should be between two values (Y & Z) that already should be defined as maximum and minimum values, for example Y<X<Z.
In conclusion, I have two questions:
    - How I can have a dialog box or any field when I click on a new extended realtionship?
    - How I can put the Values Y and Z as constraints for the value X entered by the design, where I can add these or implement these two values?

Waiting your kindly reply,

Thank you in advance,
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on October 06, 2014, 22:18:12 PM
Quote
What I need exactly is: when I click on a new extended relationship (I added one), I need to get a dialog box or any field to enter data or value in it.

Do you mean when you click on an instance of a relationship in a diagram, or do you mean when you click on the relationship tool in the palette?
Title: Re: extend the on click event of relationship
Post by: charbel on October 06, 2014, 23:17:03 PM
I mean when I click on the relationship tool in the palette
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on October 07, 2014, 11:03:08 AM
I think it's not a good idea for usability to open a dialog box when clicking on a palette tool. It's better to set values on a concept or relationship in Archi's Properties window. Unless you are trying to achieve something else?

Quote
Once the value is entered by the designer, so the designer will be able to drag and drop this relationship, i another way to use this relationship.

What do you mean by this? Do you mean anything special in the use of drag and drop?
Title: Re: extend the on click event of relationship
Post by: charbel on October 07, 2014, 11:20:06 AM
Thank you for your cooperation.
I will give you an example, consider hat I have two PCs and I need to link these two pcs by the new extended relation ship.
In order to to use this relationship from the designer or developer a value X should be entered by him and this value should between less < Y and > Z (Y<X<Z).
The Y and Z are constraints to enter the X value between.
For example if we have a constraint the value entered by the design for the connection between two servers should between Y = 50 and Z= 70 so the value X coudl be 51 or 52 .................... 68 or 69.
Hope it's more clear now

Thank you
Title: Re: extend the on click event of relationship
Post by: Jean-Baptiste Sarrodie on October 07, 2014, 12:30:01 PM
Hi,

My 2cts tips:

Your Y and Z values (or any other parameters) can be defined as preferences. Look at com.archimatetool.editor/src/com/archimatetool/editor/preferences, and in particularPreferences.java and PreferenceInitializer.java. You should find enough example to use it.

From an end-user perspective, having to set a value before creating a new relation doesn't make much sens. You should instead set it just after its creation. In an ideal world, this should be in fact nothing more than a required Property set in an ArchiMate profile. As this is not possible in Archi for the moment, maybe we could try to do a first step in this direction...

@Phil: is it possible to create some "entry points" activated on basic events like creation of a new object or relation. We could them imagine using those "entry points" in plugins. Charbel's plugin could be the hard coded behaviour for entering X, mine could be an ArchiMate profile implementation ;-)

JB
Title: Re: extend the on click event of relationship
Post by: charbel on October 14, 2014, 23:00:37 PM
Concerning the Y and Z value:
I found in the PreferenceInitialzer.java for example :  store.setDefault(GRID_SIZE, 6);  so the GRID_SIZE should be replaced by the name of my new relationship?
then, I need to go to Preferences.java and add for example??: public static int getGridSize() {
                                                                                                                return STORE.getInt(GRID_SIZE);
                                                                                                             }
As I understand currently Archi doesn't support that an end user or designer can click on a concept or on a relation and get a dialogbox to insert a value that should be between Y and Z?? is that what you mean?
In case is not possible this with Archi, do you think can I add some java code to have this dialog box and at the same time I need to read the values Y and Z on such event (ex a click on the new realtionship)??

Sorry for asking a lot, but this my contribution and I need to make sure if it's feasible or not.

Thank you for answering me,

Regards,
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on October 15, 2014, 09:43:08 AM
Quote from: Jean-Baptiste Sarrodie on October 07, 2014, 12:30:01 PM

@Phil: is it possible to create some "entry points" activated on basic events like creation of a new object or relation. We could them imagine using those "entry points" in plugins. Charbel's plugin could be the hard coded behaviour for entering X, mine could be an ArchiMate profile implementation ;-)

JB

Normally, an interested client (UI element, plugin, whatever) would register itself as a model listener in EditorModelManager and respond when a new model element is created. Always work at the "M" level of MVC. However, the type of creation event is not always easy to determine (was it copy and paste, created from palette).

But in this case, the non-intrusive behaviour should be:- create a connection without nagging the user (an exception to this is the nested relationship dialog, but even this can be turned off.) If there are additional properties to be set for the relation, these should be added to the relationship in the eCore model, and exposed in the Properties window.

What are these X, Y and Z values?
Title: Re: extend the on click event of relationship
Post by: charbel on October 15, 2014, 20:41:45 PM
I added a new relationship which is specialized only to relate two devices such a pc with a server, my main question is that:
if we consider that, this relationship is a cable and this cable could only between 50 meters and 100 meters so I need to put constraints for this realtionship ( the value should be >50 and < 100).
That is why I gave the example of X,Y,Z  so I considered Y and Z are the constraints and the X value is the value should be entered by the designer when he is using this realtionship, at the end the designer should insert a value X when he wants to use this realtionship and this value should respect the constraints the Y and Z values.
Hope it's more clear, really I need yourhelp

many thanks,
Title: Re: extend the on click event of relationship
Post by: Jean-Baptiste Sarrodie on October 15, 2014, 21:20:03 PM
In fact, what you are doing is a typical use case of an ArchiMate Profile (not supported at the moment by Archi).

If I understand well, I could translate it to: create a profile in which we define a "cable" stereotype assigned to an "association" relationship. On this stereotype, we define a "length" property with a constraint to be a number between 50 and 100.

So IMHO, the best way to manage your requirement is to try to implement a lightweight profile mecanism in Archi.

Some ideas to do it:

JB
Title: Re: extend the on click event of relationship
Post by: charbel on October 16, 2014, 19:47:34 PM
Yes you understood right and I think we are in progress, thk you a lot
I have to explain for you more what I did and what I need.
As you mentioned "it would be best to add those stereotype to the palette, to be able to create element linked to stereotypes quickly" I already did a contribution in my thesis by adding new specific concepts for marine observatories(MO). I have extended the archimate metamodel by providing a new mtemodel and we applied this metamodel in eclispe then we generate the new archi tool in order to have new concrete syntax which contains all the new specific concepts for MO. we create a new model using the new generated archi tool and so on (all is working well).
For now, I have added a new relationship which is extended from an association relationship and it should be specific only for two devices such a server and PC. I succeeded to add it to the palette as the other concepts but I need now is the following:
As you mentioned if I consider this realtionship like a cable so I need to put constraints when the designer is using this relationship. I mean for example the length of the cable should be between 50 and 100 meters. that is why I have asked you all the above questions.
What I thought is that: when the designer will use this relationship or the cable so the designer should enter a value that should be between 50 and 100 m in order to continue the design, in case the value is not between 50 and 100 meters so the designer shouldn't be able to use this realtionship or cable.
I think now it's better, so what do you advise me to do? the most simple way.
really I'm thanking you a lot
Title: Re: extend the on click event of relationship
Post by: charbel on November 30, 2014, 22:48:12 PM
Hello again, I think now the image is more clear for me.
If we consider that I'm selecting the association relation ship from the palette and I'm using it between two elements. What I need to know is that, where I can find the java code (classes or library or methods) in eclipse that is called on the on click event in the palette and the event when I'm relating the two elements. I need to see the java code for that. could you help me please?

Thank you
Title: Re: extend the on click event of relationship
Post by: charbel on December 01, 2014, 13:10:04 PM
Hello, could you help me please by answering the email below since it's urgent for work.

Thank you
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir 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
Title: Re: extend the on click event of relationship
Post by: charbel 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,
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on December 03, 2014, 18:05:00 PM
One place to hook into could be in DiagramModelArchimateConnection and the setRelationship() method.

Title: Re: extend the on click event of relationship
Post by: charbel 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?
Title: Re: extend the on click event of relationship
Post by: charbel on December 08, 2014, 20:03:24 PM
Iam kindly asking you to answer to my request below
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir 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.
Title: Re: extend the on click event of relationship
Post by: charbel 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.
Title: Re: extend the on click event of relationship
Post by: charbel 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,
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir 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.
Title: Re: extend the on click event of relationship
Post by: 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. 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
Title: Re: extend the on click event of relationship
Post by: charbel 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?
Title: Re: extend the on click event of relationship
Post by: charbel 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
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on February 18, 2015, 10:32:41 AM
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?
Title: Re: extend the on click event of relationship
Post by: charbel 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
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on February 18, 2015, 12:43:36 PM
Please explain exactly what you are trying to do in the interface. For example:

Title: Re: extend the on click event of relationship
Post by: charbel on February 18, 2015, 12:58:46 PM
Ok.

1. User creates a Business Actor in a View using the palette
2. A node is also created in the corresponding view, for example according to each business actor i need a
   technology node so it will not be on the same, it will be on the tehcnology view. yes i need to create it just in
   the model.
3. then i need to save the whole model in order to get the XMI extension

The idea of this, it's just to help the designer of the technology layer by creating some elements automatically.

do you need more clarification?
Title: Re: extend the on click event of relationship
Post by: charbel on February 19, 2015, 08:56:25 AM
Your help is highly appreciated since it's a major point to continue my research.
It remains just 5 days for me.

Thank you

Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on February 19, 2015, 09:10:22 AM
I'm sorry, but I still do not know what you are trying to do. Your points (2) and (3) are confusing. Why don't you explain what it is step by step? Do you want two boxes to be drawn on the same view? If so, where?

What do you mean by "I need a technology node so it will not be on the same, it will be on the technology view." What technology view?

Then you say "I need to create it just in the model." So you don't want it added in the view?

"Then I need to save the whole model in order to get the XMI extension" What "XMI extension"?

I'm sorry but I don't think I can help you with this.
Title: Re: extend the on click event of relationship
Post by: charbel on February 19, 2015, 09:58:37 AM
I'm really sorry, maybe I explain wrong.
What I need is: For example I'm creating a business actor by drag a drop from the palette in order to create a model, after the creation of the business actor, I need to get automatically two technology nodes from the technology layer. these technology nodes could be created below the bsuiness actor created.
In another way, I need to know in java how to call a technology node during the dragging an drop from the palette of business actor.

Imagine your self you are using the archi tool and you are creating a business actor to create a specific model, what I need is to get automatically one or two technology nodes in the same model view.

Hope it's more clear now.

Sorry but really i need your help
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on February 19, 2015, 10:09:39 AM
It's a bad UI decision. The palette should only be used for what it is intended - one item created. Maybe what you are trying to do is create a view from a template? Re-think your approach. Using the palette in this way would be a very bad user experience! How would one then create a Business Actor without the nodes being added!
Title: Re: extend the on click event of relationship
Post by: charbel on February 19, 2015, 10:16:34 AM
I will tell you exactly what I have.
I have succeeded before to add dialog box in java when I'm using a realtion ship and I got a dialog box to enter a value, this value should respect a specific number for example. these values are 10 and 50 so I should enter a number between 10 and 50. once I enter a number between 10 and 50 so I can create the realtionship between any two business actor in the business layer.
What I need now is to call a technology node after using this realtionship. so just I need to assure that I can throw automatically some elements from other layers once I create any element from a specific layer.

There is a scientific idea from this, i have published till now three publications using ArchiMate and Archi tool, this is what I need.

Any feedback?
Title: Re: extend the on click event of relationship
Post by: charbel on February 19, 2015, 10:21:20 AM
Attached is an image of How I have implemented what I explained in my previous post. I succeeded to extend ArchiMate and I got a generated design tool  using new relation ship with constraint (10 and 50).
In order to implement the idea (look the the images) I wrote inside CreateEditPart () the following:

int min = 10;
      int max = 50;       
      JFrame frame = new JFrame();
      String ValString = JOptionPane.showInputDialog(frame,"Length of marine cable should be between 10 and 50 meters:");
      int ValInt = Integer.parseInt(ValString);
      if (ValInt < max && ValInt > min){
         JOptionPane.showMessageDialog(null,"You are able to connect a Smart Sensor to a Fusion
                                                                              Server");
return new ExtensionConnectionEditPart();

      }
      JOptionPane.showMessageDialog(null,"You are not able to connect a Smart Sensor to a Fusion Server");
      return null;
   }

My question is what I have to write in jave to call for example a technology node automatically?
Title: Re: extend the on click event of relationship
Post by: charbel on February 20, 2015, 11:08:56 AM
Hello again,

Any feedback?

Thank you
Title: Re: extend the on click event of relationship
Post by: Phil Beauvoir on February 20, 2015, 12:19:15 PM
As I said, I don't really know how to achieve what you want to do, and I think it's a bad idea from the point of view of the user anyway.

The only thing I can suggest is to take a look at the class:

com.archimatetool.editor.diagram.commands.CreateDiagramArchimateObjectCommand

and see how new objects are created there, and also in its super class:

com.archimatetool.editor.diagram.commands.CreateDiagramObjectCommand