gridBuilder.newSplitPanel(GridSize.COL50);
{
// Full access groups
fs = gridBuilder.newFieldset(getString("plugins.teamcal.fullAccess"),
getString("plugins.teamcal.access.groups"));
final GroupsProvider groupsProvider = new GroupsProvider();
final Collection<GroupDO> fullAccessGroups = new GroupsProvider().getSortedGroups(getData().getFullAccessGroupIds());
fullAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(
groupsProvider.getSortedGroups());
if (fullAccessGroups != null) {
for (final GroupDO group : fullAccessGroups) {
fullAccessGroupsListHelper.addOriginalAssignedItem(group).assignItem(group);
}
}
final Select2MultiChoice<GroupDO> groups = new Select2MultiChoice<GroupDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<GroupDO>> (this.fullAccessGroupsListHelper, "assignedItems"), groupsProvider);
groups.add(new IValidator<Object>() {
@Override
public void validate(final IValidatable< Object > validatable)
{
@SuppressWarnings("unchecked")
final ArrayList<GroupDO> groups = (ArrayList<GroupDO>) validatable.getValue();
final Collection<Integer> curUserGroupIds = userDao.getAssignedGroups(PFUserContext.getUser());
boolean isInUserGroups = false;
for (final GroupDO group: groups) {
if (curUserGroupIds.contains(group.getId()) == true) {
isInUserGroups = true;
break;
}
}
if (isInUserGroups == false) {
final ValidationError validationError = new ValidationError().addKey("plugins.skillmatrix.skilltraining.error.nousergroup");
validatable.error(validationError);
}
}
});
groups.setRequired(true);
fs.addHelpIcon(getString("plugins.skillmatrix.skilltraining.fullaccess"));
fs.add(groups);
}
{
// Read-only access groups
fs = gridBuilder.newFieldset(getString("plugins.teamcal.readonlyAccess"),
getString("plugins.teamcal.access.groups"));
final GroupsProvider groupsProvider = new GroupsProvider();
final Collection<GroupDO> readOnlyAccessGroups = new GroupsProvider().getSortedGroups(getData().getReadOnlyAccessGroupIds());
readonlyAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(
groupsProvider.getSortedGroups());
if (readOnlyAccessGroups != null) {
for (final GroupDO group : readOnlyAccessGroups) {
readonlyAccessGroupsListHelper.addOriginalAssignedItem(group).assignItem(group);
}
}