Search in sources :

Example 1 with BreadcrumbCriteria

use of org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbCriteria in project opennms by OpenNMS.

the class BreadcrumbComponent method graphChanged.

@Override
public void graphChanged(GraphContainer graphContainer) {
    final BreadcrumbCriteria criteria = Criteria.getSingleCriteriaForGraphContainer(graphContainer, BreadcrumbCriteria.class, true);
    final HorizontalLayout breadcrumbLayout = (HorizontalLayout) getCompositionRoot();
    breadcrumbLayout.removeAllComponents();
    // Verify that breadcrumbs are enabled
    if (graphContainer.getTopologyServiceClient().getBreadcrumbStrategy() == BreadcrumbStrategy.SHORTEST_PATH_TO_ROOT) {
        final Collection<Vertex> displayVertices = graphContainer.getGraph().getDisplayVertices();
        if (!displayVertices.isEmpty()) {
            final PathTree pathTree = BreadcrumbPathCalculator.findPath(graphContainer.getTopologyServiceClient(), displayVertices.stream().map(v -> (VertexRef) v).collect(Collectors.toSet()));
            final List<Breadcrumb> breadcrumbs = pathTree.toBreadcrumbs();
            criteria.setBreadcrumbs(breadcrumbs);
        }
        for (Breadcrumb eachBreadcrumb : criteria.getBreadcrumbs()) {
            if (breadcrumbLayout.getComponentCount() >= 1) {
                breadcrumbLayout.addComponent(new Label(" > "));
            }
            breadcrumbLayout.addComponent(createButton(graphContainer, eachBreadcrumb));
        }
    }
}
Also used : Vertex(org.opennms.features.topology.api.topo.Vertex) Label(com.vaadin.ui.Label) Breadcrumb(org.opennms.features.topology.api.support.breadcrumbs.Breadcrumb) BreadcrumbCriteria(org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbCriteria) HorizontalLayout(com.vaadin.ui.HorizontalLayout)

Aggregations

HorizontalLayout (com.vaadin.ui.HorizontalLayout)1 Label (com.vaadin.ui.Label)1 Breadcrumb (org.opennms.features.topology.api.support.breadcrumbs.Breadcrumb)1 BreadcrumbCriteria (org.opennms.features.topology.api.support.breadcrumbs.BreadcrumbCriteria)1 Vertex (org.opennms.features.topology.api.topo.Vertex)1