Search in sources :

Example 1 with WrappedVertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria in project opennms by OpenNMS.

the class RemoveFocusOtherVerticesOperation method enabled.

@Override
public boolean enabled(List<VertexRef> targets, OperationContext operationContext) {
    if (targets == null || targets.isEmpty()) {
        return false;
    }
    final GraphContainer graphContainer = operationContext.getGraphContainer();
    final WrappedVertexHopCriteria wrappedVertexHopCriteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(graphContainer);
    if (wrappedVertexHopCriteria.isEmpty()) {
        return false;
    }
    // Are the selected vertices in focus?
    for (VertexRef target : targets) {
        if (!wrappedVertexHopCriteria.contains(target)) {
            return false;
        }
    }
    // Are there any other vertices in focus?
    for (VertexRef vertex : wrappedVertexHopCriteria.getVertices()) {
        if (!targets.contains(vertex)) {
            return true;
        }
    }
    return false;
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) WrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Example 2 with WrappedVertexHopCriteria

use of org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria in project opennms by OpenNMS.

the class RemoveFocusVerticesOperation method enabled.

@Override
public boolean enabled(List<VertexRef> targets, OperationContext operationContext) {
    if (targets == null || targets.isEmpty()) {
        return false;
    }
    final GraphContainer graphContainer = operationContext.getGraphContainer();
    final WrappedVertexHopCriteria wrappedVertexHopCriteria = VertexHopGraphProvider.getWrappedVertexHopCriteria(graphContainer);
    if (wrappedVertexHopCriteria.isEmpty()) {
        return false;
    }
    for (VertexRef target : targets) {
        // If any of the vertices are currently in the criteria, return true
        if (wrappedVertexHopCriteria.contains(target)) {
            return true;
        }
    }
    return false;
}
Also used : GraphContainer(org.opennms.features.topology.api.GraphContainer) WrappedVertexHopCriteria(org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria) VertexRef(org.opennms.features.topology.api.topo.VertexRef)

Aggregations

GraphContainer (org.opennms.features.topology.api.GraphContainer)2 WrappedVertexHopCriteria (org.opennms.features.topology.api.support.VertexHopGraphProvider.WrappedVertexHopCriteria)2 VertexRef (org.opennms.features.topology.api.topo.VertexRef)2