};
bundleTO = getSelectedBundleTO(bundles.getObject(), connectorTO);
properties = fillProperties(bundleTO, connectorTO);
final AjaxTextFieldPanel connectorName = new AjaxTextFieldPanel(
"connectorName", "connector name", new PropertyModel<String>(connectorTO, "connectorName"));
connectorName.setOutputMarkupId(true);
connectorName.setEnabled(false);
final AjaxTextFieldPanel displayName = new AjaxTextFieldPanel(
"displayName", "display name", new PropertyModel<String>(connectorTO, "displayName"));
displayName.setOutputMarkupId(true);
displayName.addRequiredLabel();
final AjaxTextFieldPanel version = new AjaxTextFieldPanel(
"version", "version", new PropertyModel<String>(connectorTO, "version"));
displayName.setOutputMarkupId(true);
version.setEnabled(false);
final AjaxDropDownChoicePanel<ConnBundleTO> bundle =
new AjaxDropDownChoicePanel<ConnBundleTO>("bundle", "bundle", new Model<ConnBundleTO>(bundleTO));
bundle.setStyleShet("long_dynamicsize");
bundle.setChoices(bundles.getObject());
bundle.setChoiceRenderer(new ChoiceRenderer<ConnBundleTO>() {
private static final long serialVersionUID = -1945543182376191187L;
@Override
public Object getDisplayValue(final ConnBundleTO object) {
return object.getBundleName() + " " + object.getVersion();
}
@Override
public String getIdValue(final ConnBundleTO object, final int index) {
// idValue must include version as well in order to cope
// with multiple version of the same bundle.
return object.getBundleName() + "#" + object.getVersion();
}
});
((DropDownChoice) bundle.getField()).setNullValid(true);
bundle.setRequired(true);
bundle.getField().add(new AjaxFormComponentUpdatingBehavior("onchange") {
private static final long serialVersionUID = -1107858522700306810L;
@Override
protected void onUpdate(final AjaxRequestTarget target) {
// reset all information stored in connectorTO
connectorTO.setConfiguration(new HashSet<ConnConfProperty>());
((DropDownChoice) bundle.getField()).setNullValid(false);
target.add(bundle.getField());
target.add(connectorName);
target.add(version);
target.add(propertiesContainer);
}
});
bundle.getField().setModel(new IModel<ConnBundleTO>() {
private static final long serialVersionUID = -3736598995576061229L;
@Override
public ConnBundleTO getObject() {
return bundleTO;
}
@Override
public void setObject(final ConnBundleTO object) {
if (object != null && connectorTO != null) {
connectorTO.setBundleName(object.getBundleName());
connectorTO.setVersion(object.getVersion());
connectorTO.setConnectorName(object.getConnectorName());
properties = fillProperties(object, connectorTO);
bundleTO = object;
}
}
@Override
public void detach() {
}
});
bundle.addRequiredLabel();
bundle.setEnabled(connectorTO.getId() == 0);
final ListView<ConnConfProperty> view = new ListView<ConnConfProperty>(
"connectorProperties", new PropertyModel(this, "properties")) {
private static final long serialVersionUID = 9101744072914090143L;
@Override
protected void populateItem(final ListItem<ConnConfProperty> item) {
final ConnConfProperty property = item.getModelObject();
final Label label = new Label("connPropAttrSchema", property.getSchema().getDisplayName() == null
|| property.getSchema().getDisplayName().isEmpty()
? property.getSchema().getName()
: property.getSchema().getDisplayName());
item.add(label);
final FieldPanel field;
boolean required = false;
boolean isArray = false;
if (property.getSchema().isConfidential()
|| GUARDED_STRING.equalsIgnoreCase(property.getSchema().getType())
|| GUARDED_BYTE_ARRAY.equalsIgnoreCase(property.getSchema().getType())) {
field = new AjaxPasswordFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());
((PasswordTextField) field.getField()).setResetPassword(false);
required = property.getSchema().isRequired();
} else {
Class<?> propertySchemaClass;
try {
propertySchemaClass =
ClassUtils.forName(property.getSchema().getType(), ClassUtils.getDefaultClassLoader());
} catch (Exception e) {
LOG.error("Error parsing attribute type", e);
propertySchemaClass = String.class;
}
if (NUMBER.contains(propertySchemaClass)) {
field = new AjaxNumberFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model(),
ClassUtils.resolvePrimitiveIfNecessary(propertySchemaClass));
required = property.getSchema().isRequired();
} else if (Boolean.class.equals(propertySchemaClass) || boolean.class.equals(propertySchemaClass)) {
field = new AjaxCheckBoxPanel("panel", label.getDefaultModelObjectAsString(), new Model());
} else {
field = new AjaxTextFieldPanel("panel", label.getDefaultModelObjectAsString(), new Model());
required = property.getSchema().isRequired();
}
if (String[].class.equals(propertySchemaClass)) {