Skip to content
Snippets Groups Projects
Commit 28b5d209 authored by Johannes Eder's avatar Johannes Eder
Browse files

added drag and drop from model element library to tree editor

parent bb893133
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,11 @@ public class LibraryView extends ViewPart {
@Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
// TODO Auto-generated method stub
/*
* if (element instanceof Prototype) { EObject prototypeObject =
* ((Prototype) element).getPrototype(); return true; }
*/
return true;
}
......@@ -135,6 +139,7 @@ public class LibraryView extends ViewPart {
return prototype.getName();
}
return super.getText(element);
}
// TODO (JE): getImage
......@@ -144,5 +149,6 @@ public class LibraryView extends ViewPart {
* return ModelElementService.getInstance().getImage(
* prototype.getPrototypeObject()); } return super.getImage(element); }
*/
}
}
......@@ -18,7 +18,6 @@ $Id$
package org.fortiss.tooling.kernel.util;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype;
......@@ -34,11 +33,15 @@ public final class DragAndDropUtils {
/** Extracts the EObject contained in the given drop object. */
public static EObject extractDroppedEObject(Object data) {
if (data instanceof IStructuredSelection) {
return EObjectSelectionUtils.getFirstElement((ISelection) data);
}
if (data instanceof Prototype) {
return ((Prototype) data).getPrototypeCopy();
if (data instanceof IStructuredSelection
&& !((IStructuredSelection) data).isEmpty()) {
Object result = ((IStructuredSelection) data).getFirstElement();
if (result instanceof Prototype) {
return ((Prototype) result).getPrototypeCopy();
}
if (result instanceof EObject) {
return (EObject) result;
}
}
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment