From 5eb2e851a88d4c8126406c28568d8148a31f43aa Mon Sep 17 00:00:00 2001 From: Purodha <bli00@hostsharing.net> Date: Tue, 19 Feb 2013 16:46:46 +0100 Subject: [PATCH] Cleanup in DomainOptionsPropertyFieldFactory; errors with domainoptions in web client resolved; do not attempt to rewrite read-only or write-once fields during updates from command line cient. --- hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java | 18 +++++------------- hsarweb/src/de/hsadmin/web/DomainModule.java | 1 - hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java | 2 +- hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java | 24 ++++++++++++++++-------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java index 054a7a5..e6f52cc 100644 --- a/hsarweb/src/de/hsadmin/web/DomainModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainModule.java @@ -58,7 +58,6 @@ }); 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 diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java index 7a2a6d3..5321f35 100644 --- a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java @@ -5,7 +5,7 @@ public interface PropertyFieldFactory { - public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value); + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) throws HsarwebException; public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException; diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java index 158d481..1ea5e28 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java @@ -1,26 +1,19 @@ 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; @@ -39,14 +32,12 @@ private boolean readOnly = false; private boolean writeOnce = false; private VerticalLayout layout; - private List<SingleDomainOption> optionLayout ; - private ListOfStringsProperty setOptions ; + private final List<SingleDomainOption> optionLayout ; public DomainOptionsPropertyFieldFactory(Module module) { this.module = module; this.config = module.getModuleConfig(); optionLayout = new ArrayList<SingleDomainOption>() ; - setOptions = new ListOfStringsProperty() ; } private void repaint() { @@ -57,11 +48,11 @@ } @Override - public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { - this.setOptions = (ListOfStringsProperty) value ; + public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) throws HsarwebException { layout = new VerticalLayout(); layout.setCaption(prop.getLabel()); layout.setData(prop.getId()); + optionLayout.clear(); if (value instanceof ListOfStringsProperty) { ListOfStringsProperty list = (ListOfStringsProperty) value; for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { @@ -71,6 +62,7 @@ else { // Eine leere Liste von Domainoptionen wird angezeigt werden. + throw new HsarwebException("Keine Liste: ListOfStringsProperty"); } repaint(); return layout; @@ -78,7 +70,7 @@ @Override public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { - setOptions = new ListOfStringsProperty() ; + ListOfStringsProperty setOptions = new ListOfStringsProperty() ; for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { if(Boolean.TRUE.equals(optionLayout.get(idx).getValue())) { diff --git a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java index e10c3b7..9cf0a27 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java @@ -33,14 +33,19 @@ public Form createAddForm() { Form f = new Form(); - ModuleConfig config = module.getModuleConfig(); - f.setCaption(config.getLabel("new")); - Layout layout = f.getLayout(); - for (PropertyConfig prop : config.getPropertyList()) { - PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); - if (!propFieldFactory.isReadOnly()) { - layout.addComponent((Component) propFieldFactory.createFieldComponent(prop, null)); + try { + ModuleConfig config = module.getModuleConfig(); + f.setCaption(config.getLabel("new")); + Layout layout = f.getLayout(); + for (PropertyConfig prop : config.getPropertyList()) { + PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); + if (!propFieldFactory.isReadOnly()) { + layout.addComponent((Component) propFieldFactory.createFieldComponent(prop, null)); + } } + } catch (HsarwebException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } return f; } @@ -148,7 +153,10 @@ Object data = ((AbstractComponent) component).getData(); String propName = (String) data; PropertyConfig property = module.getModuleConfig().getProperty(propName); - map.put(propName, property.getPropFieldFactory().getValue(property, component)); + PropertyFieldFactory fieldFactory = property.getPropFieldFactory(); + if (!fieldFactory.isReadOnly() && !fieldFactory.isWriteOnce()) { + map.put(propName, property.getPropFieldFactory().getValue(property, component)); + } } } } -- Gitblit v1.9.0-SNAPSHOT