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));
}
}
}
Aggregations