1

When I drag an item that contains html-text then users see html string. enter image description here

I use RAP 2.3

I use code based on the public Eclipse RAP examples. And I can not find the way to change feedback effect when user start a drag action.

Tree tree = new Tree( parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION );
TreeViewer result = new TreeViewer( tree );
result.setContentProvider( new TreeContentProvider() );
TreeLabelProvider labelProvider = new TreeLabelProvider( parent.getDisplay(), MODERN_STYLE );
result.setLabelProvider( labelProvider );
result.setInput( createModel() );
result.expandAll();

Transfer[] types = new Transfer[] { TreeObjectTransfer.getInstance() };
TreeDragListener dragListener = new TreeDragListener( viewer );
viewer.addDragSupport( DND.DROP_MOVE, types, dragListener );
TreeDropListener dropListener = new TreeDropListener( viewer );
viewer.addDropSupport( DND.DROP_MOVE, types, dropListener );

And DragSourceAdapter:

private static class TreeDragListener extends DragSourceAdapter {
private final TreeViewer viewer;
private Object dragData;

TreeDragListener( TreeViewer viewer ) {
    this.viewer = viewer;
}

@Override
public void dragStart( DragSourceEvent event ) {
    dragData = getTreeObject( event.x, event.y );
}

@Override
public void dragSetData( DragSourceEvent event ) {
    event.data = dragData;
}

@Override
public void dragFinished( DragSourceEvent event ) {
    viewer.refresh();
}

private TreeObject getTreeObject( int x, int y ) {
    TreeObject result = null;
    ViewerCell cell = viewer.getCell( new Point( x, y ) );
    if( cell != null ) {
        result = ( TreeObject )cell.getElement();
    }
    return result;
}
}

RESULT: Finally, I don't find a good solution so I replaced attributes of the html-tags with next methods cell.setFont() and cell.setForeground(). In this case this bug with feedback effect has not occurs.

Paul
  • 580
  • 1
  • 7
  • 22
  • Please edit the question and add the relevant code. – Rüdiger Herrmann Feb 25 '16 at 11:34
  • I added code example. – Paul Feb 25 '16 at 11:55
  • Can you try to run your code with the [latest stable build](https://www.eclipse.org/rap/downloads/)? – Rüdiger Herrmann Feb 25 '16 at 12:21
  • I can not because I use RAP 2.3, not 3.0 – Paul Feb 25 '16 at 12:25
  • Does it matter to run this code example? I just try to find solution to set tooltip when user start dragging. – Paul Feb 25 '16 at 13:11
  • 1
    What you see looks like a bug and RAP 2.3 is quite old and not maintained any more. Therefore, if you try with a revent version, this bug is either fixed already or you can report a bug and get it fixed. – Rüdiger Herrmann Feb 25 '16 at 13:22
  • 1
    To work around the issue in the meanwhile you can try to turn feedback off with `event.feedback = DND.FEEDBACK_NONE` – Rüdiger Herrmann Feb 25 '16 at 13:25
  • I don't find a good solution so I replaced attributes of the html-tags with next methods *cell.setFont()* and *cell.setForeground()*. In this case this bug with feedback effect has not occurs. – Paul Feb 25 '16 at 21:47
  • Glad to see that you solved the problem. But nonetheless, did you try to run your code on a recent version of RAP? I'd guess that would also solve your problem - or otherwise would help to find a bug in RAP. – Rüdiger Herrmann Feb 26 '16 at 00:16
  • Thanks, I will do so in the future when I have more free time! – Paul Feb 26 '16 at 06:53

0 Answers0