[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.gef] Re: Drag and drop an EditPart

Your suggestion worked. Thanks a lot. I actually based my TransferDragSourceListener to something similar to TemplateTransferDragSourceLIstener as follows:

------------------------------------------------------------------------------
private class ServiceDragSourceListener implements TransferDragSourceListener {


		private EditPartViewer viewer;
		private Transfer transfer;
		
		ServiceDragSourceListener(EditPartViewer p_viewer, Transfer p_transfer){
			this.viewer = p_viewer;
			this.transfer = p_transfer;
		}
		
		public Transfer getTransfer() {
			return this.transfer;
		}

		public void dragStart(DragSourceEvent event) {
			Object template = getTemplate();
			if (template == null)
				event.doit = false;
			TemplateTransfer.getInstance().setTemplate(template);
		}

		public void dragSetData(DragSourceEvent event) {
			event.data = getTemplate();
		}

		public void dragFinished(DragSourceEvent event) {
			TemplateTransfer.getInstance().setTemplate(null);
		}

/**
* A helper method that returns <code>null</code> or the <i>template</i> Object from the
* currently selected EditPart.
* @return the template
*/
protected Object getTemplate() {
return ((Service)(ServiceEditPart.this.getModel())).getClass();
}
}
------------------------------------------------------------------------------


and there I had a perfectly working code.

Thanks once again. Kudos to you guys that we, who are new to GEF, are getting such wonderful support.

Hoping to trouble you again with more queries,
Prashanto Chatterjee