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 { ...@@ -109,7 +109,11 @@ public class LibraryView extends ViewPart {
@Override @Override
public boolean select(Viewer viewer, Object parentElement, public boolean select(Viewer viewer, Object parentElement,
Object element) { Object element) {
// TODO Auto-generated method stub
/*
* if (element instanceof Prototype) { EObject prototypeObject =
* ((Prototype) element).getPrototype(); return true; }
*/
return true; return true;
} }
...@@ -135,6 +139,7 @@ public class LibraryView extends ViewPart { ...@@ -135,6 +139,7 @@ public class LibraryView extends ViewPart {
return prototype.getName(); return prototype.getName();
} }
return super.getText(element); return super.getText(element);
} }
// TODO (JE): getImage // TODO (JE): getImage
...@@ -144,5 +149,6 @@ public class LibraryView extends ViewPart { ...@@ -144,5 +149,6 @@ public class LibraryView extends ViewPart {
* return ModelElementService.getInstance().getImage( * return ModelElementService.getInstance().getImage(
* prototype.getPrototypeObject()); } return super.getImage(element); } * prototype.getPrototypeObject()); } return super.getImage(element); }
*/ */
} }
} }
...@@ -18,7 +18,6 @@ $Id$ ...@@ -18,7 +18,6 @@ $Id$
package org.fortiss.tooling.kernel.util; package org.fortiss.tooling.kernel.util;
import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype; import org.fortiss.tooling.kernel.services.IPrototypeService.Prototype;
...@@ -34,11 +33,15 @@ public final class DragAndDropUtils { ...@@ -34,11 +33,15 @@ public final class DragAndDropUtils {
/** Extracts the EObject contained in the given drop object. */ /** Extracts the EObject contained in the given drop object. */
public static EObject extractDroppedEObject(Object data) { public static EObject extractDroppedEObject(Object data) {
if (data instanceof IStructuredSelection) { if (data instanceof IStructuredSelection
return EObjectSelectionUtils.getFirstElement((ISelection) data); && !((IStructuredSelection) data).isEmpty()) {
} Object result = ((IStructuredSelection) data).getFirstElement();
if (data instanceof Prototype) { if (result instanceof Prototype) {
return ((Prototype) data).getPrototypeCopy(); return ((Prototype) result).getPrototypeCopy();
}
if (result instanceof EObject) {
return (EObject) result;
}
} }
return null; 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