@Test public void testSelect_NotRegistered() { SidebarLayout sidebarLayout = new SidebarLayout(); SidebarSheet sheet1 = new SidebarSheet(ANY_ICON, ANY_STRING, createNewContent()); Assertions.assertThrows(IllegalArgumentException.class, () -> { sidebarLayout.select(sheet1); }); }
public void select(SidebarSheet sheet) { if (!sidebarSheets.contains(sheet)) { throw new IllegalArgumentException("The sheet " + sheet + " is not part of this SidebarLayout"); } if (selected == sheet) { return; } Component content = sheet.getContent(); if (content.getParent() == null) { contentArea.addComponent(content); } else if (content.getParent() != contentArea) { throw new IllegalStateException("Content of the selected sidebar sheet already has a parent!"); } if (selected != null) { selected.unselect(); } this.selected = sheet; sheet.select(); }
SidebarLayout extends CssLayout { public void select(SidebarSheet sheet) { if (!sidebarSheets.contains(sheet)) { throw new IllegalArgumentException("The sheet " + sheet + " is not part of this SidebarLayout"); } if (selected == sheet) { return; } Component content = sheet.getContent(); if (content.getParent() == null) { contentArea.addComponent(content); } else if (content.getParent() != contentArea) { throw new IllegalStateException("Content of the selected sidebar sheet already has a parent!"); } if (selected != null) { selected.unselect(); } this.selected = sheet; sheet.select(); } }
SidebarLayout extends CssLayout { public void select(SidebarSheet sheet) { if (!sidebarSheets.contains(sheet)) { throw new IllegalArgumentException("The sheet " + sheet + " is not part of this SidebarLayout"); } if (selected == sheet) { return; } Component content = sheet.getContent(); if (content.getParent() == null) { contentArea.addComponent(content); } else if (content.getParent() != contentArea) { throw new IllegalStateException("Content of the selected sidebar sheet already has a parent!"); } if (selected != null) { selected.unselect(); } this.selected = sheet; sheet.select(); } SidebarLayout(); }
SidebarLayout extends CssLayout { public void select(SidebarSheet sheet) { if (!sidebarSheets.contains(sheet)) { throw new IllegalArgumentException("The sheet " + sheet + " is not part of this SidebarLayout"); } if (selected == sheet) { return; } Component content = sheet.getContent(); if (content.getParent() == null) { contentArea.addComponent(content); } else if (content.getParent() != contentArea) { throw new IllegalStateException("Content of the selected sidebar sheet already has a parent!"); } if (selected != null) { selected.unselect(); } this.selected = sheet; sheet.select(); } SidebarLayout(); void addSheets(Stream<SidebarSheet> sheets); void addSheets(Iterable<SidebarSheet> sheets); void addSheets(@NonNull SidebarSheet... sheets); void addSheet(SidebarSheet sheet); void select(SidebarSheet sheet); SidebarSheet getSelected(); List<SidebarSheet> getSidebarSheets(); }
SidebarLayout extends CssLayout { public void select(SidebarSheet sheet) { if (!sidebarSheets.contains(sheet)) { throw new IllegalArgumentException("The sheet " + sheet + " is not part of this SidebarLayout"); } if (selected == sheet) { return; } Component content = sheet.getContent(); if (content.getParent() == null) { contentArea.addComponent(content); } else if (content.getParent() != contentArea) { throw new IllegalStateException("Content of the selected sidebar sheet already has a parent!"); } if (selected != null) { selected.unselect(); } this.selected = sheet; sheet.select(); } SidebarLayout(); void addSheets(Stream<SidebarSheet> sheets); void addSheets(Iterable<SidebarSheet> sheets); void addSheets(@NonNull SidebarSheet... sheets); void addSheet(SidebarSheet sheet); void select(SidebarSheet sheet); SidebarSheet getSelected(); List<SidebarSheet> getSidebarSheets();  }