user641595
user641595

Reputation: 61

Drag and drop SWT container composite

Is it possible to drag and drop a container composite in SWT (Eclipse RCP)?
If it is can anyone explain how? Thanks!

Upvotes: 1

Views: 954

Answers (2)

Georgian
Georgian

Reputation: 8960

Since this question has been asked many times around the SWT community, I've decided to make a blog post on this, with included source code. Check it out and don't hesitate to ask any questions if you are in doubt.

Upvotes: 1

col.panic
col.panic

Reputation: 2974

I think generally it should be possible, it is quite complicated however. Let's assume an application tailored to do so, what would be done

  • You select the composite in View A, trying to drag it to View B. First it is not possible to directly select a composite, you would have to provide a hook, by possibly taking a label within this composite and fetching the labels parent.
  • You then serialize the elements contained in the composite somehow.. anyway, what is it you want to transport?
  • You drop the data into View B, which gets your serialized String coming in. What to do with this String now?
  • You would have to dynamically create a new composite, resembling the structure of the original composite (that is where the String comes into play, which must contain all this information) and fill it with the information you wanted
  • You would then have to reload this view in order to show the new structure.

I think you first have to answer the question to what scenario you want to cover with draging and dropping a container before a deeper analysis can be done.

Upvotes: 0

Related Questions