Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » firing commands when dragging a connection
firing commands when dragging a connection [message #802781] Mon, 20 February 2012 07:43 Go to next message
Eclipse UserFriend
Hello everybody,

as mentioned above i want to override a getCommand method that fires each time i drag a polylineconnection from one diagram to another. I've tried to implement a class that extends DiagramDragDropEditPolicy, but it is never invoked.

public class TestEditPolicy extends DiagramDragDropEditPolicy
{
    @Override
    public Command getCommand(Request request)
    {
      System.out.println("Test");
    }
}


Did i choose the right edit policy class? The policy is installed in an IEditPolicyProvider instance, using the DRAG_DROP_ROLE. I don't know if this is the correct approach, maybe somebody can give me a few hints.

public class TestEditPolicyProvider extends AbstractProvider implements IEditPolicyProvider
{
@Override
    public void createEditPolicies(EditPart editPart)
    {
     editPart.installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE , new TetEditPolicy());
    }
}


Regards
bj

[Updated on: Mon, 20 February 2012 07:43] by Moderator

Re: firing commands when dragging a connection [message #802790 is a reply to message #802781] Mon, 20 February 2012 07:55 Go to previous messageGo to next message
Eclipse UserFriend
Hi bj,

I think your approach is correct so far. Maybe you have to additionally register a
DropTargetListener on your GraphicalViewer.

In your Editor class:
@Override
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();
    getDiagramGraphicalViewer.addDropTargetListener(
      new DiagramDropTargetListener(diagramViewer));
}


I don't know your use case, maybe you have to implement a custom DropTargetListener.

Hope this helps,
Andreas
Re: firing commands when dragging a connection [message #802817 is a reply to message #802790] Mon, 20 February 2012 08:46 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

do you have a link mapping to a semantic element? Do you want to be informed of reorients? Maybe xxxReorientCommand is what you are looking for.

Ralph
Re: firing commands when dragging a connection [message #802836 is a reply to message #802790] Mon, 20 February 2012 09:21 Go to previous messageGo to next message
Eclipse UserFriend
Hi @all,
thank you for your replies.

@Andreas
I've modified configureGraphicalViewer() as suggested,but still the method is not called.

@Ralph
No, it's a figure not a semantic element, but your proposal regarding ReorientCommand sounds interesting. Finally, dragging a connection implies also a reorientation of the element. Could you provide a code sample?

Thanks,
bj

[Updated on: Mon, 20 February 2012 09:48] by Moderator

Re: firing commands when dragging a connection [message #803942 is a reply to message #802836] Tue, 21 February 2012 21:02 Go to previous message
Eclipse UserFriend
I do it like that.

In your xxx.diagram.edit.parts package you have a class for your Connection, called XXXEditPart.java (XXX = name of your connection).

Add a FigureListener to this class like that :

this.addFigureListener(new FigureListener() {
				
@Override
public void figureMoved(IFigure source) {
System.out.println("Here i am");				
});


This is called everytime the connection is moved.
Previous Topic:GMF + Dawn Codegen
Next Topic:automatocally Grid in Background
Goto Forum:
  


Current Time: Sat Jul 12 12:40:25 EDT 2025

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

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

Back to the top