use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.
the class UiTopoLayoutManagerTest method layout.
private static UiTopoLayout layout(String id, Region region, String parentId) {
UiTopoLayoutId parent = parentId == null ? null : layoutId(parentId);
UiTopoLayout layout = new UiTopoLayout(layoutId(id));
// TODO: set region and parent
return layout;
}
use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.
the class UiTopoSession method breadCrumbs.
/**
* Returns the breadcrumb trail from current layout to root. That is,
* element 0 of the list will be the current layout; the last element
* of the list will be the root layout. This list is guaranteed to have
* size of at least 1.
*
* @return breadcrumb trail
*/
public List<UiTopoLayout> breadCrumbs() {
UiTopoLayout current = currentLayout;
List<UiTopoLayout> crumbs = new ArrayList<>();
crumbs.add(current);
while (!current.isRoot()) {
current = layoutService.getLayout(current.parent());
crumbs.add(current);
}
return crumbs;
}
use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.
the class LayoutAddCommand method doExecute.
@Override
protected void doExecute() {
UiTopoLayoutService service = get(UiTopoLayoutService.class);
RegionService regionService = get(RegionService.class);
UiTopoLayout layout;
if (ROOT.equals(id)) {
layout = service.getRootLayout();
setAppropriateBackground(layout);
setZoomParameters(layout);
return;
}
// Otherwise, it is a user-defined layout...
Region region = nullToken(regionId) ? null : regionService.getRegion(regionId(regionId));
UiTopoLayoutId pid = nullToken(parentId) ? UiTopoLayoutId.DEFAULT_ID : layoutId(parentId);
layout = new UiTopoLayout(layoutId(id)).region(region).parent(pid);
setAppropriateBackground(layout);
setZoomParameters(layout);
service.addLayout(layout);
}
use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.
the class UiTopoLayoutManager method getPeerLayouts.
@Override
public Set<UiTopoLayout> getPeerLayouts(UiTopoLayoutId layoutId) {
checkNotNull(layoutId, ID_NULL);
UiTopoLayout layout = layoutMap.get(layoutId);
if (layout == null || layout.isRoot()) {
return Collections.emptySet();
}
UiTopoLayoutId parentId = layout.parent();
return layoutMap.values().stream().filter(l -> !Objects.equals(l.id(), layoutId) && !Objects.equals(l.id(), UiTopoLayoutId.DEFAULT_ID) && Objects.equals(l.parent(), parentId)).collect(Collectors.toSet());
}
use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.
the class UiTopoSession method getPeerNodes.
/**
* Returns the regions/devices that are "peers" to this region. That is,
* based on the layout the user is viewing, all the regions/devices that
* are associated with layouts that share the same parent layout as this
* layout, AND that are linked to an element within this region.
*
* @param layout the layout being viewed
* @return all regions/devices that are "siblings" to this layout's region
*/
public Set<UiNode> getPeerNodes(UiTopoLayout layout) {
Set<UiNode> peers = new HashSet<>();
// first, get the peer regions
Set<UiTopoLayout> peerLayouts = layoutService.getPeerLayouts(layout.id());
peerLayouts.forEach(l -> {
RegionId peerRegion = l.regionId();
peers.add(sharedModel.getRegion(peerRegion));
});
// now add the devices that reside in the parent region
if (!layout.isRoot()) {
UiTopoLayout parentLayout = layoutService.getLayout(layout.parent());
peers.addAll(getRegion(parentLayout).devices());
}
// directly to this region by an implicit link
return peers;
}
Aggregations