use of org.opennms.features.topology.api.support.breadcrumbs.Breadcrumb 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));
}
}
}
use of org.opennms.features.topology.api.support.breadcrumbs.Breadcrumb in project opennms by OpenNMS.
the class PathTree method toBreadcrumbs.
public List<Breadcrumb> toBreadcrumbs() {
final List<Breadcrumb> breadcrumbList = Lists.newArrayList();
// Build from bottom to top (including root)
List<Node> work = getLeafs();
while (!work.isEmpty() && !work.get(0).isRoot()) {
// All working nodes must be on the same layer (resulting in the same namespace)
String targetNamespace = work.get(0).getVertexRef().getNamespace();
Set<Node> parentNodes = work.stream().map(eachLeaf -> eachLeaf.getParent()).filter(node -> node != null).collect(Collectors.toSet());
breadcrumbList.add(0, new Breadcrumb(targetNamespace, parentNodes.stream().map(p -> p.getVertexRef()).filter(v -> v != null).collect(Collectors.toList())));
work = Lists.newArrayList(parentNodes);
}
return breadcrumbList;
}
Aggregations