Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 130037

Summary: [DND] Cheese after dropping TreeItem that has Image set
Product: [Eclipse Project] Platform Reporter: Benjamin Pasero <bpasero>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WONTFIX QA Contact: Kevin Barnes <cocoakevin>
Severity: normal    
Priority: P3 CC: benno.baumgartner, duongn, eclipse.felipe, snorthov, veronika_irvine
Version: 3.2Keywords: triaged
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard: stalebug
Attachments:
Description Flags
Image
none
Other Image
none
Tree #1
none
Tree #2
none
Tree #3 none

Description Benjamin Pasero CLA 2006-03-01 16:48:40 EST
I am on latest IBuild and very much like the new Tree DND effect while dragging, that shows the Name and Image of the dragged item.

However, I got some strange cheese after dropping such an item into the Tree. I can not reproduce with the normal Snippet for dragging leaf items in a tree though. I think what I do different in RSSOwl is that after dropping, I update the selection to the dragged item at its new place and resort the items of the Tree, in order to update the dragged items position.

See the attached screenshots. It looks as if the image-dnd-feedback occupies space that is not properly invalidated after drop.

I see that this might still be a bit early to file bugs against this new feature. Sorry if this is already a known issue.

Ben
Comment 1 Benjamin Pasero CLA 2006-03-01 16:49:00 EST
Created attachment 35564 [details]
Image
Comment 2 Benjamin Pasero CLA 2006-03-01 16:49:19 EST
Created attachment 35565 [details]
Other Image
Comment 3 Benjamin Pasero CLA 2006-03-01 16:50:33 EST
Btw I can try to write a snippet on this if this is not already a known issue.

Ben
Comment 4 Benjamin Pasero CLA 2006-03-01 17:36:26 EST
Got a snippet:

public class Main {
  public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final Table table = new Table(shell, SWT.BORDER);

    final TableItem item1 = new TableItem(table, SWT.NONE);
    item1.setText("Hello");

    Image img = new Image(display, 16, 16);
    GC gc = new GC(img);
    gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
    gc.fillRectangle(img.getBounds());
    gc.dispose();

    item1.setImage(img);

    final TableItem item2 = new TableItem(table, SWT.NONE);
    item2.setText("Hello World");

    new TableItem(table, SWT.NONE).setText("Foo");
    new TableItem(table, SWT.NONE).setText("Bar");

    DragSource source = new DragSource(table, DND.DROP_MOVE);
    source.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    source.addDragListener(new DragSourceAdapter() {
      public void dragStart(DragSourceEvent event) {
        event.doit = true;
      }

      public void dragSetData(DragSourceEvent event) {
        event.data = "Hello World";
      }
    });

    DropTarget drop = new DropTarget(table, DND.DROP_MOVE);
    drop.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    drop.addDropListener(new DropTargetAdapter() {
      public void drop(DropTargetEvent event) {
        item1.dispose();
        final TableItem item1 = new TableItem(table, SWT.NONE);
        item1.setText("H");

        Image img = new Image(display, 16, 16);
        GC gc = new GC(img);
        gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
        gc.fillRectangle(img.getBounds());
        gc.dispose();

        item1.setImage(img);
      }
    });

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
}


Steps to reproduce:
1. Select the first TableItem
2. Drag it below so that it is over the last TableItem "Bar"
3. Drop the Item

Parts of the feedback image are overdrawing the "Bar" item.

Ben
Comment 5 Veronika Irvine CLA 2006-03-02 13:10:23 EST
Modified the way drop target locks and unlocks for drawing to accomodate drawing in event handlers.

Fixed in HEAD for I20060314
Comment 6 Benjamin Pasero CLA 2006-03-07 16:07:40 EST
Was this fixed in the IBuild of today? I am a bit confused of the "Fixed in HEAD for I20060314" date there.

Anyways, I am still able to reproduce this issue, running latest IBuild and these steps:

1. Select the last Element
2. Drag it to the first Element
3. Drop it

Find some cheese top-right to the first item.

Ben
Comment 7 Veronika Irvine CLA 2006-03-07 17:09:50 EST
I am just forecasting a possible future date when I might actually get the fix right :-)
Comment 8 Benjamin Pasero CLA 2006-03-07 17:48:39 EST
lol, cool =)

Ben
Comment 9 Veronika Irvine CLA 2006-03-08 11:27:17 EST
OK, I released some new code to HEAD.  We should be on track for I20060314 :o)

I have restricted the drag over effect to the current application.  I had noticed that Windows File Explorer did the same thing and was wondering why.  This is also fixes cheese when dragging from one SWT application to another and when dragging from SWT over the Windows File Explorer.
Comment 10 Benjamin Pasero CLA 2006-03-08 15:05:13 EST
Thats great. I will play a bit with the upcoming nightly then and report anything if I still see cheeeeeese.

Ben
Comment 11 Benjamin Pasero CLA 2006-03-09 02:55:33 EST
I can verify that the problem is no longer showing up with Tables. However, with Trees I still see some problems after DND. I am unable to hack a snippet for that though. Maybe I can get something right when I am back from work.

See the attached images.

Ben
Comment 12 Benjamin Pasero CLA 2006-03-09 02:58:32 EST
Created attachment 35959 [details]
Tree #1
Comment 13 Benjamin Pasero CLA 2006-03-09 02:58:54 EST
Created attachment 35960 [details]
Tree #2
Comment 14 Benjamin Pasero CLA 2006-03-09 02:59:14 EST
Created attachment 35961 [details]
Tree #3
Comment 15 Benjamin Pasero CLA 2006-03-09 02:59:59 EST
Btw what I do on drop is rebuild the entire Tree (removeAll and adding all Items again), re-set the expanded states of TreeItems and re-select the item that has been dropped.

Ben
Comment 16 Veronika Irvine CLA 2006-03-13 11:41:29 EST
As a workaround, calling redraw() on you tree after you change everything shoudl cause the cheese to be fixed.  This is only a workaround though - there should not be cheese.

Sounds like a job for LockWindowUpdate - I shall give this a try.
Comment 17 Veronika Irvine CLA 2006-03-13 13:55:09 EST
LockWindowUpdate works like a charm for Table.  Not so good for Tree.  Makes all applications on your desktop flash like crazy.
Comment 18 Benjamin Pasero CLA 2006-03-13 16:30:28 EST
Yeah redraw would be a workaround. But I wanted to wait for M6 anyways =o).

If I can be of help with a snippet for the problem in the Tree, let me know.

Ben
Comment 19 Veronika Irvine CLA 2006-03-17 11:57:31 EST
I have released code for the next integration build (I20060321? I think :o) ) which hides the cursor before the application handles the drop event.  I believe this will resolve the cheese.  I am not going to do this for all DND events because it will cause too much flash.
Comment 20 Benjamin Pasero CLA 2006-03-18 05:06:48 EST
I can verify that running with HEAD this issue is resolved for me, great!

Btw I noticed, while playing around with large Fonts, that Tree-DND-Effect did not show up with Image and Text when dragging around an Item with a large (16 px) Font. It just showed the Image. Is this by intention?

Ben
Comment 21 Veronika Irvine CLA 2006-03-22 13:42:46 EST
Woohoo!  Glad to hear it.

Regarding the image only, this is not intentional.  I have seen a bug reported against Windows where only images are shown but this were based on the type of image, not the font and it was for the table not the tree. I will have a look at it.  

From http://www.timosoft-software.de/phpBB2/printview.php?t=39&start=0&sid=71b0d9969bd2c865bd1fb091a5e55fe5

"Microsoft's implementation of the LVM_CREATEDRAGIMAGE message has a bug, if the icon's color depth is 32bpp: The generated drag image contains the icon only and no text."
Comment 22 Benjamin Pasero CLA 2006-03-28 13:53:06 EST
I see a new problem in Tables that have the FULL_SELECTION bit set. The end of the Item's text is cut of if it exceeds a certain length (regardles of the font set). It becomes very visible when adding a CHECK bit to the table as well.

See this slightly modified snippet:

public class Main {
  public static void main(String[] args) {
    final Display display = new Display();
    Shell shell = new Shell(display);
    shell.setLayout(new FillLayout());

    final Table table = new Table(shell, SWT.BORDER | SWT.FULL_SELECTION | SWT.CHECK);

    final TableItem item1 = new TableItem(table, SWT.NONE);
    item1.setText("Hello Worlds");

    Image img = new Image(display, 16, 16);
    GC gc = new GC(img);
    gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
    gc.fillRectangle(img.getBounds());
    gc.dispose();

    item1.setImage(img);

    final TableItem item2 = new TableItem(table, SWT.NONE);
    item2.setText("Hello World");

    new TableItem(table, SWT.NONE).setText("Foo");
    new TableItem(table, SWT.NONE).setText("Bar");

    DragSource source = new DragSource(table, DND.DROP_MOVE);
    source.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    source.addDragListener(new DragSourceAdapter() {
      public void dragStart(DragSourceEvent event) {
        event.doit = true;
      }

      public void dragSetData(DragSourceEvent event) {
        event.data = "Hello World";
      }
    });

    DropTarget drop = new DropTarget(table, DND.DROP_MOVE);
    drop.setTransfer(new Transfer[] { TextTransfer.getInstance() });
    drop.addDropListener(new DropTargetAdapter() {
      public void drop(DropTargetEvent event) {
        item1.dispose();
        final TableItem item1 = new TableItem(table, SWT.NONE);
        item1.setText("H");

        Image img = new Image(display, 16, 16);
        GC gc = new GC(img);
        gc.setBackground(display.getSystemColor(SWT.COLOR_GREEN));
        gc.fillRectangle(img.getBounds());
        gc.dispose();

        item1.setImage(img);
      }
    });

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
  }
}

Ben
Comment 23 Veronika Irvine CLA 2006-04-03 17:27:47 EDT
*** Bug 131682 has been marked as a duplicate of this bug. ***
Comment 24 Felipe Heidrich CLA 2009-06-15 10:00:17 EDT
I can't reproduce this bug in 3.5 RC4.
Note: a lot of code has changed in drag drop feedback image since 2006.
Comment 25 Leo Ufimtsev CLA 2017-08-03 12:31:54 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 26 Eclipse Genie CLA 2020-04-14 20:04:23 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.