preselect pac if select contains single item

This commit is contained in:
Peter Hormanns 2013-07-15 12:28:04 +02:00
parent 7beee9786b
commit 2cb025e2a3

View File

@ -39,10 +39,18 @@ public class PacPrefixedNamePropertyFieldFactory implements PropertyFieldFactory
sel.setNullSelectionAllowed(false); sel.setNullSelectionAllowed(false);
sel.setNewItemsAllowed(prop.newItemsAllowed()); sel.setNewItemsAllowed(prop.newItemsAllowed());
Map<String, String> selectValues = prop.getSelectValues(); Map<String, String> selectValues = prop.getSelectValues();
for (Object key : selectValues.keySet()) { if (selectValues.size() == 1) {
String key = selectValues.keySet().iterator().next();
sel.addItem(key); sel.addItem(key);
sel.setItemCaption(key, selectValues.get(key)); sel.setItemCaption(key, selectValues.get(key));
sel.select(key);
} else {
for (Object key : selectValues.keySet()) {
sel.addItem(key);
sel.setItemCaption(key, selectValues.get(key));
}
} }
sel.setWidth(80.0f, Sizeable.UNITS_PIXELS); sel.setWidth(80.0f, Sizeable.UNITS_PIXELS);
sel.setInvalidAllowed(prop.newItemsAllowed()); sel.setInvalidAllowed(prop.newItemsAllowed());
layout.addComponent(sel); layout.addComponent(sel);