Search in sources :

Example 1 with AjaxPasswordFieldPanel

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

the class ConnConfPropertyListView method populateItem.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void populateItem(final ListItem<ConnConfProperty> item) {
    final ConnConfProperty property = item.getModelObject();
    final String label = StringUtils.isBlank(property.getSchema().getDisplayName()) ? property.getSchema().getName() : property.getSchema().getDisplayName();
    final FieldPanel<? extends Serializable> field;
    boolean required = false;
    boolean isArray = false;
    if (property.getSchema().isConfidential() || Constants.GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType()) || Constants.GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {
        field = new AjaxPasswordFieldPanel("panel", label, new Model<>(), false);
        ((PasswordTextField) field.getField()).setResetPassword(false);
        required = property.getSchema().isRequired();
    } else {
        Class<?> propertySchemaClass;
        try {
            propertySchemaClass = ClassUtils.getClass(property.getSchema().getType());
            if (ClassUtils.isPrimitiveOrWrapper(propertySchemaClass)) {
                propertySchemaClass = org.apache.commons.lang3.ClassUtils.primitiveToWrapper(propertySchemaClass);
            }
        } catch (ClassNotFoundException e) {
            LOG.error("Error parsing attribute type", e);
            propertySchemaClass = String.class;
        }
        if (ClassUtils.isAssignable(Number.class, propertySchemaClass)) {
            @SuppressWarnings("unchecked") Class<Number> numberClass = (Class<Number>) propertySchemaClass;
            field = new AjaxSpinnerFieldPanel.Builder<>().build("panel", label, numberClass, new Model<>());
            required = property.getSchema().isRequired();
        } else if (ClassUtils.isAssignable(Boolean.class, propertySchemaClass)) {
            field = new AjaxCheckBoxPanel("panel", label, new Model<>());
        } else {
            field = new AjaxTextFieldPanel("panel", label, new Model<>());
            required = property.getSchema().isRequired();
        }
        if (propertySchemaClass.isArray()) {
            isArray = true;
        }
    }
    field.setIndex(item.getIndex());
    field.setTitle(property.getSchema().getHelpMessage(), true);
    final AbstractFieldPanel<? extends Serializable> fieldPanel;
    if (isArray) {
        final MultiFieldPanel multiFieldPanel = new MultiFieldPanel.Builder(new PropertyModel<>(property, "values")).setEventTemplate(true).build("panel", label, field);
        item.add(multiFieldPanel);
        fieldPanel = multiFieldPanel;
    } else {
        setNewFieldModel(field, property.getValues());
        item.add(field);
        fieldPanel = field;
    }
    if (required) {
        fieldPanel.addRequiredLabel();
    }
    if (withOverridable) {
        fieldPanel.showExternAction(addCheckboxToggle(property));
    }
}
Also used : AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) PasswordTextField(org.apache.wicket.markup.html.form.PasswordTextField) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) AjaxPasswordFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) PropertyModel(org.apache.wicket.model.PropertyModel)

Aggregations

AjaxCheckBoxPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel)1 AjaxPasswordFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxPasswordFieldPanel)1 AjaxTextFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel)1 MultiFieldPanel (org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel)1 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)1 PasswordTextField (org.apache.wicket.markup.html.form.PasswordTextField)1 IModel (org.apache.wicket.model.IModel)1 Model (org.apache.wicket.model.Model)1 PropertyModel (org.apache.wicket.model.PropertyModel)1