access = true;
}
// set title
{
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.title"));
final RequiredMaxLengthTextField title = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<String>(data, "title"));
if (isNew() == true) {
title.add(WicketUtils.setFocus());
}
WicketUtils.setStrong(title);
fs.add(title);
if (access == false) {
title.setEnabled(false);
}
}
// set description
{
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.description"));
final MaxLengthTextArea descr = new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description"));
fs.add(descr).setAutogrow();
if (access == false) {
descr.setEnabled(false);
}
}
gridBuilder.newSplitPanel(GridSize.COL50);
// set owner
{
if (data.getOwner() == null) {
data.setOwner(getUser());
}
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.owner")).suppressLabelForWarning();
if (accessChecker.isLoggedInUserMemberOfAdminGroup() == true || ObjectUtils.equals(data.getOwnerId(), getUserId()) == true) {
final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<PFUserDO>(data, "owner"), parentPage,
"ownerId");
userSelectPanel.setRequired(true);
fs.add(userSelectPanel);
userSelectPanel.init();
} else {
fs.add(new Label(fs.newChildId(), data.getOwner().getUsername() + ""));
}
}
if (accessChecker.isRestrictedUser() == false && isNew() == false) {
icsExportDialog = new TeamCalICSExportDialog(parentPage.newModalDialogId());
parentPage.add(icsExportDialog);
icsExportDialog.init();
icsExportDialog.redraw(getData());
final FieldsetPanel fsSubscribe = gridBuilder.newFieldset(getString("plugins.teamcal.subscription")).suppressLabelForWarning();
fsSubscribe.add(new AjaxIconLinkPanel(fsSubscribe.newChildId(), IconType.SUBSCRIPTION, new ResourceModel(
"plugins.teamcal.subscription.tooltip")) {
@Override
public void onClick(final AjaxRequestTarget target)
{
icsExportDialog.setCalendarTitle(target, data.getTitle());
icsExportDialog.open(target);
};
});
}
if (access == true) {
// external subscription
final FieldsetPanel fsSubscription = gridBuilder.newFieldset(getString("plugins.teamcal.externalsubscription.label"));
final CheckBoxPanel checkboxPanel = new CheckBoxPanel(fsSubscription.newChildId(), new PropertyModel<Boolean>(data,
"externalSubscription"), null);
// ajax stuff
checkboxPanel.getCheckBox().add(new AjaxFormComponentUpdatingBehavior("change") {
@Override
protected void onUpdate(final AjaxRequestTarget target)
{
// update visibility
fsExternalSubscriptionUrl.getFieldset().setVisible(data.isExternalSubscription() == true);
fsExternalSubscriptionInterval.getFieldset().setVisible(data.isExternalSubscription() == true);
// update components through ajax
target.add(fsExternalSubscriptionUrl.getFieldset());
target.add(fsExternalSubscriptionInterval.getFieldset());
}
});
checkboxPanel.setTooltip(getString("plugins.teamcal.externalsubscription.label.tooltip"));
fsSubscription.add(checkboxPanel);
fsExternalSubscriptionUrl = gridBuilder.newFieldset(getString("plugins.teamcal.externalsubscription.url"));
fsExternalSubscriptionUrl.getFieldset().setOutputMarkupId(true);
fsExternalSubscriptionUrl.getFieldset().setOutputMarkupPlaceholderTag(true);
fsExternalSubscriptionUrl.getFieldset().setVisible(data.isExternalSubscription() == true);
fsExternalSubscriptionUrl.addHelpIcon(new ResourceModel("plugins.teamcal.externalsubscription.label.tooltip"), new ResourceModel(
"plugins.teamcal.externalsubscription.url.tooltip"));
final TextField<String> urlField = new TextField<String>(fsExternalSubscriptionUrl.getTextFieldId(), new PropertyModel<String>(data,
"externalSubscriptionUrl"));
urlField.setRequired(true);
fsExternalSubscriptionUrl.add(urlField);
fsExternalSubscriptionInterval = gridBuilder.newFieldset(getString("plugins.teamcal.externalsubscription.updateInterval"));
fsExternalSubscriptionInterval.getFieldset().setOutputMarkupId(true);
fsExternalSubscriptionInterval.getFieldset().setOutputMarkupPlaceholderTag(true);
fsExternalSubscriptionInterval.getFieldset().setVisible(data.isExternalSubscription() == true);
final IChoiceRenderer<Integer> intervalRenderer = new IChoiceRenderer<Integer>() {
@Override
public Object getDisplayValue(final Integer object)
{
return getString(SubscriptionUpdateInterval.getI18nKeyForInterval(object));
}
@Override
public String getIdValue(final Integer object, final int index)
{
return "" + object;
}
};
final DropDownChoicePanel<Integer> intervalField = new DropDownChoicePanel<Integer>(fsExternalSubscriptionUrl.getDropDownChoiceId(),
new PropertyModel<Integer>(data, "externalSubscriptionUpdateInterval"), SubscriptionUpdateInterval.getIntervals(),
intervalRenderer);
intervalField.setRequired(true);
fsExternalSubscriptionInterval.add(intervalField);
}
if (access == true) {
gridBuilder.newSplitPanel(GridSize.COL50);
// set access users
{
// Full access users
final FieldsetPanel fs = gridBuilder
.newFieldset(getString("plugins.teamcal.fullAccess"), getString("plugins.teamcal.access.users"));
final UsersProvider usersProvider = new UsersProvider();
final Collection<PFUserDO> fullAccessUsers = new UsersProvider().getSortedUsers(getData().getFullAccessUserIds());
fullAccessUsersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()).setFullList(
usersProvider.getSortedUsers());
if (fullAccessUsers != null) {
for (final PFUserDO user : fullAccessUsers) {
fullAccessUsersListHelper.addOriginalAssignedItem(user).assignItem(user);
}
}
final Select2MultiChoice<PFUserDO> users = new Select2MultiChoice<PFUserDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<PFUserDO>>(this.fullAccessUsersListHelper, "assignedItems"), usersProvider);
fs.add(users);
}
{
// Read-only access users
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.readonlyAccess"),
getString("plugins.teamcal.access.users"));
final UsersProvider usersProvider = new UsersProvider();
final Collection<PFUserDO> readOnlyAccessUsers = new UsersProvider().getSortedUsers(getData().getReadonlyAccessUserIds());
readonlyAccessUsersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()).setFullList(
usersProvider.getSortedUsers());
if (readOnlyAccessUsers != null) {
for (final PFUserDO user : readOnlyAccessUsers) {
readonlyAccessUsersListHelper.addOriginalAssignedItem(user).assignItem(user);
}
}
final Select2MultiChoice<PFUserDO> users = new Select2MultiChoice<PFUserDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<PFUserDO>>(this.readonlyAccessUsersListHelper, "assignedItems"), usersProvider);
fs.add(users);
}
{
// Minimal access users
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.minimalAccess"),
getString("plugins.teamcal.access.users"));
final UsersProvider usersProvider = new UsersProvider();
final Collection<PFUserDO> minimalAccessUsers = new UsersProvider().getSortedUsers(getData().getMinimalAccessUserIds());
minimalAccessUsersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()).setFullList(
usersProvider.getSortedUsers());
if (minimalAccessUsers != null) {
for (final PFUserDO user : minimalAccessUsers) {
minimalAccessUsersListHelper.addOriginalAssignedItem(user).assignItem(user);
}
}
final Select2MultiChoice<PFUserDO> users = new Select2MultiChoice<PFUserDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<PFUserDO>>(this.minimalAccessUsersListHelper, "assignedItems"), usersProvider);
fs.addHelpIcon(getString("plugins.teamcal.minimalAccess.users.hint"));
fs.add(users);
}
gridBuilder.newSplitPanel(GridSize.COL50);
// set access groups
{
// Full access groups
final FieldsetPanel 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);
fs.add(groups);
}
{
// Read-only access groups
final FieldsetPanel 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.add(groups);
}
{
// Minimal access groups
final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.minimalAccess"),
getString("plugins.teamcal.access.groups"));
final GroupsProvider groupsProvider = new GroupsProvider();
final Collection<GroupDO> minimalAccessGroups = new GroupsProvider().getSortedGroups(getData().getMinimalAccessGroupIds());
minimalAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(
groupsProvider.getSortedGroups());
if (minimalAccessGroups != null) {
for (final GroupDO group : minimalAccessGroups) {
minimalAccessGroupsListHelper.addOriginalAssignedItem(group).assignItem(group);
}
}
final Select2MultiChoice<GroupDO> groups = new Select2MultiChoice<GroupDO>(fs.getSelect2MultiChoiceId(),
new PropertyModel<Collection<GroupDO>>(this.minimalAccessGroupsListHelper, "assignedItems"), groupsProvider);
fs.addHelpIcon(getString("plugins.teamcal.minimalAccess.groups.hint"));
fs.add(groups);
}
}
}