// customfields
List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
int customFieldIndex = 0;
for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext();) {
CustomField customField = iterator.next();
getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
StringTokenizer tok = new StringTokenizer(customField.getValue(),ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
if (customField.getValue() == null || customField.getValue().equals("") || !tok.hasMoreTokens()) {
// no value define => Text-input
// Add StaticTextElement as workaroung for non translated label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);//null > no label
TextElement textElement = uifactory.addTextElement("customField_" + customFieldIndex, "", 157, project.getCustomFieldValue(customFieldIndex), formLayout);
textElement.setDisplaySize(157);
// textElement.setTranslator(null);
// textElement.setLabel(customField.getName(), null);
textElement.showLabel(false);
customfieldElementList.add(textElement);
} else {
// values define => dropdown selection
List<String> valueList = new ArrayList<String>();
while (tok.hasMoreTokens()) {
String value = tok.nextToken();
valueList.add(value);
getLogger().debug("valueList add: " + value);
}
String[] theValues = new String[valueList.size() + 1];
String[] theKeys = new String[valueList.size() + 1];
int arrayIndex = 0;
theValues[arrayIndex]=translate(DROPDOWN_NO_SELECETION);
theKeys[arrayIndex]=DROPDOWN_NO_SELECETION;
arrayIndex++;
for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext();) {
String value = iterator2.next();
theValues[arrayIndex]=value;
theKeys[arrayIndex]=Integer.toString(arrayIndex);
arrayIndex++;
}
// Add StaticTextElement as workaround for non translated label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);//null > no label
SingleSelection selectionElement = uifactory.addDropdownSingleselect("customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
if (project.getCustomFieldValue(customFieldIndex) != null && !project.getCustomFieldValue(customFieldIndex).equals("")) {
if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
String key = Integer.toString(valueList.indexOf(project.getCustomFieldValue(customFieldIndex)) + 1);// '+1' because no-selection at the beginning
selectionElement.select(key, true);