From a1c1b35b834730a16113e3edd856fed9395096d5 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 25 Feb 2011 23:05:13 +0000 Subject: [PATCH] generisches Formular fuer Update und Add begonnen --- hsarweb/src/de/hsadmin/web/DomainModule.java | 12 +- .../de/hsadmin/web/EMailAddressModule.java | 18 +- .../src/de/hsadmin/web/EMailAliasModule.java | 8 +- hsarweb/src/de/hsadmin/web/GenericModule.java | 238 ++++++++++++++++-- .../src/de/hsadmin/web/MainApplication.java | 12 +- .../src/de/hsadmin/web/QueueTaskModule.java | 20 +- hsarweb/src/de/hsadmin/web/Remote.java | 31 ++- .../src/de/hsadmin/web/UnixUserModule.java | 27 +- .../de/hsadmin/web/config/ModuleConfig.java | 51 +++- .../de/hsadmin/web/config/PropertyConfig.java | 12 +- hsarweb/src/texts/domain.properties | 3 +- hsarweb/src/texts/domain_de.properties | 3 +- hsarweb/src/texts/emailaddress.properties | 5 +- hsarweb/src/texts/emailaddress_de.properties | 3 +- hsarweb/src/texts/emailalias.properties | 3 +- hsarweb/src/texts/emailalias_de.properties | 3 +- hsarweb/src/texts/main.properties | 2 + hsarweb/src/texts/main_de.properties | 4 +- hsarweb/src/texts/user.properties | 1 + hsarweb/src/texts/user_de.properties | 15 +- 20 files changed, 387 insertions(+), 84 deletions(-) diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java index df3e5ab..3c44001 100644 --- a/hsarweb/src/de/hsadmin/web/DomainModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainModule.java @@ -13,12 +13,12 @@ public class DomainModule extends GenericModule { public DomainModule() { moduleConfig = new ModuleConfig("domain"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class, "")); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class)); } @Override diff --git a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java index a153270..0c8f4b8 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java @@ -11,15 +11,15 @@ public class EMailAddressModule extends GenericModule { public EMailAddressModule() { moduleConfig = new ModuleConfig("emailaddress"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domain", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domain", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, true)); } @Override diff --git a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java index 8c13985..0c437ac 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java @@ -11,10 +11,10 @@ public class EMailAliasModule extends GenericModule { public EMailAliasModule() { moduleConfig = new ModuleConfig("emailalias"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); } @Override diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java index 8301035..2a77045 100644 --- a/hsarweb/src/de/hsadmin/web/GenericModule.java +++ b/hsarweb/src/de/hsadmin/web/GenericModule.java @@ -6,17 +6,23 @@ import java.text.ParseException; import java.util.Calendar; import java.util.Date; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import com.vaadin.data.Property; +import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.ThemeResource; import com.vaadin.ui.Button; import com.vaadin.ui.Component; +import com.vaadin.ui.Form; import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; +import com.vaadin.ui.Link; import com.vaadin.ui.Table; +import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.Button.ClickEvent; @@ -31,24 +37,92 @@ public abstract class GenericModule implements Serializable { private static final long serialVersionUID = 1L; private static final DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); + private VerticalLayout layout; private Table table; private MainApplication application; public void setApplication(MainApplication app) throws HsarwebException { - this.application = app; + application = app; initTable(); + initLayout(); } - + public abstract ModuleConfig getModuleConfig(); public Component getComponent() { - return table; + return layout; } public void reload() throws HsarwebException { loadTable(); } + private void initLayout() { + layout = new VerticalLayout(); + layout.setSizeFull(); + final ModuleConfig moduleConfig = getModuleConfig(); + if (moduleConfig.isSearchAble() || moduleConfig.isAddAble()) { + HorizontalLayout toolbar = new HorizontalLayout(); + if (moduleConfig.isAddAble()) { + Button btNew = new Button(moduleConfig.getLabel("new")); + ThemeResource icon = new ThemeResource("../runo/icons/16/document-add.png"); + btNew.setIcon(icon); + btNew.addListener(new Button.ClickListener() { + private static final long serialVersionUID = 1L; + private Window childWindow; + @Override + public void buttonClick(ClickEvent event) { + final Form form = createForm(); + LocaleConfig localeConfig = application.getLocaleConfig(); + childWindow = new Window(localeConfig.getText("new")); + childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS); + VerticalLayout vLayout = new VerticalLayout(); + vLayout.setMargin(true); + vLayout.setSpacing(true); + vLayout.addComponent(form); + HorizontalLayout hLayout = new HorizontalLayout(); + Button btSaveRow = new Button(localeConfig.getText("save")); + btSaveRow.addListener(new Button.ClickListener() { + private static final long serialVersionUID = 1L; + @Override + public void buttonClick(ClickEvent event) { + application.getMainWindow().removeWindow(childWindow); + try { + insertRow(form); + } catch (HsarwebException e) { + application.showUserException(e); + } + } + }); + Button btAbort = new Button(localeConfig.getText("abort")); + btAbort.addListener(new Button.ClickListener() { + private static final long serialVersionUID = 1L; + @Override + public void buttonClick(ClickEvent event) { + application.getMainWindow().removeWindow(childWindow); + } + }); + hLayout.addComponent(btSaveRow); + hLayout.addComponent(btAbort); + vLayout.addComponent(hLayout); + childWindow.setContent(vLayout); + childWindow.setModal(true); + application.getMainWindow().addWindow(childWindow); + } + }); + toolbar.addComponent(btNew); + } +// if (moduleConfig.isSearchAble()) { +// Button btSearch = new Button("search"); +// toolbar.addComponent(btSearch); +// } + layout.addComponent(toolbar); + } + layout.addComponent(table); + layout.setExpandRatio(table, 1.0f); + layout.addComponent(new Link("Impressum", new ExternalResource("http://www.hostsharing.net/impressum"))); + } + private void initTable() throws HsarwebException { table = new Table() { private static final long serialVersionUID = 35127658139420917L; @@ -79,12 +153,16 @@ public abstract class GenericModule implements Serializable { table.setColumnCollapsed(prop.getId(), true); } } - table.addContainerProperty("edit", Button.class, null); - table.setColumnWidth("edit", 16); - table.setColumnHeader("edit", ""); - table.addContainerProperty("del", Button.class, null); - table.setColumnWidth("del", 16); - table.setColumnHeader("del", ""); + if (getModuleConfig().isUpdateAble()) { + table.addContainerProperty("edit", Button.class, null); + table.setColumnWidth("edit", 16); + table.setColumnHeader("edit", ""); + } + if (getModuleConfig().isDeleteAble()) { + table.addContainerProperty("del", Button.class, null); + table.setColumnWidth("del", 16); + table.setColumnHeader("del", ""); + } } catch (Exception e) { throw new HsarwebException(e); } @@ -99,7 +177,14 @@ public abstract class GenericModule implements Serializable { for (Object row : ((Object[])callSearch)) { long oid = -1L; if (row instanceof Map) { - Object[] itemData = new Object[propertyList.size()+2]; + int numOfcolumns = propertyList.size(); + if (getModuleConfig().isUpdateAble()) { + numOfcolumns++; + } + if (getModuleConfig().isDeleteAble()) { + numOfcolumns++; + } + Object[] itemData = new Object[numOfcolumns]; int idx = 0; for (PropertyConfig prop : propertyList) { Object valueObject = ((Map) row).get(prop.getId()); @@ -127,10 +212,14 @@ public abstract class GenericModule implements Serializable { } idx++; } - itemData[idx] = createEditButton(oid); - idx++; - itemData[idx] = createDeleteButton(oid); - idx++; + if (getModuleConfig().isUpdateAble()) { + itemData[idx] = createEditButton(oid); + idx++; + } + if (getModuleConfig().isDeleteAble()) { + itemData[idx] = createDeleteButton(oid); + idx++; + } table.addItem(itemData, oid); } } @@ -148,6 +237,40 @@ public abstract class GenericModule implements Serializable { loadTable(); } + private void updateRow(Form form) throws HsarwebException { + Map whereHash = new HashMap(); + whereHash.put(findIdKey(), ((Long) form.getData()).toString()); + Map setHash = new HashMap(); + Iterator componentIterator = form.getLayout().getComponentIterator(); + while (componentIterator.hasNext()) { + Component c = componentIterator.next(); + if (c instanceof TextField) { + TextField tf = (TextField) c; + Object data = tf.getData(); + Object value = tf.getValue(); + setHash.put((String) data, (String) value); + } + } + application.getRemote().callUpdate(getModuleConfig().getName(), setHash, whereHash); + loadTable(); + } + + private void insertRow(Form form) throws HsarwebException { + Map setHash = new HashMap(); + Iterator componentIterator = form.getLayout().getComponentIterator(); + while (componentIterator.hasNext()) { + Component c = componentIterator.next(); + if (c instanceof TextField) { + TextField tf = (TextField) c; + Object data = tf.getData(); + Object value = tf.getValue(); + setHash.put((String) data, (String) value); + } + } + application.getRemote().callAdd(getModuleConfig().getName(), setHash); + loadTable(); + } + private String findIdKey() { List propertyList = getModuleConfig().getPropertyList(); String idKey = null; @@ -162,16 +285,51 @@ public abstract class GenericModule implements Serializable { private Button createEditButton(long id) { ThemeResource icon = new ThemeResource("../runo/icons/16/document-txt.png"); - Button button = new Button(); + final Button button = new Button(); button.setIcon(icon); button.setData(id); button.setStyleName(BaseTheme.BUTTON_LINK); button.addListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; + private Window childWindow; @Override public void buttonClick(ClickEvent event) { -// loadTable(); - System.out.println("Data: " + event.getButton().getData()); + final Form form = createForm((Long) button.getData()); + LocaleConfig localeConfig = application.getLocaleConfig(); + childWindow = new Window(getModuleConfig().getLabel("moduletitle") + " " + localeConfig.getText("update")); + childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS); + VerticalLayout vLayout = new VerticalLayout(); + vLayout.setMargin(true); + vLayout.setSpacing(true); + vLayout.addComponent(form); + HorizontalLayout hLayout = new HorizontalLayout(); + Button btSaveRow = new Button(localeConfig.getText("save")); + btSaveRow.addListener(new Button.ClickListener() { + private static final long serialVersionUID = 1L; + @Override + public void buttonClick(ClickEvent event) { + application.getMainWindow().removeWindow(childWindow); + try { + updateRow(form); + } catch (HsarwebException e) { + application.showUserException(e); + } + } + }); + Button btAbort = new Button(localeConfig.getText("abort")); + btAbort.addListener(new Button.ClickListener() { + private static final long serialVersionUID = 1L; + @Override + public void buttonClick(ClickEvent event) { + application.getMainWindow().removeWindow(childWindow); + } + }); + hLayout.addComponent(btSaveRow); + hLayout.addComponent(btAbort); + vLayout.addComponent(hLayout); + childWindow.setContent(vLayout); + childWindow.setModal(true); + application.getMainWindow().addWindow(childWindow); } }); return button; @@ -228,4 +386,50 @@ public abstract class GenericModule implements Serializable { return button; } + private Form createForm(Long key) { + try { + Map where = new HashMap(); + where.put(findIdKey(), key.toString()); + Object searchResult = application.getRemote().callSearch(getModuleConfig().getName(), where); + if (searchResult instanceof Object[]) { + Map row = (Map) (((Object[]) searchResult)[0]); + Form f = new Form(); + f.setCaption(getModuleConfig().getLabel("update")); + f.setData(key); + Layout layout = f.getLayout(); + for (PropertyConfig prop : getModuleConfig().getPropertyList()) { + if (!prop.isIdent()) { + TextField tf = new TextField(prop.getLabel()); + tf.setData(prop.getId()); + tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); + Object value = row.get(prop.getId()); + tf.setValue(value != null ? value : ""); + layout.addComponent(tf); + } + } + return f; + } + } catch (HsarwebException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return null; + } + + private Form createForm() { + Form f = new Form(); + f.setCaption(getModuleConfig().getLabel("new")); + Layout layout = f.getLayout(); + for (PropertyConfig prop : getModuleConfig().getPropertyList()) { + if (!prop.isIdent()) { + TextField tf = new TextField(prop.getLabel()); + tf.setData(prop.getId()); + tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); + tf.setValue(""); + layout.addComponent(tf); + } + } + return f; + } + } diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java index ec41cbb..4641cee 100644 --- a/hsarweb/src/de/hsadmin/web/MainApplication.java +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -14,12 +14,12 @@ import org.jasig.cas.client.authentication.AuthenticationFilter; import org.jasig.cas.client.validation.Assertion; import com.vaadin.Application; -import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.Terminal; import com.vaadin.terminal.ThemeResource; import com.vaadin.terminal.gwt.server.HttpServletRequestListener; import com.vaadin.ui.Component; import com.vaadin.ui.TabSheet; +import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; import com.vaadin.ui.TabSheet.SelectedTabChangeEvent; import com.vaadin.ui.TabSheet.Tab; @@ -45,9 +45,12 @@ public class MainApplication extends Application implements HttpServletRequestLi localeConfig = new LocaleConfig(Locale.getDefault(), "main"); remote = new Remote(this); Window mainWindow = new Window(localeConfig.getText("applicationtitle")); + VerticalLayout verticalLayout = new VerticalLayout(); + verticalLayout.setSizeFull(); TabSheet tabs = new TabSheet(); - tabs.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE); - tabs.setHeight(200.0f, Sizeable.UNITS_PERCENTAGE); + tabs.setSizeFull(); +// tabs.setWidth(95.0f, Sizeable.UNITS_PERCENTAGE); +// tabs.setHeight(95.0f, Sizeable.UNITS_PERCENTAGE); String modulesParamString = getContextParam("hsarmodules"); modules = new HashMap(); GenericModule firstModule = null; @@ -67,7 +70,8 @@ public class MainApplication extends Application implements HttpServletRequestLi } } tabs.addListener(this); - mainWindow.addComponent(tabs); + verticalLayout.addComponent(tabs); + mainWindow.setContent(verticalLayout); setMainWindow(mainWindow); setErrorHandler(new Terminal.ErrorListener() { private static final long serialVersionUID = 1L; diff --git a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java index d63385c..b541500 100644 --- a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java +++ b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java @@ -13,14 +13,18 @@ public class QueueTaskModule extends GenericModule { public QueueTaskModule() { moduleConfig = new ModuleConfig("q"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, "", true)); + moduleConfig.setUpdateAble(false); + moduleConfig.setDeleteAble(false); + moduleConfig.setAddAble(false); + moduleConfig.setSearchAble(false); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, true)); } @Override diff --git a/hsarweb/src/de/hsadmin/web/Remote.java b/hsarweb/src/de/hsadmin/web/Remote.java index ffddb12..ae6188c 100644 --- a/hsarweb/src/de/hsadmin/web/Remote.java +++ b/hsarweb/src/de/hsadmin/web/Remote.java @@ -21,20 +21,41 @@ public class Remote { return xmlrpcCall(module, "search", where); } + public void callAdd(String module, Map set) throws HsarwebException { + xmlrpcCall(module, "add", set); + } + + public void callUpdate(String module, Map set, Map where) throws HsarwebException { + xmlrpcCall(module, "update", set, where); + } + public void callDelete(String module, Map where) throws HsarwebException { xmlrpcCall(module, "delete", where); } - private Object xmlrpcCall(String module, String operation, Map where) throws HsarwebException { + private Object xmlrpcCall(String module, String operation, Map param1) throws HsarwebException { Object[] params = new Object[3]; params[0] = app.getLogin(); params[1] = app.getProxyTicket(); - params[2] = where; - Object res; + params[2] = param1; + return xmlrpcCall(module + "." + operation, params); + } + + private Object xmlrpcCall(String module, String operation, Map param1, Map param2) throws HsarwebException { + Object[] params = new Object[4]; + params[0] = app.getLogin(); + params[1] = app.getProxyTicket(); + params[2] = param1; + params[3] = param2; + return xmlrpcCall(module + "." + operation, params); + } + + private Object xmlrpcCall(String operation, Object[] params) throws HsarwebException { + Object res = null; try { - res = getClient().execute(module + "." + operation, params); + res = getClient().execute(operation, params); } catch (XmlRpcException e) { - throw new HsarwebException("error in remote server call", e); + throw new HsarwebException(e.getMessage(), e); } return res; } diff --git a/hsarweb/src/de/hsadmin/web/UnixUserModule.java b/hsarweb/src/de/hsadmin/web/UnixUserModule.java index 7f576e8..4d374e8 100644 --- a/hsarweb/src/de/hsadmin/web/UnixUserModule.java +++ b/hsarweb/src/de/hsadmin/web/UnixUserModule.java @@ -11,15 +11,24 @@ public class UnixUserModule extends GenericModule { public UnixUserModule() { moduleConfig = new ModuleConfig("user"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, "", true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "comment", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "shell", String.class, "")); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "userid", Long.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "homedir", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "quota_softlimit", Long.class, "", true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "quota_hardlimit", Long.class, "", true)); + PropertyConfig propId = new PropertyConfig(moduleConfig, "id", Long.class, true, true); + moduleConfig.addProperty(propId); + PropertyConfig propUserId = new PropertyConfig(moduleConfig, "userid", Long.class, true); + moduleConfig.addProperty(propUserId); + PropertyConfig propUserName = new PropertyConfig(moduleConfig, "name", String.class); + moduleConfig.addProperty(propUserName); + PropertyConfig propUserComment = new PropertyConfig(moduleConfig, "comment", String.class); + moduleConfig.addProperty(propUserComment); + PropertyConfig propShell = new PropertyConfig(moduleConfig, "shell", String.class); + moduleConfig.addProperty(propShell); + PropertyConfig propHomeDir = new PropertyConfig(moduleConfig, "homedir", String.class, true); + moduleConfig.addProperty(propHomeDir); + PropertyConfig propPacket = new PropertyConfig(moduleConfig, "pac", String.class, true); + moduleConfig.addProperty(propPacket); + PropertyConfig propSoftQuota = new PropertyConfig(moduleConfig, "quota_softlimit", Long.class, true); + moduleConfig.addProperty(propSoftQuota); + PropertyConfig propHardQuota = new PropertyConfig(moduleConfig, "quota_hardlimit", Long.class, true); + moduleConfig.addProperty(propHardQuota); } @Override diff --git a/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java index 28e4793..ac5e3f5 100644 --- a/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java +++ b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java @@ -2,8 +2,10 @@ package de.hsadmin.web.config; import java.io.Serializable; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Locale; +import java.util.Map; public class ModuleConfig implements Serializable { @@ -11,12 +13,22 @@ public class ModuleConfig implements Serializable { private String name; private List propertyList; + private Map propertyMap; private LocaleConfig localeConfig; + private boolean deleteAble; + private boolean updateAble; + private boolean addAble; + private boolean searchAble; public ModuleConfig(String name) { this.name = name; propertyList = new ArrayList(); + propertyMap = new HashMap(); localeConfig = new LocaleConfig(Locale.getDefault(), name); + addAble = true; + updateAble = true; + deleteAble = true; + searchAble = true; } public String getName() { @@ -24,15 +36,52 @@ public class ModuleConfig implements Serializable { } public void addProperty(PropertyConfig property) { - this.propertyList.add(property); + propertyList.add(property); + propertyMap.put(property.getId(), property); } public List getPropertyList() { return propertyList; } + public PropertyConfig getProperty(String id) { + return propertyMap.get(id); + } + public String getLabel(String key) { return localeConfig.getText(key); } + + public boolean isDeleteAble() { + return deleteAble; + } + + public boolean isUpdateAble() { + return updateAble; + } + + public boolean isAddAble() { + return addAble; + } + + public boolean isSearchAble() { + return searchAble; + } + + public void setDeleteAble(boolean deleteAble) { + this.deleteAble = deleteAble; + } + + public void setUpdateAble(boolean updateAble) { + this.updateAble = updateAble; + } + + public void setAddAble(boolean addAble) { + this.addAble = addAble; + } + + public void setSearchAble(boolean searchAble) { + this.searchAble = searchAble; + } } diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java b/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java index fe7c237..e4ee6b9 100644 --- a/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java +++ b/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java @@ -13,29 +13,29 @@ public class PropertyConfig implements Serializable { private boolean hidden; private boolean ident; - public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, String defaultValue) { + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = defaultValue; + this.defaultValue = ""; this.setHidden(false); this.setIdent(false); } - public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, String defaultValue, boolean hidden) { + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, boolean hidden) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = defaultValue; + this.defaultValue = ""; this.setHidden(hidden); this.setIdent(false); } - public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, String defaultValue, boolean hidden, boolean ident) { + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, boolean hidden, boolean ident) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = defaultValue; + this.defaultValue = ""; this.setHidden(hidden); this.setIdent(ident); } diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 8e48fde..09ccef3 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -5,4 +5,5 @@ pac=packet hive=host since=connected since moduletitle=domains -moduleicon=../runo/icons/16/document-web.png \ No newline at end of file +moduleicon=../runo/icons/16/document-web.png +new=configure domain \ No newline at end of file diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index 96702ab..c3cf973 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -5,4 +5,5 @@ pac=Paket hive=Server since=aufgeschaltet seit moduletitle=Domains -moduleicon=../runo/icons/16/document-web.png \ No newline at end of file +moduleicon=../runo/icons/16/document-web.png +new=Domain konfigurieren \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress.properties b/hsarweb/src/texts/emailaddress.properties index 7e1294b..da1ec4c 100644 --- a/hsarweb/src/texts/emailaddress.properties +++ b/hsarweb/src/texts/emailaddress.properties @@ -1,5 +1,5 @@ id=identifier -emailaddress=adress +emailaddress=address localpart=local part subdomain=subdomain domain=main domain @@ -8,4 +8,5 @@ admin=admin user pac=packet fulldomain=full domain moduletitle=email addresses -moduleicon=../runo/icons/16/email.png \ No newline at end of file +moduleicon=../runo/icons/16/email.png +new=create address \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress_de.properties b/hsarweb/src/texts/emailaddress_de.properties index 9106ca7..9e73654 100644 --- a/hsarweb/src/texts/emailaddress_de.properties +++ b/hsarweb/src/texts/emailaddress_de.properties @@ -8,4 +8,5 @@ admin=Administrator pac=Paket fulldomain=volle Domain moduletitle=EMail Adressen -moduleicon=../runo/icons/16/email.png \ No newline at end of file +moduleicon=../runo/icons/16/email.png +new=EMail-Adresse anlegen \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias.properties b/hsarweb/src/texts/emailalias.properties index 8c4ef71..8fc13f7 100644 --- a/hsarweb/src/texts/emailalias.properties +++ b/hsarweb/src/texts/emailalias.properties @@ -3,4 +3,5 @@ name=name target=target(s) pac=packet moduletitle=email aliases -moduleicon=../runo/icons/16/email-send.png \ No newline at end of file +moduleicon=../runo/icons/16/email-send.png +new=create alias \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias_de.properties b/hsarweb/src/texts/emailalias_de.properties index c3a7e0c..b2d5671 100644 --- a/hsarweb/src/texts/emailalias_de.properties +++ b/hsarweb/src/texts/emailalias_de.properties @@ -3,4 +3,5 @@ name=Alias target=Ziel(e) pac=Paket moduletitle=EMail Aliases -moduleicon=../runo/icons/16/email-send.png \ No newline at end of file +moduleicon=../runo/icons/16/email-send.png +new=EMail-Alias anlegen \ No newline at end of file diff --git a/hsarweb/src/texts/main.properties b/hsarweb/src/texts/main.properties index e0e17f9..e654477 100644 --- a/hsarweb/src/texts/main.properties +++ b/hsarweb/src/texts/main.properties @@ -1,4 +1,6 @@ applicationtitle=HSAdmin Web Application +update=update delete=delete confirmdelete=confirm delete +save=save abort=abort \ No newline at end of file diff --git a/hsarweb/src/texts/main_de.properties b/hsarweb/src/texts/main_de.properties index 219cacd..9a1e627 100644 --- a/hsarweb/src/texts/main_de.properties +++ b/hsarweb/src/texts/main_de.properties @@ -1,4 +1,6 @@ applicationtitle=HSAdmin Web Application +update=bearbeiten delete=löschen -confirmdelete=Diese Zeile löschen? +confirmdelete=Diesen Eintrag löschen? +save=speichern abort=abbrechen \ No newline at end of file diff --git a/hsarweb/src/texts/user.properties b/hsarweb/src/texts/user.properties index ac929d6..9401245 100644 --- a/hsarweb/src/texts/user.properties +++ b/hsarweb/src/texts/user.properties @@ -8,4 +8,5 @@ pac=packet quota_softlimit=quota soft limit quota_hardlimit=quota hard limit moduletitle=unix user +new=create user moduleicon=../runo/icons/16/users.png \ No newline at end of file diff --git a/hsarweb/src/texts/user_de.properties b/hsarweb/src/texts/user_de.properties index 9b6c8c4..500dac5 100644 --- a/hsarweb/src/texts/user_de.properties +++ b/hsarweb/src/texts/user_de.properties @@ -1,11 +1,12 @@ id=Schlüssel name=Benutzername -comment=Beschreibung -shell=Unix Shell -userid=Numerische Id +comment=Kommentar +shell=Shell +userid=Benutzerkennung homedir=Heimat Verzeichnis pac=Paket -quota_softlimit=Weiche Quota -quota_hardlimit=Harte Quota -moduletitle=Unix Benutzer -moduleicon=../runo/icons/16/users.png \ No newline at end of file +quota_softlimit=Soft-Quota [MB] +quota_hardlimit=Hard-Quota [MB] +moduletitle=Unix User +moduleicon=../runo/icons/16/users.png +new=Benutzer anlegen \ No newline at end of file