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.
This commit is contained in:
Purodha 2013-02-19 15:46:46 +00:00
parent 950ebee553
commit 5eb2e851a8
4 changed files with 22 additions and 23 deletions

View File

@ -58,7 +58,6 @@ public class DomainModule extends GenericModule {
}); });
userProp.setWriteOnce(true); userProp.setWriteOnce(true);
PropertyConfig optionsProp = new PropertyConfig(moduleConfig, "domainoptions", String.class, PropertyTableColumn.HIDDEN, new DomainOptionsPropertyFieldFactory(this)); 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); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN);
pacProp.setDefaultValue(new PropertyDefaultValue() { pacProp.setDefaultValue(new PropertyDefaultValue() {
@Override @Override

View File

@ -5,7 +5,7 @@ import de.hsadmin.web.XmlrpcProperty;
public interface PropertyFieldFactory { 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; public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException;

View File

@ -1,26 +1,19 @@
package de.hsadmin.web.vaadin; package de.hsadmin.web.vaadin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.Sizeable;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component; import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label; import com.vaadin.ui.Label;
import com.vaadin.ui.Select; import com.vaadin.ui.Select;
import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.VerticalLayout;
import de.hsadmin.web.AbstractProperty;
import de.hsadmin.web.GenericModule;
import de.hsadmin.web.HsarwebException; import de.hsadmin.web.HsarwebException;
import de.hsadmin.web.ListOfStringsProperty; import de.hsadmin.web.ListOfStringsProperty;
import de.hsadmin.web.Module; import de.hsadmin.web.Module;
import de.hsadmin.web.XmlrpcProperty; import de.hsadmin.web.XmlrpcProperty;
import de.hsadmin.web.config.LocaleConfig;
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.PropertyFieldFactory; import de.hsadmin.web.config.PropertyFieldFactory;
@ -39,14 +32,12 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
private boolean readOnly = false; private boolean readOnly = false;
private boolean writeOnce = false; private boolean writeOnce = false;
private VerticalLayout layout; private VerticalLayout layout;
private List<SingleDomainOption> optionLayout ; private final List<SingleDomainOption> optionLayout ;
private ListOfStringsProperty setOptions ;
public DomainOptionsPropertyFieldFactory(Module module) { public DomainOptionsPropertyFieldFactory(Module module) {
this.module = module; this.module = module;
this.config = module.getModuleConfig(); this.config = module.getModuleConfig();
optionLayout = new ArrayList<SingleDomainOption>() ; optionLayout = new ArrayList<SingleDomainOption>() ;
setOptions = new ListOfStringsProperty() ;
} }
private void repaint() { private void repaint() {
@ -57,11 +48,11 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
} }
@Override @Override
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) { public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) throws HsarwebException {
this.setOptions = (ListOfStringsProperty) value ;
layout = new VerticalLayout(); layout = new VerticalLayout();
layout.setCaption(prop.getLabel()); layout.setCaption(prop.getLabel());
layout.setData(prop.getId()); layout.setData(prop.getId());
optionLayout.clear();
if (value instanceof ListOfStringsProperty) { if (value instanceof ListOfStringsProperty) {
ListOfStringsProperty list = (ListOfStringsProperty) value; ListOfStringsProperty list = (ListOfStringsProperty) value;
for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) { for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) {
@ -71,6 +62,7 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
else else
{ {
// Eine leere Liste von Domainoptionen wird angezeigt werden. // Eine leere Liste von Domainoptionen wird angezeigt werden.
throw new HsarwebException("Keine Liste: ListOfStringsProperty");
} }
repaint(); repaint();
return layout; return layout;
@ -78,7 +70,7 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
@Override @Override
public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { 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 ) { for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) {
if(Boolean.TRUE.equals(optionLayout.get(idx).getValue())) if(Boolean.TRUE.equals(optionLayout.get(idx).getValue()))
{ {

View File

@ -33,14 +33,19 @@ public class GenericForm {
public Form createAddForm() { public Form createAddForm() {
Form f = new Form(); Form f = new Form();
ModuleConfig config = module.getModuleConfig(); try {
f.setCaption(config.getLabel("new")); ModuleConfig config = module.getModuleConfig();
Layout layout = f.getLayout(); f.setCaption(config.getLabel("new"));
for (PropertyConfig prop : config.getPropertyList()) { Layout layout = f.getLayout();
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); for (PropertyConfig prop : config.getPropertyList()) {
if (!propFieldFactory.isReadOnly()) { PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
layout.addComponent((Component) propFieldFactory.createFieldComponent(prop, null)); if (!propFieldFactory.isReadOnly()) {
layout.addComponent((Component) propFieldFactory.createFieldComponent(prop, null));
}
} }
} catch (HsarwebException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }
return f; return f;
} }
@ -148,7 +153,10 @@ public class GenericForm {
Object data = ((AbstractComponent) component).getData(); Object data = ((AbstractComponent) component).getData();
String propName = (String) data; String propName = (String) data;
PropertyConfig property = module.getModuleConfig().getProperty(propName); 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));
}
} }
} }
} }