Search in sources :

Example 1 with AjaxCheckBox

use of org.apache.wicket.ajax.markup.html.form.AjaxCheckBox in project midpoint by Evolveum.

the class CheckTableHeader method initLayout.

private void initLayout() {
    AjaxCheckBox check = new AjaxCheckBox(ID_CHECK, new PropertyModel<Boolean>(getModel(), ObjectWrapper.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
        }
    };
    add(check);
    Label icon = new Label(ID_ICON);
    icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return "check-table-header-icon " + createAccountIcon();
        }
    }));
    add(icon);
    Label trigger = new Label(ID_TRIGGER);
    trigger.add(AttributeModifier.replace("title", new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return createTriggerTooltip();
        }
    }));
    trigger.add(new TooltipBehavior());
    trigger.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return hasTriggers();
        }
    });
    add(trigger);
    BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"), new Model<>(BootstrapLabel.State.DANGER));
    status.add(createFetchErrorVisibleBehaviour());
    add(status);
    AjaxLink showMore = new AjaxLink(ID_SHOW_MORE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onShowMorePerformed(target);
        }
    };
    showMore.add(createFetchErrorVisibleBehaviour());
    add(showMore);
    AjaxLink link = new AjaxLink(ID_LINK) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }
    };
    add(link);
    Label name = new Label(ID_NAME, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDisplayName();
        }
    });
    link.add(name);
    Label description = new Label(ID_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        private static final long serialVersionUID = 1L;

        @Override
        public String getObject() {
            return getDescription();
        }
    });
    add(description);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            onClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !CheckTableHeader.this.getModelObject().isMinimalized();
        }
    };
    add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) Label(org.apache.wicket.markup.html.basic.Label) BootstrapLabel(com.evolveum.midpoint.web.component.BootstrapLabel) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) TooltipBehavior(com.evolveum.midpoint.web.util.TooltipBehavior) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 2 with AjaxCheckBox

use of org.apache.wicket.ajax.markup.html.form.AjaxCheckBox 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 3 with AjaxCheckBox

use of org.apache.wicket.ajax.markup.html.form.AjaxCheckBox in project midpoint by Evolveum.

the class TaskShowAdvancedFeaturesPanel method initLayout.

protected void initLayout(VisibleEnableBehaviour checkBoxVisibleEnable) {
    final AjaxCheckBox checkBox = new AjaxCheckBox(ID_ADVANCED_FEATURES, getModel()) {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            onAdvancedFeaturesUpdate(target);
        }
    };
    if (checkBoxVisibleEnable != null) {
        checkBox.add(checkBoxVisibleEnable);
    }
    add(checkBox);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)

Example 4 with AjaxCheckBox

use of org.apache.wicket.ajax.markup.html.form.AjaxCheckBox in project midpoint by Evolveum.

the class DelegationEditorPanel method initBodyLayout.

protected void initBodyLayout(WebMarkupContainer body) {
    DateInput validFrom = new DateInput(ID_DELEGATION_VALID_FROM, createDateModel(new PropertyModel<XMLGregorianCalendar>(getModel(), AssignmentEditorDto.F_ACTIVATION + ".validFrom")));
    validFrom.setEnabled(getModel().getObject().isEditable());
    body.add(validFrom);
    DateInput validTo = new DateInput(ID_DELEGATION_VALID_TO, createDateModel(new PropertyModel<XMLGregorianCalendar>(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() {
            if (!UserDtoStatus.ADD.equals(getModelObject().getStatus())) {
                return true;
            }
            List<AssignmentsPreviewDto> 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 UserDtoStatus.ADD.equals(getModelObject().getStatus());
        }
    });
    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.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return true;
        }
    });
    assignmentPrivilegesLabel.setOutputMarkupId(true);
    labelContainer.add(assignmentPrivilegesLabel);
    addPrivilegesPanel(assignmentPrivilegesContainer);
    AjaxButton limitPrivilegesButton = new AjaxButton(ID_LIMIT_PRIVILEGES_BUTTON, pageBase.createStringResource("DelegationEditorPanel.limitPrivilegesButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            AssignmentPreviewDialog assignmentPreviewDialog = new AssignmentPreviewDialog(pageBase.getMainPopupBodyId(), selectExistingPrivileges(privilegesListModel.getObject()), null, pageBase, true) {

                @Override
                protected boolean isDelegationPreview() {
                    return true;
                }

                @Override
                public StringResourceModel getTitle() {
                    return new StringResourceModel("AssignmentPreviewDialog.delegationPreviewLabel");
                }

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

        @Override
        public boolean isVisible() {
            return UserDtoStatus.ADD.equals(getModelObject().getStatus()) && 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") {

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

        @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") {

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

        @Override
        public boolean isEnabled() {
            return getModel().getObject().isEditable();
        }
    });
    certificationRights.setOutputMarkupId(true);
    body.add(certificationRights);
    AjaxCheckBox managementWorkItems = new AjaxCheckBox(ID_DELEGATE_MANAGEMENT_WI, new Model<Boolean>(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);
    addAjaxOnUpdateBehavior(body);
}
Also used : TextArea(org.apache.wicket.markup.html.form.TextArea) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) WorkItemSelectorType(com.evolveum.midpoint.xml.ns._public.common.common_3.WorkItemSelectorType) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) OtherPrivilegesLimitationType(com.evolveum.midpoint.xml.ns._public.common.common_3.OtherPrivilegesLimitationType) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AssignmentPreviewDialog(com.evolveum.midpoint.web.page.admin.users.component.AssignmentPreviewDialog) DateInput(com.evolveum.midpoint.web.component.DateInput)

Example 5 with AjaxCheckBox

use of org.apache.wicket.ajax.markup.html.form.AjaxCheckBox in project midpoint by Evolveum.

the class DelegationEditorPanel method initHeaderRow.

@Override
protected void initHeaderRow() {
    if (delegatedToMe) {
        privilegesListModel = new LoadableModel<List<AssignmentsPreviewDto>>(false) {

            @Override
            protected List<AssignmentsPreviewDto> load() {
                return DelegationEditorPanel.this.getModelObject().getPrivilegeLimitationList();
            }
        };
    }
    AjaxCheckBox selected = new AjaxCheckBox(ID_SELECTED, new PropertyModel<>(getModel(), AssignmentEditorDto.F_SELECTED)) {

        private static final long serialVersionUID = 1L;

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

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isSimpleView();
        }
    });
    headerRow.add(selected);
    Label arrowIcon = new Label(ID_ARROW_ICON);
    headerRow.add(arrowIcon);
    WebMarkupContainer typeImage = new WebMarkupContainer(ID_TYPE_IMAGE);
    typeImage.add(AttributeModifier.append("class", createImageTypeModel(getModel())));
    headerRow.add(typeImage);
    AjaxLink name = new AjaxLink(ID_NAME) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(name);
    Label nameLabel;
    if (delegatedToMe) {
        OperationResult result = new OperationResult(OPERATION_GET_TARGET_REF_NAME);
        Task task = pageBase.createSimpleTask(OPERATION_GET_TARGET_REF_NAME);
        nameLabel = new Label(ID_NAME_LABEL, WebModelServiceUtils.resolveReferenceName(getModelObject().getTargetRef(), pageBase, task, result));
    } else {
        nameLabel = new Label(ID_NAME_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    }
    nameLabel.setOutputMarkupId(true);
    name.add(nameLabel);
    AssignmentEditorDto dto = getModelObject();
    dto.getTargetRef();
    WebMarkupContainer delegatedToTypeImage = new WebMarkupContainer(ID_DELEGATED_TO_IMAGE);
    if (delegatedToMe) {
        delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(((PageUser) pageBase).getObjectWrapper().getObject())));
    } else {
        if (getModelObject().getDelegationOwner() != null) {
            delegatedToTypeImage.add(AttributeModifier.append("class", WebComponentUtil.createDefaultIcon(getModelObject().getDelegationOwner().asPrismObject())));
        }
    }
    headerRow.add(delegatedToTypeImage);
    AjaxLink delegatedToName = new AjaxLink(ID_DELEGATED_TO) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }
    };
    headerRow.add(delegatedToName);
    Label delegatedToNameLabel;
    if (delegatedToMe) {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, pageBase.createStringResource("DelegationEditorPanel.meLabel"));
    } else {
        delegatedToNameLabel = new Label(ID_DELEGATED_TO_LABEL, getUserDisplayName());
    }
    delegatedToNameLabel.setOutputMarkupId(true);
    delegatedToName.add(delegatedToNameLabel);
    ToggleIconButton expandButton = new ToggleIconButton(ID_EXPAND, GuiStyleConstants.CLASS_ICON_EXPAND, GuiStyleConstants.CLASS_ICON_COLLAPSE) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            nameClickPerformed(target);
        }

        @Override
        public boolean isOn() {
            return !DelegationEditorPanel.this.getModelObject().isMinimized();
        }
    };
    headerRow.add(expandButton);
}
Also used : ToggleIconButton(com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton) Task(com.evolveum.midpoint.task.api.Task) Label(org.apache.wicket.markup.html.basic.Label) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PageUser(com.evolveum.midpoint.web.page.admin.users.PageUser) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Aggregations

AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)14 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)13 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)10 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)8 Label (org.apache.wicket.markup.html.basic.Label)8 PropertyModel (org.apache.wicket.model.PropertyModel)5 ToggleIconButton (com.evolveum.midpoint.gui.api.component.togglebutton.ToggleIconButton)3 List (java.util.List)3 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)3 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 DateInput (com.evolveum.midpoint.web.component.DateInput)2 InlineMenu (com.evolveum.midpoint.web.component.menu.cog.InlineMenu)2 EmptyOnBlurAjaxFormUpdatingBehaviour (com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour)2 ScheduleValidator (com.evolveum.midpoint.web.page.admin.server.dto.ScheduleValidator)2 StartEndDateValidator (com.evolveum.midpoint.web.page.admin.server.dto.StartEndDateValidator)2 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)2 Serializable (java.io.Serializable)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2