Search in sources :

Example 1 with SearchFormEnterBehavior

use of com.evolveum.midpoint.web.util.SearchFormEnterBehavior in project midpoint by Evolveum.

the class PageAccounts method initSearchForm.

private void initSearchForm(Form searchForm) {
    BasicSearchPanel<AccountDetailsSearchDto> basicSearch = new BasicSearchPanel<AccountDetailsSearchDto>(ID_SEARCH_BASIC) {

        @Override
        protected IModel<String> createSearchTextModel() {
            return new PropertyModel<>(searchModel, AccountDetailsSearchDto.F_SEARCH_TEXT);
        }

        @Override
        protected void searchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.searchPerformed(target);
        }

        @Override
        protected void clearSearchPerformed(AjaxRequestTarget target) {
            PageAccounts.this.clearSearchPerformed(target);
        }
    };
    basicSearch.setOutputMarkupId(true);
    searchForm.add(basicSearch);
    DropDownChoice failedOperationType = new DropDownChoice<>(ID_SEARCH_FAILED_OPERATION_TYPE, new PropertyModel<FailedOperationTypeType>(searchModel, AccountDetailsSearchDto.F_FAILED_OPERATION_TYPE), WebComponentUtil.createReadonlyModelFromEnum(FailedOperationTypeType.class), new EnumChoiceRenderer<FailedOperationTypeType>(this));
    failedOperationType.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    failedOperationType.setOutputMarkupId(true);
    failedOperationType.setNullValid(true);
    searchForm.add(failedOperationType);
    DropDownChoice kind = new DropDownChoice<>(ID_SEARCH_KIND, new PropertyModel<ShadowKindType>(searchModel, AccountDetailsSearchDto.F_KIND), WebComponentUtil.createReadonlyModelFromEnum(ShadowKindType.class), new EnumChoiceRenderer<ShadowKindType>(this));
    kind.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    kind.setOutputMarkupId(true);
    kind.setNullValid(true);
    searchForm.add(kind);
    DropDownChoice intent = new DropDownChoice<>(ID_SEARCH_INTENT, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_INTENT), createIntentChoices(), new StringChoiceRenderer(null));
    intent.setNullValid(true);
    intent.add(new OnChangeAjaxBehavior() {

        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            searchPerformed(target);
        }
    });
    intent.setOutputMarkupId(true);
    searchForm.add(intent);
    AutoCompleteTextField<String> objectClass = new AutoCompleteTextField<String>(ID_SEARCH_OBJECT_CLASS, new PropertyModel<String>(searchModel, AccountDetailsSearchDto.F_OBJECT_CLASS)) {

        @Override
        protected Iterator<String> getChoices(String input) {
            if (Strings.isEmpty(input)) {
                List<String> emptyList = Collections.emptyList();
                return emptyList.iterator();
            }
            AccountDetailsSearchDto dto = searchModel.getObject();
            List<QName> accountObjectClassList = dto.getObjectClassList();
            List<String> choices = new ArrayList<>(AUTO_COMPLETE_LIST_SIZE);
            for (QName s : accountObjectClassList) {
                if (s.getLocalPart().toLowerCase().startsWith(input.toLowerCase())) {
                    choices.add(s.getLocalPart());
                    if (choices.size() == AUTO_COMPLETE_LIST_SIZE) {
                        break;
                    }
                }
            }
            return choices.iterator();
        }
    };
    objectClass.add(AttributeModifier.replace("placeholder", createStringResource("PageAccounts.accounts.objectClass")));
    objectClass.setOutputMarkupId(true);
    objectClass.add(createObjectClassValidator());
    objectClass.add(new SearchFormEnterBehavior(basicSearch.getSearchButton()));
    searchForm.add(objectClass);
}
Also used : AccountDetailsSearchDto(com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) QName(javax.xml.namespace.QName) PropertyModel(org.apache.wicket.model.PropertyModel) ArrayList(java.util.ArrayList) OnChangeAjaxBehavior(org.apache.wicket.ajax.form.OnChangeAjaxBehavior) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AutoCompleteTextField(org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField) DropDownChoice(org.apache.wicket.markup.html.form.DropDownChoice) BasicSearchPanel(com.evolveum.midpoint.web.component.BasicSearchPanel) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) ShadowKindType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType) FailedOperationTypeType(com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)

Example 2 with SearchFormEnterBehavior

use of com.evolveum.midpoint.web.util.SearchFormEnterBehavior in project midpoint by Evolveum.

the class PageSizePopover method initLayout.

protected void initLayout() {
    Button popButton = new Button(ID_POP_BUTTON);
    popButton.setOutputMarkupId(true);
    add(popButton);
    WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
    popover.setOutputMarkupId(true);
    add(popover);
    Form<?> form = new MidpointForm<>(ID_FORM);
    popover.add(form);
    AjaxSubmitButton button = new AjaxSubmitButton(ID_BUTTON) {

        @Override
        protected void onError(AjaxRequestTarget target) {
            super.onError(target);
            target.add(getPageBase().getFeedbackPanel());
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            super.onSubmit(target);
            pageSizeChanged(target);
        }
    };
    form.add(button);
    TextField<?> input = new TextField<>(ID_INPUT, createInputModel());
    input.add(new RangeValidator<>(5, 100));
    input.setLabel(createStringResource("PageSizePopover.title"));
    input.add(new SearchFormEnterBehavior(button));
    input.setType(Integer.class);
    form.add(input);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) Button(org.apache.wicket.markup.html.form.Button) TextField(org.apache.wicket.markup.html.form.TextField) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 3 with SearchFormEnterBehavior

use of com.evolveum.midpoint.web.util.SearchFormEnterBehavior in project midpoint by Evolveum.

the class TableConfigurationPanel method initPopoverLayout.

private void initPopoverLayout() {
    WebMarkupContainer popover = new WebMarkupContainer(ID_POPOVER);
    popover.setOutputMarkupId(true);
    add(popover);
    Form<?> form = new MidpointForm<>(ID_FORM);
    popover.add(form);
    AjaxSubmitButton button = new AjaxSubmitButton(ID_BUTTON) {

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(TableConfigurationPanel.this.get(createComponentPath(ID_POPOVER, ID_FORM, "inputFeedback")));
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            pageSizeChanged(target);
        }
    };
    form.add(button);
    TextField<?> input = new TextField<>(ID_INPUT, createInputModel());
    input.add(new RangeValidator<>(5, 100));
    input.setLabel(createStringResource("PageSizePopover.title"));
    input.add(new SearchFormEnterBehavior(button));
    input.setType(Integer.class);
    input.setOutputMarkupId(true);
    FeedbackPanel feedback = new FeedbackPanel("inputFeedback", new ComponentFeedbackMessageFilter(input));
    feedback.setOutputMarkupId(true);
    form.add(feedback);
    form.add(input);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) AjaxSubmitButton(com.evolveum.midpoint.web.component.AjaxSubmitButton) ComponentFeedbackMessageFilter(org.apache.wicket.feedback.ComponentFeedbackMessageFilter) FeedbackPanel(org.apache.wicket.markup.html.panel.FeedbackPanel) TextField(org.apache.wicket.markup.html.form.TextField) MidpointForm(com.evolveum.midpoint.web.component.form.MidpointForm) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer)

Example 4 with SearchFormEnterBehavior

use of com.evolveum.midpoint.web.util.SearchFormEnterBehavior in project midpoint by Evolveum.

the class BasicSearchPanel method initLayout.

protected void initLayout() {
    Label label = new Label(ID_LABEL, createTextNameModel());
    add(label);
    AjaxSubmitButton searchButton = new AjaxSubmitButton(ID_SEARCH, createStringResource("BasicSearchPanel.search")) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            searchPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getFeedbackPanel());
        }
    };
    add(searchButton);
    AjaxSubmitButton clearButton = new AjaxSubmitButton(ID_CLEAR_SEARCH) {

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            clearSearchPerformed(target);
        }

        @Override
        protected void onError(AjaxRequestTarget target) {
            target.add(getFeedbackPanel());
        }
    };
    add(clearButton);
    final TextField searchText = new TextField(ID_SEARCH_TEXT, createSearchTextModel());
    searchText.add(AttributeModifier.replace("placeholder", createTextNameModel()));
    searchText.add(new SearchFormEnterBehavior(searchButton));
    add(searchText);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SearchFormEnterBehavior(com.evolveum.midpoint.web.util.SearchFormEnterBehavior) Label(org.apache.wicket.markup.html.basic.Label) TextField(org.apache.wicket.markup.html.form.TextField)

Aggregations

SearchFormEnterBehavior (com.evolveum.midpoint.web.util.SearchFormEnterBehavior)4 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)4 TextField (org.apache.wicket.markup.html.form.TextField)3 AjaxSubmitButton (com.evolveum.midpoint.web.component.AjaxSubmitButton)2 MidpointForm (com.evolveum.midpoint.web.component.form.MidpointForm)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 BasicSearchPanel (com.evolveum.midpoint.web.component.BasicSearchPanel)1 StringChoiceRenderer (com.evolveum.midpoint.web.component.input.StringChoiceRenderer)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 FailedOperationTypeType (com.evolveum.midpoint.xml.ns._public.common.common_3.FailedOperationTypeType)1 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 OnChangeAjaxBehavior (org.apache.wicket.ajax.form.OnChangeAjaxBehavior)1 AutoCompleteTextField (org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField)1 ComponentFeedbackMessageFilter (org.apache.wicket.feedback.ComponentFeedbackMessageFilter)1 Label (org.apache.wicket.markup.html.basic.Label)1 Button (org.apache.wicket.markup.html.form.Button)1 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)1 FeedbackPanel (org.apache.wicket.markup.html.panel.FeedbackPanel)1