Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Add children upon resize/move of container
Add children upon resize/move of container [message #170152] Wed, 02 March 2005 00:25 Go to next message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
I would like to implement a container that can "grab" children from its
parent by being resized or moved over them. Is there a helper method
that can locate the children within a given rectangle or do I have to
iterate over the children myself in the createChangeConstraintCommand call?

Thanks,
Barry
Re: Add children upon resize/move of container [message #170232 is a reply to message #170152] Wed, 02 March 2005 18:19 Go to previous messageGo to next message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
Barry Lay wrote:
> I would like to implement a container that can "grab" children from its
> parent by being resized or moved over them. Is there a helper method
> that can locate the children within a given rectangle or do I have to
> iterate over the children myself in the createChangeConstraintCommand call?

I had a look at how the MarqueeSelectionTool does it and it appears that
there is no equivalent to findObjectAtExcluding (which I use to find the
parent when releasing the children). At this point I have some
relatively expensive operations in edit policies which get called
repeatedly while dragging but aren't really necessary to determine if
the operation would succeed. I am now looking at what would be involved
in delaying the action until the command is executed.

It seems that the GEF architecture would suggest that the commands are
not supposed to interact with the graphical components directly - they
affect them by modifying the model. The fact that my optimization would
require loading up the command with graphical details like a reference
to the GraphicalViewer would bear this out. Does anyone have a better
way to structure this?

Thanks,
Barry
Re: Add children upon resize/move of container [message #170377 is a reply to message #170232] Fri, 04 March 2005 00:56 Go to previous messageGo to next message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
Barry Lay wrote:
> Barry Lay wrote:
>
>> I would like to implement a container that can "grab" children from
>> its parent by being resized or moved over them. Is there a helper
>> method that can locate the children within a given rectangle or do I
>> have to iterate over the children myself in the
>> createChangeConstraintCommand call?
>
> It seems that the GEF architecture would suggest that the commands are
> not supposed to interact with the graphical components directly - they
> affect them by modifying the model. The fact that my optimization would
> require loading up the command with graphical details like a reference
> to the GraphicalViewer would bear this out. Does anyone have a better
> way to structure this?

I have gotten a bit further with this. I can handle the end of the move
by creating my own DragTracker and overriding its performDrag method. I
can update the pending compound command to add commands to reparent the
affected child parts before the command gets executed.

The resize event looks more complicated. It appears that the default
ResizableEditPolicy creates DragTrackers for each of the selection
handles which get used instead of the EditPart DragTracker when the
SelectionTool hands off the drag operation for the resize. I can wrap
these trackers in an adapter but I can't get at the embedded command to
update it. The adapter can't extend ResizeTracker because it doesn't
expose the 'direction' needed for its constructor. I am left with
copying and pasting the createSelectionHandles method from
ResizableEditPolicy and addHandle from ResizableHandleKit so that I can
get my DragTracker into the equation. This doesn't look like a very
good approach but I don't see how to do it otherwise.

As always I would appeciate any help.

Thanks,
Barry
Re: Add children upon resize/move of container [message #170505 is a reply to message #170232] Sat, 05 March 2005 06:51 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
"Barry Lay" <blay@laysercomputing.com> wrote in message
news:d0504a$suq$1@www.eclipse.org...
> Barry Lay wrote:
> > I would like to implement a container that can "grab" children from its
> > parent by being resized or moved over them. Is there a helper method
> > that can locate the children within a given rectangle or do I have to
> > iterate over the children myself in the createChangeConstraintCommand
call?
>
> I had a look at how the MarqueeSelectionTool does it and it appears that
> there is no equivalent to findObjectAtExcluding (which I use to find the
> parent when releasing the children). At this point I have some

I don't understand why you can't do something like what MarqueeSelectionTool
is doing? And what do you mean when you say you're using
findObjectAtExcluding to find the parent? All children know of their
parents (which you can get via getParent()), so you shouldn't have to do
that.


> relatively expensive operations in edit policies which get called
> repeatedly while dragging but aren't really necessary to determine if
> the operation would succeed. I am now looking at what would be involved
> in delaying the action until the command is executed.
>
> It seems that the GEF architecture would suggest that the commands are
> not supposed to interact with the graphical components directly - they
> affect them by modifying the model. The fact that my optimization would
> require loading up the command with graphical details like a reference
> to the GraphicalViewer would bear this out. Does anyone have a better
> way to structure this?
>
> Thanks,
> Barry
Re: Add children upon resize/move of container [message #170701 is a reply to message #170505] Mon, 07 March 2005 00:11 Go to previous message
Barry Lay is currently offline Barry LayFriend
Messages: 48
Registered: July 2009
Member
Pratik Shah wrote:
>>I had a look at how the MarqueeSelectionTool does it and it appears that
>>there is no equivalent to findObjectAtExcluding (which I use to find the
>>parent when releasing the children). At this point I have some
>
>
> I don't understand why you can't do something like what MarqueeSelectionTool
> is doing? And what do you mean when you say you're using
> findObjectAtExcluding to find the parent? All children know of their
> parents (which you can get via getParent()), so you shouldn't have to do
> that.

I did end up doing what MarqueeSelectionTool does, which is to iterate
through all figures in the diagram to do the hit test. My concern was
that the overhead of doing this test for every movement of the mouse
might cause the cursor to jump around. I ended up creating my own drag
tracker for the resize handles in the createSelectionHandles method of
my ResizableEditPolicy. Doing that allows me to scan the figures just
once in performDrag.

I use findObjectAtExcluding when I handle the delete of the container,
allowing the orphans to drop onto whatever is beneath them. In my
diagram I allow overlapping (non-hierarchical) groups so I can't just
call getParent.

Barry
Previous Topic:undirected connections
Next Topic:Clipboard Copy and printing to PDF file
Goto Forum:
  


Current Time: Mon May 13 11:03:53 GMT 2024

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

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

Back to the top