void resetApplications(List<Application> apps) { if (apps != null && !apps.isEmpty()) { applications.clear(); for (Application a : apps) { applications.addItem(a.toDisplay(), a.getId() + ""); } for (int index = 0; index < applications.getItemCount(); index++) { int id = Integer.parseInt(applications.getValue(index)); applications.setItemSelected(index, group.getApplicationIds().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); } }