/******************************************************************************* | |
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro | |
* All rights reserved. This program and the accompanying materials | |
* are made available under the terms of the Eclipse Public License v1.0 | |
* which accompanies this distribution, and is available at | |
* http://www.eclipse.org/legal/epl-v10.html | |
* | |
* Contributors: | |
* Istvan Rath - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.treeeditor.transfer; | |
import java.util.Iterator; | |
import org.eclipse.jface.viewers.IStructuredSelection; | |
import org.eclipse.swt.dnd.DragSourceAdapter; | |
import org.eclipse.swt.dnd.DragSourceEvent; | |
import org.eclipse.viatra2.core.IModelElement; | |
import org.eclipse.viatra2.treeeditor.ViatraTreeEditor; | |
public class ViatraEditorDragSourceListener extends DragSourceAdapter { | |
protected ViatraTreeEditor iVTE; | |
public ViatraEditorDragSourceListener(ViatraTreeEditor vte) { | |
super(); | |
iVTE = vte; | |
} | |
@Override | |
public void dragSetData(DragSourceEvent event) { | |
// System.out.println("Drag set data for type: "+event.dataType.toString()); | |
IStructuredSelection sel = (IStructuredSelection)iVTE.getSite().getSelectionProvider().getSelection(); | |
if (!sel.isEmpty()) { | |
Iterator it = sel.iterator(); | |
ViatraTransferData[] fqns = new ViatraTransferData[sel.size()]; | |
int i = 0; | |
while (it.hasNext()) { | |
fqns[i] = new ViatraTransferData(); | |
fqns[i].fullyQualifiedName = ((IModelElement)it.next()).getFullyQualifiedName(); | |
i++; | |
} | |
event.data = fqns; | |
} | |
} | |
} |