canvas.addMember(selector);
}
}
private BundleGroupSelector getSelector(final Map<BundleGroup, Boolean> map, boolean readOnly) {
BundleGroupSelector result;
if (map.isEmpty()) {
result = new BundleGroupSelector(readOnly);
} else {
Set<BundleGroup> bundleGroups = map.keySet();
Integer[] idsFilter = new Integer[bundleGroups.size()];
int i = 0;
for (BundleGroup bundleGroup : bundleGroups) {
idsFilter[i++] = bundleGroup.getId();
}
List<ListGridRecord> initiallyAssigned = new ArrayList<ListGridRecord>(bundleGroups.size());
BundleGroupsDataSource ds = new BundleGroupsDataSource();
for (BundleGroup bundleGroup : bundleGroups) {
if (map.get(bundleGroup) == Boolean.TRUE) {
initiallyAssigned.add(ds.copyValues(bundleGroup));
}
}
result = new BundleGroupSelector(idsFilter, initiallyAssigned.toArray(new ListGridRecord[initiallyAssigned
.size()]), readOnly);
}
return result;
}