Reputation: 8960
I have a Label
wrapped in a POJO. All external operations are delegated to the label.
I (internally) hook a DragSource
to the said Label
. Transfer is LocalSelectionTransfer
.
Implementation of DragSourceAdapter
:
@Override public void dragSetData(DragSourceEvent e)
{
transfer.setSelection(new StructuredSelection(this)); // *this* is the POJO wrapper
}
Question:
On drop events (externally), if I do
final Object newObj = ((StructuredSelection) transfer.getSelection()).getFirstElement();
newObj would be POJO$1
, or POJO$2
etc.
What's the reason? Why don't I get an instanceof POJO
?
Upvotes: 1
Views: 57
Reputation: 170745
As you say, new StructuredSelection(this)
is inside the implementation of DragSourceAdapter
, so this
is the implementation (an anonymous inner class of your "POJO") instead of the POJO itself! You need instead new StructuredSelection(POJO.this)
to refer to the outer instance (obviously, replace POJO
with the actual name of your class).
A bit of an aside, but I wouldn't call a class which is concerned with GUI directly a "POJO".
Upvotes: 1