Search in sources :

Example 1 with DateInput

use of com.evolveum.midpoint.web.component.DateInput in project midpoint by Evolveum.

the class TaskSchedulingTabPanel method initLayoutForSchedulingTable.

private void initLayoutForSchedulingTable() {
    // models
    final IModel<Boolean> recurringCheckModel = new PropertyModel<>(taskDtoModel, TaskDto.F_RECURRING);
    final IModel<Boolean> boundCheckModel = new PropertyModel<Boolean>(taskDtoModel, TaskDto.F_BOUND);
    // behaviors
    final VisibleEnableBehaviour visibleIfEditAndRunnableOrRunning = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return parentPage.isEdit() && parentPage.getTaskDto().isRunnableOrRunning();
        }
    };
    final VisibleEnableBehaviour visibleIfRecurringAndScheduleIsAccessible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && !boundCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && (!parentPage.getTaskDto().isRunnableOrRunning() || !boundCheckModel.getObject()) && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndNotRunningAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunning() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndScheduleIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_SCHEDULE));
        }
    };
    final VisibleEnableBehaviour enabledIfEditAndThreadStopIsEditable = new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && parentPage.isEditable(new ItemPath(TaskType.F_THREAD_STOP_ACTION));
        }
    };
    // components
    final WebMarkupContainer schedulingTable = new WebMarkupContainer(ID_SCHEDULING_TABLE);
    schedulingTable.setOutputMarkupId(true);
    add(schedulingTable);
    WebMarkupContainer recurringContainer = new WebMarkupContainer(ID_RECURRING_CONTAINER);
    AjaxCheckBox recurringCheck = new AjaxCheckBox(ID_RECURRING_CHECK, recurringCheckModel) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(schedulingTable);
        }
    };
    recurringCheck.setOutputMarkupId(true);
    recurringCheck.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_RECURRENCE);
        }
    });
    recurringContainer.add(recurringCheck);
    WebMarkupContainer suspendReqRecurring = new WebMarkupContainer(ID_SUSPEND_REQ_RECURRING);
    suspendReqRecurring.add(visibleIfEditAndRunnableOrRunning);
    recurringContainer.add(suspendReqRecurring);
    recurringContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_RECURRENCE));
    schedulingTable.add(recurringContainer);
    final WebMarkupContainer boundContainer = new WebMarkupContainer(ID_BOUND_CONTAINER);
    boundContainer.setOutputMarkupId(true);
    final AjaxCheckBox bound = new AjaxCheckBox(ID_BOUND_CHECK, boundCheckModel) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(schedulingTable);
        }
    };
    bound.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return parentPage.isEdit() && !parentPage.getTaskDto().isRunnableOrRunning() && parentPage.isEditable(TaskType.F_BINDING);
        }
    });
    boundContainer.add(bound);
    WebMarkupContainer suspendReqBound = new WebMarkupContainer(ID_SUSPEND_REQ_BOUND);
    suspendReqBound.add(visibleIfEditAndRunnableOrRunning);
    boundContainer.add(suspendReqBound);
    boundContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return recurringCheckModel.getObject() && parentPage.isReadable(new ItemPath(TaskType.F_BINDING));
        }
    });
    Label boundHelp = new Label(ID_BOUND_HELP);
    boundHelp.add(new InfoTooltipBehavior());
    boundContainer.add(boundHelp);
    schedulingTable.add(boundContainer);
    WebMarkupContainer intervalContainer = new WebMarkupContainer(ID_INTERVAL_CONTAINER);
    intervalContainer.add(visibleIfRecurringAndScheduleIsAccessible);
    intervalContainer.setOutputMarkupId(true);
    schedulingTable.add(intervalContainer);
    TextField<Integer> interval = new TextField<>(ID_INTERVAL, new PropertyModel<Integer>(taskDtoModel, TaskDto.F_INTERVAL));
    interval.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    interval.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
    intervalContainer.add(interval);
    WebMarkupContainer cronContainer = new WebMarkupContainer(ID_CRON_CONTAINER);
    cronContainer.add(visibleIfRecurringAndLooselyBoundAndScheduleIsAccessible);
    cronContainer.setOutputMarkupId(true);
    schedulingTable.add(cronContainer);
    TextField<String> cron = new TextField<>(ID_CRON, new PropertyModel<String>(taskDtoModel, TaskDto.F_CRON_SPECIFICATION));
    cron.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
    cron.add(enabledIfEditAndNotRunningRunnableOrLooselyBoundAndScheduleIsEditable);
    cronContainer.add(cron);
    Label cronHelp = new Label(ID_CRON_HELP);
    cronHelp.add(new InfoTooltipBehavior());
    cronContainer.add(cronHelp);
    WebMarkupContainer notStartBeforeContainer = new WebMarkupContainer(ID_NOT_START_BEFORE_CONTAINER);
    DateInput notStartBefore = new DateInput(ID_NOT_START_BEFORE_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_BEFORE));
    notStartBefore.setOutputMarkupId(true);
    notStartBefore.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
    notStartBeforeContainer.add(notStartBefore);
    notStartBeforeContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(notStartBeforeContainer);
    WebMarkupContainer notStartAfterContainer = new WebMarkupContainer(ID_NOT_START_AFTER_CONTAINER);
    DateInput notStartAfter = new DateInput(ID_NOT_START_AFTER_FIELD, new PropertyModel<Date>(taskDtoModel, TaskDto.F_NOT_START_AFTER));
    notStartAfter.setOutputMarkupId(true);
    notStartAfter.add(enabledIfEditAndNotRunningAndScheduleIsEditable);
    notStartAfterContainer.add(notStartAfter);
    notStartAfterContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(notStartAfterContainer);
    WebMarkupContainer misfireActionContainer = new WebMarkupContainer(ID_MISFIRE_ACTION_CONTAINER);
    DropDownChoice misfire = new DropDownChoice(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(taskDtoModel, TaskDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(parentPage));
    misfire.add(enabledIfEditAndScheduleIsEditable);
    misfireActionContainer.add(misfire);
    misfireActionContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_SCHEDULE));
    schedulingTable.add(misfireActionContainer);
    WebMarkupContainer threadStopContainer = new WebMarkupContainer(ID_THREAD_STOP_CONTAINER);
    DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {

        @Override
        public ThreadStopActionType getObject() {
            return taskDtoModel.getObject().getThreadStopActionType();
        }

        @Override
        public void setObject(ThreadStopActionType object) {
            taskDtoModel.getObject().setThreadStopActionType(object);
        }
    }, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(parentPage));
    threadStop.add(enabledIfEditAndThreadStopIsEditable);
    threadStopContainer.add(threadStop);
    threadStopContainer.add(parentPage.createVisibleIfAccessible(TaskType.F_THREAD_STOP_ACTION));
    schedulingTable.add(threadStopContainer);
    org.apache.wicket.markup.html.form.Form<?> form = parentPage.getForm();
    // TODO implement more intelligently when other tabs have validators as well
    for (IFormValidator validator : form.getFormValidators()) {
        form.remove(validator);
    }
    form.add(new StartEndDateValidator(notStartBefore, notStartAfter));
    form.add(new ScheduleValidator(parentPage.getTaskManager(), recurringCheck, bound, interval, cron));
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) EmptyOnBlurAjaxFormUpdatingBehaviour(com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) TextField(org.apache.wicket.markup.html.form.TextField) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) StartEndDateValidator(com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator) IFormValidator(org.apache.wicket.markup.html.form.validation.IFormValidator) ScheduleValidator(com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) ThreadStopActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType) Date(java.util.Date) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) InfoTooltipBehavior(com.evolveum.midpoint.web.util.InfoTooltipBehavior) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) DateInput(com.evolveum.midpoint.web.component.DateInput) MisfireActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 2 with DateInput

use of com.evolveum.midpoint.web.component.DateInput in project midpoint by Evolveum.

the class DelegationEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM, AssignmentsUtil.createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.setEnabled(getModel().getObject().isEditable());
    body.add(validFrom);
    DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO, AssignmentsUtil.createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    validTo.setEnabled(getModel().getObject().isEditable());
    body.add(validTo);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<String>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    description.setEnabled(getModel().getObject().isEditable());
    body.add(description);
    WebMarkupContainer assignmentPrivilegesContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_CONTAINER);
    assignmentPrivilegesContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            List<AssignmentInfoDto> privilegesList = privilegesListModel.getObject();
            return privilegesList != null && privilegesList.size() > 0;
        }
    });
    body.add(assignmentPrivilegesContainer);
    AjaxCheckBox assignmentPrivilegesCheckbox = new AjaxCheckBox(ID_ASSIGNMENT_PRIVILEGES_CHECKBOX, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            return getModelObject().getPrivilegeLimitationList() != null && getModelObject().getPrivilegeLimitationList().size() > 0;
        }

        @Override
        public void setObject(Boolean value) {
            if (value) {
                getModelObject().setPrivilegeLimitationList(privilegesListModel.getObject());
            } else {
                getModelObject().setPrivilegeLimitationList(new ArrayList<>());
            }
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(DelegationEditorPanel.this.get(ID_BODY).get(ID_ASSIGNMENT_PRIVILEGES_CONTAINER));
        }
    };
    assignmentPrivilegesCheckbox.setOutputMarkupId(true);
    assignmentPrivilegesCheckbox.add(new AjaxFormComponentUpdatingBehavior("blur") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    assignmentPrivilegesCheckbox.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    assignmentPrivilegesContainer.add(assignmentPrivilegesCheckbox);
    WebMarkupContainer labelContainer = new WebMarkupContainer(ID_ASSIGNMENT_PRIVILEGES_LABEL_CONTAINER);
    labelContainer.setOutputMarkupId(true);
    assignmentPrivilegesContainer.add(labelContainer);
    Label assignmentPrivilegesLabel = new Label(ID_ASSIGNMENT_PRIVILEGES_LABEL, createStringResource("DelegationEditorPanel.allPrivilegesLabel"));
    assignmentPrivilegesLabel.setOutputMarkupId(true);
    labelContainer.add(assignmentPrivilegesLabel);
    addPrivilegesPanel(assignmentPrivilegesContainer);
    AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON, createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            DelegationTargetLimitationDialog assignmentsDialog = new DelegationTargetLimitationDialog(getPageBase().getMainPopupBodyId(), selectExistingPrivileges(privilegesListModel.getObject()), getPageBase()) {

                @Override
                protected void addButtonClicked(AjaxRequestTarget target, List<AssignmentInfoDto> dtoList) {
                    DelegationEditorPanel.this.getModelObject().setPrivilegeLimitationList(dtoList);
                    getPageBase().hideMainPopup(target);
                }
            };
            getPageBase().showMainPopup(assignmentsDialog, target);
        }
    };
    limitPrivilegesButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModel().getObject().isEditable() && assignmentPrivilegesCheckbox.getModelObject();
        }
    });
    labelContainer.add(limitPrivilegesButton);
    AjaxCheckBox approvalRights = new AjaxCheckBox(ID_DELEGATE_APPROVAL_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getApprovalWorkItems() == null || dto.getPrivilegesLimitation().getApprovalWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getApprovalWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setApprovalWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    approvalRights.setOutputMarkupId(true);
    approvalRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    approvalRights.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    body.add(approvalRights);
    AjaxCheckBox certificationRights = new AjaxCheckBox(ID_DELEGATE_CERTIFICATION_WI, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            AssignmentEditorDto dto = getModelObject();
            if (dto.getPrivilegesLimitation() == null || dto.getPrivilegesLimitation().getCertificationWorkItems() == null || dto.getPrivilegesLimitation().getCertificationWorkItems().isAll() == null) {
                return false;
            }
            return dto.getPrivilegesLimitation().getCertificationWorkItems().isAll();
        }

        @Override
        public void setObject(Boolean value) {
            AssignmentEditorDto dto = getModelObject();
            OtherPrivilegesLimitationType limitations = dto.getPrivilegesLimitation();
            if (limitations == null) {
                limitations = new OtherPrivilegesLimitationType();
                dto.setPrivilegesLimitation(limitations);
            }
            WorkItemSelectorType workItemSelector = new WorkItemSelectorType();
            workItemSelector.all(value);
            limitations.setCertificationWorkItems(workItemSelector);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    certificationRights.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    certificationRights.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    certificationRights.setOutputMarkupId(true);
    body.add(certificationRights);
    AjaxCheckBox managementWorkItems = new AjaxCheckBox(ID_DELEGATE_MANAGEMENT_WI, new Model<>(false)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    managementWorkItems.setOutputMarkupId(true);
    managementWorkItems.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // TODO not implemented yet
            return false;
        }
    });
    body.add(managementWorkItems);
    AjaxCheckBox allowTransitive = new AjaxCheckBox(ID_ALLOW_TRANSITIVE, new IModel<Boolean>() {

        private static final long serialVersionUID = 1L;

        @Override
        public Boolean getObject() {
            return getModelObject().isLimitTargetAllowTransitive();
        }

        @Override
        public void setObject(Boolean value) {
            getModelObject().setLimitTargetAllowTransitive(value);
        }

        @Override
        public void detach() {
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    allowTransitive.add(new AjaxFormComponentUpdatingBehavior("blur") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    });
    allowTransitive.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    allowTransitive.setOutputMarkupId(true);
    body.add(allowTransitive);
    addAjaxOnUpdateBehavior(body);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) DelegationTargetLimitationDialog(com.evolveum.midpoint.web.page.admin.users.component.DelegationTargetLimitationDialog) TextArea(org.apache.wicket.markup.html.form.TextArea) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WorkItemSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemSelectorType) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OtherPrivilegesLimitationType(com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType) DateInput(com.evolveum.midpoint.web.component.DateInput) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 3 with DateInput

use of com.evolveum.midpoint.web.component.DateInput in project midpoint by Evolveum.

the class DateFormGroup method initLayout.

private void initLayout(IModel<String> label, String labelSize, String textSize, boolean required) {
    Label l = new Label(ID_LABEL, label);
    if (StringUtils.isNotEmpty(labelSize)) {
        l.add(AttributeAppender.prepend("class", labelSize));
    }
    add(l);
    WebMarkupContainer dateWrapper = new WebMarkupContainer(ID_DATE_WRAPPER);
    if (StringUtils.isNotEmpty(textSize)) {
        dateWrapper.add(AttributeAppender.prepend("class", textSize));
    }
    add(dateWrapper);
    DateInput date = new DateInput(ID_DATE, new XmlGregorianCalendarModel(getModel()));
    date.setRequired(required);
    date.setLabel(label);
    dateWrapper.add(date);
    FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(date));
    dateWrapper.add(feedback);
}
Also used : ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) XmlGregorianCalendarModel(com.evolveum.midpoint.web.model.XmlGregorianCalendarModel) Label(org.apache.wicket.markup.html.basic.Label) DateInput(com.evolveum.midpoint.web.component.DateInput) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 4 with DateInput

use of com.evolveum.midpoint.web.component.DateInput in project midpoint by Evolveum.

the class AssignmentEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    WebMarkupContainer propertyContainer = new WebMarkupContainer(ID_PROPERTY_CONTAINER);
    propertyContainer.setOutputMarkupId(true);
    body.add(propertyContainer);
    WebMarkupContainer descriptionContainer = new WebMarkupContainer(ID_DESCRIPTION_CONTAINER);
    descriptionContainer.setOutputMarkupId(true);
    descriptionContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION));
        }
    });
    body.add(descriptionContainer);
    TextArea<String> description = new TextArea<>(ID_DESCRIPTION, new PropertyModel<>(getModel(), AssignmentEditorDto.F_DESCRIPTION));
    description.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    descriptionContainer.add(description);
    WebMarkupContainer relationContainer = new WebMarkupContainer(ID_RELATION_CONTAINER);
    relationContainer.setOutputMarkupId(true);
    relationContainer.setOutputMarkupPlaceholderTag(true);
    relationContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (!isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION))) {
                return false;
            }
            AssignmentEditorDto dto = getModel().getObject();
            if (dto != null) {
                if (AssignmentEditorDtoType.ORG_UNIT.equals(dto.getType()) || AssignmentEditorDtoType.SERVICE.equals(dto.getType()) || AssignmentEditorDtoType.ROLE.equals(dto.getType())) {
                    return true;
                }
            }
            return false;
        }
    });
    body.add(relationContainer);
    addRelationDropDown(relationContainer);
    WebMarkupContainer focusTypeContainer = new WebMarkupContainer(ID_FOCUS_TYPE_CONTAINER);
    focusTypeContainer.setOutputMarkupId(true);
    focusTypeContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE));
        }
    });
    body.add(focusTypeContainer);
    ObjectTypeSelectPanel<FocusType> focusType = new ObjectTypeSelectPanel<>(ID_FOCUS_TYPE, new PropertyModel<>(getModel(), AssignmentEditorDto.F_FOCUS_TYPE), FocusType.class);
    focusTypeContainer.add(focusType);
    Label relationLabel = new Label(ID_RELATION_LABEL, new IModel<String>() {

        @Override
        public String getObject() {
            if (getModel() == null || getModel().getObject() == null) {
                return getString("AssignmentEditorPanel.relation.notSpecified");
            }
            AssignmentEditorDto object = getModel().getObject();
            if (object.getTargetRef() != null) {
                QName relation = object.getTargetRef() != null ? object.getTargetRef().getRelation() : null;
                String propertyKey = WebComponentUtil.getRelationHeaderLabelKey(relation);
                return createStringResource(propertyKey).getString();
            } else {
                return "";
            }
        }
    });
    relationLabel.setOutputMarkupId(true);
    relationLabel.setOutputMarkupPlaceholderTag(true);
    relationLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !isCreatingNewAssignment();
        }
    });
    relationContainer.add(relationLabel);
    WebMarkupContainer tenantRefContainer = createTenantContainer();
    tenantRefContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF));
        }
    });
    body.add(tenantRefContainer);
    WebMarkupContainer orgRefContainer = createOrgContainer();
    orgRefContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
        }
    });
    body.add(orgRefContainer);
    propertyContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_DESCRIPTION)) || isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF, ObjectReferenceType.F_RELATION)) || isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_FOCUS_TYPE)) || isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_TENANT_REF)) || isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_ORG_REF));
        }
    });
    WebMarkupContainer activationBlock = new WebMarkupContainer(ID_ACTIVATION_BLOCK);
    body.add(activationBlock);
    WebMarkupContainer adminStatusContainer = new WebMarkupContainer(ID_ADMIN_STATUS_CONTAINER);
    adminStatusContainer.setOutputMarkupId(true);
    adminStatusContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
        }
    });
    activationBlock.add(adminStatusContainer);
    DropDownChoicePanel administrativeStatus = WebComponentUtil.createEnumPanel(ActivationStatusType.class, ID_ADMINISTRATIVE_STATUS, new PropertyModel<ActivationStatusType>(getModel(), AssignmentEditorDto.F_ACTIVATION + "." + ActivationType.F_ADMINISTRATIVE_STATUS.getLocalPart()), this);
    administrativeStatus.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    adminStatusContainer.add(administrativeStatus);
    WebMarkupContainer validFromContainer = new WebMarkupContainer(ID_VALID_FROM_CONTAINER);
    validFromContainer.setOutputMarkupId(true);
    validFromContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_FROM));
        }
    });
    activationBlock.add(validFromContainer);
    DateInput validFrom = new DateInput(ID_VALID_FROM, AssignmentsUtil.createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    validFromContainer.add(validFrom);
    WebMarkupContainer validToContainer = new WebMarkupContainer(ID_VALID_TO_CONTAINER);
    validToContainer.setOutputMarkupId(true);
    validToContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_ACTIVATION, ActivationType.F_VALID_TO));
        }
    });
    activationBlock.add(validToContainer);
    DateInput validTo = new DateInput(ID_VALID_TO, AssignmentsUtil.createDateModel(new PropertyModel<>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validTo")));
    validTo.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    validToContainer.add(validTo);
    activationBlock.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            // enabled activation in assignments for now.
            return true;
        }
    });
    WebMarkupContainer targetContainer = new WebMarkupContainer(ID_TARGET_CONTAINER);
    targetContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (!isItemAllowed(ItemPath.create(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF))) {
                return false;
            }
            AssignmentEditorDto dto = getModel().getObject();
            return !AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(targetContainer);
    Label target = new Label(ID_TARGET, createTargetModel());
    targetContainer.add(target);
    WebMarkupContainer constructionContainer = new WebMarkupContainer(ID_CONSTRUCTION_CONTAINER);
    constructionContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            AssignmentEditorDto dto = getModel().getObject();
            return AssignmentEditorDtoType.CONSTRUCTION.equals(dto.getType());
        }
    });
    body.add(constructionContainer);
    AjaxLink<Void> showEmpty = new AjaxLink<>(ID_SHOW_EMPTY) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            showEmptyPerformed(target);
        }
    };
    constructionContainer.add(showEmpty);
    Label showEmptyLabel = new Label(ID_SHOW_EMPTY_LABEL, createShowEmptyLabel());
    showEmptyLabel.setOutputMarkupId(true);
    showEmpty.add(showEmptyLabel);
    initAttributesLayout(constructionContainer);
    Component metadataPanel;
    if (UserDtoStatus.ADD.equals(getModel().getObject().getStatus()) || getModelObject().getOldValue().asContainerable() == null) {
        metadataPanel = new WebMarkupContainer(ID_METADATA_CONTAINER);
    } else {
        metadataPanel = new MetadataPanel(ID_METADATA_CONTAINER, new IModel<>() {

            @Override
            public MetadataType getObject() {
                return getModelObject().getOldValue().getValue().getMetadata();
            }
        }, "", "row");
    }
    metadataPanel.setOutputMarkupId(true);
    metadataPanel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !UserDtoStatus.ADD.equals(getModel().getObject().getStatus());
        }
    });
    body.add(metadataPanel);
    WebComponentUtil.addAjaxOnUpdateBehavior(body);
}
Also used : ObjectTypeSelectPanel(com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel) RelationDropDownChoicePanel(com.evolveum.midpoint.web.component.input.RelationDropDownChoicePanel) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) TextArea(org.apache.wicket.markup.html.form.TextArea) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) Component(org.apache.wicket.Component) IModel(org.apache.wicket.model.IModel) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) DateInput(com.evolveum.midpoint.web.component.DateInput)

Aggregations

DateInput (com.evolveum.midpoint.web.component.DateInput)4 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)4 Label (org.apache.wicket.markup.html.basic.Label)4 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)2 TextArea (org.apache.wicket.markup.html.form.TextArea)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 ObjectTypeSelectPanel (com.evolveum.midpoint.gui.api.component.objecttypeselect.ObjectTypeSelectPanel)1 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 RelationDropDownChoicePanel (com.evolveum.midpoint.web.component.input.RelationDropDownChoicePanel)1 XmlGregorianCalendarModel (com.evolveum.midpoint.web.model.XmlGregorianCalendarModel)1 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)1 ScheduleValidator (com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator)1 StartEndDateValidator (com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator)1 DelegationTargetLimitationDialog (com.evolveum.midpoint.web.page.admin.users.component.DelegationTargetLimitationDialog)1 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)1 MisfireActionType (com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType)1