Search in sources :

Example 6 with UiTopoLayout

use of org.onosproject.ui.model.topo.UiTopoLayout in project onos by opennetworkinglab.

the class ModelCache method fixupContainmentHierarchy.

private void fixupContainmentHierarchy(UiRegion region) {
    UiTopoLayoutService ls = services.layout();
    RegionId regionId = region.id();
    UiTopoLayout layout = ls.getLayout(regionId);
    if (layout == null) {
        // no layout backed by this region
        log.warn("No layout backed by region {}", regionId);
        return;
    }
    UiTopoLayoutId layoutId = layout.id();
    if (!layout.isRoot()) {
        UiTopoLayoutId parentId = layout.parent();
        UiTopoLayout parentLayout = ls.getLayout(parentId);
        RegionId parentRegionId = parentLayout.regionId();
        region.setParent(parentRegionId);
    }
    Set<UiTopoLayout> kids = ls.getChildren(layoutId);
    Set<RegionId> kidRegionIds = new HashSet<>(kids.size());
    kids.forEach(k -> kidRegionIds.add(k.regionId()));
    region.setChildren(kidRegionIds);
}
Also used : UiTopoLayoutService(org.onosproject.ui.UiTopoLayoutService) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) HashSet(java.util.HashSet)

Example 7 with UiTopoLayout

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);
}
Also used : UiTopoLayoutService(org.onosproject.ui.UiTopoLayoutService) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) Region(org.onosproject.net.region.Region) RegionService(org.onosproject.net.region.RegionService) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout)

Aggregations

UiTopoLayout (org.onosproject.ui.model.topo.UiTopoLayout)7 RegionId (org.onosproject.net.region.RegionId)4 UiTopoLayoutId (org.onosproject.ui.model.topo.UiTopoLayoutId)4 UiTopoLayoutService (org.onosproject.ui.UiTopoLayoutService)3 HashSet (java.util.HashSet)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 NetworkConfigEvent (org.onosproject.net.config.NetworkConfigEvent)1 NetworkConfigListener (org.onosproject.net.config.NetworkConfigListener)1 NetworkConfigRegistry (org.onosproject.net.config.NetworkConfigRegistry)1 BasicUiTopoLayoutConfig (org.onosproject.net.config.basics.BasicUiTopoLayoutConfig)1 Region (org.onosproject.net.region.Region)1