item.add(new Label("label", new ResourceModel(field.getName())));
final AbstractFieldPanel component;
try {
if (field.getClassList() != null) {
component = new AjaxDropDownChoicePanel("field", field.getName(), new PropertyModel(policy,
field.getName()));
final List<String> rules = correlationRules.getObject();
if (rules != null && !rules.isEmpty()) {
((AjaxDropDownChoicePanel) component).setChoices(correlationRules.getObject());
}
item.add(component);
item.add(getActivationControl(
component,
propDesc.getReadMethod().invoke(policy, new Object[]{}) != null,
null,
null));
} else if (field.getType().isEnum()) {
component = new AjaxDropDownChoicePanel("field", field.getName(), new PropertyModel(policy,
field.getName()));
final Serializable[] values = (Serializable[]) field.getType().getEnumConstants();
if (values != null && values.length > 0) {
((AjaxDropDownChoicePanel) component).setChoices(Arrays.asList(values));
}
item.add(component);
item.add(getActivationControl(
component,
(Enum<?>) propDesc.getReadMethod().invoke(policy, new Object[]{}) != null,
values[0],
values[0]));
} else if (field.getType().equals(boolean.class) || field.getType().equals(Boolean.class)) {
item.add(new AjaxCheckBoxPanel("check", field.getName(), new PropertyModel(policy,
field.getName())));
item.add(new Label("field", new Model(null)));
} else if (Collection.class.isAssignableFrom(field.getType())) {
if (field.getSchemaList() != null) {
final List<String> values = new ArrayList<String>();
if (field.getName().charAt(0) == 'r') {
values.addAll(roleSchemas.getObject());
if (field.getSchemaList().extended()) {
values.add("name");
}
} else {
values.addAll(userSchemas.getObject());
if (field.getSchemaList().extended()) {
values.add("id");
values.add("username");
}
}
Collection collection =
(Collection) propDesc.getReadMethod().invoke(policy, new Object[]{});
if (collection == null) {
collection = new ArrayList();
propDesc.getWriteMethod().invoke(policy, collection);
}
component = new AjaxPalettePanel("field", new PropertyModel(policy, field.getName()),
new ListModel<String>(values));
item.add(component);
item.add(getActivationControl(component,
!collection.isEmpty(), new ArrayList<String>(), new ArrayList<String>()));
} else {
final FieldPanel panel = new AjaxTextFieldPanel("panel", field.getName(),
new Model<String>(null));
panel.setRequired(true);
component = new MultiValueSelectorPanel<String>("field",
new PropertyModel(policy, field.getName()), panel);
item.add(component);
final List<String> reinitializedValue = new ArrayList<String>();
reinitializedValue.add("");
item.add(getActivationControl(component,
!((Collection) propDesc.getReadMethod().invoke(policy, new Object[]{})).isEmpty(),
new ArrayList<String>(), (Serializable) reinitializedValue));
}
} else if (field.getType().equals(int.class) || field.getType().equals(Integer.class)) {
component = new AjaxTextFieldPanel("field", field.getName(),
new PropertyModel(policy, field.getName()));
item.add(component);
item.add(getActivationControl(component,
(Integer) propDesc.getReadMethod().invoke(policy, new Object[]{}) > 0, 0, 0));