Search in sources :

Example 1 with MoveHierarchyNodeAction

use of edu.stanford.bmir.protege.web.shared.hierarchy.MoveHierarchyNodeAction in project webprotege by protegeproject.

the class EntityHierarchyDropHandler method handleDrop.

@Override
public void handleDrop(@Nonnull Path<EntityHierarchyNode> nodePath, @Nonnull Path<EntityHierarchyNode> targetPath, @Nonnull DropType dropType, @Nonnull DropEndHandler dropEndHandler) {
    GWT.log("[EntityHierarchyDropHandler] handleDrop. From: " + nodePath + " To: " + nodePath);
    if (!hierarchyId.isPresent()) {
        dropEndHandler.handleDropCancelled();
        return;
    }
    if (nodePath.isEmpty()) {
        dropEndHandler.handleDropCancelled();
        return;
    }
    if (nodePath.getLast().map(EntityHierarchyNode::getEntity).map(OWLObject::isTopEntity).orElse(false)) {
        dropEndHandler.handleDropCancelled();
        return;
    }
    // Don't drop on self
    if (targetPath.getLast().equals(nodePath.getLast())) {
        dropEndHandler.handleDropCancelled();
        return;
    }
    dispatchServiceManager.execute(new MoveHierarchyNodeAction(projectId, hierarchyId.get(), nodePath, targetPath, dropType), moveResult -> {
        if (moveResult.isMoved()) {
            dropEndHandler.handleDropComplete();
        } else {
            dropEndHandler.handleDropCancelled();
        }
    });
}
Also used : MoveHierarchyNodeAction(edu.stanford.bmir.protege.web.shared.hierarchy.MoveHierarchyNodeAction) EntityHierarchyNode(edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)

Aggregations

EntityHierarchyNode (edu.stanford.bmir.protege.web.shared.hierarchy.EntityHierarchyNode)1 MoveHierarchyNodeAction (edu.stanford.bmir.protege.web.shared.hierarchy.MoveHierarchyNodeAction)1