Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:43 Go to next message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
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 12:43]

Report message to a moderator

Re: firing commands when dragging a connection [message #802790 is a reply to message #802781] Mon, 20 February 2012 12:55 Go to previous messageGo to next message
Andreas Muelder is currently offline Andreas MuelderFriend
Messages: 73
Registered: July 2011
Member
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 13:46 Go to previous messageGo to next message
Ralph Gerbig is currently offline Ralph GerbigFriend
Messages: 702
Registered: November 2009
Senior Member
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 14:21 Go to previous messageGo to next message
Chris B. is currently offline Chris B.Friend
Messages: 37
Registered: November 2011
Member
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 14:48]

Report message to a moderator

Re: firing commands when dragging a connection [message #803942 is a reply to message #802836] Wed, 22 February 2012 02:02 Go to previous message
Snakebyte Missing name is currently offline Snakebyte Missing nameFriend
Messages: 130
Registered: November 2011
Senior Member
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: Wed Apr 24 23:56:18 GMT 2024

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

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

Back to the top