From 3ff6a8a5816799ecc448ba59b154dd00406bac40 Mon Sep 17 00:00:00 2001 From: Purodha <bli00@hostsharing.net> Date: Thu, 03 Jan 2013 15:14:32 +0100 Subject: [PATCH] Domain-options shown and editable in web interface. Minor corrections elsewhere. --- hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java | 133 ++++++++++++++++++++++---------- hsarweb/src/texts/domain_ksh.properties | 21 +++++ hsarweb/src/de/hsadmin/web/DomainModule.java | 4 + hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java | 6 + hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java | 8 - hsarweb/src/texts/home_ksh.properties | 2 hsarweb/src/texts/domain_de.properties | 10 ++ hsarweb/src/de/hsadmin/web/DomainReadonlyModule.java | 1 hsarweb/src/texts/domain.properties | 10 ++ 9 files changed, 145 insertions(+), 50 deletions(-) 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.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 @@ } }); 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 @@ 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 @@ 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 @@ public class ListOfStringsProperty implements XmlrpcProperty { - public final List<String> properties; + private final List<String> properties; public ListOfStringsProperty(){ this.properties = new ArrayList<String>(); @@ -15,6 +15,10 @@ 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<String,AbstractProperty> 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<String,AbstractProperty> optionTypes ; // TODO: auf Vorrat hier + // TODO: besorge Options .... Ende private boolean readOnly = false; private boolean writeOnce = false; private VerticalLayout layout; + private List<SingleDomainOption> optionLayout ; + private ListOfStringsProperty setOptions ; - public DomainOptionsPropertyFieldFactory() { - // TODO: besorge Options und ihre Typen aus der DB - optionTypes = new HashMap<String,AbstractProperty>() ; - 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<SingleDomainOption>() ; setOptions = new ListOfStringsProperty() ; - // TODO Auto-generated constructor stub + } + + private void repaint() { + layout.removeAllComponents(); + for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { + layout.addComponent(optionLayout.get(idx).getComponent()); + } } @Override public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { - // TODO Auto-generated method stub - return null; + this.setOptions = (ListOfStringsProperty) value ; + layout = new VerticalLayout(); + layout.setCaption(prop.getLabel()); + layout.setData(prop.getId()); + if (value instanceof ListOfStringsProperty) { + ListOfStringsProperty list = (ListOfStringsProperty) value; + for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { + optionLayout.add(new SingleDomainOption(this, OPTION_NAMES[idx], list.contains(OPTION_NAMES[idx]) )); + } + } + else + { + // Eine leere Liste von Domainoptionen wird angezeigt werden. + } + repaint(); + return layout; } @Override - public XmlrpcProperty getValue(PropertyConfig prop, Object component) - throws HsarwebException { + public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { + setOptions = new ListOfStringsProperty() ; + for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { + if(Boolean.TRUE.equals(optionLayout.get(idx).getValue())) + { + setOptions.add(OPTION_NAMES[idx]); + } + } return setOptions; } @@ -76,35 +109,49 @@ } class SingleDomainOption { + private final DomainOptionsPropertyFieldFactory owner; + private final String optionName; private HorizontalLayout targetLine; - private HorizontalLayout leftPart; - private HorizontalLayout rightPart; - private int index; - private String optionName; - private String testunusedoptionName; - private DomainOptionsPropertyFieldFactory owner; + private Select select ; - protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner, int key, String optionName, Object optionValue) { + protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner, String optionName, boolean optionValue) { this.owner = owner; - this.index = key; this.optionName = optionName; targetLine = new HorizontalLayout(); - targetLine.setWidth(480.0f, Sizeable.UNITS_PIXELS); - leftPart = new HorizontalLayout(); - leftPart.setWidth(100.0f, Sizeable.UNITS_PIXELS); - leftPart.setCaption(optionName); - rightPart = new HorizontalLayout(); - rightPart.setWidth(380.0f, Sizeable.UNITS_PIXELS); - // ToDO: Fallunterscheidungen nach Optionsart. Z.Z. nur Boolean. + targetLine.setWidth(500.0f, Sizeable.UNITS_PIXELS); + HorizontalLayout leftPart = new HorizontalLayout(); + leftPart.setWidth(220.0f, Sizeable.UNITS_PIXELS); + Label label = new Label(owner.config.getLabel("domainoption."+optionName),Label.CONTENT_RAW); + leftPart.addComponent( label); // setCaption(owner.config.getLabel("domainoption."+optionName)); + HorizontalLayout rightPart = new HorizontalLayout(); + // ToDO: Fallunterscheidungen nach Optionsart. Z.Z. nur Boolean: + { + this.select = new Select(); + this.select.setWidth(90.0f, Sizeable.UNITS_PIXELS); + this.select.setImmediate(true); + this.select.setNewItemsAllowed(false); + this.select.setNullSelectionAllowed(false); + this.select.addItem("y"); + this.select.setItemCaption("y" , owner.config.getLabel("yes")); + this.select.addItem("n"); + this.select.setItemCaption("n" , owner.config.getLabel("no")); + this.select.setValue(optionValue ? "y" : "n"); + rightPart.addComponent(this.select); + } + targetLine.addComponent(leftPart); + targetLine.addComponent(rightPart); } - public String getValue() { - String value = null; - if (rightPart.getComponentCount() > 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 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { - private Module module; + private final Module module; private boolean readOnly = false; private boolean writeOnce = false; private List<String> users; private List<String> mailAliases; - private Map<Integer, SingleEMailTarget> targets; + private final Map<Integer, SingleEMailTarget> targets; private int lastIndex; private VerticalLayout layout; public EMailTargetPropertyFieldFactory(Module module) { this.module = module; + targets = new HashMap<Integer, SingleEMailTarget>(); } public void removeTarget(SingleEMailTarget target) { @@ -66,13 +67,10 @@ @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<Integer, SingleEMailTarget>(); 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 <code lang="en">htdocs</code> +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 @@ password1=neu Pa�woot password2=et Pa�woot norr_ens comment=Aanm�rkonge -shell=d�m Metmaacher sing Shell +shell=d�m Metmaacher singe <code lang="en">shell</code> userid=d�m Metmaacher sing Nommer homedir=et Heimatverzeischne� pac=Pak�tt -- Gitblit v1.9.0-SNAPSHOT