Disable GEF TreeViewer DND Feedback [message #240124] |
Tue, 04 December 2007 10:18  |
Eclipse User |
|
|
|
Originally posted by: schiermike.xxx.at
Hello,
in my program, I use a calendar in my editor and in a separate view a tree
containing several items each having a label and an icon.
Drag&Drop from the view to the editor works perfectly and when dragging an
item, a default feedback is shown.
My problem is: I want to use a customized feedback for the drag-operation
(showing the duration of the item graphically which i want to add to the
calendar). This also worked by drawing on the SCALED_FEEDBACK_LAYER in a
function which is called by updateTargetEditPart() in my
DropTargetListener.
What is still there is the default-feedback which I mentioned previously.
It causes my feedback to flicker and some "dirt" remains on the
FEEDBACK-LAYER from previous feedback-draw-calls which can only be avoided
when i refresh the whole FEEDBACK-LAYER - but the default-Feedback is
still there :-(
Is there a way to disable this default feedback? I tried several things
including playing around with DND.FEEDBACK_NONE in the TreeViewers SWT
Tree component but nothing seems to work...
thx for your help!
|
|
|
|
Re: Disable GEF TreeViewer DND Feedback [message #240185 is a reply to message #240171] |
Wed, 05 December 2007 20:08  |
Eclipse User |
|
|
|
I could solve my problem - dirty solution, but it works:
I managed to make the underlying composite (a SWT Tree) to do a
drag-operation without painting the feedback-figure. This then enabled
me to draw my GEF-specific feedback without *dirt*.
Solution: overwrite the TreeViewer::refreshDragSourceAdapter() and there
overwrite the DragSource::getDragSourceEffect() to return no effect.
viewer = new TreeViewer()
{
@Override
protected void refreshDragSourceAdapter()
{
if (getControl() == null)
return;
if (getDelegatingDragAdapter().isEmpty())
setDragSource(null);
else
{
if (getDragSource() == null)
setDragSource(new DragSource(getControl(), DND.DROP_MOVE |
DND.DROP_COPY | DND.DROP_LINK)
{
public DragSourceEffect getDragSourceEffect()
{
return null; // don't want to have a native drag-feedback
}
@Override
protected void checkSubclass()
{
// avoid evil SWT error
}
});
getDragSource().setTransfer(getDelegatingDragAdapter().getTr ansfers());
}
}
};
}
thx for the hints.
Mélanie schrieb:
> Hi,
>
> All classes related to the DND in the TreeViewer have a default
> visibility which makes them impossible to modify. They are set in the
> constructor of the TreeViewer.
>
> addDragSourceListener(new TreeViewerTransferDragListener(this));
> addDropTargetListener(new TreeViewerTransferDropListener(this));
>
> There's a bugzilla (139666) about the limitation of the DND in GEF
> TreeViewer. I think a solution for you, not the ideal one though, could
> be to extend TreeViewer and recreate the classes required for the DND
> (which could be inspired by the actuals classes) and set them instead of
> the default one in the constructor so you can program them to do
> whatever you want.
> You can also take a look at TreeContainerEditPolicy, where there's
> private method to show feedback. I think it is tightly couple with the
> actual widget, but maybe you could change the cursor.
>
> Hope those hints helped you!
>
> Mélanie
>
|
|
|
Powered by
FUDForum. Page generated in 0.07000 seconds