From 2cb025e2a39beabfa3919777ba8ec2399af5674b Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Mon, 15 Jul 2013 12:28:04 +0200
Subject: [PATCH] preselect pac if select contains single item

---
 hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java
index 2a7fd26..83f08e5 100644
--- a/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java
+++ b/hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java
@@ -39,10 +39,18 @@
 		sel.setNullSelectionAllowed(false);
 		sel.setNewItemsAllowed(prop.newItemsAllowed());
 		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.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.setInvalidAllowed(prop.newItemsAllowed());
 		layout.addComponent(sel);

--
Gitblit v1.9.0-SNAPSHOT