Search in sources :

Example 1 with UiTopoLayout

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

Example 2 with UiTopoLayout

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;
}
Also used : ArrayList(java.util.ArrayList) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout)

Example 3 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)

Example 4 with UiTopoLayout

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());
}
Also used : BasicUiTopoLayoutConfig(org.onosproject.net.config.basics.BasicUiTopoLayoutConfig) NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DEFAULT_ID(org.onosproject.ui.model.topo.UiTopoLayoutId.DEFAULT_ID) RegionId(org.onosproject.net.region.RegionId) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) Component(org.osgi.service.component.annotations.Component) UiTopoLayoutService(org.onosproject.ui.UiTopoLayoutService) UiRegion(org.onosproject.ui.model.topo.UiRegion) Map(java.util.Map) Activate(org.osgi.service.component.annotations.Activate) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Set(java.util.Set) Collectors(java.util.stream.Collectors) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) List(java.util.List) Reference(org.osgi.service.component.annotations.Reference) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) Collections(java.util.Collections) UiTopoLayoutId(org.onosproject.ui.model.topo.UiTopoLayoutId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout)

Example 5 with UiTopoLayout

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;
}
Also used : RegionId(org.onosproject.net.region.RegionId) UiTopoLayout(org.onosproject.ui.model.topo.UiTopoLayout) UiNode(org.onosproject.ui.model.topo.UiNode) HashSet(java.util.HashSet)

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