r45 - in trunk: . billy-ui-zk billy-ui-zk/src billy-ui-zk/src/main billy-ui-zk/src/main/java billy-ui-zk/src/main/java/org billy-ui-zk/src/main/java/org/chorem billy-ui-zk/src/main/java/org/chorem/billy billy-ui-zk/src/main/java/org/chorem/billy/ui billy-ui-zk/src/main/resources billy-ui-zk/src/main/webapp billy-ui-zk/src/main/webapp/WEB-INF
Author: bbrossaud Date: 2010-08-10 12:14:01 +0200 (Tue, 10 Aug 2010) New Revision: 45 Url: http://chorem.org/repositories/revision/billy/45 Log: addition invoice form Added: trunk/billy-ui-zk/ trunk/billy-ui-zk/LICENSE.txt trunk/billy-ui-zk/README.txt trunk/billy-ui-zk/changelog.txt trunk/billy-ui-zk/pom.xml trunk/billy-ui-zk/src/ trunk/billy-ui-zk/src/main/ trunk/billy-ui-zk/src/main/java/ trunk/billy-ui-zk/src/main/java/org/ trunk/billy-ui-zk/src/main/java/org/chorem/ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryFormController.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryModel.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataConfig.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataProxy.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CompanyModel.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceController.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceFormController.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ProjectModel.java trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/SubCategoryModel.java trunk/billy-ui-zk/src/main/resources/ trunk/billy-ui-zk/src/main/resources/billy.properties trunk/billy-ui-zk/src/main/resources/log4j.properties trunk/billy-ui-zk/src/main/resources/wikitty-jdbc-config.properties trunk/billy-ui-zk/src/main/webapp/ trunk/billy-ui-zk/src/main/webapp/WEB-INF/ trunk/billy-ui-zk/src/main/webapp/WEB-INF/sun-web.xml trunk/billy-ui-zk/src/main/webapp/WEB-INF/web.xml trunk/billy-ui-zk/src/main/webapp/WEB-INF/zk.xml trunk/billy-ui-zk/src/main/webapp/categoryFormPage.zul trunk/billy-ui-zk/src/main/webapp/invoiceFormPage.zul trunk/billy-ui-zk/src/main/webapp/invoicePage.zul Modified: trunk/pom.xml Added: trunk/billy-ui-zk/pom.xml =================================================================== --- trunk/billy-ui-zk/pom.xml (rev 0) +++ trunk/billy-ui-zk/pom.xml 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,111 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + + <parent> + <groupId>org.chorem</groupId> + <artifactId>billy</artifactId> + <version>1.0.0-alpha-1-SNAPSHOT</version> + </parent> + + <groupId>org.chorem.billy</groupId> + <artifactId>billy-ui-zk</artifactId> + + + <dependencies> + + <!--<dependency> + <groupId>org.chorem.choreg</groupId> + <artifactId>choreg</artifactId> + </dependency>--> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>servlet-api</artifactId> + <scope>provided</scope> + </dependency> + + + <dependency> + <groupId>org.chorem.chorem-data</groupId> + <artifactId>data-bonzoms</artifactId> + </dependency> + + <dependency> + <groupId>jasperreports</groupId> + <artifactId>jasperreports</artifactId> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zk</artifactId> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zkplus</artifactId> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zul</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-jdbc-impl</artifactId> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + </dependency> + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + + </dependencies> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + + <name>Billy : billy-ui-zk</name> + <description>Interface Web ZK pour Billy</description> + <inceptionYear>2010</inceptionYear> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>war</packaging> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.6</source> + <target>1.6</target> + </configuration> + </plugin> + </plugins> + </build> + <properties> + + </properties> +</project> + + + Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryFormController.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryFormController.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryFormController.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,203 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.chorem.data.bonzoms.Category; +import org.chorem.data.bonzoms.CategoryImpl; +import org.chorem.data.bonzoms.SubCategory; +import org.chorem.data.bonzoms.SubCategoryImpl; +import org.nuiton.wikitty.WikittyProxy; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zkplus.databind.AnnotateDataBinder; +import org.zkoss.zkplus.databind.DataBinder; +import org.zkoss.zul.Bandbox; +import org.zkoss.zul.Caption; +import org.zkoss.zul.Intbox; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listcell; +import org.zkoss.zul.Listitem; +import org.zkoss.zul.ListitemRenderer; +import org.zkoss.zul.Textbox; +import org.zkoss.zul.Window; + +public class CategoryFormController extends GenericForwardComposer { + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + + protected Category category = new CategoryImpl(); + protected SubCategory selectedSubCategory = null; + protected SubCategoryModel subCategoryModel = new SubCategoryModel(); + protected List<String> removedSubCategories = new ArrayList<String>(); + + protected Bandbox categoryBandbox; + protected Listbox subCategoryListbox; + + public static final String EVENT_ON_SAVE_CATEGORY = "onSaveCategory"; + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + Window win = (Window) self; + win.doModal(); + win.setPosition("center"); + String categoryId = Executions.getCurrent().getParameter("categoryId"); + if (categoryId == null) { + categoryId = (String) arg.get("categoryId"); + } + if (categoryId != null) { + category = proxy.restore(Category.class, categoryId); + } + initSubCategoryModel(); + DataBinder binder = new AnnotateDataBinder(comp); + binder.bindBean("composer", this); + binder.loadAll(); + } + + protected void initSubCategoryModel() { + Set<String> ids = category.getSubCategory(); + if (ids != null && !ids.isEmpty()) { + List<SubCategory> subCategories = proxy.restore(SubCategory.class, new ArrayList<String>(ids)); + if (subCategories != null) { + subCategories = new ArrayList<SubCategory>(subCategories); + subCategoryModel.setSubCategories(subCategories); + selectedSubCategory = subCategories.get(0); + } + } + } + + protected void saveSubCategories() { + List<SubCategory> subcategories = proxy.store(subCategoryModel.getSubCategories()); + for (SubCategory subCategory : subcategories) { + category.addSubCategory(subCategory.getWikittyId()); + } + if (!removedSubCategories.isEmpty()) { + proxy.delete(removedSubCategories); + for (String id : removedSubCategories) { + category.removeSubCategory(id); + } + } + } + + protected void fillSubCategoryFields() { + if (selectedSubCategory != null) { + Caption caption = (Caption) self.getFellow("subCategoryCaption"); + caption.setLabel(selectedSubCategory.getName()); + + Intbox intbox = (Intbox) self.getFellow("subCategoryOrder"); + intbox.setValue(selectedSubCategory.getOrder()); + + Textbox textbox = (Textbox) self.getFellow("subCategoryName"); + textbox.setValue(selectedSubCategory.getName()); + + textbox = (Textbox) self.getFellow("subCategoryAccountNumber"); + textbox.setValue(selectedSubCategory.getAccountNumber()); + + textbox = (Textbox) self.getFellow("subCategoryTVA"); + textbox.setValue(selectedSubCategory.getTVA()); + } + } + + protected void clearSubCategoryFields() { + Caption caption = (Caption) self.getFellow("subCategoryCaption"); + caption.setLabel(""); + + Intbox intbox = (Intbox) self.getFellow("subCategoryOrder"); + intbox.setValue(-1); + + Textbox textbox = (Textbox) self.getFellow("subCategoryName"); + textbox.setValue(""); + + textbox = (Textbox) self.getFellow("subCategoryAccountNumber"); + textbox.setValue(""); + + textbox = (Textbox) self.getFellow("subCategoryTVA"); + textbox.setValue(""); + } + + /* + * Renderers + */ + public ListitemRenderer getSubCategoryRenderer() { + return new ListitemRenderer() { + + @Override + public void render(Listitem item, Object data) throws Exception { + item.setValue(data); + final SubCategory sub = (SubCategory) data; + Listcell name = new Listcell(sub.getName()); + item.appendChild(name); + item.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + selectedSubCategory = sub; + fillSubCategoryFields(); + } + }); + } + }; + } + + /* + * Events + */ + public void onClick$addSubCategory() { + selectedSubCategory = new SubCategoryImpl(); + selectedSubCategory.setName("New sub category"); + subCategoryModel.addData(selectedSubCategory); + fillSubCategoryFields(); + } + + public void onClick$saveSubCategory() { + if (selectedSubCategory != null) { + int rowIndex = subCategoryModel.indexOf(selectedSubCategory); + if (rowIndex != -1) { + subCategoryModel.reloadContent(rowIndex); + } + } + } + + public void onClick$save() { + saveSubCategories(); + proxy.store(category); + Events.postEvent(EVENT_ON_SAVE_CATEGORY, this.self, category.getWikittyId()); + this.self.detach(); + } + + public void onClick$deleteSubCategory() { + Listitem item = subCategoryListbox.getSelectedItem(); + if (item != null) { + SubCategory subCategory = (SubCategory) item.getValue(); + if (subCategory != null) { + subCategoryModel.removeData(subCategory); + String id = subCategory.getWikittyId(); + if (id != null && !id.isEmpty()) { + removedSubCategories.add(id); + } + clearSubCategoryFields(); + } + } + } + + /* + * Getters + */ + public SubCategoryModel getSubCategoryModel() { + return subCategoryModel; + } + + public Category getCategory() { + return category; + } + + public SubCategory getSelectedSubCategory() { + return selectedSubCategory; + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryModel.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryModel.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CategoryModel.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,118 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; + +import org.chorem.data.bonzoms.Category; +import org.nuiton.wikitty.Criteria; +import org.nuiton.wikitty.PagedResult; +import org.nuiton.wikitty.WikittyProxy; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zul.AbstractListModel; +import org.zkoss.zul.event.ListDataEvent; + +public class CategoryModel extends AbstractListModel implements BindingListModel { + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + protected Criteria criteria = null; + protected int itemsByPage = 1; + protected int currentPage = 0; + protected List<Category> categories = new ArrayList<Category>(); + + public CategoryModel(int itemsByPage) { + this.itemsByPage = itemsByPage; + createList(); + } + + @Override + public Object getElementAt(int index) { + pageChange(index); + int indexList = index % itemsByPage; + Category Category = categories.get(indexList); + return Category; + } + + @Override + public int getSize() { + if (criteria == null) { + return 0; + } + Criteria criteria = this.criteria.setFirstIndex(0).setEndIndex(0); + PagedResult<Category> result = proxy.findAllByCriteria(Category.class, criteria); + return result.getNumFound(); + } + + @Override + public int indexOf(Object obj) { + int index = 0; + String id = ((Category) obj).getWikittyId(); + for (Category data : categories) { + String dataId = data.getWikittyId(); + if (id.equals(dataId)) { + index = categories.indexOf(data) + (itemsByPage * currentPage); + break; + } + } + return index; + } + + public void addData(Category newData) { + int listSize = categories.size(); + if (listSize < (itemsByPage)) { + categories.add(newData); + } + int size = getSize(); + fireEvent(ListDataEvent.INTERVAL_ADDED, size - 1, size - 1); + } + + public void removeData(Category data) { + int index = categories.indexOf(data); + if (index != -1) { + categories.remove(index); + int interval = index + (itemsByPage * currentPage); + fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); + } + } + + public void reloadContent(int rowIndex) { + int indexList = rowIndex % itemsByPage; + Category Category = categories.get(indexList); + Category = proxy.restore(Category.class, Category.getWikittyId()); + fireEvent(ListDataEvent.CONTENTS_CHANGED, rowIndex, rowIndex); + } + + public void reload() { + createList(); + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public Criteria getCriteria() { + return criteria; + } + + public void setCriteria(Criteria criteria) { + if (criteria != null) { + this.criteria = criteria; + reload(); + } + } + + public void pageChange(int index) { + int item = index; + int page = item / itemsByPage; + if (page != currentPage ) { + currentPage = page; + createList(); + } + } + + protected void createList() { + if (criteria != null) { + int first = currentPage * itemsByPage; + int end = first + (itemsByPage - 1); + Criteria criteria = this.criteria.setFirstIndex(first).setEndIndex(end); + List<Category> Categorys = proxy.findAllByCriteria(Category.class, criteria).getAll(); + this.categories = new ArrayList<Category>(Categorys); + } + } +} \ No newline at end of file Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataConfig.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataConfig.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataConfig.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,129 @@ +/* + * #%L + * Bonzoms : bonzoms-zk + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.chorem.billy.ui; + +import static org.nuiton.i18n.I18n._; + +import java.io.File; +import org.apache.commons.lang.UnhandledException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.ApplicationConfig; + +/** + * + * @author sherkhan + */ +public class ChoremDataConfig extends ApplicationConfig { + + /** to use log facility, just put in your code: log.info(\"...\"); */ + static private Log log = LogFactory.getLog(ChoremDataConfig.class); + /** Singleton instance. */ + protected static ChoremDataConfig instance = null; + + public ChoremDataConfig() { + super(); + + // set default option (included configuration file name : important) + for (Option o : Option.values()) { + if (o.defaultValue != null) { + setDefaultOption(o.key, o.defaultValue); + } + } + } + + public static synchronized ChoremDataConfig getInstance() { + if (instance == null) { + try { + instance = new ChoremDataConfig(); + instance.parse(new String[]{}); + instance.setDataDirInSystemProps(); + } catch (Exception e) { + throw new UnhandledException(e); + } + } + return instance; + } + + /** + * Get version as string. + * + * @return version + */ + public String getVersion() { + return getOption(Option.APPLICATION_VERSION.key); + } + + public File getDataDirAsFile() { + File option = getOptionAsFile(Option.DATA_DIR.key); + return option; + } + + /** + * Set {@code solr} and {@code jms} system configuration. + * + * This is the "only" way to configure embedded solr. + */ + protected void setDataDirInSystemProps() { + String value = getOption(Option.DATA_DIR.key); + if (log.isInfoEnabled()) { + log.info("Setting system property " + Option.DATA_DIR.key + " : " + value); + } + System.setProperty(Option.DATA_DIR.key, value); + env.put(Option.DATA_DIR.key, value); + } + + /** + * Vradi option definition. + */ + public static enum Option { + + CONFIG_FILE(CONFIG_FILE_NAME, _("billy.config.configFileName.description"), + "choremData.properties", String.class, false, false), + APPLICATION_VERSION("application.version", _("billy.config.application.version.description"), + null, String.class, true, true), + DATA_DIR("solr.data.dir", _("billy.config.data.dir.description"), + System.getProperty("user.home") + "/.chorem-data/solr", String.class, false, false); + public final String key; + public final String description; + public final String defaultValue; + public final Class<?> type; + public final boolean isTransient; + public final boolean isFinal; + + private Option(String key, String description, String defaultValue, + Class<?> type, boolean isTransient, boolean isFinal) { + this.key = key; + this.description = description; + this.defaultValue = defaultValue; + this.type = type; + this.isFinal = isFinal; + this.isTransient = isTransient; + } + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataProxy.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataProxy.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ChoremDataProxy.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,56 @@ +/* + * #%L + * Bonzoms : bonzoms-zk + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.chorem.billy.ui; + +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.WikittyService; +import org.nuiton.wikitty.WikittyServiceCached; +import org.nuiton.wikitty.jdbc.WikittyServiceJDBC; + +/** + * + * @author sherkhan + */ +public class ChoremDataProxy extends WikittyProxy { + + static protected ChoremDataProxy instance; + + synchronized static public ChoremDataProxy getInstance() { + if (instance == null) { + ChoremDataConfig config = ChoremDataConfig.getInstance(); + instance = new ChoremDataProxy(config); + } + return instance; + } + + protected ChoremDataProxy(ChoremDataConfig config) { + WikittyService ws = new WikittyServiceJDBC(config.getFlatOptions()); + ws = new WikittyServiceCached(ws); + setWikittyService(ws); + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CompanyModel.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CompanyModel.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/CompanyModel.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,119 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; + +import org.chorem.billy.ui.ChoremDataProxy; +import org.chorem.data.bonzoms.Company; +import org.nuiton.wikitty.Criteria; +import org.nuiton.wikitty.PagedResult; +import org.nuiton.wikitty.WikittyProxy; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zul.AbstractListModel; +import org.zkoss.zul.event.ListDataEvent; + +public class CompanyModel extends AbstractListModel implements BindingListModel { + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + protected Criteria criteria = null; + protected int itemsByPage = 1; + protected int currentPage = 0; + protected List<Company> companies = new ArrayList<Company>(); + + public CompanyModel(int itemsByPage) { + this.itemsByPage = itemsByPage; + createList(); + } + + @Override + public Object getElementAt(int index) { + pageChange(index); + int indexList = index % itemsByPage; + Company Company = companies.get(indexList); + return Company; + } + + @Override + public int getSize() { + if (criteria == null) { + return 0; + } + Criteria criteria = this.criteria.setFirstIndex(0).setEndIndex(0); + PagedResult<Company> result = proxy.findAllByCriteria(Company.class, criteria); + return result.getNumFound(); + } + + @Override + public int indexOf(Object obj) { + int index = 0; + String id = ((Company) obj).getWikittyId(); + for (Company data : companies) { + String dataId = data.getWikittyId(); + if (id.equals(dataId)) { + index = companies.indexOf(data) + (itemsByPage * currentPage); + break; + } + } + return index; + } + + public void addData(Company newData) { + int listSize = companies.size(); + if (listSize < (itemsByPage)) { + companies.add(newData); + } + int size = getSize(); + fireEvent(ListDataEvent.INTERVAL_ADDED, size - 1, size - 1); + } + + public void removeData(Company data) { + int index = companies.indexOf(data); + if (index != -1) { + companies.remove(index); + int interval = index + (itemsByPage * currentPage); + fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); + } + } + + public void reloadContent(int rowIndex) { + int indexList = rowIndex % itemsByPage; + Company Company = companies.get(indexList); + Company = proxy.restore(Company.class, Company.getWikittyId()); + fireEvent(ListDataEvent.CONTENTS_CHANGED, rowIndex, rowIndex); + } + + public void reload() { + createList(); + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public Criteria getCriteria() { + return criteria; + } + + public void setCriteria(Criteria criteria) { + if (criteria != null) { + this.criteria = criteria; + reload(); + } + } + + public void pageChange(int index) { + int item = index; + int page = item / itemsByPage; + if (page != currentPage ) { + currentPage = page; + createList(); + } + } + + protected void createList() { + if (criteria != null) { + int first = currentPage * itemsByPage; + int end = first + (itemsByPage - 1); + Criteria criteria = this.criteria.setFirstIndex(first).setEndIndex(end); + List<Company> Companies = proxy.findAllByCriteria(Company.class, criteria).getAll(); + this.companies = new ArrayList<Company>(Companies); + } + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceController.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceController.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceController.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,19 @@ +package org.chorem.billy.ui; + +import org.chorem.billy.ui.ChoremDataProxy; +import org.nuiton.wikitty.WikittyProxy; +import org.zkoss.zk.ui.Execution; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.util.GenericForwardComposer; + +public class InvoiceController extends GenericForwardComposer{ + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + + /* + * Events + */ + public void onClick$newInvoice() { + Executions.createComponents("invoiceFormPage.zul", null, null); + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceFormController.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceFormController.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/InvoiceFormController.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,282 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.chorem.data.bonzoms.Category; +import org.chorem.data.bonzoms.Company; +import org.chorem.data.bonzoms.Invoice; +import org.chorem.data.bonzoms.InvoiceImpl; +import org.chorem.data.bonzoms.Project; +import org.chorem.data.bonzoms.SubCategory; +import org.nuiton.wikitty.Criteria; +import org.nuiton.wikitty.WikittyProxy; +import org.nuiton.wikitty.search.Element; +import org.nuiton.wikitty.search.Search; +import org.zkoss.zk.ui.Component; +import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zk.ui.event.Events; +import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zkplus.databind.AnnotateDataBinder; +import org.zkoss.zkplus.databind.DataBinder; +import org.zkoss.zul.Bandbox; +import org.zkoss.zul.Checkbox; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listcell; +import org.zkoss.zul.Listhead; +import org.zkoss.zul.Listheader; +import org.zkoss.zul.Listitem; +import org.zkoss.zul.ListitemRenderer; +import org.zkoss.zul.Row; +import org.zkoss.zul.RowRenderer; +import org.zkoss.zul.Window; + +public class InvoiceFormController extends GenericForwardComposer { + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + protected Invoice invoice = new InvoiceImpl(); + + protected CategoryModel categoryModel = new CategoryModel(2); + protected CompanyModel companyModel = new CompanyModel(5); + protected ProjectModel projectModel = new ProjectModel(5); + + protected Bandbox categoryBandbox; + protected Bandbox companyBandbox; + protected Bandbox projectBandbox; + + @Override + public void doAfterCompose(Component comp) throws Exception { + super.doAfterCompose(comp); + Window win = (Window) self; + win.doModal(); + win.setPosition("center"); + String invoiceId = Executions.getCurrent().getParameter("invoiceId"); + if (invoiceId == null) { + invoiceId = (String) arg.get("invoiceId"); + } + if (invoiceId != null) { + invoice = proxy.restore(Invoice.class, invoiceId); + } + initCategoryBandbox(); + initCompanyBandbox(); + initProjectBandbox(); + DataBinder binder = new AnnotateDataBinder(comp); + binder.bindBean("composer", this); + binder.loadAll(); + } + + protected void initCategoryBandbox() { + onOK$categoryBandbox(); + categoryBandbox.close(); + } + + protected void initCompanyBandbox() { + onOK$companyBandbox(); + String companyId = invoice.getCompany(); + if (companyId != null && !companyId.isEmpty()) { + Company company = proxy.restore(Company.class, companyId); + companyBandbox.setValue(company.getName()); + } + companyBandbox.close(); + } + + protected void initProjectBandbox() { + onOK$projectBandbox(); + String projectId = invoice.getProject(); + if (projectId != null && !projectId.isEmpty()) { + Project project = proxy.restore(Project.class, projectId); + projectBandbox.setValue(project.getName()); + } + projectBandbox.close(); + } + + protected void setSubCategoryHeader(Listbox listbox, Category category) { + if (listbox != null) { + Listhead head = new Listhead(); + listbox.appendChild(head); + String name = category.getName(); + if (name == null) { + name = ""; + } + Listheader header = new Listheader(name); + head.appendChild(header); + } + } + + /* + * Renderers + */ + public ListitemRenderer getCompanyRenderer() { + return new ListitemRenderer() { + + @Override + public void render(Listitem item, Object data) throws Exception { + item.setValue(data); + final Company company = (Company) data; + Listcell name = new Listcell(company.getName()); + Listcell type = new Listcell(company.getType()); + item.appendChild(name); + item.appendChild(type); + item.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + invoice.setCompany(company.getWikittyId()); + companyBandbox.setValue(company.getName()); + companyBandbox.close(); + } + }); + } + }; + } + + protected void createSubCategoryListbox(Listbox listbox, Set<String> subCategoryIds) { + if (subCategoryIds != null && !subCategoryIds.isEmpty()) { + List<SubCategory> subCategories = proxy.restore(SubCategory.class, new ArrayList<String>(subCategoryIds)); + SubCategoryModel subCategoryModel = new SubCategoryModel(); + subCategoryModel.setSubCategories(subCategories); + listbox.setModel(subCategoryModel); + + listbox.setItemRenderer(new ListitemRenderer() { + + @Override + public void render(Listitem item, Object data) throws Exception { + item.setValue(data); + final SubCategory subCategory = (SubCategory) data; + Listcell cell = new Listcell(); + Checkbox checkbox = new Checkbox(subCategory.getName()); + Set<String> ids = invoice.getSubCategory(); + if (ids != null && ids.contains(subCategory.getWikittyId())) { + checkbox.setChecked(true); + } + cell.appendChild(checkbox); + item.appendChild(cell); + checkbox.addEventListener(Events.ON_CHECK, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + Checkbox checkbox = (Checkbox) event.getTarget(); + if (checkbox.isChecked()) { + invoice.addSubCategory(subCategory.getWikittyId()); + } else { + String id = subCategory.getWikittyId(); + Set<String> subCategories = invoice.getSubCategory(); + if (subCategories != null && subCategories.contains(id)) { + invoice.removeSubCategory(id); + } + } + } + }); + } + }); + } + } + + public RowRenderer getCategoryRenderer() { + return new RowRenderer() { + + @Override + public void render(Row row, Object data) throws Exception { + row.setValue(data); + final Category category = (Category) data; + Set<String> subCategoryIds = category.getSubCategory(); + Listbox listbox = new Listbox(); + setSubCategoryHeader(listbox, category); + createSubCategoryListbox(listbox, subCategoryIds); + row.appendChild(listbox); + + } + }; + } + + public ListitemRenderer getProjectRenderer() { + return new ListitemRenderer() { + + @Override + public void render(Listitem item, Object data) throws Exception { + item.setValue(data); + final Project project = (Project) data; + Listcell name = new Listcell(project.getName()); + item.appendChild(name); + item.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + invoice.setProject(project.getWikittyId()); + projectBandbox.setValue(project.getName()); + projectBandbox.close(); + } + }); + } + }; + } + + /* + * Events + */ + public void onOK$companyBandbox() { + String search = companyBandbox.getValue(); + Search query = Search.query().eq(Element.ELT_EXTENSION, Company.EXT_COMPANY); + if (search != null && !search.isEmpty()) { + query = query.keyword(search); + } + Criteria criteria = query.criteria(); + companyModel.setCriteria(criteria); + companyBandbox.open(); + } + + public void onOK$projectBandbox() { + String search = projectBandbox.getValue(); + Search query = Search.query().eq(Element.ELT_EXTENSION, Project.EXT_PROJECT); + if (search != null && !search.isEmpty()) { + query = query.keyword(search); + } + Criteria criteria = query.criteria(); + projectModel.setCriteria(criteria); + projectBandbox.open(); + } + + public void onOK$categoryBandbox() { + String search = categoryBandbox.getValue(); + Search query = Search.query().eq(Element.ELT_EXTENSION, Category.EXT_CATEGORY); + if (search != null && !search.isEmpty()) { + query = query.keyword(search); + } + Criteria criteria = query.criteria(); + categoryModel.setCriteria(criteria); + categoryBandbox.open(); + } + + public void onClick$newCategory() { + Window win = (Window) Executions.createComponents("categoryFormPage.zul", null, null); + win.addEventListener(CategoryFormController.EVENT_ON_SAVE_CATEGORY, new EventListener() { + + @Override + public void onEvent(Event event) throws Exception { + categoryModel.reload(); + } + }); + } + + /* + * Getters + */ + public Invoice getInvoice() { + return invoice; + } + + public CategoryModel getCategoryModel() { + return categoryModel; + } + + public ProjectModel getProjectModel() { + return projectModel; + } + + public CompanyModel getCompanyModel() { + return companyModel; + } +} \ No newline at end of file Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ProjectModel.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ProjectModel.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/ProjectModel.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,119 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; + +import org.chorem.billy.ui.ChoremDataProxy; +import org.chorem.data.bonzoms.Project; +import org.nuiton.wikitty.Criteria; +import org.nuiton.wikitty.PagedResult; +import org.nuiton.wikitty.WikittyProxy; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zul.AbstractListModel; +import org.zkoss.zul.event.ListDataEvent; + +public class ProjectModel extends AbstractListModel implements BindingListModel { + + protected WikittyProxy proxy = ChoremDataProxy.getInstance(); + protected Criteria criteria = null; + protected int itemsByPage = 1; + protected int currentPage = 0; + protected List<Project> projects = new ArrayList<Project>(); + + public ProjectModel(int itemsByPage) { + this.itemsByPage = itemsByPage; + createList(); + } + + @Override + public Object getElementAt(int index) { + pageChange(index); + int indexList = index % itemsByPage; + Project Project = projects.get(indexList); + return Project; + } + + @Override + public int getSize() { + if (criteria == null) { + return 0; + } + Criteria criteria = this.criteria.setFirstIndex(0).setEndIndex(0); + PagedResult<Project> result = proxy.findAllByCriteria(Project.class, criteria); + return result.getNumFound(); + } + + @Override + public int indexOf(Object obj) { + int index = 0; + String id = ((Project) obj).getWikittyId(); + for (Project data : projects) { + String dataId = data.getWikittyId(); + if (id.equals(dataId)) { + index = projects.indexOf(data) + (itemsByPage * currentPage); + break; + } + } + return index; + } + + public void addData(Project newData) { + int listSize = projects.size(); + if (listSize < (itemsByPage)) { + projects.add(newData); + } + int size = getSize(); + fireEvent(ListDataEvent.INTERVAL_ADDED, size - 1, size - 1); + } + + public void removeData(Project data) { + int index = projects.indexOf(data); + if (index != -1) { + projects.remove(index); + int interval = index + (itemsByPage * currentPage); + fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); + } + } + + public void reloadContent(int rowIndex) { + int indexList = rowIndex % itemsByPage; + Project Project = projects.get(indexList); + Project = proxy.restore(Project.class, Project.getWikittyId()); + fireEvent(ListDataEvent.CONTENTS_CHANGED, rowIndex, rowIndex); + } + + public void reload() { + createList(); + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public Criteria getCriteria() { + return criteria; + } + + public void setCriteria(Criteria criteria) { + if (criteria != null) { + this.criteria = criteria; + reload(); + } + } + + public void pageChange(int index) { + int item = index; + int page = item / itemsByPage; + if (page != currentPage ) { + currentPage = page; + createList(); + } + } + + protected void createList() { + if (criteria != null) { + int first = currentPage * itemsByPage; + int end = first + (itemsByPage - 1); + Criteria criteria = this.criteria.setFirstIndex(first).setEndIndex(end); + List<Project> projects = proxy.findAllByCriteria(Project.class, criteria).getAll(); + this.projects = new ArrayList<Project>(projects); + } + } +} Added: trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/SubCategoryModel.java =================================================================== --- trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/SubCategoryModel.java (rev 0) +++ trunk/billy-ui-zk/src/main/java/org/chorem/billy/ui/SubCategoryModel.java 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,57 @@ +package org.chorem.billy.ui; + +import java.util.ArrayList; +import java.util.List; + +import org.chorem.data.bonzoms.SubCategory; +import org.zkoss.zkplus.databind.BindingListModel; +import org.zkoss.zul.AbstractListModel; +import org.zkoss.zul.event.ListDataEvent; + +public class SubCategoryModel extends AbstractListModel implements BindingListModel { + + List<SubCategory> subCategories = new ArrayList<SubCategory>(); + + @Override + public Object getElementAt(int index) { + return subCategories.get(index); + } + + @Override + public int getSize() { + return subCategories.size(); + } + + @Override + public int indexOf(Object obj) { + return subCategories.indexOf(obj); + } + + public void setSubCategories(List<SubCategory> subCategories) { + this.subCategories = subCategories; + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public void addData(SubCategory newData) { + subCategories.add(newData); + fireEvent(ListDataEvent.INTERVAL_ADDED, subCategories.size() - 1, subCategories.size() - 1); + } + + public void removeData(SubCategory data) { + int interval = subCategories.indexOf(data); + subCategories.remove(data); + fireEvent(ListDataEvent.INTERVAL_REMOVED, interval, interval); + } + + public void reloadContent(int rowIndex) { + fireEvent(ListDataEvent.CONTENTS_CHANGED, rowIndex, rowIndex); + } + + public void reload() { + fireEvent(ListDataEvent.CONTENTS_CHANGED, -1, -1); + } + + public List<SubCategory> getSubCategories() { + return subCategories; + } +} Added: trunk/billy-ui-zk/src/main/resources/billy.properties =================================================================== --- trunk/billy-ui-zk/src/main/resources/billy.properties (rev 0) +++ trunk/billy-ui-zk/src/main/resources/billy.properties 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1 @@ +application.version=${project.version} Added: trunk/billy-ui-zk/src/main/resources/log4j.properties =================================================================== --- trunk/billy-ui-zk/src/main/resources/log4j.properties (rev 0) +++ trunk/billy-ui-zk/src/main/resources/log4j.properties 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,2 @@ +# solr +log4j.logger.org.apache.solr=WARN \ No newline at end of file Added: trunk/billy-ui-zk/src/main/resources/wikitty-jdbc-config.properties =================================================================== --- trunk/billy-ui-zk/src/main/resources/wikitty-jdbc-config.properties (rev 0) +++ trunk/billy-ui-zk/src/main/resources/wikitty-jdbc-config.properties 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,5 @@ +#Connection parameters +jdbc.con.driver=org.h2.Driver +jdbc.con.host=jdbc:h2:file:~/.chorem-data/localdb/localdb +jdbc.con.userName=sa +jdbc.con.password= Added: trunk/billy-ui-zk/src/main/webapp/WEB-INF/sun-web.xml =================================================================== --- trunk/billy-ui-zk/src/main/webapp/WEB-INF/sun-web.xml (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/WEB-INF/sun-web.xml 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd"> +<sun-web-app error-url=""> + <context-root>/bonzoms-ui-zk-2.0-SNAPSHOT</context-root> + <class-loader delegate="true"/> + <jsp-config> + <property name="keepgenerated" value="true"> + <description>Keep a copy of the generated servlet class' java code.</description> + </property> + </jsp-config> +</sun-web-app> Added: trunk/billy-ui-zk/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/billy-ui-zk/src/main/webapp/WEB-INF/web.xml (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/WEB-INF/web.xml 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> + <display-name>MyApp</display-name> + + <listener> + <description>Used to cleanup when a session is destroyed</description> + <display-name>ZK Session Cleaner</display-name> + <listener-class>org.zkoss.zk.ui.http.HttpSessionListener</listener-class> + </listener> + + <servlet> + <description>The servlet loads the DSP pages.</description> + <servlet-name>dspLoader</servlet-name> + <servlet-class>org.zkoss.web.servlet.dsp.InterpreterServlet</servlet-class> + </servlet> + + <servlet> + <description>ZK loader for ZUML pages</description> + <servlet-name>zkLoader</servlet-name> + <servlet-class>org.zkoss.zk.ui.http.DHtmlLayoutServlet</servlet-class> + <init-param> + <param-name>update-uri</param-name> + <param-value>/zkau</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet> + <description>The asynchronous update engine for ZK</description> + <servlet-name>auEngine</servlet-name> + <servlet-class>org.zkoss.zk.au.http.DHtmlUpdateServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>dspLoader</servlet-name> + <url-pattern>*.dsp</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>zkLoader</servlet-name> + <url-pattern>*.zul</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>zkLoader</servlet-name> + <url-pattern>*.zhtml</url-pattern> + </servlet-mapping> + + <servlet-mapping> + <servlet-name>auEngine</servlet-name> + <url-pattern>/zkau/*</url-pattern> + </servlet-mapping> + + <welcome-file-list> + <welcome-file>index.html</welcome-file> + <welcome-file>invoicePage.zul</welcome-file> + <welcome-file>index.htm</welcome-file> + <welcome-file>index.jsp</welcome-file> + <welcome-file>default.html</welcome-file> + <welcome-file>default.htm</welcome-file> + <welcome-file>default.jsp</welcome-file> + <welcome-file>index.zul</welcome-file> + </welcome-file-list> + +</web-app> Added: trunk/billy-ui-zk/src/main/webapp/WEB-INF/zk.xml =================================================================== --- trunk/billy-ui-zk/src/main/webapp/WEB-INF/zk.xml (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/WEB-INF/zk.xml 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- + Created by ZK Studio +--> +<zk> +</zk> \ No newline at end of file Added: trunk/billy-ui-zk/src/main/webapp/categoryFormPage.zul =================================================================== --- trunk/billy-ui-zk/src/main/webapp/categoryFormPage.zul (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/categoryFormPage.zul 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,65 @@ +<?page id="contract" title="Contract" cacheable="false" language="xul/html" zscriptLanguage="Java"?> +<?meta content="text/html; charset=UTF-8" pageEncoding="UTF-8"?> + +<window closable="true" maximizable="true" sizable="true" height="390px" width="400px" contentStyle="overflow:auto" apply="org.chorem.billy.ui.CategoryFormController"> +<caption label="Category" /> + + <vbox> + <hbox> + + <groupbox> + <caption id="categoryCaption" label="@{composer.category.name}" /> + <vbox> + + <label value="Order"/> + <intbox id="categoryOrder" value="@{composer.category.order, save-when='save.onClick'}" /> + + <label value="Name"/> + <textbox id="categoryName" value="@{composer.category.name, save-when='save.onClick'}" /> + + <label value="Type" /> + <textbox id="categoryType" value="@{composer.category.type, save-when='save.onClick'}" /> + + </vbox> + </groupbox> + + </hbox> + + <hbox> + + <vbox> + <listbox autopaging="true" mold="paging" rows="10" width="200px" model="@{composer.subCategoryModel}" + itemRenderer="@{composer.subCategoryRenderer}"> + <listhead> + <listheader label="Name" /> + </listhead> + </listbox> + <button id="addSubCategory" label="Add sub category" /> + </vbox> + + <groupbox> + <caption id="subCategoryCaption" label="@{composer.selectedSubCategory.name, save-when='saveSubCategory.onClick'}" /> + <vbox> + + <label value="Order"/> + <intbox id="subCategoryOrder" value="@{composer.selectedSubCategory.order, save-when='saveSubCategory.onClick'}" /> + + <label value="Name"/> + <textbox id="subCategoryName" value="@{composer.selectedSubCategory.name, save-when='saveSubCategory.onClick'}" /> + + <label value="Account number" /> + <textbox id="subCategoryAccountNumber" value="@{composer.selectedSubCategory.accountNumber, save-when='saveSubCategory.onClick'}" /> + + <label value="TVA" /> + <textbox id="subCategoryTVA" value="@{composer.selectedSubCategory.TVA, save-when='saveSubCategory.onClick'}" /> + + </vbox> + </groupbox> + <button id="saveSubCategory" label="Save" /> + + </hbox> + </vbox> + + <button id="save" label="Save and quit" /> + +</window> \ No newline at end of file Added: trunk/billy-ui-zk/src/main/webapp/invoiceFormPage.zul =================================================================== --- trunk/billy-ui-zk/src/main/webapp/invoiceFormPage.zul (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/invoiceFormPage.zul 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,87 @@ +<?page id="invoice" title="Invoice" cacheable="false" language="xul/html" zscriptLanguage="Java"?> +<?meta content="text/html; charset=UTF-8" pageEncoding="UTF-8"?> + +<window closable="true" maximizable="true" sizable="true" height="390px" width="400px" contentStyle="overflow:auto" apply="org.chorem.billy.ui.InvoiceFormController"> + <caption label="Invoice" /> + <separator /> + <groupbox> + <caption label="@{composer.invoice.number}" /> + <separator /> + <hbox> + + <vbox> + <label value="Payment date" /> + <datebox format="yyyy/MM/dd" value="@{composer.invoice.payment, save-when='saveInvoice.onClick'}" /> + <label value="Expected date" /> + <datebox format="yyyy/MM/dd" value="@{composer.invoice.expected, save-when='saveInvoice.onClick'}" /> + <label value="Posted date" /> + <datebox format="yyyy/MM/dd" value="@{composer.invoice.posted, save-when='saveInvoice.onClick'}" /> + + <hbox> + <toolbarbutton id="editProject" label="Edit project" /> / <toolbarbutton id="newProject" label="New project" /> + </hbox> + + <bandbox id="projectBandbox" mold="rounded"> + <bandpopup> + <vbox> + <listbox autopaging="true" mold="paging" id="projectListbox" rows="5" width="200px" model="@{composer.projectModel}" + itemRenderer="@{composer.projectRenderer}"> + <listhead> + <listheader label="Name" /> + </listhead> + </listbox> + </vbox> + </bandpopup> + </bandbox> + + <hbox> + <toolbarbutton id="editCompany" label="Edit company" /> / <toolbarbutton id="newCompany" label="New company" /> + </hbox> + + <bandbox id="companyBandbox" mold="rounded"> + <bandpopup> + <vbox> + <listbox autopaging="true" mold="paging" id="companyListbox" rows="5" width="200px" model="@{composer.companyModel}" + itemRenderer="@{composer.companyRenderer}"> + <listhead> + <listheader label="Name" /> + <listheader label="Type" /> + </listhead> + </listbox> + </vbox> + </bandpopup> + </bandbox> + + <hbox> + <toolbarbutton id="editCategory" label="Edit category" /> / <toolbarbutton id="newCategory" label="New category" /> + </hbox> + + <bandbox id="categoryBandbox" mold="rounded"> + <bandpopup> + <vbox> + <grid mold="paging" id="categoryGrid" pageSize="2" width="200px" model="@{composer.categoryModel}" + rowRenderer="@{composer.categoryRenderer}"> + </grid> + </vbox> + </bandpopup> + </bandbox> + + </vbox> + + <space /> + + <vbox> + <label value="HT price" /> + <doublebox value="@{composer.invoice.HTPrice, save-when='saveInvoice.onClick'}" /> + <label value="TTC price" /> + <doublebox value="@{composer.invoice.TTCPrice, save-when='saveInvoice.onClick'}" /> + <label value="Invoice number" /> + <textbox value="@{composer.invoice.number, save-when='saveInvoice.onClick'}" /> + <label value="Description" /> + <textbox rows="8" value="@{composer.invoice.description, save-when='saveInvoice.onClick'}" /> + <separator /> + </vbox> + </hbox> + </groupbox> + <button id="saveInvoice" label="Save"/> +</window> \ No newline at end of file Added: trunk/billy-ui-zk/src/main/webapp/invoicePage.zul =================================================================== --- trunk/billy-ui-zk/src/main/webapp/invoicePage.zul (rev 0) +++ trunk/billy-ui-zk/src/main/webapp/invoicePage.zul 2010-08-10 10:14:01 UTC (rev 45) @@ -0,0 +1,13 @@ +<?page id="home" title="HOME" cacheable="false" language="xul/html" zscriptLanguage="Java"?> +<?meta content="text/html; charset=UTF-8" pageEncoding="UTF-8"?> +<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="win"?> + +<window id="win" title="Win" border="normal" apply="org.chorem.billy.ui.InvoiceController"> + <vbox> + <toolbarbutton id="newInvoice" label="Add new invoice" /> + </vbox> + <separator bar="true" /> + <vbox> + + </vbox> +</window> \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-07-01 13:16:38 UTC (rev 44) +++ trunk/pom.xml 2010-08-10 10:14:01 UTC (rev 45) @@ -17,8 +17,9 @@ <version>1.0.0-alpha-1-SNAPSHOT</version> <modules> - <module>billy-ui</module> - <module>billy-business</module> + <!-- <module>billy-ui</module> + <module>billy-business</module> --> + <module>billy-ui-zk</module> </modules> <dependencyManagement> @@ -98,6 +99,75 @@ <artifactId>javassist</artifactId> <version>3.8.0.GA</version> </dependency> + + <!-- dependencies for billy-zk --> + <dependency> + <groupId>org.chorem.chorem-data</groupId> + <artifactId>data-bonzoms</artifactId> + <version>${chorem-data.version}</version> + </dependency> + + <dependency> + <groupId>jasperreports</groupId> + <artifactId>jasperreports</artifactId> + <version>3.5.3</version> + <exclusions> + <exclusion> + <groupId>commons-collections</groupId> + <artifactId>commons-collections</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zk</artifactId> + <version>${zk.version}</version> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zkplus</artifactId> + <version>${zk.version}</version> + </dependency> + + <dependency> + <groupId>org.zkoss.zk</groupId> + <artifactId>zul</artifactId> + <version>${zk.version}</version> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>${junit.version}</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-api</artifactId> + <version>${wikitty.version}</version> + </dependency> + + <dependency> + <groupId>org.nuiton.wikitty</groupId> + <artifactId>wikitty-jdbc-impl</artifactId> + <version>${wikitty.version}</version> + </dependency> + + <dependency> + <groupId>com.h2database</groupId> + <artifactId>h2</artifactId> + <version>1.2.134</version> + </dependency> + + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + <version>1.5.11</version> + </dependency> + </dependencies> </dependencyManagement> @@ -131,6 +201,20 @@ <role>Développeur</role> </roles> </developer> + + <developer> + <id>bbrossaud</id> + <name>Benoît Brossaud</name> + <email>bbrossaud@codelutin.com</email> + <organization>Code Lutin</organization> + <organizationUrl>http://www.codelutin.com/</organizationUrl> + <timezone>+1</timezone> + <roles> + <role>Analyste</role> + <role>Développeur</role> + </roles> + </developer> + </developers> <!-- ************************************************************* --> @@ -145,6 +229,10 @@ <projectId>billy</projectId> <platform>chorem.org</platform> + <chorem-data.version>0.1-SNAPSHOT</chorem-data.version> + <zk.version>5.0.2</zk.version> + <wikitty.version>2.0</wikitty.version> + <!-- Nuiton librairies --> <topia.version>2.2.0</topia.version> <generator.version>1.0.0</generator.version>
participants (1)
-
bbrossaud@users.chorem.org