Search in sources :

Example 1 with AjaxDropDownChoicePanel

use of org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel in project syncope by apache.

the class SearchClausePanel method settingsDependingComponents.

@Override
public FieldPanel<SearchClause> settingsDependingComponents() {
    final SearchClause searchClause = this.clause.getObject();
    final WebMarkupContainer operatorContainer = new WebMarkupContainer("operatorContainer");
    operatorContainer.setOutputMarkupId(true);
    field.add(operatorContainer);
    final BootstrapToggleConfig config = new BootstrapToggleConfig().withOnStyle(BootstrapToggleConfig.Style.info).withOffStyle(BootstrapToggleConfig.Style.warning).withSize(BootstrapToggleConfig.Size.mini);
    operatorFragment.add(new BootstrapToggle("operator", new Model<Boolean>() {

        private static final long serialVersionUID = -7157802546272668001L;

        @Override
        public Boolean getObject() {
            return searchClause.getOperator() == Operator.AND;
        }

        @Override
        public void setObject(final Boolean object) {
            searchClause.setOperator(object ? Operator.AND : Operator.OR);
        }
    }, config) {

        private static final long serialVersionUID = 2969634208049189343L;

        @Override
        protected IModel<String> getOffLabel() {
            return Model.of("OR");
        }

        @Override
        protected IModel<String> getOnLabel() {
            return Model.of("AND");
        }

        @Override
        protected CheckBox newCheckBox(final String id, final IModel<Boolean> model) {
            final CheckBox checkBox = super.newCheckBox(id, model);
            checkBox.add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onUpdate(final AjaxRequestTarget target) {
                }
            });
            return checkBox;
        }
    }.setOutputMarkupPlaceholderTag(true));
    if (getIndex() > 0) {
        operatorContainer.add(operatorFragment);
    } else {
        operatorContainer.add(searchButtonFragment);
    }
    final AjaxTextFieldPanel property = new AjaxTextFieldPanel("property", "property", new PropertyModel<String>(searchClause, "property"), false);
    property.hideLabel().setOutputMarkupId(true).setEnabled(true);
    property.setChoices(properties.getObject());
    field.add(property);
    property.getField().add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) { event.preventDefault(); }")));
    property.getField().add(new IndicatorAjaxEventBehavior("onkeyup") {

        private static final long serialVersionUID = -7866120562087857309L;

        @Override
        protected void onEvent(final AjaxRequestTarget target) {
            if (field.getModel().getObject() == null || field.getModel().getObject().getType() == null) {
                return;
            }
            if (field.getModel().getObject().getType() == Type.GROUP_MEMBERSHIP) {
                String[] inputAsArray = property.getField().getInputAsArray();
                if (StringUtils.isBlank(property.getField().getInput()) || inputAsArray.length == 0) {
                    property.setChoices(properties.getObject());
                } else {
                    String inputValue = (inputAsArray.length > 1 && inputAsArray[1] != null) ? inputAsArray[1] : property.getField().getInput();
                    inputValue = (inputValue.startsWith("*") && !inputValue.endsWith("*")) ? inputValue + "*" : (!inputValue.startsWith("*") && inputValue.endsWith("*")) ? "*" + inputValue : (inputValue.startsWith("*") && inputValue.endsWith("*") ? inputValue : "*" + inputValue + "*");
                    if (groupInfo.getRight() > AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY) {
                        List<GroupTO> filteredGroups = groupRestClient.search("/", SyncopeClient.getGroupSearchConditionBuilder().is("name").equalToIgnoreCase(inputValue).query(), 1, AnyObjectSearchPanel.MAX_GROUP_LIST_CARDINALITY, new SortParam<>("name", true), null);
                        Collection<String> newList = CollectionUtils.collect(filteredGroups, new Transformer<GroupTO, String>() {

                            @Override
                            public String transform(final GroupTO input) {
                                return input.getName();
                            }
                        });
                        final List<String> names = new ArrayList<>(newList);
                        Collections.sort(names);
                        property.setChoices(names);
                    }
                }
            }
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().clear();
        }
    }, new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
        }
    });
    final AjaxDropDownChoicePanel<SearchClause.Comparator> comparator = new AjaxDropDownChoicePanel<>("comparator", "comparator", new PropertyModel<>(searchClause, "comparator"));
    comparator.setChoices(comparators);
    comparator.setNullValid(false).hideLabel().setOutputMarkupId(true);
    comparator.setRequired(required);
    comparator.setChoiceRenderer(getComparatorRender(field.getModel()));
    field.add(comparator);
    final AjaxTextFieldPanel value = new AjaxTextFieldPanel("value", "value", new PropertyModel<>(searchClause, "value"), false);
    value.hideLabel().setOutputMarkupId(true);
    field.add(value);
    value.getField().add(AttributeModifier.replace("onkeydown", Model.of("if(event.keyCode == 13) {event.preventDefault();}")));
    value.getField().add(new IndicatorAjaxEventBehavior("onkeydown") {

        private static final long serialVersionUID = -7133385027739964990L;

        @Override
        protected void onEvent(final AjaxRequestTarget target) {
            target.focusComponent(null);
            value.getField().inputChanged();
            value.getField().validate();
            if (value.getField().isValid()) {
                value.getField().valid();
                value.getField().updateModel();
            }
        }

        @Override
        protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
            super.updateAjaxAttributes(attributes);
            attributes.getAjaxCallListeners().add(new AjaxCallListener() {

                private static final long serialVersionUID = 7160235486520935153L;

                @Override
                public CharSequence getPrecondition(final Component component) {
                    return "if (Wicket.Event.keyCode(attrs.event)  == 13) { return true; } else { return false; }";
                }
            });
        }
    });
    final AjaxDropDownChoicePanel<SearchClause.Type> type = new AjaxDropDownChoicePanel<>("type", "type", new PropertyModel<>(searchClause, "type"));
    type.setChoices(types).hideLabel().setRequired(required).setOutputMarkupId(true);
    type.setNullValid(false);
    type.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            final SearchClause searchClause = new SearchClause();
            if (StringUtils.isNotEmpty(type.getDefaultModelObjectAsString())) {
                searchClause.setType(Type.valueOf(type.getDefaultModelObjectAsString()));
            }
            SearchClausePanel.this.clause.setObject(searchClause);
            setFieldAccess(searchClause.getType(), property, comparator, value);
            // reset property value in case and just in case of change of type
            property.setModelObject(StringUtils.EMPTY);
            target.add(property);
            target.add(comparator);
            target.add(value);
        }
    });
    field.add(type);
    comparator.getField().add(new IndicatorAjaxFormComponentUpdatingBehavior(Constants.ON_CHANGE) {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            if (type.getModelObject() == SearchClause.Type.ATTRIBUTE || type.getModelObject() == SearchClause.Type.RELATIONSHIP) {
                if (comparator.getModelObject() == SearchClause.Comparator.IS_NULL || comparator.getModelObject() == SearchClause.Comparator.IS_NOT_NULL) {
                    value.setModelObject(StringUtils.EMPTY);
                    value.setEnabled(false);
                } else {
                    value.setEnabled(true);
                }
                target.add(value);
            }
            if (type.getModelObject() == SearchClause.Type.RELATIONSHIP) {
                property.setEnabled(true);
                final SearchClause searchClause = new SearchClause();
                searchClause.setType(Type.valueOf(type.getDefaultModelObjectAsString()));
                searchClause.setComparator(comparator.getModelObject());
                SearchClausePanel.this.clause.setObject(searchClause);
                target.add(property);
            }
        }
    });
    setFieldAccess(searchClause.getType(), property, comparator, value);
    return this;
}
Also used : Transformer(org.apache.commons.collections4.Transformer) IndicatorAjaxFormComponentUpdatingBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxFormComponentUpdatingBehavior) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) SortParam(org.apache.wicket.extensions.markup.html.repeater.util.SortParam) Comparator(org.apache.syncope.client.console.panels.search.SearchClause.Comparator) IndicatorAjaxEventBehavior(org.apache.syncope.client.console.wicket.ajax.form.IndicatorAjaxEventBehavior) List(java.util.List) ArrayList(java.util.ArrayList) Component(org.apache.wicket.Component) FormComponent(org.apache.wicket.markup.html.form.FormComponent) IModel(org.apache.wicket.model.IModel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) GroupTO(org.apache.syncope.common.lib.to.GroupTO) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) Type(org.apache.syncope.client.console.panels.search.SearchClause.Type) BootstrapToggleConfig(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggleConfig) BootstrapToggle(de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggle) CheckBox(org.apache.wicket.markup.html.form.CheckBox) Collection(java.util.Collection) AjaxCallListener(org.apache.wicket.ajax.attributes.AjaxCallListener)

Example 2 with AjaxDropDownChoicePanel

use of org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel in project syncope by apache.

the class ParametersDetailsPanel method getFieldPanel.

@SuppressWarnings({ "rawtypes", "unchecked" })
private Panel getFieldPanel(final String id, final AttrTO attrTO) {
    final String valueHeaderName = getString("values");
    final PlainSchemaTO schemaTO = schemaRestClient.read(SchemaType.PLAIN, attrTO.getSchema());
    final FieldPanel panel;
    switch(schemaTO.getType()) {
        case Date:
            final String datePattern = schemaTO.getConversionPattern() == null ? SyncopeConstants.DEFAULT_DATE_PATTERN : schemaTO.getConversionPattern();
            if (StringUtils.containsIgnoreCase(datePattern, "H")) {
                panel = new AjaxDateTimeFieldPanel("panel", schemaTO.getKey(), new Model<>(), datePattern);
            } else {
                panel = new AjaxDateFieldPanel("panel", schemaTO.getKey(), new Model<>(), datePattern);
            }
            break;
        case Boolean:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(Arrays.asList("true", "false"));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid(false);
            break;
        case Enum:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(SchemaUtils.getEnumeratedValues(schemaTO));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid("false".equalsIgnoreCase(schemaTO.getMandatoryCondition()));
            break;
        case Long:
            panel = new AjaxSpinnerFieldPanel.Builder<Long>().build(id, valueHeaderName, Long.class, new Model<Long>());
            break;
        case Double:
            panel = new AjaxSpinnerFieldPanel.Builder<Double>().build(id, valueHeaderName, Double.class, new Model<Double>());
            break;
        case Binary:
            panel = new BinaryFieldPanel(id, valueHeaderName, new Model<>(), schemaTO.getMimeType(), schema.getModelObject());
            break;
        case Encrypted:
            panel = new EncryptedFieldPanel(id, valueHeaderName, new Model<>(), true);
            break;
        default:
            panel = new AjaxTextFieldPanel(id, valueHeaderName, new Model<>(), false);
    }
    if (schemaTO.isMultivalue()) {
        return new MultiFieldPanel.Builder<>(new PropertyModel<List<String>>(attrTO, "values")).build(id, valueHeaderName, panel);
    } else {
        panel.setNewModel(attrTO.getValues());
    }
    panel.setRequired("true".equalsIgnoreCase(schemaTO.getMandatoryCondition()));
    return panel;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Example 3 with AjaxDropDownChoicePanel

use of org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel in project syncope by apache.

the class ParametersCreateWizardAttrStep method getFieldPanel.

@SuppressWarnings({ "rawtypes", "unchecked" })
private Panel getFieldPanel(final String id, final AttrTO attrTO, final PlainSchemaTO plainSchemaTO) {
    final String valueHeaderName = getString("values");
    final FieldPanel panel;
    switch(plainSchemaTO.getType()) {
        case Date:
            final String dataPattern = plainSchemaTO.getConversionPattern() == null ? SyncopeConstants.DEFAULT_DATE_PATTERN : plainSchemaTO.getConversionPattern();
            if (dataPattern.contains("H")) {
                panel = new AjaxDateTimeFieldPanel(id, valueHeaderName, new Model<>(), dataPattern);
            } else {
                panel = new AjaxDateFieldPanel("panel", valueHeaderName, new Model<>(), dataPattern);
            }
            break;
        case Boolean:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(Arrays.asList("true", "false"));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid(false);
            break;
        case Enum:
            panel = new AjaxDropDownChoicePanel<>(id, valueHeaderName, new Model<>(), false);
            ((AjaxDropDownChoicePanel<String>) panel).setChoices(SchemaUtils.getEnumeratedValues(plainSchemaTO));
            if (!attrTO.getValues().isEmpty()) {
                ((AjaxDropDownChoicePanel) panel).setChoiceRenderer(new IChoiceRenderer<String>() {

                    private static final long serialVersionUID = -3724971416312135885L;

                    @Override
                    public String getDisplayValue(final String value) {
                        return value;
                    }

                    @Override
                    public String getIdValue(final String value, final int i) {
                        return value;
                    }

                    @Override
                    public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
                        return id;
                    }
                });
            }
            ((AjaxDropDownChoicePanel<String>) panel).setNullValid("true".equalsIgnoreCase(plainSchemaTO.getMandatoryCondition()));
            break;
        case Long:
            panel = new AjaxSpinnerFieldPanel.Builder<Long>().build(id, valueHeaderName, Long.class, new Model<Long>());
            break;
        case Double:
            panel = new AjaxSpinnerFieldPanel.Builder<Double>().build(id, valueHeaderName, Double.class, new Model<Double>());
            break;
        case Binary:
            panel = new BinaryFieldPanel(id, valueHeaderName, new Model<>(), plainSchemaTO.getMimeType(), schema.getModelObject());
            break;
        case Encrypted:
            panel = new EncryptedFieldPanel(id, valueHeaderName, new Model<>(), true);
            break;
        default:
            panel = new AjaxTextFieldPanel(id, valueHeaderName, new Model<>(), false);
    }
    if (plainSchemaTO.isMultivalue()) {
        return new MultiFieldPanel.Builder<>(new PropertyModel<>(attrTO, "values")).build(id, valueHeaderName, panel);
    } else {
        panel.setNewModel(attrTO.getValues());
    }
    panel.setRequired("true".equalsIgnoreCase(plainSchemaTO.getMandatoryCondition()));
    return panel;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) LoadableDetachableModel(org.apache.wicket.model.LoadableDetachableModel) PropertyModel(org.apache.wicket.model.PropertyModel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Example 4 with AjaxDropDownChoicePanel

use of org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel in project syncope by apache.

the class BeanPanel method buildSinglePanel.

@SuppressWarnings({ "unchecked", "rawtypes" })
private FieldPanel buildSinglePanel(final Serializable bean, final Class<?> type, final String fieldName, final String id) {
    FieldPanel result = null;
    PropertyModel model = new PropertyModel(bean, fieldName);
    if (ClassUtils.isAssignable(Boolean.class, type)) {
        result = new AjaxCheckBoxPanel(id, fieldName, model);
    } else if (ClassUtils.isAssignable(Number.class, type)) {
        result = new AjaxSpinnerFieldPanel.Builder<>().build(id, fieldName, (Class<Number>) ClassUtils.resolvePrimitiveIfNecessary(type), model);
    } else if (Date.class.equals(type)) {
        result = new AjaxDateTimeFieldPanel(id, fieldName, model, SyncopeConstants.DEFAULT_DATE_PATTERN);
    } else if (type.isEnum()) {
        result = new AjaxDropDownChoicePanel(id, fieldName, model).setChoices(Arrays.asList(type.getEnumConstants()));
    }
    // treat as String if nothing matched above
    if (result == null) {
        result = new AjaxTextFieldPanel(id, fieldName, model);
    }
    result.hideLabel();
    return result;
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)

Example 5 with AjaxDropDownChoicePanel

use of org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel in project syncope by apache.

the class HistoryConfDetails method initDropdownDiffConfForm.

private Form<?> initDropdownDiffConfForm() {
    final Form<T> form = new Form<>("form");
    form.setModel(new CompoundPropertyModel<>(selectedHistoryConfTO));
    form.setOutputMarkupId(true);
    final Map<String, String> namesMap = getDropdownNamesMap(availableHistoryConfTOs);
    List<String> keys = new ArrayList<>(namesMap.keySet());
    final AjaxDropDownChoicePanel<String> dropdownElem = new AjaxDropDownChoicePanel<>("compareDropdown", getString("compare"), new PropertyModel<>(selectedHistoryConfTO, "key"), false);
    dropdownElem.setChoices(keys);
    dropdownElem.setChoiceRenderer(new IChoiceRenderer<String>() {

        private static final long serialVersionUID = -6265603675261014912L;

        @Override
        public Object getDisplayValue(final String value) {
            return namesMap.get(value) == null ? value : namesMap.get(value);
        }

        @Override
        public String getIdValue(final String value, final int i) {
            return value;
        }

        @Override
        public String getObject(final String id, final IModel<? extends List<? extends String>> choices) {
            return id;
        }
    });
    dropdownElem.setNullValid(true);
    dropdownElem.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {

        private static final long serialVersionUID = -1107858522700306810L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            List<T> elemsToCompare = new ArrayList<>();
            elemsToCompare.add(selectedHistoryConfTO);
            final String selectedKey = dropdownElem.getModelObject();
            if (selectedKey != null) {
                if (!selectedKey.isEmpty()) {
                    T confToCompare = availableHistoryConfTOs.stream().filter(object -> object.getKey().equals(selectedKey)).findAny().orElse(null);
                    elemsToCompare.add(confToCompare);
                    showConfigurationDiffPanel(elemsToCompare);
                } else {
                    showConfigurationSinglePanel();
                }
            }
            target.add(jsonPanel);
        }
    });
    form.add(dropdownElem);
    return form;
}
Also used : AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) Form(org.apache.wicket.markup.html.form.Form) AjaxFormComponentUpdatingBehavior(org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior) SyncopeConsoleSession(org.apache.syncope.client.console.SyncopeConsoleSession) ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) JsonDiffPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonDiffPanel) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IModel(org.apache.wicket.model.IModel) ResourceRestClient(org.apache.syncope.client.console.rest.ResourceRestClient) JsonEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.JsonEditorPanel) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) BaseModal(org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AbstractHistoryConf(org.apache.syncope.common.lib.to.AbstractHistoryConf) IOException(java.io.IOException) PageReference(org.apache.wicket.PageReference) Collectors(java.util.stream.Collectors) List(java.util.List) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) PropertyModel(org.apache.wicket.model.PropertyModel) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnectorRestClient(org.apache.syncope.client.console.rest.ConnectorRestClient) Form(org.apache.wicket.markup.html.form.Form) ArrayList(java.util.ArrayList) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

AjaxDropDownChoicePanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel)6 AjaxTextFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel)5 IModel (org.apache.wicket.model.IModel)5 PropertyModel (org.apache.wicket.model.PropertyModel)5 AjaxDateTimeFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel)4 AjaxSpinnerFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel)4 FieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel)4 MultiFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel)4 AjaxDateFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel)3 BinaryFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel)3 EncryptedFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel)3 Model (org.apache.wicket.model.Model)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AjaxCheckBoxPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel)2 PageReference (org.apache.wicket.PageReference)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 CompoundPropertyModel (org.apache.wicket.model.CompoundPropertyModel)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 BootstrapToggle (de.agilecoders.wicket.extensions.markup.html.bootstrap.form.checkbox.bootstraptoggle.BootstrapToggle)1