use of org.onosproject.ui.model.topo.UiTopoLayoutId in project onos by opennetworkinglab.
the class SubjectFactoriesTest method testUITopoLayoutIdFactory.
@Test
public void testUITopoLayoutIdFactory() {
SubjectFactory<UiTopoLayoutId> uiTopoLayoutIdFactory = SubjectFactories.LAYOUT_SUBJECT_FACTORY;
assertThat(uiTopoLayoutIdFactory, notNullValue());
String layout1 = "layout1";
UiTopoLayoutId id = UiTopoLayoutId.layoutId(layout1);
UiTopoLayoutId createdLayouId = uiTopoLayoutIdFactory.createSubject(layout1);
assertThat(createdLayouId.id(), equalTo(layout1));
assertThat(uiTopoLayoutIdFactory.subjectKey(id), is(layout1));
}
use of org.onosproject.ui.model.topo.UiTopoLayoutId 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.UiTopoLayoutId 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.UiTopoLayoutId 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.UiTopoLayoutId 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);
}
Aggregations