Search in sources :

Example 1 with GridBuilder

use of org.projectforge.web.wicket.bootstrap.GridBuilder in project projectforge by micromata.

the class ModalDialog method init.

@SuppressWarnings("serial")
protected void init(final Form<?> form) {
    this.form = form;
    csrfTokenHandler = new CsrfTokenHandler(form);
    mainSubContainer.add(form);
    form.add(gridContentContainer);
    form.add(buttonBarContainer);
    if (showCancelButton == true) {
        final SingleButtonPanel cancelButton = appendNewAjaxActionButton(new AjaxCallback() {

            @Override
            public void callback(final AjaxRequestTarget target) {
                csrfTokenHandler.onSubmit();
                onCancelButtonSubmit(target);
                close(target);
            }
        }, getString("cancel"), SingleButtonPanel.CANCEL);
        cancelButton.getButton().setDefaultFormProcessing(false);
    }
    closeButtonPanel = appendNewAjaxActionButton(new AjaxFormSubmitCallback() {

        @Override
        public void callback(final AjaxRequestTarget target) {
            csrfTokenHandler.onSubmit();
            if (onCloseButtonSubmit(target)) {
                close(target);
            }
        }

        @Override
        public void onError(final AjaxRequestTarget target, final Form<?> form) {
            csrfTokenHandler.onSubmit();
            ModalDialog.this.onError(target, form);
        }
    }, closeButtonLabel != null ? closeButtonLabel : getString("close"), SingleButtonPanel.NORMAL);
    buttonBarContainer.add(actionButtons.getRepeatingView());
    form.setDefaultButton(closeButtonPanel.getButton());
    if (autoGenerateGridBuilder == true) {
        gridBuilder = new GridBuilder(gridContentContainer, "flowform");
    }
    initFeedback(gridContentContainer);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) CsrfTokenHandler(org.projectforge.web.wicket.CsrfTokenHandler) Form(org.apache.wicket.markup.html.form.Form) AjaxFormSubmitCallback(de.micromata.wicket.ajax.AjaxFormSubmitCallback) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel) AjaxCallback(de.micromata.wicket.ajax.AjaxCallback)

Example 2 with GridBuilder

use of org.projectforge.web.wicket.bootstrap.GridBuilder in project projectforge by micromata.

the class SetupForm method init.

@Override
@SuppressWarnings("serial")
protected void init() {
    add(createFeedbackPanel());
    final GridBuilder gridBuilder = newGridBuilder(this, "flowform");
    gridBuilder.newFormHeading(getString("administration.setup.heading"));
    final DivPanel panel = gridBuilder.getPanel();
    panel.add(new ParTextPanel(panel.newChildId(), getString("administration.setup.heading.subtitle")));
    {
        // RadioChoice mode
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.setup.target"));
        final DivPanel radioPanel = fs.addNewRadioBoxButtonDiv();
        fs.add(radioPanel);
        fs.setLabelFor(radioPanel);
        final RadioGroupPanel<SetupTarget> radioGroup = new RadioGroupPanel<>(radioPanel.newChildId(), "setuptarget", setupModeModel);
        radioPanel.add(radioGroup);
        for (final SetupTarget target : SetupTarget.values()) {
            radioGroup.add(new Model<SetupTarget>(target), getString(target.getI18nKey()), getString(target.getI18nKey() + ".tooltip"));
        }
    }
    // final RequiredMaxLengthTextField organizationField = new RequiredMaxLengthTextField(this, "organization", getString("organization"),
    // new PropertyModel<String>(this, "organization"), 100);
    // add(organizationField);
    {
        // User name
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("username"));
        RequiredMaxLengthTextField usernameTextField = new RequiredMaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<String>(adminUser, "username"), 100);
        usernameTextField.setMarkupId("username");
        usernameTextField.setOutputMarkupId(true);
        fs.add(usernameTextField);
    }
    final PasswordTextField passwordField = createPasswordField();
    passwordField.setMarkupId("password").setOutputMarkupId(true);
    {
        // Password
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("password"));
        // No setReset(true), otherwise uploading and re-entering passwords is a real pain.
        passwordField.setRequired(true);
        fs.add(passwordField);
        WicketUtils.setFocus(passwordField);
    }
    {
        // Password repeat
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("passwordRepeat"));
        final PasswordTextField passwordRepeatField = createPasswordField();
        // No setReset(true), otherwise uploading and re-entering passwords is a real pain.
        passwordRepeatField.setRequired(true);
        passwordRepeatField.setMarkupId("passwordRepeat").setOutputMarkupId(true);
        passwordRepeatField.add((IValidator<String>) validatable -> {
            final String input = validatable.getValue();
            final String passwordInput = passwordField.getConvertedInput();
            if (StringUtils.equals(input, passwordInput) == false) {
                passwordRepeatField.error(getString("user.error.passwordAndRepeatDoesNotMatch"));
                adminUser.setPassword(null);
                return;
            }
            if (MAGIC_PASSWORD.equals(passwordInput) == false || adminUser.getPassword() == null) {
                final List<I18nKeyAndParams> errorMsgKeys = passwordQualityService.checkPasswordQuality(passwordInput.toCharArray());
                if (errorMsgKeys.isEmpty() == false) {
                    adminUser.setPassword(null);
                    for (I18nKeyAndParams errorMsgKey : errorMsgKeys) {
                        passwordField.error(I18nHelper.getLocalizedMessage(errorMsgKey));
                    }
                } else {
                    userService.createEncryptedPassword(adminUser, passwordInput.toCharArray());
                }
            }
        });
        fs.add(passwordRepeatField);
    }
    {
        // Time zone
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.param.timezone"));
        final TimeZonePanel timeZone = new TimeZonePanel(fs.newChildId(), new PropertyModel<>(this, "timeZone"));
        fs.setLabelFor(timeZone);
        fs.add(timeZone);
        fs.addHelpIcon(getString("administration.configuration.param.timezone.description"));
    }
    {
        // Calendar domain
        calendarDomainModel.setObject("local");
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.param.calendarDomain"));
        final RequiredMaxLengthTextField textField = new RequiredMaxLengthTextField(InputPanel.WICKET_ID, calendarDomainModel, ConfigurationDO.Companion.getParamLength());
        fs.add(textField);
        textField.setMarkupId("calendarDomain").setOutputMarkupId(true);
        textField.add(new IValidator<String>() {

            @Override
            public void validate(final IValidatable<String> validatable) {
                if (Configuration.isDomainValid(validatable.getValue()) == false) {
                    textField.error(getString("validation.error.generic"));
                }
            }
        });
        fs.addHelpIcon(getString("administration.configuration.param.calendarDomain.description"));
    }
    {
        // E-Mail sysops
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.param.systemAdministratorEMail.label"), getString("email"));
        fs.add(new MaxLengthTextField(InputPanel.WICKET_ID, sysopEMailModel, ConfigurationDO.Companion.getParamLength()));
        fs.addHelpIcon(getString("administration.configuration.param.systemAdministratorEMail.description"));
    }
    {
        // E-Mail sysops
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("administration.configuration.param.feedbackEMail.label"), getString("email"));
        fs.add(new MaxLengthTextField(InputPanel.WICKET_ID, feedbackEMailModel, ConfigurationDO.Companion.getParamLength()));
        fs.addHelpIcon(getString("administration.configuration.param.feedbackEMail.description"));
    }
    final RepeatingView actionButtons = new RepeatingView("buttons");
    add(actionButtons);
    {
        final Button finishButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("finish")) {

            @Override
            public final void onSubmit() {
                csrfTokenHandler.onSubmit();
                parentPage.finishSetup();
            }
        };
        finishButton.setMarkupId("finish").setOutputMarkupId(true);
        final SingleButtonPanel finishButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), finishButton, getString("administration.setup.finish"), SingleButtonPanel.DEFAULT_SUBMIT);
        actionButtons.add(finishButtonPanel);
        setDefaultButton(finishButton);
    }
}
Also used : PropertyModel(org.apache.wicket.model.PropertyModel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) TimeZonePanel(org.projectforge.web.wicket.components.TimeZonePanel) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) IValidatable(org.apache.wicket.validation.IValidatable) GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) IValidator(org.apache.wicket.validation.IValidator) Button(org.apache.wicket.markup.html.form.Button) MaxLengthTextField(org.projectforge.web.wicket.components.MaxLengthTextField) RequiredMaxLengthTextField(org.projectforge.web.wicket.components.RequiredMaxLengthTextField) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) I18nKeyAndParams(org.projectforge.framework.i18n.I18nKeyAndParams) RequiredMaxLengthTextField(org.projectforge.web.wicket.components.RequiredMaxLengthTextField) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Example 3 with GridBuilder

use of org.projectforge.web.wicket.bootstrap.GridBuilder in project projectforge by micromata.

the class HRPlanningEditForm method refresh.

@SuppressWarnings("serial")
void refresh() {
    if (hasError() == true) {
        // Do nothing.
        return;
    }
    if (data.hasDeletedEntries() == false) {
        this.showDeletedOnly = false;
    }
    if (isNew() == true) {
        this.predecessorUpdToDate = false;
    }
    entriesRepeater.removeAll();
    if (CollectionUtils.isEmpty(data.getEntries()) == true) {
        // Ensure that at least one entry is available:
        data.addEntry(new HRPlanningEntryDO());
    }
    projektSelectPanels.clear();
    int idx = -1;
    dependentEntryFormComponents.clear();
    dependentEntryFormComponentsArray = null;
    int uiId = -1;
    for (final HRPlanningEntryDO entry : data.getEntries()) {
        ++idx;
        ++uiId;
        if (entry.isDeleted() != showDeletedOnly) {
            // Don't show deleted/undeleted entries.
            --uiId;
            continue;
        }
        final ToggleContainerPanel positionsPanel = new ToggleContainerPanel(entriesRepeater.newChildId());
        positionsPanel.getContainer().setOutputMarkupId(true);
        entriesRepeater.add(positionsPanel);
        String heading = escapeHtml(entry.getProjektNameOrStatus());
        if (StringUtils.isBlank(heading) == true) {
            heading = "???";
        }
        final BigDecimal totalHours = entry.getTotalHours();
        if (NumberHelper.isNotZero(totalHours) == true) {
            heading += ": " + NumberHelper.formatFraction2(totalHours);
        }
        positionsPanel.setHeading(new HtmlCodePanel(ToggleContainerPanel.HEADING_TEXT_ID, heading));
        final DivPanel content = new DivPanel(ToggleContainerPanel.CONTENT_ID);
        positionsPanel.add(content);
        final GridBuilder posGridBuilder = new GridBuilder(content, content.newChildId());
        {
            // DropDownChoice status / project
            final FieldsetPanel fs = posGridBuilder.newFieldset(WicketUtils.createMultipleFieldsetLabel(getString("status"), getString("fibu.projekt")));
            final LabelValueChoiceRenderer<HRPlanningEntryStatus> statusChoiceRenderer = new LabelValueChoiceRenderer<HRPlanningEntryStatus>(fs, HRPlanningEntryStatus.values());
            final DropDownChoice<HRPlanningEntryStatus> statusChoice = new DropDownChoice<HRPlanningEntryStatus>(fs.getDropDownChoiceId(), new PropertyModel<HRPlanningEntryStatus>(entry, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer);
            statusChoice.setNullValid(true).setRequired(false).setEnabled(!entry.isDeleted());
            fs.add(statusChoice);
            dependentEntryFormComponents.add(statusChoice);
            final NewProjektSelectPanel projektSelectPanel = new NewProjektSelectPanel(fs.newChildId(), new PropertyModel<ProjektDO>(entry, "projekt"), parentPage, "projektId:" + idx + ":" + uiId);
            projektSelectPanel.setRequired(false).setEnabled(!entry.isDeleted());
            fs.add(projektSelectPanel);
            projektSelectPanel.init();
            dependentEntryFormComponents.add(projektSelectPanel);
            projektSelectPanels.add(projektSelectPanel);
            final Button button = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("deleteUndelete")) {

                @Override
                public final void onSubmit() {
                    if (entry.isDeleted() == true) {
                        // Undelete
                        entry.setDeleted(false);
                    } else {
                        getData().deleteEntry(entry);
                    }
                    refresh();
                }
            };
            final String buttonLabel, classNames;
            if (entry.isDeleted() == true) {
                buttonLabel = getString("undelete");
                classNames = SingleButtonPanel.NORMAL;
            } else {
                buttonLabel = getString("delete");
                classNames = SingleButtonPanel.DELETE;
                if (entry.getId() != null) {
                    button.add(AttributeModifier.prepend("onclick", "if (showDeleteQuestionDialog() == false) return false;"));
                }
            }
            button.setDefaultFormProcessing(false);
            fs.add(new SingleButtonPanel(fs.newChildId(), button, buttonLabel, classNames) {
            });
        }
        posGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // DropDownChoice Priority
            final FieldsetPanel fs = posGridBuilder.newFieldset(getString("hr.planning.priority"));
            final LabelValueChoiceRenderer<Priority> priorityChoiceRenderer = new LabelValueChoiceRenderer<Priority>(fs, Priority.values());
            final DropDownChoice<Priority> priorityChoice = new DropDownChoice<Priority>(fs.getDropDownChoiceId(), new PropertyModel<Priority>(entry, "priority"), priorityChoiceRenderer.getValues(), priorityChoiceRenderer);
            priorityChoice.setNullValid(true).setEnabled(!entry.isDeleted());
            fs.add(priorityChoice);
        }
        posGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // DropDownChoice probability
            final FieldsetPanel fs = posGridBuilder.newFieldset(getString("hr.planning.probability"));
            final LabelValueChoiceRenderer<Integer> probabilityChoiceRenderer = new LabelValueChoiceRenderer<Integer>();
            probabilityChoiceRenderer.addValue(25, "25%");
            probabilityChoiceRenderer.addValue(50, "50%");
            probabilityChoiceRenderer.addValue(75, "75%");
            probabilityChoiceRenderer.addValue(95, "95%");
            probabilityChoiceRenderer.addValue(100, "100%");
            final DropDownChoice<Integer> probabilityChoice = new DropDownChoice<Integer>(fs.getDropDownChoiceId(), new PropertyModel<Integer>(entry, "probability"), probabilityChoiceRenderer.getValues(), probabilityChoiceRenderer);
            probabilityChoice.setNullValid(true).setEnabled(!entry.isDeleted());
            fs.add(probabilityChoice);
        }
        posGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // Hours
            final FieldsetPanel fs = posGridBuilder.newFieldset(getString("hours")).suppressLabelForWarning();
            final HRPlanningEditTablePanel table = new HRPlanningEditTablePanel(fs.newChildId());
            fs.add(table);
            table.init(entry);
        }
        posGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // Description
            final FieldsetPanel fs = posGridBuilder.newFieldset(getString("hr.planning.description"));
            final IModel<String> model = new PropertyModel<String>(entry, "description");
            final MaxLengthTextArea description = new MaxLengthTextArea(TextAreaPanel.WICKET_ID, model);
            if (entry.isDeleted() == true) {
                description.setEnabled(false);
            }
            fs.add(description);
            fs.add(new JiraIssuesPanel(fs.newChildId(), entry.getDescription()));
            fs.addJIRAField(model);
        }
    }
}
Also used : NewProjektSelectPanel(org.projectforge.web.fibu.NewProjektSelectPanel) Button(org.apache.wicket.markup.html.form.Button) IModel(org.apache.wicket.model.IModel) Priority(org.projectforge.common.i18n.Priority) PropertyModel(org.apache.wicket.model.PropertyModel) BigDecimal(java.math.BigDecimal) GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 4 with GridBuilder

use of org.projectforge.web.wicket.bootstrap.GridBuilder in project projectforge by micromata.

the class TaskEditForm method init.

@SuppressWarnings("serial")
@Override
protected void init() {
    super.init();
    add(new IFormValidator() {

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

        @SuppressWarnings("unchecked")
        @Override
        public void validate(final Form<?> form) {
            final MinMaxNumberField<BigDecimal> durationField = (MinMaxNumberField<BigDecimal>) dependentFormComponents[0];
            final LocalDatePanel endDate = (LocalDatePanel) dependentFormComponents[1];
            if (durationField.getConvertedInput() != null && endDate.getDateField().getConvertedInput() != null) {
                error(getString("gantt.error.durationAndEndDateAreMutuallyExclusive"));
            }
        }
    });
    gridBuilder.newGridPanel();
    {
        // Parent task
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task.parentTask"));
        final TaskSelectPanel parentTaskSelectPanel = new TaskSelectPanel(fs, new PropertyModel<>(data, "parentTask"), parentPage, "parentTaskId");
        fs.add(parentTaskSelectPanel);
        fs.getFieldset().setOutputMarkupId(true);
        parentTaskSelectPanel.init();
        if (!TaskTree.getInstance().isRootNode(data)) {
            parentTaskSelectPanel.setRequired(true);
        } else {
            fs.setVisible(false);
        }
        parentTaskSelectPanel.setRequired(true);
    }
    {
        // Title
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task.title"));
        final MaxLengthTextField title = new RequiredMaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "title"));
        WicketUtils.setStrong(title);
        fs.add(title);
        if (isNew()) {
            WicketUtils.setFocus(title);
        }
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        // Status drop down box:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("status"));
        final LabelValueChoiceRenderer<TaskStatus> statusChoiceRenderer = new LabelValueChoiceRenderer<>(fs, TaskStatus.values());
        final DropDownChoice<TaskStatus> statusChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "status"), statusChoiceRenderer.getValues(), statusChoiceRenderer);
        statusChoice.setNullValid(false).setRequired(true);
        fs.add(statusChoice);
    }
    {
        // Assigned user:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task.assignedUser"));
        PFUserDO responsibleUser = data.getResponsibleUser();
        if (!Hibernate.isInitialized(responsibleUser)) {
            responsibleUser = UserGroupCache.getInstance().getUser(responsibleUser.getId());
            data.setResponsibleUser(responsibleUser);
        }
        final UserSelectPanel responsibleUserSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<>(data, "responsibleUser"), parentPage, "responsibleUserId");
        fs.add(responsibleUserSelectPanel);
        responsibleUserSelectPanel.init();
    }
    gridBuilder.newSplitPanel(GridSize.COL50);
    {
        // Priority drop down box:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("priority"));
        final LabelValueChoiceRenderer<Priority> priorityChoiceRenderer = new LabelValueChoiceRenderer<>(fs, Priority.values());
        final DropDownChoice<Priority> priorityChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "priority"), priorityChoiceRenderer.getValues(), priorityChoiceRenderer);
        priorityChoice.setNullValid(true);
        fs.add(priorityChoice);
    }
    {
        // Max hours:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task.maxHours"));
        final MinMaxNumberField<Integer> maxNumberField = new MinMaxNumberField<>(InputPanel.WICKET_ID, new PropertyModel<>(data, "maxHours"), 0, 9999);
        WicketUtils.setSize(maxNumberField, 6);
        fs.add(maxNumberField);
        if (!isNew() && TaskTree.getInstance().hasOrderPositions(data.getId(), true)) {
            WicketUtils.setWarningTooltip(maxNumberField);
            WicketUtils.addTooltip(maxNumberField, getString("task.edit.maxHoursIngoredDueToAssignedOrders"));
        }
    }
    gridBuilder.newGridPanel();
    {
        // Short description:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("shortDescription"));
        final IModel<String> model = new PropertyModel<>(data, "shortDescription");
        fs.add(new MaxLengthTextField(InputPanel.WICKET_ID, model));
        fs.addJIRAField(model);
    }
    {
        // Reference
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("task.reference"));
        fs.add(new MaxLengthTextField(InputPanel.WICKET_ID, new PropertyModel<>(data, "reference")));
    }
    // ///////////////////////////////
    // GANTT
    // ///////////////////////////////
    gridBuilder.newGridPanel();
    {
        final ToggleContainerPanel extendedSettingsPanel = new ToggleContainerPanel(gridBuilder.getPanel().newChildId()) {

            /**
             * @see org.projectforge.web.wicket.flowlayout.ToggleContainerPanel#wantsOnStatusChangedNotification()
             */
            @Override
            protected boolean wantsOnStatusChangedNotification() {
                return true;
            }
        };
        extendedSettingsPanel.setHeading(getString("task.gantt.settings"));
        gridBuilder.getPanel().add(extendedSettingsPanel);
        extendedSettingsPanel.setClosed();
        final GridBuilder innerGridBuilder = extendedSettingsPanel.createGridBuilder();
        innerGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // Gantt object type:
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.objectType"));
            final LabelValueChoiceRenderer<GanttObjectType> objectTypeChoiceRenderer = new LabelValueChoiceRenderer<>(fs, GanttObjectType.values());
            final DropDownChoice<GanttObjectType> objectTypeChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "ganttObjectType"), objectTypeChoiceRenderer.getValues(), objectTypeChoiceRenderer);
            objectTypeChoice.setNullValid(true);
            fs.add(objectTypeChoice);
        }
        {
            // Gantt: start date
            final FieldProperties<LocalDate> props = getStartDateProperties();
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.startDate"));
            LocalDatePanel components = new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel()));
            fs.add(components);
        }
        {
            // Gantt: end date
            final FieldProperties<LocalDate> props = getEndDateProperties();
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.endDate"));
            LocalDatePanel components = new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel()));
            fs.add(components);
            dependentFormComponents[1] = components;
        }
        innerGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // Progress
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("task.progress")).setUnit("%");
            final MinMaxNumberField<Integer> progressField = new MinMaxNumberField<Integer>(InputPanel.WICKET_ID, new PropertyModel<>(data, "progress"), 0, 100) {

                @SuppressWarnings({ "unchecked", "rawtypes" })
                @Override
                public IConverter getConverter(final Class type) {
                    return new IntegerPercentConverter(0);
                }
            };
            WicketUtils.setSize(progressField, 3);
            fs.add(progressField);
        }
        {
            // Gantt: duration
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.duration")).suppressLabelForWarning();
            final MinMaxNumberField<BigDecimal> durationField = new MinMaxNumberField<>(InputPanel.WICKET_ID, new PropertyModel<>(data, "duration"), BigDecimal.ZERO, TaskEditForm.MAX_DURATION_DAYS);
            WicketUtils.setSize(durationField, 6);
            fs.add(durationField);
            dependentFormComponents[0] = durationField;
        }
        {
            // Gantt: predecessor offset
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.predecessorOffset")).setUnit(getString("days"));
            final MinMaxNumberField<Integer> ganttPredecessorField = new MinMaxNumberField<>(InputPanel.WICKET_ID, new PropertyModel<>(data, "ganttPredecessorOffset"), Integer.MIN_VALUE, Integer.MAX_VALUE);
            WicketUtils.setSize(ganttPredecessorField, 6);
            fs.add(ganttPredecessorField);
        }
        innerGridBuilder.newGridPanel();
        {
            // Gantt relation type:
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.relationType"));
            final LabelValueChoiceRenderer<GanttRelationType> relationTypeChoiceRenderer = new LabelValueChoiceRenderer<>(fs, GanttRelationType.values());
            final DropDownChoice<GanttRelationType> relationTypeChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "ganttRelationType"), relationTypeChoiceRenderer.getValues(), relationTypeChoiceRenderer);
            relationTypeChoice.setNullValid(true);
            fs.add(relationTypeChoice);
        }
        {
            // Gantt: predecessor
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("gantt.predecessor"));
            final TaskSelectPanel ganttPredecessorSelectPanel = new TaskSelectPanel(fs, new PropertyModel<>(data, "ganttPredecessor"), parentPage, "ganttPredecessorId");
            fs.add(ganttPredecessorSelectPanel);
            ganttPredecessorSelectPanel.setShowFavorites(true);
            ganttPredecessorSelectPanel.init();
        }
    }
    // ///////////////////////////////
    // FINANCE ADMINISTRATION
    // ///////////////////////////////
    gridBuilder.newGridPanel();
    {
        final ToggleContainerPanel extendedSettingsPanel = new ToggleContainerPanel(gridBuilder.getPanel().newChildId()) {

            /**
             * @see org.projectforge.web.wicket.flowlayout.ToggleContainerPanel#wantsOnStatusChangedNotification()
             */
            @Override
            protected boolean wantsOnStatusChangedNotification() {
                return true;
            }
        };
        extendedSettingsPanel.setHeading(getString("financeAdministration"));
        gridBuilder.getPanel().add(extendedSettingsPanel);
        extendedSettingsPanel.setClosed();
        final GridBuilder innerGridBuilder = extendedSettingsPanel.createGridBuilder();
        innerGridBuilder.newSplitPanel(GridSize.COL50);
        if (Configuration.getInstance().isCostConfigured()) {
            // Cost 2 settings
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("fibu.kost2"));
            this.projektKostLabel = new DivTextPanel(fs.newChildId(), "");
            WicketUtils.addTooltip(projektKostLabel.getLabel(), new Model<String>() {

                @Override
                public String getObject() {
                    final List<Kost2DO> kost2DOs = TaskTree.getInstance().getKost2List(projekt, data, data.getKost2BlackWhiteItems(), data.getKost2IsBlackList());
                    final String[] kost2s = TaskListPage.getKost2s(kost2DOs);
                    if (kost2s == null || kost2s.length == 0) {
                        return " - (-)";
                    }
                    return StringHelper.listToString("\n", kost2s);
                }
            });
            fs.add(projektKostLabel);
            final PropertyModel<String> model = new PropertyModel<>(data, "kost2BlackWhiteList");
            kost2BlackWhiteTextField = new MaxLengthTextField(InputPanel.WICKET_ID, model);
            WicketUtils.setSize(kost2BlackWhiteTextField, 10);
            fs.add(kost2BlackWhiteTextField);
            final LabelValueChoiceRenderer<Boolean> kost2listTypeChoiceRenderer = // 
            new LabelValueChoiceRenderer<Boolean>().addValue(Boolean.FALSE, // 
            getString("task.kost2list.whiteList")).addValue(Boolean.TRUE, getString("task.kost2list.blackList"));
            kost2listTypeChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "kost2IsBlackList"), kost2listTypeChoiceRenderer.getValues(), kost2listTypeChoiceRenderer);
            kost2listTypeChoice.setNullValid(false);
            fs.add(kost2listTypeChoice);
            final Kost2SelectPanel kost2SelectPanel = new Kost2SelectPanel(fs.newChildId(), new PropertyModel<>(this, "kost2Id"), parentPage, "kost2Id") {

                @Override
                protected void beforeSelectPage(final PageParameters parameters) {
                    super.beforeSelectPage(parameters);
                    if (projekt != null) {
                        parameters.add(Kost2ListPage.PARAMETER_KEY_STORE_FILTER, false);
                        parameters.add(Kost2ListPage.PARAMETER_KEY_SEARCH_STRING, "nummer:" + projekt.getKost() + ".*");
                    }
                }
            };
            fs.add(kost2SelectPanel);
            kost2SelectPanel.init();
        }
        {
            // Time sheet booking status drop down box:
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("task.timesheetBooking"));
            final LabelValueChoiceRenderer<TimesheetBookingStatus> timesheetBookingStatusChoiceRenderer = new LabelValueChoiceRenderer<>(fs, TimesheetBookingStatus.values());
            timesheetBookingStatusChoice = new DropDownChoice<>(fs.getDropDownChoiceId(), new PropertyModel<>(data, "timesheetBookingStatus"), timesheetBookingStatusChoiceRenderer.getValues(), timesheetBookingStatusChoiceRenderer);
            timesheetBookingStatusChoice.setNullValid(false);
            fs.add(timesheetBookingStatusChoice);
        }
        innerGridBuilder.newSplitPanel(GridSize.COL50);
        {
            // Protection of privacy:
            innerGridBuilder.newFieldset(getString("task.protectionOfPrivacy")).addCheckBox(new PropertyModel<>(data, "protectionOfPrivacy"), null).setTooltip(getString("task.protectionOfPrivacy.tooltip"));
        }
        {
            // Protection until
            final FieldsetPanel fs = innerGridBuilder.newFieldset(getString("task.protectTimesheetsUntil"));
            final FieldProperties<LocalDate> props = getProtectionProperties();
            LocalDatePanel components = new LocalDatePanel(fs.newChildId(), new LocalDateModel(props.getModel()));
            fs.add(components);
            if (!UserGroupCache.getInstance().isUserMemberOfFinanceGroup()) {
                components.setEnabled(false);
            }
        }
    }
    gridBuilder.newGridPanel();
    {
        // Description:
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("description"));
        final IModel<String> model = new PropertyModel<>(data, "description");
        fs.add(new MaxLengthTextArea(TextAreaPanel.WICKET_ID, model), true);
        fs.addJIRAField(model);
    }
}
Also used : GanttRelationType(org.projectforge.business.gantt.GanttRelationType) LocalDate(java.time.LocalDate) TimesheetBookingStatus(org.projectforge.common.task.TimesheetBookingStatus) IFormValidator(org.apache.wicket.markup.html.form.validation.IFormValidator) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) IntegerPercentConverter(org.projectforge.web.wicket.converter.IntegerPercentConverter) Kost2SelectPanel(org.projectforge.web.fibu.Kost2SelectPanel) PFUserDO(org.projectforge.framework.persistence.user.entities.PFUserDO) UserSelectPanel(org.projectforge.web.user.UserSelectPanel) GanttObjectType(org.projectforge.business.gantt.GanttObjectType) Kost2DO(org.projectforge.business.fibu.kost.Kost2DO) IModel(org.apache.wicket.model.IModel) PropertyModel(org.apache.wicket.model.PropertyModel) BigDecimal(java.math.BigDecimal) GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Example 5 with GridBuilder

use of org.projectforge.web.wicket.bootstrap.GridBuilder in project projectforge by micromata.

the class ErrorForm method init.

@Override
@SuppressWarnings("serial")
protected void init() {
    super.init();
    add(createFeedbackPanel());
    final DivPanel errorMessagePanel = new DivPanel("errorMessage");
    add(errorMessagePanel);
    errorMessagePanel.add(new TextPanel(errorMessagePanel.newChildId(), new Model<String>() {

        @Override
        public String getObject() {
            return parentPage.errorMessage;
        }
    }));
    final GridBuilder gridBuilder = newGridBuilder(this, "flowform");
    gridBuilder.newGridPanel();
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("feedback.receiver")).suppressLabelForWarning();
        fs.add(new DivTextPanel(fs.newChildId(), data.getReceiver()));
    }
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("feedback.sender")).suppressLabelForWarning();
        fs.add(new DivTextPanel(fs.newChildId(), data.getSender()));
    }
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("errorpage.feedback.messageNumber")).suppressLabelForWarning();
        fs.add(new DivTextPanel(fs.newChildId(), data.getMessageNumber()));
    }
    {
        final FieldsetPanel fs = gridBuilder.newFieldset(getString("errorpage.feedback.description"));
        final MaxLengthTextArea description = new MaxLengthTextArea(fs.getTextAreaId(), new PropertyModel<String>(data, "description"), 4000);
        description.add(AttributeModifier.append("placeholder", getString("errorpage.feedback.placeholder")));
        WicketUtils.setFocus(description);
        fs.add(description, true);
    }
    actionButtons = new MyComponentsRepeater<SingleButtonPanel>("buttons");
    add(actionButtons.getRepeatingView());
    {
        final Button cancelButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("cancel")) {

            @Override
            public final void onSubmit() {
                parentPage.cancel();
            }
        };
        // No validation of the form.
        cancelButton.setDefaultFormProcessing(false);
        final SingleButtonPanel callButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), cancelButton, getString("cancel"), SingleButtonPanel.CANCEL);
        actionButtons.add(callButtonPanel);
    }
    {
        final Button sendButton = new Button(SingleButtonPanel.WICKET_ID, new Model<String>("send")) {

            @Override
            public final void onSubmit() {
                parentPage.sendFeedback();
            }
        };
        WicketUtils.addTooltip(sendButton, getString("feedback.send.title"));
        final SingleButtonPanel sendButtonPanel = new SingleButtonPanel(actionButtons.newChildId(), sendButton, getString("send"), SingleButtonPanel.DEFAULT_SUBMIT);
        actionButtons.add(sendButtonPanel);
        setDefaultButton(sendButton);
    }
}
Also used : GridBuilder(org.projectforge.web.wicket.bootstrap.GridBuilder) Button(org.apache.wicket.markup.html.form.Button) PropertyModel(org.apache.wicket.model.PropertyModel) Model(org.apache.wicket.model.Model) MaxLengthTextArea(org.projectforge.web.wicket.components.MaxLengthTextArea) PropertyModel(org.apache.wicket.model.PropertyModel) SingleButtonPanel(org.projectforge.web.wicket.components.SingleButtonPanel)

Aggregations

GridBuilder (org.projectforge.web.wicket.bootstrap.GridBuilder)15 PropertyModel (org.apache.wicket.model.PropertyModel)7 Button (org.apache.wicket.markup.html.form.Button)6 Model (org.apache.wicket.model.Model)6 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)5 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4 BigDecimal (java.math.BigDecimal)3 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)3 IModel (org.apache.wicket.model.IModel)3 SingleButtonPanel (org.projectforge.web.wicket.components.SingleButtonPanel)3 FieldsetPanel (org.projectforge.web.wicket.flowlayout.FieldsetPanel)3 List (java.util.List)2 Component (org.apache.wicket.Component)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 IFormValidator (org.apache.wicket.markup.html.form.validation.IFormValidator)2 RepeatingView (org.apache.wicket.markup.repeater.RepeatingView)2 ComponentWrapperPanel (org.projectforge.web.wicket.flowlayout.ComponentWrapperPanel)2 DivPanel (org.projectforge.web.wicket.flowlayout.DivPanel)2 AttrDescription (de.micromata.genome.db.jpa.tabattr.api.AttrDescription)1 AttrGroup (de.micromata.genome.db.jpa.tabattr.api.AttrGroup)1