Search in sources :

Example 41 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class DefinitionScopePanel method initLayout.

protected void initLayout() {
    final TextField nameField = new TextField(ID_NAME, new PropertyModel<>(getModel(), DefinitionScopeDto.F_NAME));
    nameField.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return true;
        }
    });
    add(nameField);
    final TextArea descriptionField = new TextArea(ID_DESCRIPTION, new PropertyModel<>(getModel(), DefinitionScopeDto.F_DESCRIPTION));
    descriptionField.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            return true;
        }
    });
    add(descriptionField);
    DropDownChoicePanel objectTypeChooser = new DropDownChoicePanel(ID_OBJECT_TYPE_CHOOSER, new PropertyModel(getModel(), DefinitionScopeDto.F_OBJECT_TYPE), WebComponentUtil.createReadonlyModelFromEnum(DefinitionScopeObjectType.class), new EnumChoiceRenderer<DefinitionScopeObjectType>());
    add(objectTypeChooser);
    add(WebComponentUtil.createHelp(ID_OBJECT_TYPE_HELP));
    TextArea filterTextArea = new TextArea(ID_SEARCH_FILTER, new PropertyModel<String>(getModel(), DefinitionScopeDto.F_SEARCH_FILTER_TEXT));
    filterTextArea.setOutputMarkupId(true);
    add(filterTextArea);
    add(WebComponentUtil.createHelp(ID_SEARCH_FILTER_HELP));
    add(new CheckBox(ID_INCLUDE_ASSIGNMENTS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ASSIGNMENTS)));
    add(new CheckBox(ID_INCLUDE_INDUCEMENTS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_INDUCEMENTS)));
    add(WebComponentUtil.createHelp(ID_ASSIGNMENTS_INDUCEMENTS_HELP));
    add(new CheckBox(ID_INCLUDE_RESOURCES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_RESOURCES)));
    add(new CheckBox(ID_INCLUDE_ROLES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ROLES)));
    add(new CheckBox(ID_INCLUDE_ORGS, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ORGS)));
    add(new CheckBox(ID_INCLUDE_SERVICES, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_SERVICES)));
    add(WebComponentUtil.createHelp(ID_INCLUDE_TARGET_TYPES_HELP));
    add(new CheckBox(ID_INCLUDE_ENABLED_ITEMS_ONLY, new PropertyModel<Boolean>(getModel(), DefinitionScopeDto.F_INCLUDE_ENABLED_ITEMS_ONLY)));
    add(WebComponentUtil.createHelp(ID_INCLUDE_BY_STATUS_HELP));
}
Also used : DefinitionScopeObjectType(com.evolveum.midpoint.web.page.admin.certification.dto.DefinitionScopeObjectType) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) PropertyModel(org.apache.wicket.model.PropertyModel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 42 with PropertyModel

use of org.apache.wicket.model.PropertyModel 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)

Example 43 with PropertyModel

use of org.apache.wicket.model.PropertyModel 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 44 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class PageAccountActivation method initLayout.

private void initLayout() {
    WebMarkupContainer activationContainer = new WebMarkupContainer(ID_ACTIVATION_CONTAINER);
    activationContainer.setOutputMarkupId(true);
    add(activationContainer);
    activationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return !activated;
        }
    });
    Form form = new Form<>(ID_MAIN_FORM);
    activationContainer.add(form);
    Label usernamePanel = new Label(ID_NAME, createStringResource("PageAccountActivation.activate.accounts.label", new PropertyModel<>(userModel, "name.orig")));
    usernamePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            return false;
        }
    });
    form.add(usernamePanel);
    PasswordTextField passwordPanel = new PasswordTextField(ID_PASSWORD, Model.of(new String()));
    form.add(passwordPanel);
    AjaxSubmitButton confirmPasswrod = new AjaxSubmitButton(ID_CONFIRM) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            propagatePassword(target, form);
        }

        @Override
        protected void onError(AjaxRequestTarget target, Form<?> form) {
            getSession().error(getString("PageAccountActivation.account.activation.failed"));
            target.add(getFeedbackPanel());
        }
    };
    form.add(confirmPasswrod);
    WebMarkupContainer confirmationContainer = new WebMarkupContainer(ID_CONFIRMATION_CONTAINER);
    confirmationContainer.setOutputMarkupId(true);
    confirmationContainer.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return activated;
        }
    });
    add(confirmationContainer);
    AjaxLink<Void> linkToLogin = new AjaxLink<Void>(ID_LINK_TO_LOGIN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            setResponsePage(PageLogin.class);
        }
    };
    confirmationContainer.add(linkToLogin);
    RepeatingView activatedShadows = new RepeatingView(ID_ACTIVATED_SHADOWS);
    confirmationContainer.add(activatedShadows);
    List<ShadowType> shadowsToActivate = getShadowsToActivate();
    if (shadowsToActivate.isEmpty()) {
        LOGGER.error("No accounts to validate for user {}", userModel.getObject());
        getSession().warn(getString("PageAccountActivation.nothing.to.activate"));
        throw new RestartResponseException(PageLogin.class);
    }
    for (ShadowType shadow : shadowsToActivate) {
        Label shadowDesc = new Label(activatedShadows.newChildId(), WebComponentUtil.getName(shadow) + " on resource " + WebComponentUtil.getName(shadow.getResourceRef()));
        activatedShadows.add(shadowDesc);
    }
}
Also used : AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Form(org.apache.wicket.markup.html.form.Form) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) RepeatingView(org.apache.wicket.markup.repeater.RepeatingView) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) RestartResponseException(org.apache.wicket.RestartResponseException) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 45 with PropertyModel

use of org.apache.wicket.model.PropertyModel in project midpoint by Evolveum.

the class OperationResultPanel method createMessage.

private Label createMessage() {
    Label message = null;
    if (StringUtils.isNotBlank(getModelObject().getMessage())) {
        PropertyModel<String> messageModel = new PropertyModel<String>(getModel(), "message");
        message = new Label(ID_MESSAGE_LABEL, messageModel);
    } else {
        message = new Label(ID_MESSAGE_LABEL, new LoadableModel<Object>() {

            private static final long serialVersionUID = 1L;

            @Override
            protected Object load() {
                OpResult result = OperationResultPanel.this.getModelObject();
                String resourceKey = OPERATION_RESOURCE_KEY_PREFIX + result.getOperation();
                return getPage().getString(resourceKey, null, resourceKey);
            }
        });
    }
    //message.setRenderBodyOnly(true);
    message.setOutputMarkupId(true);
    return message;
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel)

Aggregations

PropertyModel (org.apache.wicket.model.PropertyModel)70 Label (org.apache.wicket.markup.html.basic.Label)38 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)37 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)32 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)29 ArrayList (java.util.ArrayList)22 List (java.util.List)21 IModel (org.apache.wicket.model.IModel)21 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)20 ListItem (org.apache.wicket.markup.html.list.ListItem)17 ListView (org.apache.wicket.markup.html.list.ListView)15 Model (org.apache.wicket.model.Model)13 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)10 TextField (org.apache.wicket.markup.html.form.TextField)10 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)9 QName (javax.xml.namespace.QName)8 Form (org.apache.wicket.markup.html.form.Form)8 InfoTooltipBehavior (com.evolveum.midpoint.web.util.InfoTooltipBehavior)6 AttributeAppender (org.apache.wicket.behavior.AttributeAppender)6 MultiValueTextEditPanel (com.evolveum.midpoint.web.component.form.multivalue.MultiValueTextEditPanel)5