Skip to main content


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 19:40 Go to next message
Lidder is currently offline LidderFriend
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 14:03 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
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 20:29 Go to previous messageGo to next message
Lidder is currently offline LidderFriend
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 13:15 Go to previous message
Miguel Moreo is currently offline Miguel MoreoFriend
Messages: 8
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:Databinding + PreferenceStore
Next Topic:Getting TreeViewer object from a CTabItem
Goto Forum:
  


Current Time: Thu Apr 25 20:35:18 GMT 2024

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

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

Back to the top