From fa9cd9865b75e907aea2aaffa21e598db2be26dd Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Tue, 18 Dec 2012 13:59:38 +0100
Subject: [PATCH] new editor widget for alias name

---
 hsarweb/src/texts/emailalias.properties          |    5 ++++-
 hsarweb/src/texts/emailalias_de.properties       |    3 +++
 hsarweb/src/de/hsadmin/web/EMailAliasModule.java |   44 +++++++-------------------------------------
 3 files changed, 14 insertions(+), 38 deletions(-)

diff --git a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java
index 51a4139..c6012ce 100644
--- a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java
+++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java
@@ -6,11 +6,10 @@
 
 import de.hsadmin.web.config.ModuleConfig;
 import de.hsadmin.web.config.PropertyConfig;
-import de.hsadmin.web.config.PropertyDefaultValue;
 import de.hsadmin.web.config.PropertySelectValues;
 import de.hsadmin.web.config.PropertyTableColumn;
 import de.hsadmin.web.vaadin.EMailTargetPropertyFieldFactory;
-import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
+import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory;
 
 public class EMailAliasModule extends GenericModule {
 
@@ -22,40 +21,10 @@
 	protected void initModule() {
 		MainApplication application = getApplication();
 		moduleConfig = new ModuleConfig("emailalias", application.getLocale());
-		String login = application.getRunAs();
-		final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
 		PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
 		idProp.setReadOnly(true);
-		PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
-		nameProp.setDefaultValue(new PropertyDefaultValue() {
-			@Override
-			public String getDefaultValue() {
-				if (pac.length() >= 5) {
-					return pac + "-";
-				}
-				return "";
-			}
-		});
-		nameProp.setWriteOnce(true);
-		PropertyConfig targetProp = new PropertyConfig(moduleConfig, "target", String.class, new EMailTargetPropertyFieldFactory(this));
-		targetProp.setExpandRatio(0.8f);
-		targetProp.setDefaultValue(new PropertyDefaultValue() {
-			@Override
-			public String getDefaultValue() {
-				if (pac.length() >= 5) {
-					return pac + "-";
-				}
-				return "";
-			}
-		});
-		PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
-		pacProp.setDefaultValue(new PropertyDefaultValue() {
-			@Override
-			public String getDefaultValue() {
-				return pac;
-			}
-		});
-		pacProp.setSelectValues(new PropertySelectValues() {
+		PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this));
+		nameProp.setSelectValues(new PropertySelectValues() {
 			@Override
 			public boolean newItemsAllowed() {
 				return false;
@@ -64,6 +33,7 @@
 			public boolean hasSelectList() {
 				return true;
 			}
+			
 			@Override
 			public Map<String, String> getSelectValues() {
 				List<String> list = getPackets();
@@ -74,11 +44,11 @@
 				return map;
 			}
 		});
-		pacProp.setWriteOnce(true);
+		nameProp.setWriteOnce(true);
+		PropertyConfig targetProp = new PropertyConfig(moduleConfig, "target", String.class, new EMailTargetPropertyFieldFactory(this));
+		targetProp.setExpandRatio(0.8f);
 		idProp.setShowInForm(false);
-		pacProp.setShowInForm(false);
 		moduleConfig.addProperty(idProp);
-		moduleConfig.addProperty(pacProp);
 		moduleConfig.addProperty(nameProp);
 		moduleConfig.addProperty(targetProp);
 	}
diff --git a/hsarweb/src/texts/emailalias.properties b/hsarweb/src/texts/emailalias.properties
index 02d411d..d14bd86 100644
--- a/hsarweb/src/texts/emailalias.properties
+++ b/hsarweb/src/texts/emailalias.properties
@@ -1,5 +1,8 @@
 id=identifier
-name=name
+name=alias
+name.pacprefix=packet
+name.separator=-
+name.postfix=aliaspart
 target=target(s)
 pac=packet
 moduletitle=email aliases
diff --git a/hsarweb/src/texts/emailalias_de.properties b/hsarweb/src/texts/emailalias_de.properties
index 6b385f5..804b719 100644
--- a/hsarweb/src/texts/emailalias_de.properties
+++ b/hsarweb/src/texts/emailalias_de.properties
@@ -1,5 +1,8 @@
 id=Schl´┐Żssel
 name=Alias
+name.pacprefix=Paket
+name.separator=-
+name.postfix=Alias-Postfix
 target=Ziel(e)
 pac=Paket
 moduletitle=EMail Aliases

--
Gitblit v1.9.0-SNAPSHOT