Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor
Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor [message #53580] Fri, 10 January 2003 17:35 Go to next message
Eclipse UserFriend
Originally posted by: sy_cheung2.yahoo.com

I want to enable users to drag some elements from Package Explorer
View/Hierarchy View in JDT and drop it to the GEF Editor main panel. And the
GEF editor will create Labels with the text equals to the names of the
elements being dropped.

From previous postings, I have an idea about how to handle drop to GEF
editor. I can drag from Task View to GEF editor. But how can I drag from
Package Explorer/Hierarchy View to the GEF editor?

Do I need to implement a different GEF Transfer Drop Target Listener?
Currently, it has TextTransferDropTargetListener and Logic Template Transfer
Drop TargetListener. The Package Explorer has SelectionTransferDragAdapter,
esourceTransferDragAdapter, FleTransferDragAdapter

I think I need another a Selection Transfer Drop Target Listener for
dragging from Package Explorer View/Hierarchy View? What should I do in that
Drop Target Listener to handle drop from Package Explorer?


Thanks in advance.
Sam
Re: Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor [message #53633 is a reply to message #53580] Fri, 10 January 2003 19:46 Go to previous messageGo to next message
Eric Bordeau is currently offline Eric BordeauFriend
Messages: 259
Registered: July 2009
Senior Member
Sam,

You'll need to create a new TransferDropTargetListener and register it
with the viewer (see LogicEditor.initializeGraphicalViewer()) using the
correct transfer type, like ResourceTransfer. In your listener,
override createTargetRequest() to create and return a CreateRequest.
You'll need to set a factory on the request. The factory should create
a new model object. Here's what I did...

private CreateRequest.Factory labelFactory = new CreateRequest.Factory() {
public Object getNewObject() {
return new LogicLabel();
}
public Object getObjectType() {
return LogicPlugin.TEMPLATE_LOGIC_LABEL;
}
};

Set this as the factory for your newly created request. You'll also
need to set the location for the CreateRequest in updateTargetRequest().
This is where you can take advantage of getDropLocation(). Finally,
override handleDrop() (be sure to call super.handleDrop()) so that you
can get the dragged resource and set the new labels text. You'll have
to get the target request, cast it to a CreateRequest and call
getNewObject(), which will return your new LogicLabel. Then, get the
current event's data object (which for a ResourceTransfer is an
IResource[]). Get the first resource and set the label's text to the
resource's name.

One thing to be careful of... By default, the dnd operation is a move.
If you move a resource from the package explorer, it will be deleted.
You should set the current event's detail to DND.DROP_COPY in the
handleDrop() method, since you're not moving the resource. I would also
do the same in handleDragOver() just so the cursor will reflect the copy
operation you're going to perform.

I hope this helps.

Eric

Sam Cheung wrote:
> I want to enable users to drag some elements from Package Explorer
> View/Hierarchy View in JDT and drop it to the GEF Editor main panel. And the
> GEF editor will create Labels with the text equals to the names of the
> elements being dropped.
>
> From previous postings, I have an idea about how to handle drop to GEF
> editor. I can drag from Task View to GEF editor. But how can I drag from
> Package Explorer/Hierarchy View to the GEF editor?
>
> Do I need to implement a different GEF Transfer Drop Target Listener?
> Currently, it has TextTransferDropTargetListener and Logic Template Transfer
> Drop TargetListener. The Package Explorer has SelectionTransferDragAdapter,
> esourceTransferDragAdapter, FleTransferDragAdapter
>
> I think I need another a Selection Transfer Drop Target Listener for
> dragging from Package Explorer View/Hierarchy View? What should I do in that
> Drop Target Listener to handle drop from Package Explorer?
>
>
> Thanks in advance.
> Sam
>
>
Re: Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor [message #58651 is a reply to message #53633] Tue, 28 January 2003 15:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:avn73a$fno$1@rogue.oti.com...
> Sam,
>
> You'll need to create a new TransferDropTargetListener and register it
> with the viewer (see LogicEditor.initializeGraphicalViewer()) using the
> correct transfer type, like ResourceTransfer. In your listener,
> override createTargetRequest() to create and return a CreateRequest.
> You'll need to set a factory on the request. The factory should create
> a new model object. Here's what I did...
>
> private CreateRequest.Factory labelFactory = new CreateRequest.Factory() {
> public Object getNewObject() {
> return new LogicLabel();
> }
> public Object getObjectType() {
> return LogicPlugin.TEMPLATE_LOGIC_LABEL;
> }
> };
>
> Set this as the factory for your newly created request. You'll also
> need to set the location for the CreateRequest in updateTargetRequest().
> This is where you can take advantage of getDropLocation(). Finally,
> override handleDrop() (be sure to call super.handleDrop()) so that you
> can get the dragged resource and set the new labels text. You'll have
> to get the target request, cast it to a CreateRequest and call
> getNewObject(), which will return your new LogicLabel. Then, get the
> current event's data object (which for a ResourceTransfer is an
> IResource[]). Get the first resource and set the label's text to the
> resource's name.
>
> One thing to be careful of... By default, the dnd operation is a move.
> If you move a resource from the package explorer, it will be deleted.
> You should set the current event's detail to DND.DROP_COPY in the

Shouldn't this be done sooner than drop, so that the cursor will change?
Maybe on drag over.

> handleDrop() method, since you're not moving the resource. I would also
> do the same in handleDragOver() just so the cursor will reflect the copy
> operation you're going to perform.
>
> I hope this helps.
>
> Eric
>
> Sam Cheung wrote:
> > I want to enable users to drag some elements from Package Explorer
> > View/Hierarchy View in JDT and drop it to the GEF Editor main panel. And
the
> > GEF editor will create Labels with the text equals to the names of the
> > elements being dropped.
> >
> > From previous postings, I have an idea about how to handle drop to GEF
> > editor. I can drag from Task View to GEF editor. But how can I drag from
> > Package Explorer/Hierarchy View to the GEF editor?
> >
> > Do I need to implement a different GEF Transfer Drop Target Listener?
> > Currently, it has TextTransferDropTargetListener and Logic Template
Transfer
> > Drop TargetListener. The Package Explorer has
SelectionTransferDragAdapter,
> > esourceTransferDragAdapter, FleTransferDragAdapter
> >
> > I think I need another a Selection Transfer Drop Target Listener for
> > dragging from Package Explorer View/Hierarchy View? What should I do in
that
> > Drop Target Listener to handle drop from Package Explorer?
> >
> >
> > Thanks in advance.
> > Sam
> >
> >
>
Re: Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor [message #58699 is a reply to message #58651] Tue, 28 January 2003 16:45 Go to previous messageGo to next message
Eric Bordeau is currently offline Eric BordeauFriend
Messages: 259
Registered: July 2009
Senior Member
Randy Hudson wrote:
> "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> news:avn73a$fno$1@rogue.oti.com...
>
>>Sam,
>>
>>You'll need to create a new TransferDropTargetListener and register it
>>with the viewer (see LogicEditor.initializeGraphicalViewer()) using the
>>correct transfer type, like ResourceTransfer. In your listener,
>>override createTargetRequest() to create and return a CreateRequest.
>>You'll need to set a factory on the request. The factory should create
>>a new model object. Here's what I did...
>>
>>private CreateRequest.Factory labelFactory = new CreateRequest.Factory() {
>>public Object getNewObject() {
>>return new LogicLabel();
>>}
>>public Object getObjectType() {
>>return LogicPlugin.TEMPLATE_LOGIC_LABEL;
>>}
>>};
>>
>>Set this as the factory for your newly created request. You'll also
>>need to set the location for the CreateRequest in updateTargetRequest().
>> This is where you can take advantage of getDropLocation(). Finally,
>>override handleDrop() (be sure to call super.handleDrop()) so that you
>>can get the dragged resource and set the new labels text. You'll have
>>to get the target request, cast it to a CreateRequest and call
>>getNewObject(), which will return your new LogicLabel. Then, get the
>>current event's data object (which for a ResourceTransfer is an
>>IResource[]). Get the first resource and set the label's text to the
>>resource's name.
>>
>>One thing to be careful of... By default, the dnd operation is a move.
>>If you move a resource from the package explorer, it will be deleted.
>>You should set the current event's detail to DND.DROP_COPY in the
>
>
> Shouldn't this be done sooner than drop, so that the cursor will change?
> Maybe on drag over.
>

Hence the next sentence. ;)

>
>>handleDrop() method, since you're not moving the resource. I would also
>>do the same in handleDragOver() just so the cursor will reflect the copy
>>operation you're going to perform.
>>
>>I hope this helps.
>>
>>Eric
>>
>>Sam Cheung wrote:
>>
>>>I want to enable users to drag some elements from Package Explorer
>>>View/Hierarchy View in JDT and drop it to the GEF Editor main panel. And
>
> the
>
>>>GEF editor will create Labels with the text equals to the names of the
>>>elements being dropped.
>>>
>>>From previous postings, I have an idea about how to handle drop to GEF
>>>editor. I can drag from Task View to GEF editor. But how can I drag from
>>>Package Explorer/Hierarchy View to the GEF editor?
>>>
>>>Do I need to implement a different GEF Transfer Drop Target Listener?
>>>Currently, it has TextTransferDropTargetListener and Logic Template
>
> Transfer
>
>>>Drop TargetListener. The Package Explorer has
>
> SelectionTransferDragAdapter,
>
>>>esourceTransferDragAdapter, FleTransferDragAdapter
>>>
>>>I think I need another a Selection Transfer Drop Target Listener for
>>>dragging from Package Explorer View/Hierarchy View? What should I do in
>
> that
>
>>>Drop Target Listener to handle drop from Package Explorer?
>>>
>>>
>>>Thanks in advance.
>>>Sam
>>>
>>>
>>
>
>
Re: Drag from Package Explorer View/Hierarchy View in JDT to Graph Editor [message #59571 is a reply to message #58699] Wed, 29 January 2003 16:38 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

DOH!

"Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
news:b16as9$39a$1@rogue.oti.com...
> Randy Hudson wrote:
> > "Eric Bordeau" <ebordeau@us.ibm.com> wrote in message
> > news:avn73a$fno$1@rogue.oti.com...
> >
> >>Sam,
> >>
> >>You'll need to create a new TransferDropTargetListener and register it
> >>with the viewer (see LogicEditor.initializeGraphicalViewer()) using the
> >>correct transfer type, like ResourceTransfer. In your listener,
> >>override createTargetRequest() to create and return a CreateRequest.
> >>You'll need to set a factory on the request. The factory should create
> >>a new model object. Here's what I did...
> >>
> >>private CreateRequest.Factory labelFactory = new CreateRequest.Factory()
{
> >>public Object getNewObject() {
> >>return new LogicLabel();
> >>}
> >>public Object getObjectType() {
> >>return LogicPlugin.TEMPLATE_LOGIC_LABEL;
> >>}
> >>};
> >>
> >>Set this as the factory for your newly created request. You'll also
> >>need to set the location for the CreateRequest in updateTargetRequest().
> >> This is where you can take advantage of getDropLocation(). Finally,
> >>override handleDrop() (be sure to call super.handleDrop()) so that you
> >>can get the dragged resource and set the new labels text. You'll have
> >>to get the target request, cast it to a CreateRequest and call
> >>getNewObject(), which will return your new LogicLabel. Then, get the
> >>current event's data object (which for a ResourceTransfer is an
> >>IResource[]). Get the first resource and set the label's text to the
> >>resource's name.
> >>
> >>One thing to be careful of... By default, the dnd operation is a move.
> >>If you move a resource from the package explorer, it will be deleted.
> >>You should set the current event's detail to DND.DROP_COPY in the
> >
> >
> > Shouldn't this be done sooner than drop, so that the cursor will change?
> > Maybe on drag over.
> >
>
> Hence the next sentence. ;)
>
> >
> >>handleDrop() method, since you're not moving the resource. I would also
> >>do the same in handleDragOver() just so the cursor will reflect the copy
> >>operation you're going to perform.
> >>
> >>I hope this helps.
> >>
> >>Eric
> >>
> >>Sam Cheung wrote:
> >>
> >>>I want to enable users to drag some elements from Package Explorer
> >>>View/Hierarchy View in JDT and drop it to the GEF Editor main panel.
And
> >
> > the
> >
> >>>GEF editor will create Labels with the text equals to the names of the
> >>>elements being dropped.
> >>>
> >>>From previous postings, I have an idea about how to handle drop to GEF
> >>>editor. I can drag from Task View to GEF editor. But how can I drag
from
> >>>Package Explorer/Hierarchy View to the GEF editor?
> >>>
> >>>Do I need to implement a different GEF Transfer Drop Target Listener?
> >>>Currently, it has TextTransferDropTargetListener and Logic Template
> >
> > Transfer
> >
> >>>Drop TargetListener. The Package Explorer has
> >
> > SelectionTransferDragAdapter,
> >
> >>>esourceTransferDragAdapter, FleTransferDragAdapter
> >>>
> >>>I think I need another a Selection Transfer Drop Target Listener for
> >>>dragging from Package Explorer View/Hierarchy View? What should I do in
> >
> > that
> >
> >>>Drop Target Listener to handle drop from Package Explorer?
> >>>
> >>>
> >>>Thanks in advance.
> >>>Sam
> >>>
> >>>
> >>
> >
> >
>
Previous Topic:[SWT] Widget for the "Debug" icon?
Next Topic:Is it possible to have two figures attached to the same model?
Goto Forum:
  


Current Time: Thu Dec 26 12:10:53 GMT 2024

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

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

Back to the top