Search in sources :

Example 1 with ModelProjectTreeViewer

use of org.eclipse.vorto.perspective.view.ModelProjectTreeViewer in project vorto by eclipse.

the class ModelDropListener method performDrop.

@SuppressWarnings("unchecked")
public boolean performDrop(Object data) {
    Object target = getTarget();
    if (data instanceof IStructuredSelection) {
        Object droppedResource = ((IStructuredSelection) data).getFirstElement();
        IModelElement result = null;
        for (DropSourceValidatorAndAction dropActor : dropActors) {
            if (dropActor.validator.allow(target, droppedResource)) {
                result = dropActor.action.performDrop(target, droppedResource);
                break;
            }
        }
        if (target != null) {
            ModelProjectTreeViewer viewer = (ModelProjectTreeViewer) this.getViewer();
            viewer.getLocalModelWorkspace().refreshCurrent();
            if (target instanceof IModelElement) {
                IModelElement targetModelElement = findTarget((IModelElement) target, (Collection<IModelElement>) viewer.getInput());
                if (targetModelElement != null) {
                    viewer.expandToLevel(targetModelElement, 1);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : IModelElement(org.eclipse.vorto.core.ui.model.IModelElement) ModelProjectTreeViewer(org.eclipse.vorto.perspective.view.ModelProjectTreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 IModelElement (org.eclipse.vorto.core.ui.model.IModelElement)1 ModelProjectTreeViewer (org.eclipse.vorto.perspective.view.ModelProjectTreeViewer)1