Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Adding Native Drag Support to Editor(When adding native drag support to the editor, the edit parts cannot be moved inside the editor anymore.)
Adding Native Drag Support to Editor [message #549824] Wed, 28 July 2010 07:07 Go to next message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
Hi everyone,

when using the code below, the edit parts cannot be moved around inside the editor anymore. I am not using any 'DRAG_DROP_ROLE' edit policy. From what I've learned so far, the drag and drop is required to drag an edit part into a different control.

How do I enable dragging (to other controls) and moving (inside the editor) at the same time?

Best regards,
Erich

private void enableDrag() {
	class EditPartDragSourceListener implements TransferDragSourceListener {
		@Override
		public void dragStart(DragSourceEvent event) {
		}

		// Dragging the ID of the model element is fine.
		@Override
		public void dragSetData(DragSourceEvent event) {
			EditPart ep = getSelectedEditPart();
			if (ep != null) {
				ModelElement me = getModelElement(ep); 
				final String transferData = getIdFromModelElement(me);
				event.data = transferData;
			}
		}
		
		@Override
		public void dragFinished(DragSourceEvent event) {
		}
		
		@Override
		public Transfer getTransfer() {
			return TextTransfer.getInstance();
		}
	}
	
	DragSource source = new DragSource(getDiagramGraphicalViewer().getControl(), DND.DROP_MOVE | DND.DROP_COPY);
	source.setTransfer(new Transfer[] { TextTransfer.getInstance() });
	getDiagramGraphicalViewer().addDragSourceListener(new EditPartDragSourceListener());
}
Re: Adding Native Drag Support to Editor [message #551314 is a reply to message #549824] Thu, 05 August 2010 21:41 Go to previous message
Erich  is currently offline Erich Friend
Messages: 10
Registered: July 2010
Junior Member
As it turned out, when i want to drag from the editor to another view, i have to add the drag listener directly to the graphical viewer this way:

getDiagramGraphicalViewer().addDragSourceListener(new TransferDragSourceListener() {...});


After doing that, it's not possible to move around nodes unless i implement a drop listener.

Best regards
Erich
Previous Topic:Blocks with defined inputs and ouptuts
Next Topic:Problems with Taipan & Tutorials
Goto Forum:
  


Current Time: Fri May 24 23:03:00 GMT 2024

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

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

Back to the top