Domain-options shown and editable in web interface.

Minor corrections elsewhere.
This commit is contained in:
Purodha 2013-01-03 14:14:32 +00:00
parent fd02157854
commit 3ff6a8a581
9 changed files with 145 additions and 50 deletions

View File

@ -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);

View File

@ -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()));

View File

@ -6,7 +6,7 @@ import java.util.List;
public class ListOfStringsProperty implements XmlrpcProperty {
public final List<String> properties;
private final List<String> properties;
public ListOfStringsProperty(){
this.properties = new ArrayList<String>();
@ -16,6 +16,10 @@ public class ListOfStringsProperty implements XmlrpcProperty {
return properties.add(string);
}
public boolean contains(String string){
return properties.contains(string);
}
@Override
public Object toXmlrpcParam() {
String[] result = new String[properties.size()];

View File

@ -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 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
}
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;
}

View File

@ -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<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 @@ 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<Integer, SingleEMailTarget>();
lastIndex = 0;
if (value instanceof AbstractProperty) {
String stringValue = ((AbstractProperty) value).toStringValue();

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 <code lang="en">shell</code>
userid=däm Metmaacher sing Nommer
homedir=et Heimatverzeischneß
pac=Pakätt