Author: bbrossaud Date: 2010-08-13 14:13:00 +0200 (Fri, 13 Aug 2010) New Revision: 128 Url: http://chorem.org/repositories/revision/bonzoms/128 Log: rename file Added: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/BonzomsController.java trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataConfig.java trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataProxy.java trunk/bonzoms-ui-zk/src/main/resources/choremData.properties trunk/bonzoms-ui-zk/src/main/webapp/bonzoms.zul Modified: trunk/bonzoms-ui-zk/src/main/webapp/WEB-INF/web.xml Added: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/BonzomsController.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/BonzomsController.java (rev 0) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/BonzomsController.java 2010-08-13 12:13:00 UTC (rev 128) @@ -0,0 +1,75 @@ +/* + * #%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% + */ +package org.chorem.bonzoms.ui; + +import org.zkoss.zk.ui.util.GenericForwardComposer; +import org.zkoss.zul.Textbox; +import org.zkoss.zul.Include; + +/** + * + * @author bbrossaud + */ +public class BonzomsController extends GenericForwardComposer { + + protected Textbox searchBox; + protected Include include; + /* + * Events + */ + public void onOK$searchBox() { + String search = searchBox.getValue(); + include.setSrc(null); + include.setSrc("resultPage.zul?search=" + search); + } + + public void onClick$searchButton() { + onOK$searchBox(); + } + + public void onClick$employees() { + include.setSrc(null); + include.setSrc("employeePage.zul"); + } + + public void onClick$persons() { + include.setSrc(null); + include.setSrc("personPage.zul"); + } + + public void onClick$companies() { + include.setSrc(null); + include.setSrc("companyPage.zul"); + } + + public void onClick$services() { + include.setSrc(null); + include.setSrc("servicePage.zul"); + } + + public void onClick$contracts() { + include.setSrc(null); + include.setSrc("contractPage.zul"); + } +} Added: trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataConfig.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataConfig.java (rev 0) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataConfig.java 2010-08-13 12:13:00 UTC (rev 128) @@ -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.bonzoms.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, _("bonzoms.config.configFileName.description"), + "choremData.properties", String.class, false, false), + APPLICATION_VERSION("application.version", _("bonzoms.config.application.version.description"), + null, String.class, true, true), + DATA_DIR("solr.data.dir", _("bonzoms.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/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataProxy.java =================================================================== --- trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataProxy.java (rev 0) +++ trunk/bonzoms-ui-zk/src/main/java/org/chorem/bonzoms/ui/ChoremDataProxy.java 2010-08-13 12:13:00 UTC (rev 128) @@ -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.bonzoms.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/bonzoms-ui-zk/src/main/resources/choremData.properties =================================================================== --- trunk/bonzoms-ui-zk/src/main/resources/choremData.properties (rev 0) +++ trunk/bonzoms-ui-zk/src/main/resources/choremData.properties 2010-08-13 12:13:00 UTC (rev 128) @@ -0,0 +1 @@ +application.version=${project.version} Modified: trunk/bonzoms-ui-zk/src/main/webapp/WEB-INF/web.xml =================================================================== --- trunk/bonzoms-ui-zk/src/main/webapp/WEB-INF/web.xml 2010-08-13 08:20:26 UTC (rev 127) +++ trunk/bonzoms-ui-zk/src/main/webapp/WEB-INF/web.xml 2010-08-13 12:13:00 UTC (rev 128) @@ -52,6 +52,7 @@ </servlet-mapping> <welcome-file-list> + <welcome-file>bonzoms.zul</welcome-file> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> Added: trunk/bonzoms-ui-zk/src/main/webapp/bonzoms.zul =================================================================== --- trunk/bonzoms-ui-zk/src/main/webapp/bonzoms.zul (rev 0) +++ trunk/bonzoms-ui-zk/src/main/webapp/bonzoms.zul 2010-08-13 12:13:00 UTC (rev 128) @@ -0,0 +1,25 @@ +<?page id="home" title="Bonzoms" 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="Bonzoms" border="normal" apply="org.chorem.bonzoms.ui.BonzomsController"> + <hbox> + <groupbox height="800px" > + <caption label="Menu" /> + <vbox> + <toolbarbutton id="companies" label="Companies" /> + <toolbarbutton id="contracts" label="Contracts" /> + <toolbarbutton id="employees" label="Employees" /> + <toolbarbutton id="persons" label="Persons" /> + <toolbarbutton id="services" label="Services" /> + </vbox> + </groupbox> + <vbox id="content" > + <hbox> + Search: <textbox id="searchBox" /> <button label="Search" id="searchButton" /> + </hbox> + <separator bar="true" /> + <include id="include" src="employeePage.zul" /> + </vbox> + </hbox> +</window> \ No newline at end of file