Skip to content

Commit

Permalink
Merge pull request #370 from bsinno/bug/369_dragdrop_modelrepo
Browse files Browse the repository at this point in the history
Fixes #369 - Bug in Drag/Drop from Model Repository Browser
  • Loading branch information
aedelmann authored Jul 28, 2016
2 parents 90fa690 + 81654a0 commit 334e93d
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ public boolean performDrop(Object data) {
}
}

if (result != null) {
if (target != null) {
ModelProjectTreeViewer viewer = (ModelProjectTreeViewer) this.getViewer();
viewer.getLocalModelWorkspace().refreshCurrent();
IModelElement targetModelElement = findTarget((IModelElement) target,
(Collection<IModelElement>) viewer.getInput());
if (targetModelElement != null) {
viewer.expandToLevel(targetModelElement, 1);

if (target instanceof IModelElement) {
IModelElement targetModelElement = findTarget((IModelElement) target,
(Collection<IModelElement>) viewer.getInput());
if (targetModelElement != null) {
viewer.expandToLevel(targetModelElement, 1);
}
}

return true;
}

Expand All @@ -103,13 +107,20 @@ private IModelElement findTarget(IModelElement target, Collection<IModelElement>
private Object getTarget() {
Object target = this.getCurrentTarget();

if (target instanceof IModelElement) {
if (target == null) {
Viewer viewer = this.getViewer();
if (viewer instanceof ModelProjectTreeViewer) {
target = ((ModelProjectTreeViewer) viewer).getLocalModelWorkspace().getProjectBrowser().getSelectedProject();
}
} else if (target instanceof IModelElement) {
// Get the latest version of this IModelElement
IModelProject project = localModelBrowser.getProjectBrowser().getSelectedProject();
return project.getModelElementById(((IModelElement) target).getId());
target = project.getModelElementById(((IModelElement) target).getId());
} else {
throw new RuntimeException("Target is not an IModelElement");
}

throw new RuntimeException("Target is not an IModelElement");
return target;
}

public boolean validateDrop(Object target, int operation, TransferData transferType) {
Expand Down

0 comments on commit 334e93d

Please sign in to comment.