net.vectorpublish.desktop.vp.LayerDropAuthorithy Maven / Gradle / Ivy
/*
* Copyright (c) 2016, Peter Rader. All rights reserved.
* ___ ___ __ ______ __ __ __ __
* | | |.-----..----.| |_ .-----..----.| __ \.--.--.| |--.| ||__|.-----.| |--.
* | | || -__|| __|| _|| _ || _|| __/| | || _ || || ||__ --|| |
* \_____/ |_____||____||____||_____||__| |___| |_____||_____||__||__||_____||__|__|
*
* http://www.gnu.org/licenses/gpl-3.0.html
*/
package net.vectorpublish.desktop.vp;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Named;
import net.vectorpublish.desktop.vp.api.layer.dnd.DropVetoCouncilor;
import net.vectorpublish.desktop.vp.api.layer.dnd.LayerDragNDropTransferHandler;
import net.vectorpublish.desktop.vp.api.vpd.VectorPublishNode;
/**
* Authorithy to decide what movements are disallowed.
*
* Not responsible in case of movements that are blessed in past (i.e. part of a
* loading-process of mementos, deserialization, loading a.s.).
*
* Notice that this council is only responsible for non-headless-environments.
*
* This implementation disallows the move of a node to its very own child.
*/
@Named
public final class LayerDropAuthorithy extends LayerDragNDropTransferHandler {
/**
* The council to decide where to drop elements.
*/
@Inject
public final Set dropVetoCouncil = null;
@Override
public boolean allowsMove(final VectorPublishNode target, final Set nodesConcerned) {
boolean blocked = false;
for (DropVetoCouncilor dropVetoCouncilor : dropVetoCouncil) {
blocked |= dropVetoCouncilor.blockMove(nodesConcerned, target);
}
return !blocked;
}
}