void resetRegions(List<Region> regions) { if (regions != null && !regions.isEmpty()) { this.regions.clear(); for (Region a : regions) { this.regions.addItem(a.toDisplay(), a.getId() + ""); } for (int index = 0; index < this.regions.getItemCount(); index++) { int id = Integer.parseInt(this.regions.getValue(index)); this.regions.setItemSelected(index, group.getRegionIds().contains(id)); } } adjustListBox(box.getValue()); }
GroupPanel(CheckBoxItem box, Group group, List<Application> apps, List<Region> regions) { this.group = group; this.box = box; box.addValueChangeHandler( new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { adjustListBox(event.getValue()); } }); add(box); if (group.hasApplications()) { add(new Label("applications")); add(applications); if (apps != null && !apps.isEmpty()) { applications.clear(); for (Application a : apps) { applications.addItem(a.toDisplay(), a.getId() + ""); } } else { applications.addItem("loading . . ."); } applications.setEnabled(false); } if (group.hasRegions()) { add(new Label("regions")); add(this.regions); if (regions != null && !regions.isEmpty()) { regions.clear(); for (Region a : regions) { this.regions.addItem(a.toDisplay(), a.getId() + ""); } } else { this.regions.addItem("loading . . ."); } this.regions.setEnabled(false); } }