Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Disable drag-drop resizing when creating nodes
Disable drag-drop resizing when creating nodes [message #645587] Sat, 18 December 2010 11:42 Go to next message
Wu Du is currently offline Wu DuFriend
Messages: 6
Registered: December 2010
Junior Member
Hi,
Is it possible to disable the drag-drop resizing when creating nodes with mouse, now i want to keep my nodes fixed size and users shouldn't assign the size by drag and drop when creating nodes. Thanks in advance for any hints.
Re: Disable drag-drop resizing when creating nodes [message #645746 is a reply to message #645587] Mon, 20 December 2010 11:24 Go to previous messageGo to next message
Michael Golubev is currently offline Michael GolubevFriend
Messages: 383
Registered: July 2009
Senior Member
Hello,

This is done by LayoutEditPolicy registered for container (e.g, by XYLayoutEditPolicy hosted by diagram editpart in case of creation of top-level nodes).

E.g, for XYlayoutEditPolicy you may override the

protected Command getCreateCommand(CreateRequest request) 


and

protected Command createAddCommand(EditPart child, Object constraint)


which are called for creation of the new element and reparenting of the existing element respectively.

Then you need to register the new extended edit-policy as a gmfgen CustomBehavior with the key of EditPolicy.LAYOUT_ROLE to replace the default one.

Regards,
Michael
Re: Disable drag-drop resizing when creating nodes [message #645770 is a reply to message #645746] Mon, 20 December 2010 14:03 Go to previous message
Wu Du is currently offline Wu DuFriend
Messages: 6
Registered: December 2010
Junior Member
Michael,
Thanks very much. I solve the problem under your tip. The bound of the created node depends on the method getConstraintFor(request), which is invoked by the method getCreateCommand. I make my custom LayoutEditPolicy extended from XYLayoutEditPolicy and override the method getCreateCommand. To be easy, i just copy the method code and give the bound a fixed value and whenever you create a new node, the size of the node will not rely on the rectangle assigned by your drag-drop operation.
protected Command getCreateCommand(CreateRequest request){
...
final Rectangle BOUNDS = (Rectangle) getConstraintFor(request);
BOUNDS.height = -1;
BOUNDS.width = -1;
...
}

Here i make the bound default size, in effect, any size is ok.
Previous Topic:Generated RCP
Next Topic:Different Connection Decorators for the same model
Goto Forum:
  


Current Time: Wed Apr 24 21:11:20 GMT 2024

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

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

Back to the top