parentSelectPanel.setRequired(true);
parentSelectPanel.init();
// Title of training
fs = gridBuilder.newFieldset(TrainingDO.class, "title");
final RequiredMaxLengthTextField titleField = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data,
"title"));
fs.add(titleField);
dependentFormComponents[0] = titleField;
WicketUtils.setFocus(titleField);
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);
}
}
final Select2MultiChoice<GroupDO> groups = new Select2MultiChoice<GroupDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<GroupDO>>(this.readonlyAccessGroupsListHelper, "assignedItems"), groupsProvider);
fs.addHelpIcon(getString("plugins.skillmatrix.skilltraining.readonlyaccess"));
fs.add(groups);
}
gridBuilder.newGridPanel();
{
// Description
fs = gridBuilder.newFieldset(TrainingDO.class, "description");
fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description"))).setAutogrow();
}
{
// startDate
fs = gridBuilder.newFieldset(TrainingDO.class, "startDate");
fs.add(new DatePanel(fs.newChildId(), new PropertyModel<Date>(data, "startDate"), DatePanelSettings.get().withTargetType(
java.sql.Date.class)));
}
{
// EndDate
fs = gridBuilder.newFieldset(TrainingDO.class, "endDate");
fs.add(new DatePanel(fs.newChildId(), new PropertyModel<Date>(data, "endDate"), DatePanelSettings.get().withTargetType(
java.sql.Date.class)));
}
{
// Rating
fs = gridBuilder.newFieldset(TrainingDO.class, "rating");
valuesRating = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "rating"));
fs.addHelpIcon(getString("plugins.marketing.addressCampaign.values.format"));
fs.add(valuesRating);
fs.addAlertIcon(getString("plugins.skillmatrix.skilltraining.edit.warning.doNotChangeValues"));
valuesRating.setRequired(false);
valuesRating.add(new IValidator<String>() {
@Override
public void validate(final IValidatable<String> validatable)
{
if (TrainingDO.getValuesArray(validatable.getValue()) == null) {
valuesRating.error(getString("plugins.skillmatrix.skilltraining.values.invalidFormat"));
}
}
});
}
{
// Certificate
fs = gridBuilder.newFieldset(TrainingDO.class, "certificate");
valuesCertificate = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "certificate"));
fs.addHelpIcon(getString("plugins.marketing.addressCampaign.values.format"));
fs.add(valuesCertificate);
fs.addAlertIcon(getString("plugins.skillmatrix.skilltraining.edit.warning.doNotChangeValues"));
valuesCertificate.setRequired(false);
valuesCertificate.add(new IValidator<String>() {