Search in sources :

Example 1 with ThreadStopActionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType 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 ThreadStopActionType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType in project midpoint by Evolveum.

the class PageTaskAdd method initAdvanced.

private void initAdvanced(Form mainForm) {
    CheckBox runUntilNodeDown = new CheckBox(ID_RUN_UNTIL_NODW_DOWN, new PropertyModel<Boolean>(model, TaskAddDto.F_RUN_UNTIL_NODW_DOWN));
    mainForm.add(runUntilNodeDown);
    final IModel<Boolean> createSuspendedCheck = new PropertyModel<>(model, TaskAddDto.F_SUSPENDED_STATE);
    CheckBox createSuspended = new CheckBox(ID_CREATE_SUSPENDED, createSuspendedCheck);
    mainForm.add(createSuspended);
    DropDownChoice threadStop = new DropDownChoice<>(ID_THREAD_STOP, new Model<ThreadStopActionType>() {

        @Override
        public ThreadStopActionType getObject() {
            TaskAddDto dto = model.getObject();
            //				}
            return dto.getThreadStop();
        }

        @Override
        public void setObject(ThreadStopActionType object) {
            model.getObject().setThreadStop(object);
        }
    }, WebComponentUtil.createReadonlyModelFromEnum(ThreadStopActionType.class), new EnumChoiceRenderer<ThreadStopActionType>(PageTaskAdd.this));
    mainForm.add(threadStop);
    mainForm.add(new TsaValidator(runUntilNodeDown, threadStop));
    DropDownChoice misfire = new DropDownChoice<>(ID_MISFIRE_ACTION, new PropertyModel<MisfireActionType>(model, TaskAddDto.F_MISFIRE_ACTION), WebComponentUtil.createReadonlyModelFromEnum(MisfireActionType.class), new EnumChoiceRenderer<MisfireActionType>(PageTaskAdd.this));
    mainForm.add(misfire);
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) PropertyModel(org.apache.wicket.model.PropertyModel) ThreadStopActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TsaValidator(com.evolveum.midpoint.web.page.admin.server.dto.TsaValidator) MisfireActionType(com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType)

Aggregations

MisfireActionType (com.evolveum.midpoint.xml.ns._public.common.common_3.MisfireActionType)2 ThreadStopActionType (com.evolveum.midpoint.xml.ns._public.common.common_3.ThreadStopActionType)2 AjaxCheckBox (org.apache.wicket.ajax.markup.html.form.AjaxCheckBox)2 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)2 PropertyModel (org.apache.wicket.model.PropertyModel)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)1 DateInput (com.evolveum.midpoint.web.component.DateInput)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)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 TaskAddDto (com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto)1 TsaValidator (com.evolveum.midpoint.web.page.admin.server.dto.TsaValidator)1 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)1 Date (java.util.Date)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1 CheckBox (org.apache.wicket.markup.html.form.CheckBox)1 TextField (org.apache.wicket.markup.html.form.TextField)1