Search in sources :

Example 21 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class MultiValueAutoCompleteTextPanel method initLayout.

private void initLayout(final boolean inputEnabled, final NonEmptyModel<Boolean> readOnlyModel) {
    WebMarkupContainer placeholderContainer = new WebMarkupContainer(ID_PLACEHOLDER_CONTAINER);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.setOutputMarkupPlaceholderTag(true);
    placeholderContainer.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModel().getObject().isEmpty();
        }
    });
    add(placeholderContainer);
    AjaxLink placeholderAdd = new AjaxLink(ID_PLACEHOLDER_ADD) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            addValuePerformed(target);
        }
    };
    placeholderAdd.add(new AttributeAppender("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            if (buttonsDisabled()) {
                return " " + CSS_DISABLED;
            }
            return "";
        }
    }));
    placeholderAdd.setOutputMarkupId(true);
    placeholderAdd.setOutputMarkupPlaceholderTag(true);
    placeholderAdd.add(WebComponentUtil.visibleIfFalse(readOnlyModel));
    placeholderContainer.add(placeholderAdd);
    ListView repeater = new ListView<T>(ID_REPEATER, getModel()) {

        @Override
        protected void populateItem(final ListItem<T> item) {
            AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
            autoCompleteSettings.setShowListOnEmptyInput(true);
            autoCompleteSettings.setMaxHeightInPx(200);
            AutoCompleteTextField<String> autoCompleteEditor = new AutoCompleteTextField<String>(ID_TEXT, createTextModel(item.getModel()), autoCompleteSettings) {

                @Override
                protected Iterator<String> getChoices(String input) {
                    return createAutoCompleteObjectList(input);
                }
            };
            autoCompleteEditor.add(createAutoCompleteValidator());
            autoCompleteEditor.add(new AjaxFormComponentUpdatingBehavior("change") {

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            item.add(autoCompleteEditor);
            autoCompleteEditor.add(AttributeAppender.replace("placeholder", createEmptyItemPlaceholder()));
            if (!inputEnabled) {
                autoCompleteEditor.add(new AttributeModifier("disabled", "disabled"));
            }
            item.add(autoCompleteEditor);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            item.add(buttonGroup);
            initButtons(buttonGroup, item, readOnlyModel);
        }
    };
    repeater.setOutputMarkupId(true);
    repeater.setOutputMarkupPlaceholderTag(true);
    repeater.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModel().getObject().isEmpty();
        }
    });
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) AttributeModifier(org.apache.wicket.AttributeModifier) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) ListView(org.apache.wicket.markup.html.list.ListView) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) AttributeAppender(org.apache.wicket.behavior.AttributeAppender)

Example 22 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class MultiValueChoosePanel method initLayout.

private void initLayout(final IModel<List<T>> chosenValues, final List<PrismReferenceValue> filterValues, final boolean required, final boolean multiselect) {
    AjaxLink<String> edit = new AjaxLink<String>(ID_EDIT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            editValuePerformed(chosenValues.getObject(), filterValues, target, multiselect);
        }
    };
    edit.setOutputMarkupPlaceholderTag(true);
    add(edit);
    ListView<T> selectedRowsList = new ListView<T>(ID_SELECTED_ROWS, chosenValues) {

        @Override
        protected void populateItem(ListItem<T> item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.setOutputMarkupPlaceholderTag(true);
            //was value
            TextField<String> text = new TextField<String>(ID_TEXT, createTextModel(item.getModel()));
            text.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
                }
            });
            text.setRequired(required);
            text.setEnabled(false);
            text.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(text);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(text));
            feedback.setOutputMarkupPlaceholderTag(true);
            textWrapper.add(feedback);
            initButtons(item, item);
            item.add(textWrapper);
        }
    };
    selectedRowsList.setReuseItems(true);
    add(selectedRowsList);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink)

Example 23 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class PageTaskAdd method initLayout.

private void initLayout() {
    Form mainForm = new Form(ID_FORM_MAIN);
    add(mainForm);
    final DropDownChoice resource = new DropDownChoice<>(ID_RESOURCE, new PropertyModel<TaskAddResourcesDto>(model, TaskAddDto.F_RESOURCE), new AbstractReadOnlyModel<List<TaskAddResourcesDto>>() {

        @Override
        public List<TaskAddResourcesDto> getObject() {
            return createResourceList();
        }
    }, new ChoiceableChoiceRenderer<TaskAddResourcesDto>());
    resource.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    resource.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            PageTaskAdd.this.loadResource();
            target.add(get(ID_FORM_MAIN + ":" + ID_OBJECT_CLASS));
        }
    });
    resource.setOutputMarkupId(true);
    mainForm.add(resource);
    final DropDownChoice focusType = new DropDownChoice<>(ID_FOCUS_TYPE, new PropertyModel<QName>(model, TaskAddDto.F_FOCUS_TYPE), new AbstractReadOnlyModel<List<QName>>() {

        @Override
        public List<QName> getObject() {
            return createFocusTypeList();
        }
    }, new QNameChoiceRenderer());
    focusType.setOutputMarkupId(true);
    focusType.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            return TaskCategory.RECOMPUTATION.equals(dto.getCategory());
        }
    });
    mainForm.add(focusType);
    final DropDownChoice kind = new DropDownChoice<>(ID_KIND, new PropertyModel<ShadowKindType>(model, TaskAddDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>());
    kind.setOutputMarkupId(true);
    kind.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(kind);
    final TextField<String> intent = new TextField<>(ID_INTENT, new PropertyModel<String>(model, TaskAddDto.F_INTENT));
    mainForm.add(intent);
    intent.setOutputMarkupId(true);
    intent.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    if (model.getObject() != null && model.getObject().getResource() != null && model.getObject().getResource().getOid() != null) {
        loadResource();
    }
    AutoCompleteSettings autoCompleteSettings = new AutoCompleteSettings();
    autoCompleteSettings.setShowListOnEmptyInput(true);
    autoCompleteSettings.setMaxHeightInPx(200);
    final AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_OBJECT_CLASS, new PropertyModel<String>(model, TaskAddDto.F_OBJECT_CLASS), autoCompleteSettings) {

        @Override
        protected Iterator<String> getChoices(String input) {
            return prepareObjectClassChoiceList(input);
        }
    };
    objectClass.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isEnabled() {
            TaskAddDto dto = model.getObject();
            boolean sync = TaskCategory.LIVE_SYNCHRONIZATION.equals(dto.getCategory());
            boolean recon = TaskCategory.RECONCILIATION.equals(dto.getCategory());
            boolean importAccounts = TaskCategory.IMPORTING_ACCOUNTS.equals(dto.getCategory());
            return sync || recon || importAccounts;
        }
    });
    mainForm.add(objectClass);
    DropDownChoice type = new DropDownChoice<>(ID_CATEGORY, new PropertyModel<String>(model, TaskAddDto.F_CATEGORY), new AbstractReadOnlyModel<List<String>>() {

        @Override
        public List<String> getObject() {
            return WebComponentUtil.createTaskCategoryList();
        }
    }, new StringChoiceRenderer("pageTask.category."));
    type.add(new AjaxFormComponentUpdatingBehavior("change") {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            target.add(resource);
            target.add(intent);
            target.add(kind);
            target.add(objectClass);
            target.add(focusType);
        }
    });
    type.setRequired(true);
    mainForm.add(type);
    TextField<String> name = new TextField<>(ID_NAME, new PropertyModel<String>(model, TaskAddDto.F_NAME));
    name.setRequired(true);
    mainForm.add(name);
    initScheduling(mainForm);
    initAdvanced(mainForm);
    CheckBox dryRun = new CheckBox(ID_DRY_RUN, new PropertyModel<Boolean>(model, TaskAddDto.F_DRY_RUN));
    mainForm.add(dryRun);
    initButtons(mainForm);
}
Also used : TaskAddDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddDto) Form(org.apache.wicket.markup.html.form.Form) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) 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) List(java.util.List) ArrayList(java.util.ArrayList) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteSettings(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteSettings) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) CheckBox(org.apache.wicket.markup.html.form.CheckBox) AjaxCheckBox(org.apache.wicket.ajax.markup.html.form.AjaxCheckBox) TaskAddResourcesDto(com.evolveum.midpoint.web.page.admin.server.dto.TaskAddResourcesDto) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)

Example 24 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class ItemPathPanel method initLayout.

private void initLayout() {
    ItemPathSegmentPanel itemDefPanel = new ItemPathSegmentPanel(ID_DEFINITION, new AbstractReadOnlyModel<ItemPathDto>() {

        private static final long serialVersionUID = 1L;

        public ItemPathDto getObject() {
            return ItemPathPanel.this.getModelObject();
        }
    }) {

        private static final long serialVersionUID = 1L;

        @Override
        protected Map<QName, Collection<ItemDefinition<?>>> getSchemaDefinitionMap() {
            return initNamspaceDefinitionMap();
        }
    };
    itemDefPanel.setOutputMarkupId(true);
    add(itemDefPanel);
    AjaxButton plusButton = new AjaxButton(ID_PLUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            refreshItemPathPanel(new ItemPathDto(ItemPathPanel.this.getModelObject()), true, target);
        }
    };
    plusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null) {
                return true;
            }
            return (getModelObject().getParentPath().getItemDef() instanceof PrismContainerDefinition);
        }
    });
    plusButton.setOutputMarkupId(true);
    add(plusButton);
    AjaxButton minusButton = new AjaxButton(ID_MINUS) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClick(AjaxRequestTarget target) {
            ItemPathDto path = ItemPathPanel.this.getModelObject();
            //				ItemPathDto parent = null;
            //				if (path.getItemDef() == null){
            //					parent = path.getParentPath();
            //				} else {
            //					parent = path;
            //				}
            refreshItemPathPanel(path, false, target);
        }
    };
    minusButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() != null && getModelObject().getParentPath().toItemPath() != null;
        }
    });
    minusButton.setOutputMarkupId(true);
    add(minusButton);
    DropDownChoicePanel<QName> namespacePanel = new DropDownChoicePanel<QName>(ID_NAMESPACE, new PropertyModel<QName>(getModel(), "objectType"), new ListModel<QName>(WebComponentUtil.createObjectTypeList()), new QNameChoiceRenderer());
    namespacePanel.getBaseFormComponent().add(new AjaxFormComponentUpdatingBehavior("change") {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            refreshItemPath(ItemPathPanel.this.getModelObject(), target);
        }
    });
    namespacePanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            return getModelObject().getParentPath() == null || getModelObject().getParentPath().toItemPath() == null;
        }
    });
    namespacePanel.setOutputMarkupId(true);
    add(namespacePanel);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) QNameChoiceRenderer(com.evolveum.midpoint.web.component.input.QNameChoiceRenderer) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) QName(javax.xml.namespace.QName) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) Collection(java.util.Collection) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 25 with AjaxFormComponentUpdatingBehavior

use of org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior in project midpoint by Evolveum.

the class ObjectPolicyConfigurationEditor method initLayout.

protected void initLayout() {
    final Label label = new Label(ID_LABEL, createStringResource("objectPolicyConfigurationEditor.label"));
    add(label);
    ListView<ObjectPolicyConfigurationTypeDto> repeater = new ListView<ObjectPolicyConfigurationTypeDto>(ID_REPEATER, getModel()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void populateItem(final ListItem<ObjectPolicyConfigurationTypeDto> item) {
            WebMarkupContainer textWrapper = new WebMarkupContainer(ID_TEXT_WRAPPER);
            textWrapper.add(AttributeAppender.prepend("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return OFFSET_CLASS + " " + CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(textWrapper);
            TextField<String> name = new TextField<>(ID_NAME, createNameModel(item.getModel()));
            name.setOutputMarkupId(true);
            name.add(new AjaxFormComponentUpdatingBehavior("blur") {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(AjaxRequestTarget target) {
                }
            });
            name.setEnabled(false);
            name.add(AttributeAppender.replace("placeholder", createStringResource("objectPolicyConfigurationEditor.name.placeholder")));
            textWrapper.add(name);
            FeedbackPanel feedback = new FeedbackPanel(ID_FEEDBACK, new ComponentFeedbackMessageFilter(name));
            textWrapper.add(feedback);
            AjaxLink<String> edit = new AjaxLink<String>(ID_BUTTON_EDIT) {

                private static final long serialVersionUID = 1L;

                @Override
                public void onClick(AjaxRequestTarget target) {
                    editPerformed(target, item);
                }
            };
            textWrapper.add(edit);
            WebMarkupContainer buttonGroup = new WebMarkupContainer(ID_BUTTON_GROUP);
            buttonGroup.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    if (item.getIndex() > 0) {
                        return CLASS_MULTI_VALUE;
                    }
                    return null;
                }
            }));
            item.add(buttonGroup);
            initButtons(buttonGroup, item);
        }
    };
    //        initDialog();
    repeater.setOutputMarkupId(true);
    add(repeater);
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) ListView(org.apache.wicket.markup.html.list.ListView) TextField(org.apache.wicket.markup.html.form.TextField) ListItem(org.apache.wicket.markup.html.list.ListItem) AjaxLink(org.apache.wicket.ajax.markup.html.AjaxLink) ObjectPolicyConfigurationTypeDto(com.evolveum.midpoint.web.page.admin.configuration.dto.ObjectPolicyConfigurationTypeDto)

Aggregations

AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)34 AjaxFormComponentUpdatingBehavior (org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior)34 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)17 TextField (org.apache.wicket.markup.html.form.TextField)17 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)16 AjaxLink (org.apache.wicket.ajax.markup.html.AjaxLink)13 Label (org.apache.wicket.markup.html.basic.Label)12 ListItem (org.apache.wicket.markup.html.list.ListItem)9 ListView (org.apache.wicket.markup.html.list.ListView)9 List (java.util.List)8 AbstractReadOnlyModel (org.apache.wicket.model.AbstractReadOnlyModel)8 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)7 ArrayList (java.util.ArrayList)7 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)7 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)6 IModel (org.apache.wicket.model.IModel)6 Form (org.apache.wicket.markup.html.form.Form)5 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)4 AutoCompleteTextField (org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField)4 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)4