Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drag and Drop in GEF
Drag and Drop in GEF [message #65011] Mon, 17 February 2003 17:11 Go to next message
yinglcs is currently offline yinglcsFriend
Messages: 64
Registered: July 2009
Member
Support I have 2 container figures (e.g. Circuit in Logic Editor), and one
of them has an AndGate Figure.

Can I add Drag and Drop functionality to the Circuit so that I can drag an
AndGate Figure from 1 circuit and drop it to a new Circuit , so that at the
end both Ciruit has an AndGate and the original AndGate Figure never moves
its location?

Thanks for any help.
Re: Drag and Drop in GEF [message #65185 is a reply to message #65011] Mon, 17 February 2003 20:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

The correct way to do this (if i understand you) is to hold the CTRL key
while dragging. There is no reason to use native drag and drop to copy
something within the same viewer. Instead, make a subclass of
DragEditPartsTracker that changes the Request somehow whenever CTRL is
pressed in released.

override handleKeyPressed(...), handleKeyReleased(...) to update the cursor
(cursor is either normal drag cursor or SharedCursors.CURSOR_TREE_ADD). You
could also store whether CTRL is pressed or not, but you can query this from
Display at any time.

in updateTargetRequest(), indicate whether the drag is a "copy" or a "move".

Finally, submit this code to GEF so we can release it :-)

"yinglcs" <yinglcs@netscape.com> wrote in message
news:b2r3j1$6ld$1@rogue.oti.com...
> Support I have 2 container figures (e.g. Circuit in Logic Editor), and one
> of them has an AndGate Figure.
>
> Can I add Drag and Drop functionality to the Circuit so that I can drag an
> AndGate Figure from 1 circuit and drop it to a new Circuit , so that at
the
> end both Ciruit has an AndGate and the original AndGate Figure never moves
> its location?
>
> Thanks for any help.
>
>
>
Re: Drag and Drop in GEF [message #65586 is a reply to message #65185] Wed, 19 February 2003 06:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sy_cheung2.yahoo.com

I can't find handleKeyPressed(...), handleKeyReleased(...) in the
DragEditPartsTracker to overload.
I try overloading
handleKeyDown(KeyEvent e)

handleKeyUp(KeyEvent e),

And I put breakpoints in handleKeyDown() and handleKeyUp(), they won't
break until I I start drag and then press a Key.

this is not what we want. Right? We want to identify if a Ctrl key was press
when we start drag NOT when we drag if a Ctrl Key is press.

Am I missing something? Please provide further advice.

Thanks for your help.


"Randy Hudson" <none@us.ibm.com> wrote in message
news:b2rete$fdr$1@rogue.oti.com...
> The correct way to do this (if i understand you) is to hold the CTRL key
> while dragging. There is no reason to use native drag and drop to copy
> something within the same viewer. Instead, make a subclass of
> DragEditPartsTracker that changes the Request somehow whenever CTRL is
> pressed in released.
>
> override handleKeyPressed(...), handleKeyReleased(...) to update the
cursor
> (cursor is either normal drag cursor or SharedCursors.CURSOR_TREE_ADD).
You
> could also store whether CTRL is pressed or not, but you can query this
from
> Display at any time.
>
> in updateTargetRequest(), indicate whether the drag is a "copy" or a
"move".
>
> Finally, submit this code to GEF so we can release it :-)
>
> "yinglcs" <yinglcs@netscape.com> wrote in message
> news:b2r3j1$6ld$1@rogue.oti.com...
> > Support I have 2 container figures (e.g. Circuit in Logic Editor), and
one
> > of them has an AndGate Figure.
> >
> > Can I add Drag and Drop functionality to the Circuit so that I can drag
an
> > AndGate Figure from 1 circuit and drop it to a new Circuit , so that at
> the
> > end both Ciruit has an AndGate and the original AndGate Figure never
moves
> > its location?
> >
> > Thanks for any help.
> >
> >
> >
>
>
Re: Drag and Drop in GEF [message #65671 is a reply to message #65586] Wed, 19 February 2003 15:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> I can't find handleKeyPressed(...), handleKeyReleased(...) in the
> DragEditPartsTracker to overload.
> I try overloading
> handleKeyDown(KeyEvent e)
>
> handleKeyUp(KeyEvent e),
>
> And I put breakpoints in handleKeyDown() and handleKeyUp(), they won't
> break until I I start drag and then press a Key.

correct, the drag tracker is loaded when you press the mouse.

> this is not what we want. Right? We want to identify if a Ctrl key was
press
> when we start drag NOT when we drag if a Ctrl Key is press.

> Am I missing something? Please provide further advice.

You can detect if the Control key is down (in the cases where control key
pressed comes before the DragTracker is even created) several way, the
easiest would be:

The drag tracker does receive the initial mouseDown event. So in
handleMouseDown(int) call
getCurrentInput().isControlKeyPressed().

>
> Thanks for your help.
>
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:b2rete$fdr$1@rogue.oti.com...
> > The correct way to do this (if i understand you) is to hold the CTRL key
> > while dragging. There is no reason to use native drag and drop to copy
> > something within the same viewer. Instead, make a subclass of
> > DragEditPartsTracker that changes the Request somehow whenever CTRL is
> > pressed in released.
> >
> > override handleKeyPressed(...), handleKeyReleased(...) to update the
> cursor
> > (cursor is either normal drag cursor or SharedCursors.CURSOR_TREE_ADD).
> You
> > could also store whether CTRL is pressed or not, but you can query this
> from
> > Display at any time.
> >
> > in updateTargetRequest(), indicate whether the drag is a "copy" or a
> "move".
> >
> > Finally, submit this code to GEF so we can release it :-)
> >
> > "yinglcs" <yinglcs@netscape.com> wrote in message
> > news:b2r3j1$6ld$1@rogue.oti.com...
> > > Support I have 2 container figures (e.g. Circuit in Logic Editor), and
> one
> > > of them has an AndGate Figure.
> > >
> > > Can I add Drag and Drop functionality to the Circuit so that I can
drag
> an
> > > AndGate Figure from 1 circuit and drop it to a new Circuit , so that
at
> > the
> > > end both Ciruit has an AndGate and the original AndGate Figure never
> moves
> > > its location?
> > >
> > > Thanks for any help.
> > >
> > >
> > >
> >
> >
>
>
Re: Drag and Drop in GEF [message #65881 is a reply to message #65671] Thu, 20 February 2003 17:03 Go to previous messageGo to next message
yinglcs is currently offline yinglcsFriend
Messages: 64
Registered: July 2009
Member
I able to create MyDragEditPartsTracker instead of DragEditPartsTracker when
a Ctrl during Dragging.

And I change teh cursor to TREE_ADD and change the ChangeBoundsRequest to
be type REQ_ADD (instead of REQ_MOVE),

But when I drag it, the cursor DOES NOT change, it still end up a MOVE
command. I can tell that because the Label become gray and with dotted lines
(the way it appears when I move it).

Could you please tell me what do I miss?

Thanks.

public class MyDragEditPartsTracker extends DragEditPartsTracker {

protected boolean handleDragStarted() {

System.out.println("drag");

setCursor(SharedCursors.CURSOR_TREE_ADD); /// <----------------

return super.handleDragStarted();

}

protected void updateTargetRequest() {

ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();

request.setEditParts(getOperationSet());

Dimension d = getDragMoveDelta();

request.setMoveDelta(new Point(d.width, d.height));

request.setLocation(getLocation());

request.setType(REQ_ADD); /// this is REQ_ADD

}

}



"Randy Hudson" <none@us.ibm.com> wrote in message
news:b306j5$s90$1@rogue.oti.com...
> > I can't find handleKeyPressed(...), handleKeyReleased(...) in the
> > DragEditPartsTracker to overload.
> > I try overloading
> > handleKeyDown(KeyEvent e)
> >
> > handleKeyUp(KeyEvent e),
> >
> > And I put breakpoints in handleKeyDown() and handleKeyUp(), they
won't
> > break until I I start drag and then press a Key.
>
> correct, the drag tracker is loaded when you press the mouse.
>
> > this is not what we want. Right? We want to identify if a Ctrl key was
> press
> > when we start drag NOT when we drag if a Ctrl Key is press.
>
> > Am I missing something? Please provide further advice.
>
> You can detect if the Control key is down (in the cases where control key
> pressed comes before the DragTracker is even created) several way, the
> easiest would be:
>
> The drag tracker does receive the initial mouseDown event. So in
> handleMouseDown(int) call
> getCurrentInput().isControlKeyPressed().
>
> >
> > Thanks for your help.
> >
> >
> > "Randy Hudson" <none@us.ibm.com> wrote in message
> > news:b2rete$fdr$1@rogue.oti.com...
> > > The correct way to do this (if i understand you) is to hold the CTRL
key
> > > while dragging. There is no reason to use native drag and drop to
copy
> > > something within the same viewer. Instead, make a subclass of
> > > DragEditPartsTracker that changes the Request somehow whenever CTRL is
> > > pressed in released.
> > >
> > > override handleKeyPressed(...), handleKeyReleased(...) to update the
> > cursor
> > > (cursor is either normal drag cursor or
SharedCursors.CURSOR_TREE_ADD).
> > You
> > > could also store whether CTRL is pressed or not, but you can query
this
> > from
> > > Display at any time.
> > >
> > > in updateTargetRequest(), indicate whether the drag is a "copy" or a
> > "move".
> > >
> > > Finally, submit this code to GEF so we can release it :-)
> > >
> > > "yinglcs" <yinglcs@netscape.com> wrote in message
> > > news:b2r3j1$6ld$1@rogue.oti.com...
> > > > Support I have 2 container figures (e.g. Circuit in Logic Editor),
and
> > one
> > > > of them has an AndGate Figure.
> > > >
> > > > Can I add Drag and Drop functionality to the Circuit so that I can
> drag
> > an
> > > > AndGate Figure from 1 circuit and drop it to a new Circuit , so that
> at
> > > the
> > > > end both Ciruit has an AndGate and the original AndGate Figure never
> > moves
> > > > its location?
> > > >
> > > > Thanks for any help.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Re: Drag and Drop in GEF [message #65935 is a reply to message #65881] Fri, 21 February 2003 00:15 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

ADD is a special type of MOVE, which is why you are seeing the same
feedback. You need to invent a new ID that doesn't exist yet.

A MOVE is within a single parent. An ADD is what happens when you MOVE
across parents. This is actually treated as an ORPHAN with the old parent,
and an ADD to the new parent.

"yinglcs" <yinglcs@netscape.com> wrote in message
news:b3304l$2mg$1@rogue.oti.com...
> I able to create MyDragEditPartsTracker instead of DragEditPartsTracker
when
> a Ctrl during Dragging.
>
> And I change teh cursor to TREE_ADD and change the ChangeBoundsRequest to
> be type REQ_ADD (instead of REQ_MOVE),
>
> But when I drag it, the cursor DOES NOT change, it still end up a MOVE
> command. I can tell that because the Label become gray and with dotted
lines
> (the way it appears when I move it).
>
> Could you please tell me what do I miss?
>
> Thanks.
>
> public class MyDragEditPartsTracker extends DragEditPartsTracker {
>
> protected boolean handleDragStarted() {
>
> System.out.println("drag");
>
> setCursor(SharedCursors.CURSOR_TREE_ADD); /// <----------------
>
> return super.handleDragStarted();
>
> }
>
> protected void updateTargetRequest() {
>
> ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
>
> request.setEditParts(getOperationSet());
>
> Dimension d = getDragMoveDelta();
>
> request.setMoveDelta(new Point(d.width, d.height));
>
> request.setLocation(getLocation());
>
> request.setType(REQ_ADD); /// this is REQ_ADD
>
> }
>
> }
>
>
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:b306j5$s90$1@rogue.oti.com...
> > > I can't find handleKeyPressed(...), handleKeyReleased(...) in the
> > > DragEditPartsTracker to overload.
> > > I try overloading
> > > handleKeyDown(KeyEvent e)
> > >
> > > handleKeyUp(KeyEvent e),
> > >
> > > And I put breakpoints in handleKeyDown() and handleKeyUp(), they
> won't
> > > break until I I start drag and then press a Key.
> >
> > correct, the drag tracker is loaded when you press the mouse.
> >
> > > this is not what we want. Right? We want to identify if a Ctrl key was
> > press
> > > when we start drag NOT when we drag if a Ctrl Key is press.
> >
> > > Am I missing something? Please provide further advice.
> >
> > You can detect if the Control key is down (in the cases where control
key
> > pressed comes before the DragTracker is even created) several way, the
> > easiest would be:
> >
> > The drag tracker does receive the initial mouseDown event. So in
> > handleMouseDown(int) call
> > getCurrentInput().isControlKeyPressed().
> >
> > >
> > > Thanks for your help.
> > >
> > >
> > > "Randy Hudson" <none@us.ibm.com> wrote in message
> > > news:b2rete$fdr$1@rogue.oti.com...
> > > > The correct way to do this (if i understand you) is to hold the CTRL
> key
> > > > while dragging. There is no reason to use native drag and drop to
> copy
> > > > something within the same viewer. Instead, make a subclass of
> > > > DragEditPartsTracker that changes the Request somehow whenever CTRL
is
> > > > pressed in released.
> > > >
> > > > override handleKeyPressed(...), handleKeyReleased(...) to update the
> > > cursor
> > > > (cursor is either normal drag cursor or
> SharedCursors.CURSOR_TREE_ADD).
> > > You
> > > > could also store whether CTRL is pressed or not, but you can query
> this
> > > from
> > > > Display at any time.
> > > >
> > > > in updateTargetRequest(), indicate whether the drag is a "copy" or a
> > > "move".
> > > >
> > > > Finally, submit this code to GEF so we can release it :-)
> > > >
> > > > "yinglcs" <yinglcs@netscape.com> wrote in message
> > > > news:b2r3j1$6ld$1@rogue.oti.com...
> > > > > Support I have 2 container figures (e.g. Circuit in Logic Editor),
> and
> > > one
> > > > > of them has an AndGate Figure.
> > > > >
> > > > > Can I add Drag and Drop functionality to the Circuit so that I can
> > drag
> > > an
> > > > > AndGate Figure from 1 circuit and drop it to a new Circuit , so
that
> > at
> > > > the
> > > > > end both Ciruit has an AndGate and the original AndGate Figure
never
> > > moves
> > > > > its location?
> > > > >
> > > > > Thanks for any help.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
Previous Topic:connections not reconnecting
Next Topic:tabulated vie problem
Goto Forum:
  


Current Time: Sun Nov 24 08:15:16 GMT 2024

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

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

Back to the top