Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re-order children in compartment
Re-order children in compartment [message #171529] Tue, 05 February 2008 11:33 Go to next message
Eclipse UserFriend
Originally posted by: taggartboy.hotmail.com

Hello,

I have been trying for some time to allow Drag and Drop re-order of
children within a compartment. I have a custom layout manager to layout
the children in the compartment and the compartment is of type
ListCompartmentEditPart which arranges the children in an ordered list.

I am able to drag and drop children of the compartments from one
compartment to another and they are appended to the end of the compartment.

However, I would like to be able to drag one child into a space between
two other children in the compartment and have the children move
accordingly.

I have considered a few ways of achieving this like changing the sorting
keys in the sorting edit policy of the list compartment class to include
an attribute from the model or issuing a move children command but I can't
seem to get either of those to work.

I hope someone has done this before and can guide me or knows how i might
be able to achieve this, thanks.
Re: Re-order children in compartment [message #173763 is a reply to message #171529] Fri, 22 February 2008 10:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.kenner.reflex.at

Hello Peter,

I think the following HowTo could help you:

http://wiki.eclipse.org/GMF/Recipes

"Recipe: HowTo reorder children in a GMF compartment with Drag & Drop"

If you have any questions about it or something is unclear, just send me an
e-mail.

Regards,
Thomas

Peter Taggart wrote:

> Hello,
>
> I have been trying for some time to allow Drag and Drop re-order of
> children within a compartment. I have a custom layout manager to layout
> the children in the compartment and the compartment is of type
> ListCompartmentEditPart which arranges the children in an ordered list.
>
> I am able to drag and drop children of the compartments from one
> compartment to another and they are appended to the end of the
> compartment.
>
> However, I would like to be able to drag one child into a space between
> two other children in the compartment and have the children move
> accordingly.
>
> I have considered a few ways of achieving this like changing the sorting
> keys in the sorting edit policy of the list compartment class to include
> an attribute from the model or issuing a move children command but I can't
> seem to get either of those to work.
>
> I hope someone has done this before and can guide me or knows how i might
> be able to achieve this, thanks.

--
Thomas Kenner
Re: Re-order children in compartment [message #174217 is a reply to message #173763] Mon, 25 February 2008 12:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: taggartboy.hotmail.com

Thanks Thomas,

This is exactly what I am looking for, there is however one part that I do
not fully inderstand:

From tutorial:

"installEditPolicy(EditPolicy.LAYOUT_ROLE, new
CompartmentEditPolicy(xxxPackage.Literals.xxx));

Note: xxxPackage.Literals.xxx has to be the EStructuralFeature of the
EList Attribute that contains the Objects which should be reordered. "

I presume that i must have an EList containing the children to be
re-ordered (maybe the getModelChilden() method) but I do not understand
what the EStructuralFeature is.

Thanks again for you help and any further assistance would be great.
Re: Re-order children in compartment [message #174359 is a reply to message #174217] Tue, 26 February 2008 09:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: taggartboy.hotmail.com

I figured out that i need to pass in my "Package.eINSTANCE.Type_Feature()"
and it works now.

I do however have a problem with the insertion of new elements into the
compartment, the line feedback displays properly but when i insert an
element into the compartment at a particular point, it will still appear
at the end of the list.

do I need to implement the "getCreateCommand(CreateRequest request)"
method to create the new element at a particular point in the compartment?

Thanks
Re: Re-order children in compartment [message #178346 is a reply to message #174359] Thu, 20 March 2008 07:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: thomas.kenner.reflex.at

Hello Peter,

I added a new recipe to http://wiki.eclipse.org/GMF/Recipes for adding new
children to the compartment at a concrete position.

Please contact me if you need more information.

Regards,
Thomas

Peter Taggart wrote:

> I figured out that i need to pass in my "Package.eINSTANCE.Type_Feature()"
> and it works now.
>
> I do however have a problem with the insertion of new elements into the
> compartment, the line feedback displays properly but when i insert an
> element into the compartment at a particular point, it will still appear
> at the end of the list.
>
> do I need to implement the "getCreateCommand(CreateRequest request)"
> method to create the new element at a particular point in the compartment?
>
> Thanks

--
Thomas Kenner
Re: Re-order children in compartment [message #181181 is a reply to message #178346] Mon, 07 April 2008 09:10 Go to previous message
Eclipse UserFriend
Originally posted by: taggartboy.hotmail.com

Hi,

The adding of children within a compartment in order works great, thanks
for the update on the tutorial, I do however have one more question.

When dragging and dropping a node from one compartment to another, nodes
are always placed at the end of the list, I would like to be able to drag
and drop them into a particular order in the compartment.

Currently I have "installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE, new
DragDropEditPolicy());" installed in the create edit policies method of
the compartment figure along with your edit policy from the GMF/Recipes.
With just the DragDropEditPolicy() installed the nodes go to the bottom
when dragged and with just your edit policy installed the following error
occurrs when I drag a node into the desired position:

************************************************************ ******************
org.eclipse.core.commands.ExecutionException: While executing the
operation, an exception occurred

Caused by: java.lang.IllegalArgumentException: The 'no duplicates'
constraint is violated
at org.eclipse.emf.common.util.BasicEList.add(BasicEList.java:6 69)
at
org.eclipse.gmf.runtime.notation.impl.ViewImpl.insertChildAt (ViewImpl.java:711)
************************************************************ ******************

On the debug it shows that the insertChildAt gets the correct index but
fails with this error and the node is placed at the end of the compartment.

If you have any ideas on how this might be solved please let me know,

Thank you.

Peter.
Previous Topic:is it possible to create or modify an image at runtime
Next Topic:Copy/Paste tutorial
Goto Forum:
  


Current Time: Sun Jul 13 06:50:13 EDT 2025

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

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

Back to the top