use of org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel 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));
}
}
Aggregations