Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCapture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/514750/#msg_514750
Hallo,
I create my nodes and links from db and based on some relationships between objects, set the width of thier connection. How can I capture the linestyle and change it?
Best regards,
Alireza]]>Alireza Missing name2010-02-16T14:34:53-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515412/#msg_515412
Anybody any idea? When I create a gmf relationship, it does not have any method to set the width of its line. I have seen some samples but they change the line width of all objects of the model.
Best,
Alireza]]>Alireza Missing name2010-02-18T17:26:31-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515438/#msg_515438
--
Regards, Milan]]>Milan Milanovich2010-02-18T18:52:14-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515520/#msg_515520
Dear Milan,
Thank you for your answer.
I create the gmf diagram inside an Eclipse view. Inside this view how could I access the EditPart of a connection? Should I create an instance? If yes, what should be the input parameter of the construtor (of type View)?
Best regards,
Alireza ]]>Alireza Missing name2010-02-19T08:24:44-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515545/#msg_515545
isn't there a refresh method at each EditPart (a ConnectionEditPart in
your case) that is called on any model change of the underlaying eObject
by the canonical edit policy? This might be the starting point for your
investigation.
Sven]]>Sven Krause2010-02-19T10:42:36-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515574/#msg_515574
I do not know how to use this ConnectionEditPart. Could you give me more explanation about its usage? What is a ConnectionEditPart? The object related to the link that I want to set its width?
Best,
Alireza
]]>Alireza Missing name2010-02-19T12:41:05-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515781/#msg_515781
the edit part is the controller between the view (gef IFigure) and the model (EObject). There are three generell kinds of edit parts: DiagramEditPart, ShapeEditPart and ConnectionEditPart. As the name says belongs these different edit parts to different kind of figures. Each edit part has a releation to its model element (getNotationView().getElement()). The refresh method is called indirectly on each model element change. So you have the freedom changing the line style, width, color or what ever you want as result of a model change.
Sven]]>Sven Krause2010-02-20T17:43:24-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/515900/#msg_515900
Dear Sven,
Thank you for your explanation. Since I want to change the line'swidth of a connection I tried to use it as follows:
AppSwtEditPart ep = new AppSwtEditPart(null);
ep.setModel(appSwitch);
ep.getPrimaryShape().setLineWidth(20);
ep.getPrimaryShape().refreshLine();
but it does not work. AppSwt is the name of the connection. How should access the edit part related to a specific connection?
Best,
Alireza
]]>Alireza Missing name2010-02-22T07:52:25-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/516786/#msg_516786
why do you need to create a new editpart? The edit part is a piece of
the diagram edit part tree. It is created in the context of your editor
for each of your models AppSwt connection instance.
It should be suffient overwrting the refresh() method of your
AppSwtEditPart a la:
Am 22.02.2010 08:52, schrieb Alireza:
>
>
> Dear Sven,
> Thank you for your explanation. Since I want to change the line'swidth
> of a connection I tried to use it as follows:
> AppSwtEditPart ep = new AppSwtEditPart(null);
> ep.setModel(appSwitch);
> ep.getPrimaryShape().setLineWidth(20);
> ep.getPrimaryShape().refreshLine();
>
> but it does not work. AppSwt is the name of the connection. How should
> access the edit part related to a specific connection?
> Best,
> Alireza
>]]>Sven Krause2010-02-25T07:54:35-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/516791/#msg_516791
Dear Sven,
I think I need to explain a little more about my problem: I read data from DB and then generate a gmf diagram elements based of the db data. This is done in a Eclipse view class. So, whenever I create a connection, I want to be able to set its line width. Based on what you said, I need to overwrite refresh method, this works if want same line width for all connection of the same type. So, it does not work for me. The reason that I said I need an instance of EditPart is because of this, i.e., when create a connection, I could be able to call its getPrimaryShape and change the linestyle (linewidth). What do you think?
Best,
Alireza ]]>Alireza Missing name2010-02-25T08:20:57-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/516813/#msg_516813
it is not suffifient creating a new edit part at a dedicated point. The
edit part needs to be integrated into the diagram (represented as the
diagram edit part). The edit part creation is usually in the
responsibility fo the canonical edit part. In your concrete case: the
connection element container has an edit part (lets say SourceElement -
there will be an SourceElemenentCanonicalEditPolicy - dependent of the
graph model named figure descriptor). This edit part will ensure that
the AppSwtEditPart is created and registered at the
SourceElemenentEditParts children. So there is no need to create the
edit part by yourself - independent of the diagrams presentation -
editor or view.
At the other hand: if you are maintaing the edit part tree by yourself,
then you need of course to play the CanonicalEditPolicys role: creating
the edit part, but also adding is to its parent edit parts children list.
Sven]]>Sven Krause2010-02-25T09:21:06-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/516832/#msg_516832
Dear Sven,
Well, I was too complicate for me ! Could give a more concrete example of how to use this CanonicalEditPolicy to create EditPart and manage. In the list of CanonicalEditPolicy methods there is no method for EditPart creation.
Best,
Alireza ]]>Alireza Missing name2010-02-25T10:07:59-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/516841/#msg_516841
in the responsibility of one of the various edit policies. The only one
you need to do is to customize the refresh method of your specific
connection edit part. Only and only: if you don't have due to whatever
reasons no canonical edit policy - you have to create an edit part view
new XYZEditPart().
Just override the refresh method, set a breakpoint and look when its
called within the debugger.
Sven
Am 25.02.2010 11:07, schrieb Alireza:
>
>
> Dear Sven,
>
> Well, I was too complicate for me ! Could give a more concrete example
> of how to use this CanonicalEditPolicy to create EditPart and manage. In
> the list of CanonicalEditPolicy methods there is no method for EditPart
> creation.
> Best,
> Alireza]]>Sven Krause2010-02-25T10:37:34-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/517090/#msg_517090
Sven,
There is no refresh method in the entire GMF project.
Ali
]]>Alireza Missing name2010-02-26T08:43:42-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/517152/#msg_517152
what is the AppSwtEditParts class hierarchy? Isn't there a
org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionNodeE ditPart?
This has a refresh method you can override? If not, where did you get
your AppSwtEditPart class from?
Sven]]>Sven Krause2010-02-26T11:53:51-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/518518/#msg_518518
Dear Sven,
Let me give a more concrete example of what I intend to do:
Suppose we have one entity A with a self relationship (source and target of the relationship are of the same type) and we also want to have label for this relationship. So, we create another entity name RelEntity that contains one string as label and two references both of type A as source and target. Now, given this EMF model and its corresponding GMF diagram, we have a db containing self-relationships between instances of A and strength of each relationship. Suppose there are a1 and a2 with relationship strength of w in db , so I call the factory of gmf to build instances of A namely a1 and a2 and set their attributes and add them to my diagram. Then I create the RelEntity to connect a1 and a2 and add it to the diagram. The final step is to set the width of the link between a1 and a2 based on w (strength of the relationship). How could I do this?
Best,
Alireza
]]>Alireza Missing name2010-03-04T11:17:18-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/518546/#msg_518546
comments below.
>
>
> Dear Sven,
>
> Let me give a more concrete example of what I intend to do:
>
> Suppose we have one entity A with a self relationship (source and target
> of the relationship are of the same type) and we also want to have label
> for this relationship. So, we create another entity name RelEntity that
> contains one string as label and two references both of type A as source
> and target.
Thats the way as gmf deals with connections.
> Now, given this EMF model and its corresponding GMF diagram,
> we have a db containing self-relationships between instances of A and
> strength of each relationship. Suppose there are a1 and a2 with
> relationship strength of w in db , so I call the factory of gmf to build
> instances of A namely a1 and a2 and set their attributes and add them to
> my diagram. Then I create the RelEntity to connect a1 and a2 and add it
> to the diagram.
How is this RelEntity referenced from your entity A? There should be a A
<<contains>> RelEntity relation (e.g. "connections"). Addionally should
the relation RelEntity.source defined as opposite to this contaiment
relation. And how is the mapping for the connection made in the
graphmapping? The link mapping has 4 domain attributes:
Element == RelEntity
Source Feature == RelEntity.source: A
Target Feature == RelEntity.target: A
ContainerFeaturen = A.connections.
> The final step is to set the width of the link between
> a1 and a2 based on w (strength of the relationship). How could I do this?
Back to the former discussion: this task should be part of the
element/view creation process. You would like to set a graphical style
dependent on an model attribute value however this value is calculated.
Here joins the edit part the game. His job is to mediate between model
and view. The edit part knows its view (getFigure()) and the model
(getNotationView().getElement()). So the challange is to locate the
proper place when to reflect the model state to the view and this is
afik the edit parts refresh() method. Remark that your view should be
updated, when someone else (might be a command triggered by any kind of
adapter attached to your model) manipulates your relation between a1 and a2.
> Best,
> Alireza
Sven]]>Sven Krause2010-03-04T12:47:22-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/518548/#msg_518548
comments below.
>
>
> Dear Sven,
>
> Let me give a more concrete example of what I intend to do:
>
> Suppose we have one entity A with a self relationship (source and target
> of the relationship are of the same type) and we also want to have label
> for this relationship. So, we create another entity name RelEntity that
> contains one string as label and two references both of type A as source
> and target.
Thats the way as gmf deals with connections.
> Now, given this EMF model and its corresponding GMF diagram,
> we have a db containing self-relationships between instances of A and
> strength of each relationship. Suppose there are a1 and a2 with
> relationship strength of w in db , so I call the factory of gmf to build
> instances of A namely a1 and a2 and set their attributes and add them to
> my diagram. Then I create the RelEntity to connect a1 and a2 and add it
> to the diagram.
How is this RelEntity referenced from your entity A? There should be a A
<<contains>> RelEntity relation (e.g. "connections"). Addionally should
the relation RelEntity.source defined as opposite to this contaiment
relation. And how is the mapping for the connection made in the
graphmapping? The link mapping has 4 domain attributes:
Element == RelEntity
Source Feature == RelEntity.source: A
Target Feature == RelEntity.target: A
ContainerFeaturen = A.connections.
> The final step is to set the width of the link between
> a1 and a2 based on w (strength of the relationship). How could I do this?
Back to the former discussion: this task should be NOT part of the
element/view creation process. You would like to set a graphical style
dependent on an model attribute value however this value is calculated.
Here joins the edit part the game. His job is to mediate between model
and view. The edit part knows its view (getFigure()) and the model
(getNotationView().getElement()). So the challange is to locate the
proper place when to reflect the model state to the view and this is
afik the edit parts refresh() method. Remark that your view should be
updated, when someone else (might be a command triggered by any kind of
adapter attached to your model) manipulates your relation between a1 and a2.
> Best,
> Alireza
Sven]]>Sven Krause2010-03-04T12:54:24-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/520242/#msg_520242
Dear Sven,
I tried hard to figure out the solution, but I could not.
Suppose I create an Eclipse view (ViewPart) and inside the class of this view I read data from DB and I build the GMF diagram accordingly. How can I do the line width setting part? How I access edit part? Could you please give some sample code sample?
Regards,
Alireza
]]>Alireza Missing name2010-03-11T16:44:17-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/521012/#msg_521012
sorry for the delay...
The thread become an endless nature right now. Would send me your skype
or icq contact to my email account, so that we might speed up the
communication?
Sven]]>Sven Krause2010-03-16T08:23:46-00:00Re: Capture linestyle of a connection and change it
https://www.eclipse.org/forums/index.php/mv/msg/162728/521339/#msg_521339
Dear Sven,