Search in sources :

Example 1 with StringChoiceRenderer

use of com.evolveum.midpoint.web.component.input.StringChoiceRenderer 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 StringChoiceRenderer

use of com.evolveum.midpoint.web.component.input.StringChoiceRenderer 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 3 with StringChoiceRenderer

use of com.evolveum.midpoint.web.component.input.StringChoiceRenderer in project midpoint by Evolveum.

the class LoggingConfigPanel method initLoggerColumns.

private List<IColumn<LoggerConfiguration, String>> initLoggerColumns() {
    List<IColumn<LoggerConfiguration, String>> columns = new ArrayList<>();
    IColumn column = new CheckBoxHeaderColumn<LoggerConfiguration>();
    columns.add(column);
    //name editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.logger"), "name") {

        @Override
        protected Component createInputPanel(String componentId, final IModel<LoggerConfiguration> model) {
            if (model.getObject() instanceof StandardLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "logger"), WebComponentUtil.createReadonlyModelFromEnum(StandardLoggerType.class), new EnumChoiceRenderer<StandardLoggerType>());
                FormComponent<StandardLoggerType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<StandardLoggerType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else if (model.getObject() instanceof ComponentLogger) {
                DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, "component"), WebComponentUtil.createReadonlyModelFromEnum(LoggingComponentType.class), new EnumChoiceRenderer<LoggingComponentType>());
                FormComponent<LoggingComponentType> input = dropDownChoicePanel.getBaseFormComponent();
                input.add(new NotNullValidator<LoggingComponentType>("logger.emptyLogger"));
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                addAjaxFormComponentUpdatingBehavior(input);
                return dropDownChoicePanel;
            } else {
                TextPanel textPanel = new TextPanel<>(componentId, new PropertyModel<String>(model, getPropertyExpression()));
                FormComponent input = textPanel.getBaseFormComponent();
                addAjaxFormComponentUpdatingBehavior(input);
                input.add(new AttributeAppender("style", "width: 100%"));
                input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
                input.add(new NotNullValidator<StandardLoggerType>("message.emptyString"));
                return textPanel;
            }
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    //level editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersLevel"), "level") {

        @Override
        protected Component createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            DropDownChoicePanel dropDownChoicePanel = new DropDownChoicePanel(componentId, new PropertyModel(model, getPropertyExpression()), WebComponentUtil.createReadonlyModelFromEnum(LoggingLevelType.class));
            FormComponent<LoggingLevelType> input = dropDownChoicePanel.getBaseFormComponent();
            input.add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
            input.add(new NotNullValidator<LoggingLevelType>("message.emptyLevel"));
            addAjaxFormComponentUpdatingBehavior(input);
            return dropDownChoicePanel;
        }

        @Override
        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            LoggerConfiguration configuration = rowModel.getObject();
            return WebComponentUtil.createLocalizedModelForEnum(configuration.getLevel(), getPageBase());
        }
    });
    //appender editing column
    columns.add(new EditableLinkColumn<LoggerConfiguration>(createStringResource("LoggingConfigPanel.loggersAppender"), "appenders") {

        @Override
        protected IModel<String> createLinkModel(IModel<LoggerConfiguration> rowModel) {
            final LoggerConfiguration configuration = rowModel.getObject();
            if (configuration.getAppenders().isEmpty()) {
                return createStringResource("LoggingConfigPanel.appenders.Inherit");
            } else {
                return new LoadableModel<String>() {

                    @Override
                    protected String load() {
                        StringBuilder builder = new StringBuilder();
                        for (String appender : configuration.getAppenders()) {
                            if (configuration.getAppenders().indexOf(appender) != 0) {
                                builder.append(", ");
                            }
                            builder.append(appender);
                        }
                        return builder.toString();
                    }
                };
            }
        }

        @Override
        protected InputPanel createInputPanel(String componentId, IModel<LoggerConfiguration> model) {
            IModel<Map<String, String>> options = new Model(null);
            Map<String, String> optionsMap = new HashMap<String, String>();
            optionsMap.put("nonSelectedText", createStringResource("LoggingConfigPanel.appenders.Inherit").getString());
            options.setObject(optionsMap);
            ListMultipleChoicePanel panel = new ListMultipleChoicePanel<>(componentId, new PropertyModel<List<String>>(model, getPropertyExpression()), createNewLoggerAppendersListModel(), new StringChoiceRenderer(null), options);
            FormComponent<AppenderConfigurationType> input = panel.getBaseFormComponent();
            input.add(new EmptyOnChangeAjaxFormUpdatingBehavior());
            addAjaxFormComponentUpdatingBehavior(input);
            return panel;
        }

        public void onClick(AjaxRequestTarget target, IModel<LoggerConfiguration> rowModel) {
            loggerEditPerformed(target, rowModel);
        }
    });
    return columns;
}
Also used : FormComponent(org.apache.wicket.markup.html.form.FormComponent) DropDownChoicePanel(com.evolveum.midpoint.web.component.input.DropDownChoicePanel) EnumChoiceRenderer(org.apache.wicket.markup.html.form.EnumChoiceRenderer) ArrayList(java.util.ArrayList) TextPanel(com.evolveum.midpoint.web.component.input.TextPanel) ListMultipleChoicePanel(com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel) CheckBoxHeaderColumn(com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) AttributeAppender(org.apache.wicket.behavior.AttributeAppender) LoggerConfiguration(com.evolveum.midpoint.web.page.admin.configuration.dto.LoggerConfiguration) StandardLoggerType(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLoggerType) StandardLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.StandardLogger) IModel(org.apache.wicket.model.IModel) InputPanel(com.evolveum.midpoint.web.component.prism.InputPanel) PropertyModel(org.apache.wicket.model.PropertyModel) NotNullValidator(com.evolveum.midpoint.web.component.input.validator.NotNullValidator) ComponentLogger(com.evolveum.midpoint.web.page.admin.configuration.dto.ComponentLogger) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) StringChoiceRenderer(com.evolveum.midpoint.web.component.input.StringChoiceRenderer) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) IModel(org.apache.wicket.model.IModel) AbstractReadOnlyModel(org.apache.wicket.model.AbstractReadOnlyModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) LoadableModel(com.evolveum.midpoint.gui.api.model.LoadableModel) LoggingComponentType(com.evolveum.midpoint.xml.ns._public.common.common_3.LoggingComponentType) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

StringChoiceRenderer (com.evolveum.midpoint.web.component.input.StringChoiceRenderer)3 ArrayList (java.util.ArrayList)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 ShadowKindType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType)2 QName (javax.xml.namespace.QName)2 AutoCompleteTextField (org.apache.wicket.extensions.ajax.markup.html.autocomplete.AutoCompleteTextField)2 DropDownChoice (org.apache.wicket.markup.html.form.DropDownChoice)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 BasicSearchPanel (com.evolveum.midpoint.web.component.BasicSearchPanel)1 CheckBoxHeaderColumn (com.evolveum.midpoint.web.component.data.column.CheckBoxHeaderColumn)1 DropDownChoicePanel (com.evolveum.midpoint.web.component.input.DropDownChoicePanel)1 ListMultipleChoicePanel (com.evolveum.midpoint.web.component.input.ListMultipleChoicePanel)1 QNameChoiceRenderer (com.evolveum.midpoint.web.component.input.QNameChoiceRenderer)1 TextPanel (com.evolveum.midpoint.web.component.input.TextPanel)1 NotNullValidator (com.evolveum.midpoint.web.component.input.validator.NotNullValidator)1 InputPanel (com.evolveum.midpoint.web.component.prism.InputPanel)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AccountDetailsSearchDto (com.evolveum.midpoint.web.page.admin.configuration.dto.AccountDetailsSearchDto)1 ComponentLogger (com.evolveum.midpoint.web.page.admin.configuration.dto.ComponentLogger)1 LoggerConfiguration (com.evolveum.midpoint.web.page.admin.configuration.dto.LoggerConfiguration)1