use of org.opennms.features.topology.api.topo.CollapsibleCriteria in project opennms by OpenNMS.
the class SearchBox method collapseIfSuggMapEmpty.
private void collapseIfSuggMapEmpty(SearchResult searchResult, GraphContainer graphContainer) {
// A special check for categories that were added then after re-login can't collapse
boolean isDirty = false;
Criteria[] criteria = graphContainer.getCriteria();
for (Criteria criterion : criteria) {
if (criterion instanceof CollapsibleCriteria) {
if (((CollapsibleCriteria) criterion).getLabel().equals(searchResult.getLabel())) {
((CollapsibleCriteria) criterion).setCollapsed(!((CollapsibleCriteria) criterion).isCollapsed());
isDirty = true;
}
}
}
if (isDirty) {
graphContainer.redoLayout();
}
}
use of org.opennms.features.topology.api.topo.CollapsibleCriteria in project opennms by OpenNMS.
the class VertexHopGraphProviderTest method testCollapseEdges.
@Test
public void testCollapseEdges() {
CollapsibleCriteria collapseMe = new CollapsibleCriteria() {
@Override
public void setCollapsed(boolean collapsed) {
}
@Override
public boolean isCollapsed() {
return true;
}
@Override
public Set<VertexRef> getVertices() {
Set<VertexRef> retval = new HashSet<>();
retval.add(new DefaultVertexRef("nodes", "g2"));
return retval;
}
@Override
public String getNamespace() {
return "nodes";
}
@Override
public String getLabel() {
return "Test Criteria";
}
@Override
public String getId() {
return "Test Criteria";
}
@Override
public Vertex getCollapsedRepresentation() {
return new AbstractVertex("category", "c");
}
};
Set<Edge> edges = VertexHopGraphProvider.collapseEdges(new HashSet<Edge>(m_provider.getEdges()), new CollapsibleCriteria[] { collapseMe });
for (Edge edge : edges) {
assertEquals("nodes", edge.getNamespace());
/*
Here's the original list of edges
.edge("e1", "g0", "g1").eLabel("edge1").eStyleName("edge")
.edge("e2", "g0", "g2").eLabel("edge2").eStyleName("edge")
.edge("e3", "g1", "v1").eLabel("edge3").eStyleName("edge")
.edge("e4", "g1", "v2").eLabel("edge4").eStyleName("edge")
.edge("e5", "g2", "v3").eLabel("edge5").eStyleName("edge")
.edge("e6", "g2", "v4").eLabel("edge6").eStyleName("edge")
*/
if (edge.getId().equals("e1")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g0", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("g1", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedTarget-e2")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g0", edge.getSource().getVertex().getId());
assertEquals("category", edge.getTarget().getVertex().getNamespace());
assertEquals("c", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("e3")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g1", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v1", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("e4")) {
assertEquals("nodes", edge.getSource().getVertex().getNamespace());
assertEquals("g1", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v2", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedSource-e5")) {
assertEquals("category", edge.getSource().getVertex().getNamespace());
assertEquals("c", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v3", edge.getTarget().getVertex().getId());
} else if (edge.getId().equals("collapsedSource-e6")) {
assertEquals("category", edge.getSource().getVertex().getNamespace());
assertEquals("c", edge.getSource().getVertex().getId());
assertEquals("nodes", edge.getTarget().getVertex().getNamespace());
assertEquals("v4", edge.getTarget().getVertex().getId());
} else {
fail("Unexpected edge found: " + edge.toString());
}
}
}
use of org.opennms.features.topology.api.topo.CollapsibleCriteria in project opennms by OpenNMS.
the class SavedHistory method getFocusVertices.
private static Set<VertexRef> getFocusVertices(GraphContainer graphContainer) {
final Set<VertexRef> retVal = new HashSet<>();
Criteria[] criterias = graphContainer.getCriteria();
for (Criteria crit : criterias) {
if (crit instanceof VertexHopGraphProvider.VertexHopCriteria && !(crit instanceof CollapsibleCriteria)) {
retVal.addAll(((VertexHopGraphProvider.VertexHopCriteria) crit).getVertices());
}
}
return retVal;
}
use of org.opennms.features.topology.api.topo.CollapsibleCriteria in project opennms by OpenNMS.
the class SearchBox method updateTokenFieldList.
private void updateTokenFieldList(GraphContainer graphContainer) {
final List<SearchSuggestion> suggestions = Lists.newArrayList();
final Criteria[] criterium = graphContainer.getCriteria();
for (Criteria criteria : criterium) {
try {
CollapsibleCriteria crit = (CollapsibleCriteria) criteria;
SearchSuggestion suggestion = new SearchSuggestion(crit.getNamespace(), crit.getId(), crit.getLabel());
suggestion.setCollapsible(true);
suggestion.setCollapsed(crit.isCollapsed());
suggestions.add(suggestion);
continue;
} catch (ClassCastException e) {
}
try {
VertexHopCriteria crit = (VertexHopCriteria) criteria;
SearchSuggestion suggestion = new SearchSuggestion(crit.getNamespace(), crit.getId(), crit.getLabel());
suggestions.add(suggestion);
continue;
} catch (ClassCastException e) {
}
}
getState().setFocused(suggestions);
}
use of org.opennms.features.topology.api.topo.CollapsibleCriteria in project opennms by OpenNMS.
the class CategorySearchProvider method onToggleCollapse.
@Override
public void onToggleCollapse(SearchResult searchResult, GraphContainer graphContainer) {
CollapsibleCriteria criteria = getMatchingCriteria(graphContainer, searchResult.getId());
if (criteria != null) {
criteria.setCollapsed(!criteria.isCollapsed());
graphContainer.redoLayout();
}
}
Aggregations