Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Arc from Label
Arc from Label [message #637299] Thu, 04 November 2010 22:30 Go to next message
Schoenboeck  is currently offline Schoenboeck Friend
Messages: 7
Registered: August 2010
Junior Member
Hello!

I created a class diagram editor similar to the one to graphically create ecore models. In this case attributes are realized by means of simple lables. These attributes are contained in classes, thus I added the according compartment. This works fine, but when I try to create an arc originating from the attribute I only get the actual parent as source, in my case a class. So my question is, how is it possible to create a connection originating from an attribute (which is a simple label and thus only a label)? Do I have to register additional EditPolicies in the AttributeEditPart??

Many thanks in advance for your help

Hannes
Re: Arc from Label [message #637323 is a reply to message #637299] Fri, 05 November 2010 03:46 Go to previous messageGo to next message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

Here you are only asking about the visual representation of the connection. Do you want this connection to be somehow represented on your semantic model as well? I mean given an Attribute model object, do you want to find out to which other element it has been connected to? If so, you need to change your Attribute model class so that it has an "outgoingConnection" reference which is of the type of your Connection model object - and then you'll need to add a new link mapping in your mapping definition.

On the other hand if you simply need connections leaving out of the parent to be 'snapped' into attribute labels, you need to employ a custom NodeFigure on the parent edit part and customize the anchoring behavior. You can follow http://gmfsamples.tuxfamily.org/wiki/doku.php?id=gmf_tutoria l6 to find out how to customize anchoring behavior.

Hope this helps.

- Asiri
Re: Arc from Label [message #637333 is a reply to message #637323] Fri, 05 November 2010 06:46 Go to previous messageGo to next message
Schoenboeck  is currently offline Schoenboeck Friend
Messages: 7
Registered: August 2010
Junior Member
Hi,

I do have a representation in my semantic model. And I also created an according link mapping which has as source an Attrbiute and as a target a so called AttributeInPort. I am not caring aboute the layout now but my problem is, when I create a connection I always get the container (Class) as a source of the connection also I am starting form the Attribute label. I debugged the following method in the generated class AttributePortArcCreateCommand (so AttributePortArc is the semantic model element)

public boolean canExecute() {
if (source == null && target == null) {
return false;
}
if (source != null && false == source instanceof Attribute) {
return false;
}
if (target != null && false == target instanceof AttributeInPort) {
return false;
}
if (getSource() == null) {
return true; // link creation is in progress; source is not defined yet
}
// target may be null here but it's possible to check constraint
if (getContainer() == null) {
return false;
}
return MopsBaseItemSemanticEditPolicy.LinkConstraints
.canCreateAttributePortArc_4010(getContainer(), getSource(),
getTarget());
}

And here the second check returns false since the source is not an instanceof Attribute but of its actual parent class "Class".

That's why I assumed that the AttributeEditPart, which only extends CompartmentEditPart. My other EditParts (e.g., those for a Class extend the base class ShapeNodeEditPart)

Thanks,

Hannes
Re: Arc from Label [message #637341 is a reply to message #637299] Fri, 05 November 2010 07:22 Go to previous messageGo to next message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

I'm afraid I cannot give you a direct answer, but I have few questions (to understand your problem clearly).

- So your AttributeEditParts are contained within a XXXCompartmentEditPart which is inside your ClassEditPart is it?

- In your link mapping for attribute connections, what is the containment feature of AttributePortArc?

- I will deduce that you also have another form of links associated with classes themselves, is there some overlapping between these two link types that might be causing the problem?

- Asiri
Re: Arc from Label [message #637346 is a reply to message #637341] Fri, 05 November 2010 07:46 Go to previous messageGo to next message
Schoenboeck  is currently offline Schoenboeck Friend
Messages: 7
Registered: August 2010
Junior Member
Hi,

My semantic model looks like this: Class contains Attribute, Class and Attribute both contain Arcs (ClassPortArc and AttributePortArc). Both MM elements contain a containment reference portAssignment (typed to ClassPortArc and AttributePortArc). A ClassPortArc originates form a Class. A Class is graphically represented by an Rectangle-Figure. I also have a NodeMapping for this in the gmfgraph model. This arc wroks fine!

An AttributePort arc now should be similar but instead of having a NodeMapping Í have only a DiagramLabel mapping in the gmfgraph model. In this case different code is generated. When I change the graphical representation of Attribute to let's say again a Rectanlge with a Label and if I introduce a NodeMapping for Attributes in the gmfgraph model everything works fine. So I assume that there is no error in the semantic model in the gmfmap model.

Hannes
Re: Arc from Label [message #637348 is a reply to message #637346] Fri, 05 November 2010 07:53 Go to previous message
Asiri Rathnayake is currently offline Asiri RathnayakeFriend
Messages: 80
Registered: September 2010
Location: Colombo, Sri Lanka.
Member
Hi,

Schoenboeck wrote on Fri, 05 November 2010 03:46

When I change the graphical representation of Attribute to let's say again a Rectanlge with a Label and if I introduce a NodeMapping for Attributes in the gmfgraph model everything works fine.


To me this looks like the correct approach (I'm bit unclear about how you have made the other approach work). Any reason why you don't like this (working) approach?

- Asiri

[Updated on: Fri, 05 November 2010 07:55]

Report message to a moderator

Previous Topic:Code compliance level of generated diagram code
Next Topic:ColorPropertyContributionItem
Goto Forum:
  


Current Time: Sat Apr 27 04:19:33 GMT 2024

Powered by FUDForum. Page generated in 0.03700 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top