Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » [DND] Drop business object from external TableViewer
[DND] Drop business object from external TableViewer [message #881375] Mon, 04 June 2012 12:37 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 756
Registered: July 2009
Senior Member
I am trying to drop a business object from an 'external' TableViewer, i.e. in a workbench part outside the DiagramEditor. When entering the diagram area, the DROP operation does not change, i.e. I cannot drop the object.

What SWT Transfer do I have to use? Or how do I have to configure the TableViewer to be able to drop its selection onto the diagram?
Re: [DND] Drop business object from external TableViewer [message #881756 is a reply to message #881375] Tue, 05 June 2012 07:57 Go to previous messageGo to next message
Henning Losert is currently offline Henning LosertFriend
Messages: 5
Registered: March 2012
Junior Member
Hi Erdal,

I have something similar for my Graphiti editor: I have an "external" view with some TableViewers that show certain business objects in my model that I can then drag onto the diagram to initiate certain actions.

The code to enable drag support on my TableViewers looks like this:

this.tblv.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { LocalSelectionTransfer.getTransfer() },
				new DragSourceAdapter() {

					@Override
					public void dragStart(DragSourceEvent event) {
						LocalSelectionTransfer.getTransfer().setSelection(CatalogView.this.tblv.getSelection());
					}
			
				});


I use the LocalSelectionTransfer, as you can see, and just pass it the selection of my TableViewer.

What you also need is an AddFeature in your Graphiti editor for the kind of business object you're trying to drop. In that AddFeature, you can use the canAdd(IAddContext context) method to implement a check whether the business object should be "droppable" at the desired location, for example by checking the target container of the given context.

I hope this helps you in any way.

Cheers
Henning
Re: [DND] Drop business object from external TableViewer [message #881854 is a reply to message #881756] Tue, 05 June 2012 11:38 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 756
Registered: July 2009
Senior Member
Thanks Henning, that is a good starting point!
Previous Topic:Spray: containment of different objects
Next Topic:ICreateConnection.create(): returning null Connection allowed?
Goto Forum:
  


Current Time: Thu Nov 27 00:31:42 GMT 2014

Powered by FUDForum. Page generated in 0.02678 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software