Search in sources :

Example 1 with DateTimeField

use of org.apache.wicket.extensions.yui.calendar.DateTimeField in project midpoint by Evolveum.

the class PageTaskAdd method initScheduling.

private void initScheduling(final Form mainForm) {
    final WebMarkupContainer container = new WebMarkupContainer(ID_CONTAINER);
    container.setOutputMarkupId(true);
    mainForm.add(container);
    final IModel<Boolean> recurringCheck = new PropertyModel<>(model, TaskAddDto.F_RECURRING);
    final IModel<Boolean> boundCheck = new PropertyModel<>(model, TaskAddDto.F_BOUND);
    final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
    boundContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheck.getObject();
        }
    });
    boundContainer.setOutputMarkupId(true);
    container.add(boundContainer);
    final WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
    intervalContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheck.getObject();
        }
    });
    intervalContainer.setOutputMarkupId(true);
    container.add(intervalContainer);
    final WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
    cronContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheck.getObject() && !boundCheck.getObject();
        }
    });
    cronContainer.setOutputMarkupId(true);
    container.add(cronContainer);
    AjaxCheckBox recurring = new AjaxCheckBox(ID_RECURRING, recurringCheck) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(container);
        }
    };
    mainForm.add(recurring);
    AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND, boundCheck) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(container);
        }
    };
    boundContainer.add(bound);
    Label boundHelp = new Label(ID_BOUND_HELP);
    boundHelp.add(new InfoTooltipBehavior());
    boundContainer.add(boundHelp);
    TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(model, TaskAddDto.F_INTERVAL));
    interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    intervalContainer.add(interval);
    TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(model, TaskAddDto.F_CRON));
    cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    //		if (recurringCheck.getObject() && !boundCheck.getObject()) {
    //			cron.setRequired(true);
    //		}
    cronContainer.add(cron);
    Label cronHelp = new Label(ID_CRON_HELP);
    cronHelp.add(new InfoTooltipBehavior());
    cronContainer.add(cronHelp);
    final DateTimeField notStartBefore = new DateTimeField(ID_NO_START_BEFORE_FIELD, new PropertyModel<Date>(model, TaskAddDto.F_NOT_START_BEFORE)) {

        @Override
        protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) {
            // todo i18n
            return DateTextField.forDatePattern(id, dateFieldModel, "dd/MMM/yyyy");
        }
    };
    notStartBefore.setOutputMarkupId(true);
    mainForm.add(notStartBefore);
    final DateTimeField notStartAfter = new DateTimeField(ID_NO_START_AFTER_FIELD, new PropertyModel<Date>(model, TaskAddDto.F_NOT_START_AFTER)) {

        @Override
        protected DateTextField newDateTextField(String id, PropertyModel dateFieldModel) {
            // todo i18n
            return DateTextField.forDatePattern(id, dateFieldModel, "dd/MMM/yyyy");
        }
    };
    notStartAfter.setOutputMarkupId(true);
    mainForm.add(notStartAfter);
    mainForm.add(new StartEndDateValidator(notStartBefore, notStartAfter));
    mainForm.add(new ScheduleValidator(getTaskManager(), recurring, bound, interval, cron));
}
Also used : StartEndDateValidator(com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator) ScheduleValidator(com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator) PropertyModel(org.apache.wicket.model.PropertyModel) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) Date(java.util.Date) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) DateTextField(org.apache.wicket.datetime.markup.html.form.DateTextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 2 with DateTimeField

use of org.apache.wicket.extensions.yui.calendar.DateTimeField in project midpoint by Evolveum.

the class PrismValuePanel method createInputComponent.

private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();
    ObjectWrapper objectWrapper = null;
    if (valueWrapper.getItem().getContainer() != null) {
        objectWrapper = valueWrapper.getItem().getContainer().getObject();
    }
    Item property = valueWrapper.getItem().getItem();
    boolean required = property.getDefinition().getMinOccurs() > 0;
    Panel component = createTypedInputComponent(id);
    if (component instanceof InputPanel) {
        InputPanel inputPanel = (InputPanel) component;
        //adding valid from/to date range validator, if necessary
        ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
        if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
        } else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
            DateValidator validator = WebComponentUtil.getRangeValidator(form, activation);
            validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
        }
        final List<FormComponent> formComponents = inputPanel.getFormComponents();
        for (FormComponent formComponent : formComponents) {
            formComponent.setLabel(labelModel);
            formComponent.setRequired(required);
            if (formComponent instanceof TextField) {
                formComponent.add(new AttributeModifier("size", "42"));
            }
            formComponent.add(new AjaxFormComponentUpdatingBehavior("blur") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
        // Validation occurs when submitting the form
        //            if (form != null) {
        //                AjaxFormValidatingBehavior validator = new AjaxFormValidatingBehavior(form, "Blur"); 
        //                 
        //                formComponent.add(validator);
        //            }
        }
    }
    if (component == null) {
        throw new RuntimeException("Cannot create input component for item " + property + " (" + valueWrapper + ") in " + objectWrapper);
    }
    return component;
}
Also used : DateValidator(com.evolveum.midpoint.web.util.DateValidator) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) FormComponent(org.apache.wicket.markup.html.form.FormComponent) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField) AttributeModifier(org.apache.wicket.AttributeModifier) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) LockoutStatusPanel(com.evolveum.midpoint.web.component.LockoutStatusPanel) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) AutoCompleteTextPanel(com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel) ValueChoosePanel(com.evolveum.midpoint.web.component.form.ValueChoosePanel) PasswordPanel(com.evolveum.midpoint.gui.api.component.password.PasswordPanel) ModificationsPanel(com.evolveum.midpoint.web.component.model.delta.ModificationsPanel) Panel(org.apache.wicket.markup.html.panel.Panel) AssociationValueChoicePanel(com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel) TextField(org.apache.wicket.markup.html.form.TextField) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 3 with DateTimeField

use of org.apache.wicket.extensions.yui.calendar.DateTimeField in project midpoint by Evolveum.

the class DatePanelFactory method getPanel.

@Override
protected InputPanel getPanel(PrismPropertyPanelContext<XMLGregorianCalendar> panelCtx) {
    DatePanel panel = new DatePanel(panelCtx.getComponentId(), panelCtx.getRealValueModel());
    Form<?> form = Form.findForm(panelCtx.getForm());
    DateValidator validator;
    String validatorErrorMessageKey;
    if (ScheduleType.F_EARLIEST_START_TIME.equals(panelCtx.getDefinitionName()) || ScheduleType.F_LATEST_START_TIME.equals(panelCtx.getDefinitionName())) {
        validator = WebComponentUtil.getRangeValidator(form, TaskType.F_SCHEDULE);
        validatorErrorMessageKey = "ScheduleType.dateValidator.errorMessage";
    } else {
        validator = WebComponentUtil.getRangeValidator(form, SchemaConstants.PATH_ACTIVATION);
        validatorErrorMessageKey = "DateValidator.message.fromAfterTo";
    }
    if (ActivationType.F_VALID_FROM.equals(panelCtx.getDefinitionName()) || ScheduleType.F_EARLIEST_START_TIME.equals(panelCtx.getDefinitionName())) {
        validator.setDateFrom((DateTimeField) panel.getBaseFormComponent());
    } else if (ActivationType.F_VALID_TO.equals(panelCtx.getDefinitionName()) || ScheduleType.F_LATEST_START_TIME.equals(panelCtx.getDefinitionName())) {
        validator.setDateTo((DateTimeField) panel.getBaseFormComponent());
    }
    validator.setMessageKey(validatorErrorMessageKey);
    return panel;
}
Also used : DateValidator(com.evolveum.midpoint.web.util.DateValidator) DatePanel(com.evolveum.midpoint.web.component.input.DatePanel) DateTimeField(org.apache.wicket.extensions.yui.calendar.DateTimeField)

Aggregations

DateTimeField (org.apache.wicket.extensions.yui.calendar.DateTimeField)3 DateValidator (com.evolveum.midpoint.web.util.DateValidator)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AutoCompleteTextField (org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField)2 TextField (org.apache.wicket.markup.html.form.TextField)2 AutoCompleteTextPanel (com.evolveum.midpoint.gui.api.component.autocomplete.AutoCompleteTextPanel)1 PasswordPanel (com.evolveum.midpoint.gui.api.component.password.PasswordPanel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 LockoutStatusPanel (com.evolveum.midpoint.web.component.LockoutStatusPanel)1 ValueChoosePanel (com.evolveum.midpoint.web.component.form.ValueChoosePanel)1 DatePanel (com.evolveum.midpoint.web.component.input.DatePanel)1 ModificationsPanel (com.evolveum.midpoint.web.component.model.delta.ModificationsPanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 ScheduleValidator (com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator)1 StartEndDateValidator (com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator)1 AssociationValueChoicePanel (com.evolveum.midpoint.web.page.admin.users.component.AssociationValueChoicePanel)1 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)1 Date (java.util.Date)1 AttributeModifier (org.apache.wicket.AttributeModifier)1 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)1