From 3ff6a8a5816799ecc448ba59b154dd00406bac40 Mon Sep 17 00:00:00 2001 From: Purodha Date: Thu, 3 Jan 2013 14:14:32 +0000 Subject: [PATCH] Domain-options shown and editable in web interface. Minor corrections elsewhere. --- hsarweb/src/de/hsadmin/web/DomainModule.java | 4 + .../de/hsadmin/web/DomainReadonlyModule.java | 1 + .../de/hsadmin/web/ListOfStringsProperty.java | 6 +- .../DomainOptionsPropertyFieldFactory.java | 133 ++++++++++++------ .../EMailTargetPropertyFieldFactory.java | 8 +- hsarweb/src/texts/domain.properties | 10 ++ hsarweb/src/texts/domain_de.properties | 10 ++ hsarweb/src/texts/domain_ksh.properties | 21 +++ hsarweb/src/texts/home_ksh.properties | 2 +- 9 files changed, 145 insertions(+), 50 deletions(-) create mode 100644 hsarweb/src/texts/domain_ksh.properties diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java index d1ddfef..054a7a5 100644 --- a/hsarweb/src/de/hsadmin/web/DomainModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainModule.java @@ -11,6 +11,7 @@ import de.hsadmin.web.config.PropertyDefaultValue; import de.hsadmin.web.config.PropertySelectValues; import de.hsadmin.web.config.PropertyTableColumn; import de.hsadmin.web.vaadin.DatePropertyFieldFactory; +import de.hsadmin.web.vaadin.DomainOptionsPropertyFieldFactory; import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; public class DomainModule extends GenericModule { @@ -56,6 +57,8 @@ public class DomainModule extends GenericModule { } }); userProp.setWriteOnce(true); + PropertyConfig optionsProp = new PropertyConfig(moduleConfig, "domainoptions", String.class, PropertyTableColumn.HIDDEN, new DomainOptionsPropertyFieldFactory(this)); + optionsProp.setWriteOnce(true); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN); pacProp.setDefaultValue(new PropertyDefaultValue() { @Override @@ -74,6 +77,7 @@ public class DomainModule extends GenericModule { moduleConfig.addProperty(idProp); moduleConfig.addProperty(nameProp); moduleConfig.addProperty(userProp); + moduleConfig.addProperty(optionsProp); moduleConfig.addProperty(pacProp); moduleConfig.addProperty(hiveProp); moduleConfig.addProperty(sinceProp); diff --git a/hsarweb/src/de/hsadmin/web/DomainReadonlyModule.java b/hsarweb/src/de/hsadmin/web/DomainReadonlyModule.java index 505cada..affff7d 100644 --- a/hsarweb/src/de/hsadmin/web/DomainReadonlyModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainReadonlyModule.java @@ -19,6 +19,7 @@ public class DomainReadonlyModule extends AbstractModule { moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domainoptions", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class, new DatePropertyFieldFactory())); diff --git a/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java index 97358f0..e901296 100644 --- a/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java +++ b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java @@ -6,7 +6,7 @@ import java.util.List; public class ListOfStringsProperty implements XmlrpcProperty { - public final List properties; + private final List properties; public ListOfStringsProperty(){ this.properties = new ArrayList(); @@ -15,6 +15,10 @@ public class ListOfStringsProperty implements XmlrpcProperty { public boolean add(String string){ return properties.add(string); } + + public boolean contains(String string){ + return properties.contains(string); + } @Override public Object toXmlrpcParam() { diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java index fd00e75..158d481 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java @@ -1,57 +1,90 @@ package de.hsadmin.web.vaadin; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.AbstractField; +import com.vaadin.ui.Button; +import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Label; +import com.vaadin.ui.Select; import com.vaadin.ui.VerticalLayout; import de.hsadmin.web.AbstractProperty; +import de.hsadmin.web.GenericModule; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.ListOfStringsProperty; +import de.hsadmin.web.Module; import de.hsadmin.web.XmlrpcProperty; +import de.hsadmin.web.config.LocaleConfig; +import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; /** - * @author pblissenbach + * @author Purodha Blissenbach * */ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory { - private Map optionTypes ; // TODO: auf Vorrat hier - private ListOfStringsProperty setOptions ; + private final Module module; + private final ModuleConfig config ; + // TODO: besorge Options und ihre Typen aus der DB + private static final String[] OPTION_NAMES = new String[] { "backupmxforexternalmx", "greylisting", "htdocsfallback", "includes", "indexes", "multiviews", "php"}; +// private final Map optionTypes ; // TODO: auf Vorrat hier + // TODO: besorge Options .... Ende private boolean readOnly = false; private boolean writeOnce = false; private VerticalLayout layout; + private List optionLayout ; + private ListOfStringsProperty setOptions ; - public DomainOptionsPropertyFieldFactory() { - // TODO: besorge Options und ihre Typen aus der DB - optionTypes = new HashMap() ; - optionTypes.put("backupmxforexternalmx", null); - optionTypes.put("greylisting", null); - optionTypes.put("htdocsfallback", null); - optionTypes.put("includes", null); - optionTypes.put("indexes", null); - optionTypes.put("multiviews", null); - optionTypes.put("nonexistiondomainoptionfortesting", null); // TESTCASE - optionTypes.put("php", null); - // TODO: besorge Options .... Ende -// setOptions = null ; + public DomainOptionsPropertyFieldFactory(Module module) { + this.module = module; + this.config = module.getModuleConfig(); + optionLayout = new ArrayList() ; setOptions = new ListOfStringsProperty() ; - // TODO Auto-generated constructor stub + } + + private void repaint() { + layout.removeAllComponents(); + for (int idx=0 ; idx 0) { - Object object = ((AbstractField) rightPart.getComponent(0)).getValue(); - if (object != null && object instanceof String) { - value = ((String) object).trim(); - } + public Component getComponent() { + return targetLine; + } + + public Boolean getValue() { + Boolean value = null; + String val = (String) this.select.getValue(); + if( val.equals("y") || val.equals("n") ) + { + value = (val.equals("y")); } return value; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java index 0b9b549..240873e 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java @@ -28,17 +28,18 @@ import de.hsadmin.web.config.PropertyFieldFactory; public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { - private Module module; + private final Module module; private boolean readOnly = false; private boolean writeOnce = false; private List users; private List mailAliases; - private Map targets; + private final Map targets; private int lastIndex; private VerticalLayout layout; public EMailTargetPropertyFieldFactory(Module module) { this.module = module; + targets = new HashMap(); } public void removeTarget(SingleEMailTarget target) { @@ -66,13 +67,10 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { @Override public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { GenericModule genModule = (GenericModule) module; - users = genModule.getUsers(); - mailAliases = genModule.getEMailAliases(); layout = new VerticalLayout(); layout.setCaption(prop.getLabel()); layout.setData(prop.getId()); - targets = new HashMap(); lastIndex = 0; if (value instanceof AbstractProperty) { String stringValue = ((AbstractProperty) value).toStringValue(); diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 6d5a419..47398bd 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -1,6 +1,16 @@ id=identifier name=domain user=admin +domainoptions=domain options +domainoption.backupmxforexternalmx=BackUpMxForExternalMx +domainoption.greylisting=GreyListing +domainoption.htdocsfallback=HtDocsFallback +domainoption.includes=Includes +domainoption.indexes=Indexes +domainoption.multiviews=MultiViews +domainoption.php=PHP +yes=Yes +no=No pac=packet hive=host since=connected since diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index c75bfbc..fddd54f 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -1,6 +1,16 @@ id=Schlüssel name=Domain user=Administrator +domainoptions=Optionen +domainoption.backupmxforexternalmx=BackUpMxForExternalMx +domainoption.greylisting=GreyListing +domainoption.htdocsfallback=HtDocsFallback +domainoption.includes=Includes +domainoption.indexes=Indexes +domainoption.multiviews=MultiViews +domainoption.php=PHP +yes=Ja +no=Nein pac=Paket hive=Server since=aufgeschaltet seit diff --git a/hsarweb/src/texts/domain_ksh.properties b/hsarweb/src/texts/domain_ksh.properties new file mode 100644 index 0000000..d9a340e --- /dev/null +++ b/hsarweb/src/texts/domain_ksh.properties @@ -0,0 +1,21 @@ +id=Schlößelnommer +name=Domähn +user=Verwallder +domainoptions=Enschtällonge +domainoption.backupmxforexternalmx=BackUpMxForExternalMx +domainoption.greylisting=Jräilesteng +domainoption.htdocsfallback=Zeröckfalle op htdocs +domainoption.includes=Enkluudes +domainoption.indexes=Endäxe +domainoption.multiviews=Maltivjuhs +domainoption.php=PHP +yes=Joh +no=Nää +pac=Packätt +hive=ßööver +since=opjeschalldt zigg +moduletitle=Domähne +moduleicon=../runo/icons/16/document-web.png +new=En neue Domähn aanjääje +update=Enschtällonge för en Domähn ändern +delete=En Domähne fottschmiiße \ No newline at end of file diff --git a/hsarweb/src/texts/home_ksh.properties b/hsarweb/src/texts/home_ksh.properties index 9e55f94..492858e 100644 --- a/hsarweb/src/texts/home_ksh.properties +++ b/hsarweb/src/texts/home_ksh.properties @@ -4,7 +4,7 @@ password=et Pa password1=neu Paßwoot password2=et Paßwoot norr_ens comment=Aanmärkonge -shell=däm Metmaacher sing Shell +shell=däm Metmaacher singe shell userid=däm Metmaacher sing Nommer homedir=et Heimatverzeischneß pac=Pakätt