new editor widget for alias name

This commit is contained in:
Peter Hormanns 2012-12-18 13:59:38 +01:00
parent ed89351c71
commit fa9cd9865b
3 changed files with 14 additions and 38 deletions

View File

@ -6,11 +6,10 @@ import java.util.TreeMap;
import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues; import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.EMailTargetPropertyFieldFactory; import de.hsadmin.web.vaadin.EMailTargetPropertyFieldFactory;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory;
public class EMailAliasModule extends GenericModule { public class EMailAliasModule extends GenericModule {
@ -22,40 +21,10 @@ public class EMailAliasModule extends GenericModule {
protected void initModule() { protected void initModule() {
MainApplication application = getApplication(); MainApplication application = getApplication();
moduleConfig = new ModuleConfig("emailalias", application.getLocale()); 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); PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
idProp.setReadOnly(true); idProp.setReadOnly(true);
PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this));
nameProp.setDefaultValue(new PropertyDefaultValue() { nameProp.setSelectValues(new PropertySelectValues() {
@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() {
@Override @Override
public boolean newItemsAllowed() { public boolean newItemsAllowed() {
return false; return false;
@ -64,6 +33,7 @@ public class EMailAliasModule extends GenericModule {
public boolean hasSelectList() { public boolean hasSelectList() {
return true; return true;
} }
@Override @Override
public Map<String, String> getSelectValues() { public Map<String, String> getSelectValues() {
List<String> list = getPackets(); List<String> list = getPackets();
@ -74,11 +44,11 @@ public class EMailAliasModule extends GenericModule {
return map; 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); idProp.setShowInForm(false);
pacProp.setShowInForm(false);
moduleConfig.addProperty(idProp); moduleConfig.addProperty(idProp);
moduleConfig.addProperty(pacProp);
moduleConfig.addProperty(nameProp); moduleConfig.addProperty(nameProp);
moduleConfig.addProperty(targetProp); moduleConfig.addProperty(targetProp);
} }

View File

@ -1,5 +1,8 @@
id=identifier id=identifier
name=name name=alias
name.pacprefix=packet
name.separator=-
name.postfix=aliaspart
target=target(s) target=target(s)
pac=packet pac=packet
moduletitle=email aliases moduletitle=email aliases

View File

@ -1,5 +1,8 @@
id=Schlüssel id=Schlüssel
name=Alias name=Alias
name.pacprefix=Paket
name.separator=-
name.postfix=Alias-Postfix
target=Ziel(e) target=Ziel(e)
pac=Paket pac=Paket
moduletitle=EMail Aliases moduletitle=EMail Aliases