From 28b5d20936d01dfe91d7f99ed7418d1aa5d00e45 Mon Sep 17 00:00:00 2001 From: Johannes Eder <eder@fortiss.org> Date: Thu, 31 Mar 2011 13:16:14 +0000 Subject: [PATCH] added drag and drop from model element library to tree editor --- .../kernel/internal/views/LibraryView.java | 8 +++++++- .../tooling/kernel/util/DragAndDropUtils.java | 15 +++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java index b39966f3c..ff68cd427 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/internal/views/LibraryView.java @@ -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); } */ + } } diff --git a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/util/DragAndDropUtils.java b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/util/DragAndDropUtils.java index 4137f3178..7102c34ed 100644 --- a/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/util/DragAndDropUtils.java +++ b/org.fortiss.tooling.kernel/trunk/src/org/fortiss/tooling/kernel/util/DragAndDropUtils.java @@ -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; } -- GitLab