Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » drag and drop change icon
drag and drop change icon [message #536990] Mon, 31 May 2010 15:40 Go to next message
Lidder is currently offline Lidder
Messages: 46
Registered: July 2009
Member
Hello,

I implemented drag and drop support in my plugin using the following article.
http://www.eclipse.org/articles/Article-Workbench-DND/drag_d rop.html

Is there a way to change the icon that is displayed when something is dragged. I have a multi column custom tree viewer extended from TreeViewer. When I drag a row from the tree, I see multiple colums being dragged. Can I change that to to text of the first column only?

Thanks.
Re: drag and drop change icon [message #537739 is a reply to message #536990] Thu, 03 June 2010 10:03 Go to previous messageGo to next message
Grant Gayed is currently offline Grant Gayed
Messages: 2148
Registered: July 2009
Senior Member
Hi,

You can set the image in the DragSourceListener's image field:

source.addDragListener (new DragSourceListener () {
public void dragStart(DragSourceEvent event) {
event.image = image; // <----
...
}
...
}

In your specific case of setting the drag image to the item's column 0 text,
you'll need to create an Image with this content. You could do this either
by using a GC to capture the bounds of the item's column 0 cell to an Image
(somewhat related example of this:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet95.java?view=co )
, or create an Image from scratch and GC.drawString(...) the item's column 0
text to it.

HTH,
Grant


"Lidder" <ulidder@gmail.com> wrote in message
news:hu13c7$o4j$1@build.eclipse.org...
> Hello,
>
> I implemented drag and drop support in my plugin using the following
article.
> http://www.eclipse.org/articles/Article-Workbench-DND/drag_d rop.html
>
> Is there a way to change the icon that is displayed when something is
dragged. I have a multi column custom tree viewer extended from TreeViewer.
When I drag a row from the tree, I see multiple colums being dragged. Can I
change that to to text of the first column only?
>
> Thanks.
Re: drag and drop change icon [message #538871 is a reply to message #537739] Tue, 08 June 2010 16:29 Go to previous messageGo to next message
Lidder is currently offline Lidder
Messages: 46
Registered: July 2009
Member
Thanks Grant. Worked beautifully.
Re: drag and drop change icon [message #1022748 is a reply to message #538871] Fri, 22 March 2013 09:15 Go to previous message
Miguel Moreo is currently offline Miguel Moreo
Messages: 1
Registered: March 2013
Junior Member
Hello,

Could you please post the solution to this problem?
I am pretty new in JFace and I can not find a way to get the GC to capture the bounds of the item's column. Sad
I am only able to capture the full table.

Thanks!


Previous Topic:dynamic dispose and create of treeviewer + columns
Next Topic:treeviewer columns disposal
Goto Forum:
  


Current Time: Wed Jul 23 16:09:01 EDT 2014

Powered by FUDForum. Page generated in 0.02154 seconds