Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Copy GMF diagram coordinates to model
Copy GMF diagram coordinates to model [message #56001] Tue, 26 September 2006 12:28 Go to next message
Eclipse UserFriend
Originally posted by: snej_NO-SPAM_.esuark.de

Hi!

I have a figure (Field) in a compartment, when the user set its
position, it gets x and y values in the view. So i want that the
corresponding object in the model (also Field :) ) get its values for x
and y from the view coordinates.
Must i implement a move-listener for the figure?
Any idea is welcome ...

regards
Jens
Re: Copy GMF diagram coordinates to model [message #57701 is a reply to message #56001] Fri, 29 September 2006 16:16 Go to previous messageGo to next message
Eclipse UserFriend
Jens,

Do you have your own editpart for this model element? Why don't you
just listen to changes to the location in the view and then update your
element? Check out ShapeEditPart.handleNotificationEvent().

Regards,
Cherie

Jens Krause wrote:
> Hi!
>
> I have a figure (Field) in a compartment, when the user set its
> position, it gets x and y values in the view. So i want that the
> corresponding object in the model (also Field :) ) get its values for x
> and y from the view coordinates.
> Must i implement a move-listener for the figure?
> Any idea is welcome ...
>
> regards
> Jens
Re: Copy GMF diagram coordinates to model [message #59520 is a reply to message #57701] Thu, 05 October 2006 09:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: snej_NO-SPAM_.esuark.de

Cherie Revells wrote:
> Do you have your own editpart for this model element? Why don't you
> just listen to changes to the location in the view and then update your
> element? Check out ShapeEditPart.handleNotificationEvent().

Thanks for this tip, works well :).

Jens
Re: Copy GMF diagram coordinates to model [message #59859 is a reply to message #59520] Fri, 06 October 2006 01:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi Jens,


Right now I've got a very similar problem to the one you posted in the
newsgroup. I'm glad you could manage the problem and I wonder if you
could provide some codesnipets for me?
I'd appreciate your help very much as it could help me save some time
trying to resolve the problem on my own.

Thanks in advance
Alex


Jens Krause wrote:
> Cherie Revells wrote:
>> Do you have your own editpart for this model element? Why don't you
>> just listen to changes to the location in the view and then update
>> your element? Check out ShapeEditPart.handleNotificationEvent().
>
> Thanks for this tip, works well :).
>
> Jens
Re: Copy GMF diagram coordinates to model [message #60125 is a reply to message #59859] Fri, 06 October 2006 08:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: snej_NO-SPAM_.esuark.de

Alex Haag wrote:
> Right now I've got a very similar problem to the one you posted in the
> newsgroup. I'm glad you could manage the problem and I wonder if you
> could provide some codesnipets for me?

Hi Alex,

here you have a snippet of my code...

This is the method from my
<DomainModel-Name>.diagram.edit.parts.FieldEditPart

/**
* @generated not
*/
protected void handleNotificationEvent(Notification arg0) {
// SET was the type i need
if (arg0.getEventType() == Notification.SET) {
// the notifier sends his new Bounds ...
if (arg0.getNotifier() instanceof BoundsImpl) {
BoundsImpl notifier = (BoundsImpl) arg0.getNotifier();
// for my special coordinate mapping i also need the node,
// so i save it in this variable ...
NodeImpl node = (NodeImpl) this.getModel();
// get the corresponding FieldLabel Object from the model
FieldLabel model = (FieldLabel) node.getElement();

if (arg0.getFeature() instanceof EAttributeImpl) {
// Get the attribute that has changed
EAttributeImpl attribute =
(EAttributeImpl) arg0.getFeature();
// set the values for x and y in the model
if (attribute.getName().equals("x")) {
model.setX(notifier.getX());
} else if (attribute.getName().equals("y")) {
model.setY(notifier.getY());
}
}
}
}
}

So everytime the bounds change the information is stored in the model.
If the user moves the FieldFigure or if the values are changed in the
editor doesn't matter

hth
Jens
Re: Copy GMF diagram coordinates to model [message #60151 is a reply to message #60125] Fri, 06 October 2006 09:06 Go to previous message
Eclipse UserFriend
Hi jens,

I just tried to use your code. It works perfect!! Thanks for your quick
answer..

Greetings and have a nice weekend
Alex


Jens Krause wrote:
> Alex Haag wrote:
>> Right now I've got a very similar problem to the one you posted in the
>> newsgroup. I'm glad you could manage the problem and I wonder if you
>> could provide some codesnipets for me?
>
> Hi Alex,
>
> here you have a snippet of my code...
>
> This is the method from my
> <DomainModel-Name>.diagram.edit.parts.FieldEditPart
>
> /**
> * @generated not
> */
> protected void handleNotificationEvent(Notification arg0) {
> // SET was the type i need
> if (arg0.getEventType() == Notification.SET) {
> // the notifier sends his new Bounds ...
> if (arg0.getNotifier() instanceof BoundsImpl) {
> BoundsImpl notifier = (BoundsImpl) arg0.getNotifier();
> // for my special coordinate mapping i also need the node,
> // so i save it in this variable ...
> NodeImpl node = (NodeImpl) this.getModel();
> // get the corresponding FieldLabel Object from the model
> FieldLabel model = (FieldLabel) node.getElement();
>
> if (arg0.getFeature() instanceof EAttributeImpl) {
> // Get the attribute that has changed
> EAttributeImpl attribute =
> (EAttributeImpl) arg0.getFeature();
> // set the values for x and y in the model
> if (attribute.getName().equals("x")) {
> model.setX(notifier.getX());
> } else if (attribute.getName().equals("y")) {
> model.setY(notifier.getY());
> }
> }
> }
> }
> }
>
> So everytime the bounds change the information is stored in the model.
> If the user moves the FieldFigure or if the values are changed in the
> editor doesn't matter
>
> hth
> Jens
Previous Topic:Implementing custom delete action
Next Topic:Validating notation.genmodel
Goto Forum:
  


Current Time: Thu May 08 12:23:23 EDT 2025

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

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

Back to the top