Search in sources :

Example 1 with MultiChoiceListHelper

use of org.projectforge.web.common.MultiChoiceListHelper in project projectforge by micromata.

the class TeamCalEditForm method init.

/**
 * @see org.projectforge.web.wicket.AbstractEditForm#init()
 */
@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    gridBuilder.newSplitPanel(GridSize.COL50);
    // checking visibility rights
    final TeamCalRight right = new TeamCalRight(accessChecker);
    if (isNew() == true || right.hasUpdateAccess(getUser(), data, data) == true) {
        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"));
        title.setMarkupId("title").setOutputMarkupId(true);
        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"));
        descr.setMarkupId("description").setOutputMarkupId(true);
        fs.add(descr).setAutogrow();
        if (access == false) {
            descr.setEnabled(false);
        }
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    // ID
    {
        if (isNew() == false && accessChecker.isLoggedInUserMemberOfAdminGroup() == true) {
            final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.id"));
            fs.add(new Label(fs.newChildId(), data.getId()));
        }
    }
    // set owner
    {
        if (data.getOwner() == null) {
            data.setOwner(getUser());
        }
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.owner")).suppressLabelForWarning();
        if (accessChecker.isLoggedInUserMemberOfAdminGroup() == true || Objects.equals(data.getOwnerId(), getUserId()) == true) {
            final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<PFUserDO>(data, "owner"), parentPage, "ownerId");
            userSelectPanel.getFormComponent().setMarkupId("owner").setOutputMarkupId(true);
            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().setMarkupId("externalSubscription").setOutputMarkupId(true);
        checkboxPanel.getCheckBox().add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                // update visibility
                fsExternalSubscriptionUrl.getFieldset().setVisible(data.getExternalSubscription() == true);
                fsExternalSubscriptionInterval.getFieldset().setVisible(data.getExternalSubscription() == 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.getExternalSubscription() == 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.getExternalSubscription() == 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.toString();
            }

            @Override
            public Integer getObject(final String s, final IModel<? extends List<? extends Integer>> iModel) {
                if (s == null) {
                    return null;
                }
                for (Integer instance : iModel.getObject()) {
                    // TODO sn migration
                    if (s.equals(instance.toString())) {
                        return instance;
                    }
                }
                return null;
            }
        };
        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(userDao);
            final Collection<PFUserDO> fullAccessUsers = new UsersProvider(userDao).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);
            users.setMarkupId("fullAccessUsers").setOutputMarkupId(true);
            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(userDao);
            final Collection<PFUserDO> readOnlyAccessUsers = new UsersProvider(userDao).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);
            users.setMarkupId("readOnlyAccessUsers").setOutputMarkupId(true);
            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(userDao);
            final Collection<PFUserDO> minimalAccessUsers = new UsersProvider(userDao).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);
            users.setMarkupId("minimalAccessUsers").setOutputMarkupId(true);
            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 Collection<GroupDO> fullAccessGroups = groupService.getSortedGroups(getData().getFullAccessGroupIds());
            fullAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(groupService.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"), new GroupsWicketProvider(groupService));
            groups.setMarkupId("fullAccessGroups").setOutputMarkupId(true);
            fs.add(groups);
        }
        {
            // Read-only access groups
            final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.readonlyAccess"), getString("plugins.teamcal.access.groups"));
            final Collection<GroupDO> readOnlyAccessGroups = groupService.getSortedGroups(getData().getReadonlyAccessGroupIds());
            readonlyAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(groupService.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"), new GroupsWicketProvider(groupService));
            groups.setMarkupId("readOnlyAccessGroups").setOutputMarkupId(true);
            fs.add(groups);
        }
        {
            // Minimal access groups
            final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.minimalAccess"), getString("plugins.teamcal.access.groups"));
            final Collection<GroupDO> minimalAccessGroups = groupService.getSortedGroups(getData().getMinimalAccessGroupIds());
            minimalAccessGroupsListHelper = new MultiChoiceListHelper<GroupDO>().setComparator(new GroupsComparator()).setFullList(groupService.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"), new GroupsWicketProvider(groupService));
            groups.setMarkupId("minimalAccessGroups").setOutputMarkupId(true);
            fs.addHelpIcon(getString("plugins.teamcal.minimalAccess.groups.hint"));
            fs.add(groups);
        }
    }
}
Also used : IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) UsersProvider(org.projectforge.web.user.UsersProvider) Label(org.apache.wicket.markup.html.basic.Label) PFUserDO(org.projectforge.framework.persistence.user.entities.PFUserDO) GroupsComparator(org.projectforge.business.user.GroupsComparator) UserSelectPanel(org.projectforge.web.user.UserSelectPanel) MultiChoiceListHelper(org.projectforge.web.common.MultiChoiceListHelper) ResourceModel(org.apache.wicket.model.ResourceModel) TextField(org.apache.wicket.markup.html.form.TextField) RequiredMaxLengthTextField(org.projectforge.web.wicket.components.RequiredMaxLengthTextField) List(java.util.List) GroupDO(org.projectforge.framework.persistence.user.entities.GroupDO) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) UsersComparator(org.projectforge.business.user.UsersComparator) IModel(org.apache.wicket.model.IModel) GroupsWicketProvider(org.projectforge.web.user.GroupsWicketProvider) PropertyModel(org.apache.wicket.model.PropertyModel) MaxLengthTextArea(org.projectforge.web.wicket.components.MaxLengthTextArea) TeamCalRight(org.projectforge.business.teamcal.admin.right.TeamCalRight) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) Collection(java.util.Collection) RequiredMaxLengthTextField(org.projectforge.web.wicket.components.RequiredMaxLengthTextField) TeamCalICSExportDialog(org.projectforge.web.teamcal.dialog.TeamCalICSExportDialog)

Example 2 with MultiChoiceListHelper

use of org.projectforge.web.common.MultiChoiceListHelper in project projectforge by micromata.

the class TeamEventListForm method onOptionsPanelCreate.

/**
 * @see org.projectforge.web.wicket.AbstractListForm#onOptionsPanelCreate(org.projectforge.web.wicket.flowlayout.FieldsetPanel,
 * org.projectforge.web.wicket.flowlayout.DivPanel)
 */
@SuppressWarnings("serial")
@Override
protected void onOptionsPanelCreate(final FieldsetPanel optionsFieldsetPanel, final DivPanel optionsCheckBoxesPanel) {
    {
        optionsFieldsetPanel.setOutputMarkupId(true);
        startDate = new LocalDatePanel(optionsFieldsetPanel.newChildId(), new LocalDateModel(new PropertyModel<LocalDate>(getSearchFilter(), "startDate")), DatePanelSettings.get().withSelectPeriodMode(true), true);
        optionsFieldsetPanel.add(dependentFormComponents[0] = startDate);
        optionsFieldsetPanel.setLabelFor(startDate);
        optionsFieldsetPanel.add(new DivTextPanel(optionsFieldsetPanel.newChildId(), " - "));
        endDate = new LocalDatePanel(optionsFieldsetPanel.newChildId(), new LocalDateModel(new PropertyModel<LocalDate>(getSearchFilter(), "endDate")), DatePanelSettings.get().withSelectPeriodMode(true), true);
        optionsFieldsetPanel.add(dependentFormComponents[1] = endDate);
        {
            final SubmitLink unselectPeriod = new SubmitLink(IconLinkPanel.LINK_ID) {

                @Override
                public void onSubmit() {
                    getSearchFilter().setStartDate(null);
                    getSearchFilter().setEndDate(null);
                    clearInput();
                    parentPage.refresh();
                }
            };
            unselectPeriod.setDefaultFormProcessing(false);
            optionsFieldsetPanel.add(new IconLinkPanel(optionsFieldsetPanel.newChildId(), IconType.REMOVE_SIGN, new ResourceModel("calendar.tooltip.unselectPeriod"), unselectPeriod).setColor(CSSColor.RED));
        }
        final QuickSelectPanel quickSelectPanel = new QuickSelectPanel(optionsFieldsetPanel.newChildId(), parentPage, "quickSelect", startDate);
        optionsFieldsetPanel.add(quickSelectPanel);
        quickSelectPanel.init();
        optionsFieldsetPanel.add(new HtmlCommentPanel(optionsFieldsetPanel.newChildId(), new Model<String>() {

            @Override
            public String getObject() {
                return WicketUtils.getUTCDates(getSearchFilter().getStartDate(), getSearchFilter().getEndDate());
            }
        }));
    }
    {
        // Team calendar
        // .setLabelSide(false);
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.teamcal.calendar"));
        final TeamCalsProvider calendarProvider = new TeamCalsProvider(teamCalCache);
        calendarsListHelper = new MultiChoiceListHelper<TeamCalDO>().setComparator(new TeamCalsComparator()).setFullList(calendarProvider.getSortedCalenders());
        final Collection<Integer> list = getFilter().getTeamCals();
        if (list != null) {
            for (final Integer calId : list) {
                final TeamCalDO cal = teamCalCache.getCalendar(calId);
                calendarsListHelper.addOriginalAssignedItem(cal).assignItem(cal);
            }
        }
        final Select2MultiChoice<TeamCalDO> calendars = new Select2MultiChoice<TeamCalDO>(fs.getSelect2MultiChoiceId(), new PropertyModel<Collection<TeamCalDO>>(this.calendarsListHelper, "assignedItems"), calendarProvider);
        fs.add(calendars);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) LocalDateModel(org.projectforge.web.wicket.components.LocalDateModel) QuickSelectPanel(org.projectforge.web.calendar.QuickSelectPanel) TeamCalsProvider(org.projectforge.web.teamcal.admin.TeamCalsProvider) TeamCalsComparator(org.projectforge.business.teamcal.admin.TeamCalsComparator) LocalDatePanel(org.projectforge.web.wicket.components.LocalDatePanel) SubmitLink(org.apache.wicket.markup.html.form.SubmitLink) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) MultiChoiceListHelper(org.projectforge.web.common.MultiChoiceListHelper) ResourceModel(org.apache.wicket.model.ResourceModel) Collection(java.util.Collection) TeamCalDO(org.projectforge.business.teamcal.admin.model.TeamCalDO)

Example 3 with MultiChoiceListHelper

use of org.projectforge.web.common.MultiChoiceListHelper in project projectforge by micromata.

the class VisitorbookEditForm method init.

@Override
protected void init() {
    super.init();
    gridBuilder.newSplitPanel(GridSize.COL50, true).newSubSplitPanel(GridSize.COL100);
    {
        // Firstname
        final FieldsetPanel fs = gridBuilder.newFieldset(VisitorbookDO.class, "firstname");
        MaxLengthTextField firstname = new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "firstname"));
        firstname.setMarkupId("firstname").setOutputMarkupId(true);
        firstname.setRequired(true);
        fs.add(firstname);
    }
    {
        // Lastname
        final FieldsetPanel fs = gridBuilder.newFieldset(VisitorbookDO.class, "lastname");
        MaxLengthTextField lastname = new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "lastname"));
        lastname.setMarkupId("lastname").setOutputMarkupId(true);
        lastname.setRequired(true);
        fs.add(lastname);
    }
    {
        // Company
        final FieldsetPanel fs = gridBuilder.newFieldset(VisitorbookDO.class, "company");
        MaxLengthTextField company = new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "company"));
        company.setMarkupId("company").setOutputMarkupId(true);
        fs.add(company);
    }
    {
        // ATTENDEE
        final FieldsetPanel fieldSet = gridBuilder.newFieldset(getString("orga.visitorbook.contactPerson"));
        final Collection<Integer> set = visitorbookService.getAssignedContactPersonsIds(data);
        assignContactPersonsListHelper = new MultiChoiceListHelper<EmployeeDO>().setComparator(new EmployeeComparator()).setFullList(employeeService.findAllActive(false));
        if (set != null) {
            for (final Integer employeeId : set) {
                final EmployeeDO employee = employeeService.selectByPkDetached(employeeId);
                if (employee != null) {
                    assignContactPersonsListHelper.addOriginalAssignedItem(employee).assignItem(employee);
                }
            }
        }
        employeeWicketProvider = new VisitorbookEmployeeWicketProvider(data, employeeService);
        final Select2MultiChoice<EmployeeDO> employees = new Select2MultiChoice<EmployeeDO>(fieldSet.getSelect2MultiChoiceId(), new PropertyModel<Collection<EmployeeDO>>(this.assignContactPersonsListHelper, "assignedItems"), employeeWicketProvider);
        employees.setMarkupId("contactPersons").setOutputMarkupId(true);
        fieldSet.add(employees);
    }
    {
        // DropDownChoice visitor type
        final FieldsetPanel fs = gridBuilder.newFieldset(VisitorbookDO.class, "visitortype");
        final LabelValueChoiceRenderer<VisitorType> visitortypeChoiceRenderer = new LabelValueChoiceRenderer<>(this, VisitorType.values());
        final DropDownChoice<VisitorType> statusChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "visitortype"), visitortypeChoiceRenderer.getValues(), visitortypeChoiceRenderer);
        statusChoice.setNullValid(false).setRequired(true);
        statusChoice.setMarkupId("visitortype").setOutputMarkupId(true);
        fs.add(statusChoice);
    }
    // set hasSubSplitPanel to true to remove borders from this split panel
    gridBuilder.newSplitPanel(GridSize.COL100, true);
    {
        // AttrPanels
        final Function<AttrGroup, VisitorbookTimedDO> addNewEntryFunction = group -> visitorbookService.addNewTimeAttributeRow(data, group.getName());
        attrSchemaService.createTimedAttrPanels(gridBuilder.getPanel(), data, parentPage, addNewEntryFunction);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) EmployeeDO(org.projectforge.business.fibu.EmployeeDO) EmployeeComparator(org.projectforge.business.fibu.EmployeeComparator) VisitorbookDO(org.projectforge.business.orga.VisitorbookDO) Function(java.util.function.Function) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) LabelValueChoiceRenderer(org.projectforge.web.wicket.components.LabelValueChoiceRenderer) MaxLengthTextField(org.projectforge.web.wicket.components.MaxLengthTextField) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) MultiChoiceListHelper(org.projectforge.web.common.MultiChoiceListHelper) Collection(java.util.Collection) FieldsetPanel(org.projectforge.web.wicket.flowlayout.FieldsetPanel)

Example 4 with MultiChoiceListHelper

use of org.projectforge.web.common.MultiChoiceListHelper in project projectforge by micromata.

the class LicenseEditForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    {
        // Organization
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("organization"));
        final PFAutoCompleteMaxLengthTextField organizationField = new PFAutoCompleteMaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "organization")) {

            @Override
            protected List<String> getChoices(final String input) {
                return getBaseDao().getAutocompletion("organization", input);
            }
        };
        organizationField.withMatchContains(true).withMinChars(2).withFocus(true);
        WicketUtils.setStrong(organizationField);
        fs.add(organizationField);
    }
    {
        // Product
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.product"));
        final PFAutoCompleteMaxLengthTextField productField = new PFAutoCompleteMaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "product")) {

            @Override
            protected List<String> getChoices(final String input) {
                return getBaseDao().getAutocompletion("product", input);
            }
        };
        productField.withMatchContains(true).withMinChars(2);
        productField.setRequired(true);
        WicketUtils.setStrong(productField);
        fs.add(productField);
    }
    {
        // Version
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.version"));
        final RequiredMaxLengthTextField versionField = new RequiredMaxLengthTextField(fs.getTextFieldId(), new PropertyModel<>(data, "version"));
        WicketUtils.setStrong(versionField);
        fs.add(versionField);
    }
    {
        // UpdateFromVersion
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.updateFromVersion"));
        fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<>(data, "updateFromVersion")));
        fs.addHelpIcon(getString("plugins.licensemanagement.updateFromVersion.tooltip"));
    }
    {
        // Device
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.device"));
        fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<>(data, "device")));
        fs.addHelpIcon(getString("plugins.licensemanagement.device.tooltip"));
    }
    {
        // Number of license:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.numberOfLicenses"));
        final MinMaxNumberField<Integer> maxNumberField = new MinMaxNumberField<>(InputPanel.WICKET_ID, new PropertyModel<>(data, "numberOfLicenses"), 0, 999999);
        WicketUtils.setSize(maxNumberField, 6);
        fs.add(maxNumberField);
    }
    {
        // Owners
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.owner")).setLabelSide(false);
        final UsersProvider usersProvider = new UsersProvider(userDao);
        assignOwnersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()).setFullList(usersProvider.getSortedUsers());
        final Collection<PFUserDO> owners = ((LicenseDao) getBaseDao()).getSortedOwners(data);
        if (owners != null) {
            for (final PFUserDO owner : owners) {
                assignOwnersListHelper.addOriginalAssignedItem(owner).assignItem(owner);
            }
        }
        final Select2MultiChoice<PFUserDO> ownersChoice = new Select2MultiChoice<>(fs.getSelect2MultiChoiceId(), new PropertyModel<>(this.assignOwnersListHelper, "assignedItems"), usersProvider);
        fs.add(ownersChoice);
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        // Valid since
        final FieldProperties<LocalDate> props = getValidSinceProperties();
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.validSince"));
        LocalDatePanel components = new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel()));
        fs.add(components);
    }
    gridBuilder.newSplitPanel(GridSize.COL33);
    {
        // Valid until
        final FieldProperties<LocalDate> props = getValidUntilProperties();
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.validUntil"));
        LocalDatePanel components = new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel()));
        fs.add(components);
    }
    gridBuilder.newGridPanel();
    {
        // License holder
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.licenseHolder"));
        fs.add(new MaxLengthTextField(fs.getTextFieldId(), new PropertyModel<>(data, "licenseHolder")));
    }
    final LicenseManagementRight right = (LicenseManagementRight) userRights.getRight(LicensemanagementPluginUserRightsId.PLUGIN_LICENSE_MANAGEMENT);
    {
        // Text key
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("plugins.licensemanagement.key"));
        if (right.isLicenseKeyVisible(getUser(), data)) {
            fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<>(data, "key"))).setAutogrow();
        } else {
            fs.add(new DivTextPanel(fs.newChildId(), getString("plugins.licensemanagement.key.notvisible")));
            fs.addHelpIcon(getString("plugins.licensemanagement.key.notvisible.tooltip"));
        }
    }
    if (// 
    (isNew() && right.hasInsertAccess(getUser())) || (right.hasUpdateAccess(getUser(), data, null) && right.isLicenseKeyVisible(getUser(), data))) {
        gridBuilder.newSplitPanel(GridSize.COL50);
        FieldsetPanel fs = gridBuilder.newFieldset(gridBuilder.getString("plugins.licensemanagement.file1"));
        fileUploadPanel1 = new FileUploadPanel(fs.newChildId(), fs, this, true, new PropertyModel<>(data, "filename1"), new PropertyModel<>(data, "file1"));
        if (!isNew() && (data.getFile1() != null || data.getFile2() != null)) {
            // Swap files:
            fs.add(new IconButtonPanel(fs.newChildId(), IconType.SWAP, getString("plugins.licensemanagement.swapFiles")) {

                /**
                 * @see org.projectforge.web.wicket.flowlayout.IconButtonPanel#onSubmit()
                 */
                @Override
                protected void onSubmit() {
                    final byte[] swap = data.getFile1();
                    final String swapFilename = data.getFilename1();
                    data.setFile1(data.getFile2());
                    data.setFilename1(data.getFilename2());
                    data.setFile2(swap);
                    data.setFilename2(swapFilename);
                }
            });
        }
        gridBuilder.newSplitPanel(GridSize.COL50);
        fs = gridBuilder.newFieldset(gridBuilder.getString("plugins.licensemanagement.file2"));
        fileUploadPanel2 = new FileUploadPanel(fs.newChildId(), fs, this, true, new PropertyModel<>(data, "filename2"), new PropertyModel<>(data, "file2"));
        gridBuilder.newGridPanel();
    } else if (right.isLicenseKeyVisible(getUser(), data)) {
    }
    {
        // Text comment
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("comment"));
        fs.add(new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<>(data, "comment"))).setAutogrow();
    }
    addCloneButton();
}
Also used : UsersProvider(org.projectforge.web.user.UsersProvider) PFUserDO(org.projectforge.framework.persistence.user.entities.PFUserDO) PFAutoCompleteMaxLengthTextField(org.projectforge.web.wicket.autocompletion.PFAutoCompleteMaxLengthTextField) MultiChoiceListHelper(org.projectforge.web.common.MultiChoiceListHelper) List(java.util.List) UsersComparator(org.projectforge.business.user.UsersComparator) PFAutoCompleteMaxLengthTextField(org.projectforge.web.wicket.autocompletion.PFAutoCompleteMaxLengthTextField) PropertyModel(org.apache.wicket.model.PropertyModel) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) Collection(java.util.Collection)

Example 5 with MultiChoiceListHelper

use of org.projectforge.web.common.MultiChoiceListHelper in project projectforge by micromata.

the class TeamEventEditForm method init.

/**
 * @see org.projectforge.web.wicket.AbstractEditForm#init()
 */
@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    recurrenceData = data.getRecurrenceData(ThreadLocalUserContext.getTimeZone());
    gridBuilder.newSplitPanel(GridSize.COL50);
    final TeamCalDO teamCal = data.getCalendar();
    // setting access view
    if (isNew() || teamCal == null || teamCal.getOwner() == null) {
        access = true;
    } else {
        if (right.hasUpdateAccess(getUser(), data, data)) {
            access = true;
        } else {
            access = false;
            if (right.hasMinimalAccess(data, getUserId())) {
                final TeamEventDO newTeamEventDO = new TeamEventDO();
                newTeamEventDO.setId(data.getId());
                newTeamEventDO.setStartDate(data.getStartDate());
                newTeamEventDO.setEndDate(data.getEndDate());
                data = newTeamEventDO;
                access = false;
            }
        }
    }
    // add teamCal drop down
    initTeamCalPicker(gridBuilder.newFieldset(getString("plugins.teamcal.event.teamCal")));
    {
        // SUBJECT
        final FieldsetPanel fieldSet = gridBuilder.newFieldset(getString("plugins.teamcal.event.subject"));
        final MaxLengthTextField subjectField = new MaxLengthTextField(fieldSet.getTextFieldId(), new PropertyModel<>(data, "subject"));
        subjectField.setRequired(true);
        fieldSet.add(subjectField);
        if (!access) {
            fieldSet.setEnabled(false);
        } else {
            WicketUtils.setFocus(subjectField);
        }
    }
    {
        // LOCATION
        final FieldsetPanel fieldSet = gridBuilder.newFieldset(getString("plugins.teamcal.event.location"));
        final PFAutoCompleteMaxLengthTextField locationTextField = new PFAutoCompleteMaxLengthTextField(fieldSet.getTextFieldId(), new PropertyModel<>(data, "location")) {

            @Override
            protected List<String> getChoices(final String input) {
                return teamEventDao.getLocationAutocompletion(input, calendarsWithFullAccess);
            }
        };
        locationTextField.withMatchContains(true).withMinChars(3);
        fieldSet.add(locationTextField);
        if (!access)
            fieldSet.setEnabled(false);
    }
    {
        // ATTENDEE
        final FieldsetPanel fieldSet = gridBuilder.newFieldset(getString("plugins.teamcal.attendees"));
        List<TeamEventAttendeeDO> fullAttendeeList = teamEventService.getAddressesAndUserAsAttendee();
        assignAttendeesListHelper = new MultiChoiceListHelper<TeamEventAttendeeDO>().setComparator(new AttendeeComparator()).setFullList(fullAttendeeList);
        if (data.getAttendees() != null) {
            for (final TeamEventAttendeeDO attendee : data.getAttendees()) {
                assignAttendeesListHelper.addOriginalAssignedItem(attendee).assignItem(attendee);
            }
        }
        attendeeWicketProvider = new AttendeeWicketProvider(data, teamEventService);
        final Select2MultiChoice<TeamEventAttendeeDO> attendees = new Select2MultiChoice<>(fieldSet.getSelect2MultiChoiceId(), new PropertyModel<>(this.assignAttendeesListHelper, "assignedItems"), attendeeWicketProvider);
        attendees.setMarkupId("attendees").setOutputMarkupId(true);
        attendees.add(new TeamEventAttendeeValidator());
        attendees.getSettings().setCloseOnSelect(true);
        fieldSet.add(attendees);
        if (!access) {
            fieldSet.setEnabled(false);
        }
    }
    {
        // NOTE
        final FieldsetPanel fieldSet = gridBuilder.newFieldset(getString("plugins.teamcal.event.note"));
        final MaxLengthTextArea noteField = new MaxLengthTextArea(fieldSet.getTextAreaId(), new PropertyModel<>(data, "note"));
        fieldSet.add(noteField).setAutogrow();
        if (!access)
            fieldSet.setEnabled(false);
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    // add date panel
    initDatePanel();
    {
        // ALL DAY CHECKBOX
        final FieldsetPanel fieldSet = gridBuilder.newFieldset("").suppressLabelForWarning();
        final DivPanel divPanel = fieldSet.addNewCheckBoxButtonDiv();
        final CheckBoxButton checkBox = new CheckBoxButton(divPanel.newChildId(), new PropertyModel<>(data, "allDay"), getString("plugins.teamcal.event.allDay"));
        checkBox.getCheckBox().add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (!data.getAllDay()) {
                    setDateDropChoiceVisible(true);
                } else {
                    setDateDropChoiceVisible(false);
                }
                target.add(startDateTimePanel.getTimeContainer(), endDateTimePanel.getTimeContainer());
            }
        });
        setDateDropChoiceVisible(!data.getAllDay());
        divPanel.add(checkBox);
        fieldSet.add(divPanel);
        if (!access)
            fieldSet.setEnabled(false);
        // ///////////////////////////////
        // Reminder
        // ///////////////////////////////
        final FieldsetPanel reminderPanel = gridBuilder.newFieldset(getString("plugins.teamcal.event.reminder.title"));
        reminderPanel.add(new TeamEventReminderComponent(reminderPanel.newChildId(), Model.of(data), reminderPanel));
        reminderPanel.addHelpIcon(getString("plugins.teamcal.event.reminder.tooltip"));
    }
    // ///////////////////////////////
    // Recurrence
    // ///////////////////////////////
    gridBuilder.newSplitPanel(GridSize.COL50);
    gridBuilder.newFormHeading(getString("plugins.teamcal.event.recurrence"));
    {
        // Recurrence interval type:
        recurrenceFieldset = gridBuilder.newFieldset(getString("plugins.teamcal.event.recurrence"));
        recurrencePanel = gridBuilder.getPanel().getDiv();
        recurrencePanel.setOutputMarkupId(true);
        final RecurrenceFrequency[] supportedFrequencies = new RecurrenceFrequency[] { RecurrenceFrequency.NONE, RecurrenceFrequency.DAILY, RecurrenceFrequency.WEEKLY, RecurrenceFrequency.MONTHLY, RecurrenceFrequency.YEARLY };
        final LabelValueChoiceRenderer<RecurrenceFrequency> frequencyChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceFieldset, supportedFrequencies);
        final DropDownChoice<RecurrenceFrequency> frequencyChoice = new DropDownChoice<>(recurrenceFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "frequency"), frequencyChoiceRenderer.getValues(), frequencyChoiceRenderer);
        frequencyChoice.setNullValid(false);
        recurrenceFieldset.add(frequencyChoice);
        recurrenceFieldset.getFieldset().setOutputMarkupId(true);
        frequencyChoice.add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                setRecurrenceComponentsVisibility(target);
            }
        });
        customizedCheckBoxButton = recurrenceFieldset.addNewCheckBoxButtonDiv();
        final CheckBoxButton checkBox = new CheckBoxButton(customizedCheckBoxButton.newChildId(), new PropertyModel<>(recurrenceData, "customized"), getString("plugins.teamcal.event.recurrence.customized"));
        checkBox.getCheckBox().add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                setRecurrenceComponentsVisibility(target);
            }
        });
        customizedCheckBoxButton.add(checkBox);
    }
    {
        // IntervallSet
        recurrenceIntervalFieldset = gridBuilder.newFieldset("");
        DivTextPanel panel = new DivTextPanel(recurrenceIntervalFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.customized.all"), false) + "&nbsp;");
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceIntervalFieldset.add(panel);
        final MinMaxNumberField<Integer> intervalNumberField = new MinMaxNumberField<>(InputPanel.WICKET_ID, new PropertyModel<>(recurrenceData, "interval"), 0, 1000);
        WicketUtils.setSize(intervalNumberField, 2);
        recurrenceIntervalFieldset.add(intervalNumberField);
        panel = new DivTextPanel(recurrenceIntervalFieldset.newChildId(), new Model<String>() {

            @Override
            public String getObject() {
                final RecurrenceFrequency interval = recurrenceData.getFrequency();
                final String unitI18nKey = getString(interval.getUnitI18nKey());
                if (unitI18nKey != null) {
                    return "&nbsp;" + HtmlHelper.escapeHtml(unitI18nKey, false);
                }
                return "";
            }
        });
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceIntervalFieldset.add(panel);
        recurrenceIntervalFieldset.getFieldset().setOutputMarkupId(true);
    }
    // ToDO i18nKey
    {
        // WeekSet
        recurrenceWeekIntervalFieldset = gridBuilder.newFieldset("");
        DivTextPanel panel = new DivTextPanel(recurrenceWeekIntervalFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.atthe") + ":", false));
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceWeekIntervalFieldset.add(panel);
        recurrenceWeekIntervalFieldset.getFieldset().setOutputMarkupId(true);
        addNewDayButtons();
    }
    {
        // MonthSet
        recurrenceMonthIntervalFieldset = gridBuilder.newFieldset("");
        // Selecet für (erster, zweiter, dritter, vierter, letzter)
        final RecurrenceMonthMode[] supportedModes = new RecurrenceMonthMode[] { RecurrenceMonthMode.NONE, RecurrenceMonthMode.ATTHE, RecurrenceMonthMode.EACH };
        final LabelValueChoiceRenderer<RecurrenceMonthMode> frequencyModeChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceMonthIntervalFieldset, supportedModes);
        final DropDownChoice modeDropDownChoiceMonth = new DropDownChoice<>(recurrenceMonthIntervalFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "monthMode"), frequencyModeChoiceRenderer.getValues(), frequencyModeChoiceRenderer);
        modeDropDownChoiceMonth.setNullValid(false).setOutputMarkupId(true);
        modeDropDownChoiceMonth.add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                setRecurrenceComponentsVisibility(target);
            }
        });
        recurrenceMonthIntervalFieldset.add(modeDropDownChoiceMonth);
        recurrenceMonthIntervalFieldset.getFieldset().setOutputMarkupId(true);
        recurrenceMonthModeFirstFieldset = gridBuilder.newFieldset("");
        addDayMonthButtons();
        recurrenceMonthModeSecondFieldset = gridBuilder.newFieldset("");
        recurrenceMonthModeSecondFieldset.setOutputMarkupId(true);
        DivTextPanel panel = new DivTextPanel(recurrenceMonthModeSecondFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.atthe") + ":", false));
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceMonthModeSecondFieldset.add(panel);
        // Selecet für (erster, zweiter, dritter, vierter, letzter)
        final LabelValueChoiceRenderer<RecurrenceFrequencyModeOne> frequencyModeOneChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceMonthModeSecondFieldset, SUPPORTED_MODE_ONE);
        modeOneDropDownChoiceMonth = new DropDownChoice<>(recurrenceMonthModeSecondFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "modeOneMonth"), frequencyModeOneChoiceRenderer.getValues(), frequencyModeOneChoiceRenderer);
        modeOneDropDownChoiceMonth.setNullValid(false).setOutputMarkupId(true);
        recurrenceMonthModeSecondFieldset.add(modeOneDropDownChoiceMonth);
        recurrenceMonthModeSecondFieldset.getFieldset().setOutputMarkupId(true);
        // Select für (Wochentage, Tag, Wochentag, Wochenende)
        final LabelValueChoiceRenderer<RecurrenceFrequencyModeTwo> frequencyModeTwoChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceMonthModeSecondFieldset, SUPPORTED_MODE_TWO);
        modeTwoDropDownChoiceMonth = new DropDownChoice<>(recurrenceMonthModeSecondFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "modeTwoMonth"), frequencyModeTwoChoiceRenderer.getValues(), frequencyModeTwoChoiceRenderer);
        modeTwoDropDownChoiceMonth.setNullValid(false).setOutputMarkupId(true);
        recurrenceMonthModeSecondFieldset.add(modeTwoDropDownChoiceMonth);
        recurrenceMonthModeSecondFieldset.getFieldset().setOutputMarkupId(true);
        panel = new DivTextPanel(recurrenceMonthModeSecondFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.ofmonth"), false));
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceMonthModeSecondFieldset.add(panel);
    }
    {
        // YearSet
        recurrenceYearIntervalFieldset = gridBuilder.newFieldset("");
        DivTextPanel panel = new DivTextPanel(recurrenceYearIntervalFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.in") + " :", false));
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceYearIntervalFieldset.add(panel);
        recurrenceYearIntervalFieldset.getFieldset().setOutputMarkupId(true);
        addMonthYearButtons();
        recurrenceYearModeFieldset = gridBuilder.newFieldset("");
        DivPanel components = recurrenceYearModeFieldset.addNewCheckBoxButtonDiv();
        final CheckBoxButton checkBox = new CheckBoxButton(components.newChildId(), new PropertyModel<>(recurrenceData, "yearMode"), getString("plugins.teamcal.event.recurrence.atthe"));
        checkBox.getCheckBox().add(new AjaxFormComponentUpdatingBehavior("change") {

            @Override
            protected void onUpdate(final AjaxRequestTarget target) {
                if (checkBox.getCheckBox().getConvertedInput()) {
                    modeOneDropDownChoiceYear.setEnabled(true);
                    modeTwoDropDownChoiceYear.setEnabled(true);
                } else {
                    modeOneDropDownChoiceYear.setEnabled(false);
                    modeTwoDropDownChoiceYear.setEnabled(false);
                }
                target.add(modeOneDropDownChoiceYear, modeTwoDropDownChoiceYear);
            }
        });
        components.add(checkBox);
        // Selecet für (erster, zweiter, dritter, vierter, letzter)
        final LabelValueChoiceRenderer<RecurrenceFrequencyModeOne> frequencyModeOneChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceYearModeFieldset, SUPPORTED_MODE_ONE);
        modeOneDropDownChoiceYear = new DropDownChoice<>(recurrenceYearModeFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "modeOneYear"), frequencyModeOneChoiceRenderer.getValues(), frequencyModeOneChoiceRenderer);
        modeOneDropDownChoiceYear.setNullValid(false).setOutputMarkupId(true);
        recurrenceYearModeFieldset.add(modeOneDropDownChoiceYear);
        recurrenceYearModeFieldset.getFieldset().setOutputMarkupId(true);
        if (!recurrenceData.isYearMode())
            modeOneDropDownChoiceYear.setEnabled(false);
        // Select für (Wochentage, Tag, Wochentag, Wochenende)
        final LabelValueChoiceRenderer<RecurrenceFrequencyModeTwo> frequencyModeTwoChoiceRenderer = new LabelValueChoiceRenderer<>(recurrenceYearModeFieldset, SUPPORTED_MODE_TWO);
        modeTwoDropDownChoiceYear = new DropDownChoice<>(recurrenceYearModeFieldset.getDropDownChoiceId(), new PropertyModel<>(recurrenceData, "modeTwoYear"), frequencyModeTwoChoiceRenderer.getValues(), frequencyModeTwoChoiceRenderer);
        modeTwoDropDownChoiceYear.setNullValid(false).setOutputMarkupId(true);
        recurrenceYearModeFieldset.add(modeTwoDropDownChoiceYear);
        if (!recurrenceData.isYearMode())
            modeTwoDropDownChoiceYear.setEnabled(false);
        recurrenceYearModeFieldset.getFieldset().setOutputMarkupId(true);
        panel = new DivTextPanel(recurrenceYearModeFieldset.newChildId(), HtmlHelper.escapeHtml(getString("plugins.teamcal.event.recurrence.oftheyear"), false));
        panel.getLabel().setEscapeModelStrings(false);
        recurrenceYearModeFieldset.add(panel);
    }
    {
        // Until. Only visible if recurrenceData.interval != NONE.
        recurrenceUntilDateFieldset = gridBuilder.newFieldset(getString("plugins.teamcal.event.recurrence.until"));
        final DatePanel untilDatePanel = new DatePanel(recurrenceUntilDateFieldset.newChildId(), new PropertyModel<>(recurrenceData, "until"), DatePanelSettings.get().withTimeZone(DateHelper.UTC));
        recurrenceUntilDateFieldset.add(untilDatePanel);
        recurrenceUntilDateFieldset.getFieldset().setOutputMarkupId(true);
    }
    gridBuilder.newGridPanel();
    {
        final ToggleContainerPanel extendedSettingsPanel = new ToggleContainerPanel(gridBuilder.getPanel().newChildId());
        extendedSettingsPanel.setHeading(getString("plugins.teamcal.event.expertSettings"));
        gridBuilder.getPanel().add(extendedSettingsPanel);
        extendedSettingsPanel.setClosed();
        final GridBuilder innerGridBuilder = extendedSettingsPanel.createGridBuilder();
        {
            // Until. Only visible if recurrenceData.interval != NONE.
            recurrenceExDateFieldset = innerGridBuilder.newFieldset(getString("plugins.teamcal.event.recurrence.exDate"));
            recurrenceExDateFieldset.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, new PropertyModel<>(data, "recurrenceExDate"), 4000));
            recurrenceExDateFieldset.getFieldset().setOutputMarkupId(true);
            recurrenceExDateFieldset.addHelpIcon(getString("plugins.teamcal.event.recurrence.exDate.tooltip"));
        }
        {
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("plugins.teamcal.event.uid"));
            fs.add(new LabelPanel(fs.getTextFieldId(), new PropertyModel<>(data, "uid")));
        }
        {
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("plugins.teamcal.event.ownership"));
            fs.addCheckBox(new PropertyModel<>(data, "ownership"), null);
            fs.addHelpIcon(getString("plugins.teamcal.event.ownership.tooltip"));
        }
    }
    gridBuilder.newGridPanel();
    if (parentPage.getRecurrencyChangeType() != null) {
        final FieldsetPanel fs = gridBuilder.newFieldset((String) null).setLabelSide(false).suppressLabelForWarning();
        fs.add(new DivTextPanel(fs.newChildId(), getString("plugins.teamcal.event.recurrence.change.text") + " " + getString(parentPage.getRecurrencyChangeType().getI18nKey()) + "."));
    }
    setRecurrenceComponentsVisibility(null);
    addCloneButton();
    add(new IFormValidator() {

        @Override
        public FormComponent<?>[] getDependentFormComponents() {
            return dependentFormComponents;
        }

        @Override
        public void validate(final Form<?> form) {
            final DateHolder startDate = new DateHolder(startDateTimePanel.getConvertedInput());
            final DateHolder endDate = new DateHolder(endDateTimePanel.getConvertedInput());
            data.setStartDate(startDate.getUtilDate());
            data.setEndDate(endDate.getUtilDate());
            if (data.getDuration() < 60000) {
                // Duration is less than 60 seconds.
                error(getString("plugins.teamcal.event.duration.error"));
            }
        }
    });
}
Also used : RecurrenceFrequency(org.projectforge.framework.time.RecurrenceFrequency) TeamEventDO(org.projectforge.business.teamcal.event.model.TeamEventDO) PFAutoCompleteMaxLengthTextField(org.projectforge.web.wicket.autocompletion.PFAutoCompleteMaxLengthTextField) MultiChoiceListHelper(org.projectforge.web.common.MultiChoiceListHelper) List(java.util.List) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) TeamEventAttendeeDO(org.projectforge.business.teamcal.event.model.TeamEventAttendeeDO) DateHolder(org.projectforge.framework.time.DateHolder) IFormValidator(org.apache.wicket.markup.html.form.validation.IFormValidator) PFAutoCompleteMaxLengthTextField(org.projectforge.web.wicket.autocompletion.PFAutoCompleteMaxLengthTextField) PropertyModel(org.apache.wicket.model.PropertyModel) AttendeeWicketProvider(org.projectforge.web.user.AttendeeWicketProvider) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) Select2MultiChoice(org.wicketstuff.select2.Select2MultiChoice) TeamCalDO(org.projectforge.business.teamcal.admin.model.TeamCalDO)

Aggregations

PropertyModel (org.apache.wicket.model.PropertyModel)6 MultiChoiceListHelper (org.projectforge.web.common.MultiChoiceListHelper)6 Select2MultiChoice (org.wicketstuff.select2.Select2MultiChoice)6 Collection (java.util.Collection)4 List (java.util.List)3 UsersComparator (org.projectforge.business.user.UsersComparator)3 PFUserDO (org.projectforge.framework.persistence.user.entities.PFUserDO)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)2 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)2 ResourceModel (org.apache.wicket.model.ResourceModel)2 TeamCalDO (org.projectforge.business.teamcal.admin.model.TeamCalDO)2 UsersProvider (org.projectforge.web.user.UsersProvider)2 PFAutoCompleteMaxLengthTextField (org.projectforge.web.wicket.autocompletion.PFAutoCompleteMaxLengthTextField)2 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)2 Set (java.util.Set)1 Function (java.util.function.Function)1 Label (org.apache.wicket.markup.html.basic.Label)1 IChoiceRenderer (org.apache.wicket.markup.html.form.IChoiceRenderer)1 SubmitLink (org.apache.wicket.markup.html.form.SubmitLink)1