in client/idrepo/console/src/main/java/org/apache/syncope/client/console/wizards/any/AbstractAttrsWizardStep.java [187:370]
protected AbstractFieldPanel<?> getFieldPanel(final PlainSchemaTO plainSchema) {
final boolean required;
final boolean readOnly;
final AttrSchemaType type;
final boolean jexlHelp;
if (mode == AjaxWizard.Mode.TEMPLATE) {
required = false;
readOnly = false;
type = AttrSchemaType.String;
jexlHelp = true;
} else {
required = plainSchema.getMandatoryCondition().equalsIgnoreCase("true");
readOnly = plainSchema.isReadonly();
type = plainSchema.getType();
jexlHelp = false;
}
AbstractFieldPanel<?> panel;
switch (type) {
case Boolean:
panel = new AjaxCheckBoxPanel(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
new Model<>(),
true);
panel.setRequired(required);
break;
case Date:
String datePattern = plainSchema.getConversionPattern() == null
? DateFormatUtils.ISO_8601_EXTENDED_DATETIME_TIME_ZONE_FORMAT.getPattern()
: plainSchema.getConversionPattern();
if (StringUtils.containsIgnoreCase(datePattern, "H")) {
panel = new AjaxDateTimeFieldPanel(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
new Model<>(),
FastDateFormat.getInstance(datePattern));
} else {
panel = new AjaxDateFieldPanel(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
new Model<>(),
FastDateFormat.getInstance(datePattern));
}
if (required) {
panel.addRequiredLabel();
}
break;
case Enum:
panel = new AjaxDropDownChoicePanel<>("panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()), new Model<>(), true);
((AjaxDropDownChoicePanel<String>) panel).setChoices(
plainSchema.getEnumValues().keySet().stream().sorted().toList());
if (!plainSchema.getEnumValues().isEmpty()) {
Map<String, String> valueMap = plainSchema.getEnumValues();
((AjaxDropDownChoicePanel<String>) panel).setChoiceRenderer(new IChoiceRenderer<String>() {
private static final long serialVersionUID = -3724971416312135885L;
@Override
public String getDisplayValue(final String value) {
return valueMap.get(value) == null ? value : valueMap.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;
}
});
}
if (required) {
panel.addRequiredLabel();
}
break;
case Dropdown:
List<String> dropdownValues = attributable instanceof AnyTO anyTO
? schemaRestClient.getDropdownValues(plainSchema.getKey(), anyTO)
: attributable instanceof RealmTO realmTO
? schemaRestClient.getDropdownValues(plainSchema.getKey(), realmTO)
: List.of();
if (plainSchema.isMultivalue()) {
panel = new AjaxPalettePanel.Builder<String>().
setName(plainSchema.getLabel(SyncopeConsoleSession.get().getLocale())).
build("panel", new ListModel<>(), new ListModel<>(dropdownValues));
} else {
panel = new AjaxDropDownChoicePanel<>("panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()), new Model<>(), true);
((AjaxDropDownChoicePanel<String>) panel).setChoices(dropdownValues);
}
if (required) {
panel.addRequiredLabel();
}
break;
case Long:
panel = new AjaxNumberFieldPanel.Builder<Long>().enableOnChange().build(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
Long.class,
new Model<>());
if (required) {
panel.addRequiredLabel();
}
break;
case Double:
panel = new AjaxNumberFieldPanel.Builder<Double>().enableOnChange().step(0.1).build(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
Double.class,
new Model<>());
if (required) {
panel.addRequiredLabel();
}
break;
case Binary:
PageReference pageRef = getPageReference();
panel = new BinaryFieldPanel(
"panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()),
new Model<>(),
plainSchema.getMimeType(),
fileKey) {
private static final long serialVersionUID = -3268213909514986831L;
@Override
protected PageReference getPageReference() {
return pageRef;
}
};
if (required) {
panel.addRequiredLabel();
}
break;
case Encrypted:
panel = SyncopeConstants.ENCRYPTED_DECODE_CONVERSION_PATTERN.equals(plainSchema.getConversionPattern())
? new AjaxTextFieldPanel("panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()), new Model<>(), true)
: new EncryptedFieldPanel("panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()), new Model<>(), true);
if (required) {
panel.addRequiredLabel();
}
break;
default:
panel = new AjaxTextFieldPanel("panel",
plainSchema.getLabel(SyncopeConsoleSession.get().getLocale()), new Model<>(), true);
if (jexlHelp) {
AjaxTextFieldPanel.class.cast(panel).enableJexlHelp();
}
if (required) {
panel.addRequiredLabel();
}
}
panel.setReadOnly(readOnly);
return panel;
}