Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
April 2010
- 5 participants
- 60 discussions
r2851 - in trunk/lima-swing: . src/main/java/org/chorem/lima src/main/java/org/chorem/lima/actions src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:21:50 +0200 (Fri, 09 Apr 2010)
New Revision: 2851
Log:
Misc refactoring an updates (splash, actions, useless code)
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java
trunk/lima-swing/src/main/java/org/chorem/lima/actions/
trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/Main.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java
Modified:
trunk/lima-swing/pom.xml
trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java
Modified: trunk/lima-swing/pom.xml
===================================================================
--- trunk/lima-swing/pom.xml 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/pom.xml 2010-04-09 16:21:50 UTC (rev 2851)
@@ -59,6 +59,21 @@
<artifactId>jdom</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-core</artifactId>
+ </dependency>
+
+ <!-- for remote mode only -->
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>openejb-client</artifactId>
+ </dependency>
</dependencies>
<!-- ************************************************************* -->
@@ -72,11 +87,6 @@
<!-- *** Build Settings ****************************************** -->
<!-- ************************************************************* -->
<properties>
-
- <!-- jaxx configuration
- <jaxx.addProjectClassPath>true</jaxx.addProjectClassPath>
- <jaxx.addSourcesToClassPath>true</jaxx.addSourcesToClassPath>-->
-
<!--Main class in JAR -->
<maven.jar.main.class>org.chorem.lima.Main</maven.jar.main.class>
@@ -109,6 +119,10 @@
<plugin>
<groupId>org.nuiton.jaxx</groupId>
<artifactId>maven-jaxx-plugin</artifactId>
+ <configuration>
+ <addCompileClassPath>true</addCompileClassPath>
+ <addProjectClassPath>true</addProjectClassPath>
+ </configuration>
<executions>
<execution>
<goals>
@@ -123,7 +137,6 @@
<artifactId>maven-i18n-plugin</artifactId>
<executions>
<execution>
- <id>java</id>
<configuration>
<entries>
<entry>
@@ -133,7 +146,7 @@
</configuration>
<goals>
<goal>parserJava</goal>
- <goal>bundle</goal>
+ <goal>gen</goal>
</goals>
</execution>
</executions>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/DataManager.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,243 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima;
-
-import java.util.List;
-
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.StatusDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.service.PeriodService;
-import org.chorem.lima.service.ServiceFactory;
-import org.chorem.lima.service.util.ProgressListener;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.table.model.ClosureTableModel;
-import org.chorem.lima.table.model.JournalTableModel;
-import org.chorem.lima.table.model.TransactionDataTableModel;
-import org.chorem.lima.tree.model.AccountTreeTableModel;
-
-/**
- * Cette classe permet de gérer les données de Lima. Chaque type de données
- * peut être récupéré. Certaines données peuvent être retourner sous forme
- * de model (essentiellement pour les données en tableau).
- * Exemple : pour récupérer les transactions, il suffit d'appeler la méthode
- * getTransactionModel, qui ensuite possède une méthode pour récuper les données
- * sous forme de liste.
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class DataManager {
-
- protected ClosureTableModel closureModel;
- protected JournalTableModel journalModel;
- protected AccountTreeTableModel accountModel;
- protected TransactionDataTableModel transactionModel;
- protected List<PeriodDTO> periodes;
- protected List<StatusDTO> status;
- protected JournalDTO currentJournal;
- protected PeriodDTO currentPeriod;
-
- /**
- * Constructor
- */
- public DataManager() {
- }
-
- /**
- * @return
- */
- public JournalTableModel getJournalModel() {
- if (journalModel == null) {
- /** Services */
- List<JournalDTO> journals = LimaContext.getContext().getNeogiaFactory().getJournalService().getAllJournal();
- journalModel = new JournalTableModel(journals);
- }
- return journalModel;
- }
-
- /**
- * @return
- */
- public ClosureTableModel getClosureModel() {
- if (closureModel == null) {
- /** Services */
- // Création de la liste des périodes
- List<PeriodDTO> listPeriodDTO = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(getStatus());
- // Parcourt toutes les périodes (2007 / 2008 / etc)
- for (PeriodDTO period : getPeriodes())
- {
- // Parcourt toutes les périodes mensuelles pour chaque exercice
- for (PeriodDTO periodChild : period.getChildren())
- {
- listPeriodDTO.add(periodChild);
- }
- }
- closureModel = new ClosureTableModel(listPeriodDTO);
- }
- return closureModel;
- }
-
- /**
- * @return
- */
- public AccountTreeTableModel getAccountModel() {
- if (accountModel == null) {
- /** Services */
- AccountDTO account = LimaContext.getContext().getNeogiaFactory().getAccountService().getAllAccount();
- accountModel = new AccountTreeTableModel(account);
- }
- return accountModel;
- }
-
- public AccountTreeTableModel resetAccountModel() {
- /** Services */
- AccountDTO account = LimaContext.getContext().getNeogiaFactory().getAccountService().getAllAccount();
- accountModel = new AccountTreeTableModel(account);
- return accountModel;
- }
-
- public AccountTreeTableModel resetAccountModel(AccountDTO account) {
- /** Services */
- accountModel = new AccountTreeTableModel(account);
- return accountModel;
- }
-
- /**
- * @return
- */
- public TransactionDataTableModel getTransactionModel() {
-
-
- if (transactionModel == null) {
- /** Services */
- List<TransactionDTO> data = LimaContext.getContext().getNeogiaFactory().getTransactionService().getAllTransaction(
- ServiceHelper.getAllFlatPeriod(
- getPeriodes()),
- getJournalModel().getData(),
- ServiceHelper.getAllFlatAccount(getAccountModel().getData()),
- getStatus(), null);
- transactionModel = new TransactionDataTableModel(data);
- }
- return transactionModel;
- }
-
- public TransactionDataTableModel getTransactionModel(ProgressListener progressListener) {
-
-
- if (transactionModel == null) {
- /** Services */
- List<TransactionDTO> data = LimaContext.getContext().getNeogiaFactory().getTransactionService().getAllTransaction(
- ServiceHelper.getAllFlatPeriod(
- getPeriodes()),
- getJournalModel().getData(),
- ServiceHelper.getAllFlatAccount(getAccountModel().getData()),
- getStatus(), progressListener);
- transactionModel = new TransactionDataTableModel(data);
- }
- return transactionModel;
- }
-
-
- /**
- * Permet de relancer le model des transactions. Il a besoin en entrée de
- * la liste des transactions à charger dans Lima. Cette méthode peut être
- * utilisée dans le cas d'un import de données par exemple.
- * @param listTransactions
- * @return
- */
- public TransactionDataTableModel resetTransactionModel (List<TransactionDTO> listTransactions) {
- transactionModel = new TransactionDataTableModel(listTransactions);
- return transactionModel;
- }
-
- /**
- * @return
- */
- public List<PeriodDTO> getPeriodes() {
- if (periodes == null) {
- /** Services */
- LimaContext context = LimaContext.getContext();
- ServiceFactory factory = context.getNeogiaFactory();
- PeriodService periodService =factory.getPeriodService();
- status = getStatus();
- periodes= periodService.getAllPeriod(status);
-// periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
-// getStatus());
- }
- return periodes;
- }
-
- public List<PeriodDTO> resetPeriodes() {
- periodes.clear();
- periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
- getStatus());
- return periodes;
- }
-
- public List<PeriodDTO> resetPeriodes(List<PeriodDTO> listPeriodes) {
- periodes.clear();
- periodes = listPeriodes;
- return periodes;
- }
-
- /**
- * @return
- */
- public List<StatusDTO> getStatus() {
- if (status == null) {
- /** Services */
- status = LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus();
- }
- return status;
- }
-
- /**
- *
- */
- public void reset() {
- journalModel = null;
- accountModel = null;
- transactionModel = null;
- periodes = null;
- }
-
- public JournalDTO getCurrentJournal() {
- return currentJournal == null ? getJournalModel().getData().get(0) : currentJournal;
- }
-
- public void setCurrentJournal(JournalDTO currentJournal) {
- this.currentJournal = currentJournal;
- }
-
- public PeriodDTO getCurrentPeriod() {
- return (currentPeriod == null && !getPeriodes().isEmpty()) ? getPeriodes().get(0) : currentPeriod;
- }
-
- public void setCurrentPeriod(PeriodDTO currentPeriod) {
- this.currentPeriod = currentPeriod;
- }
-
- public boolean isPeriodSelected() {
- return currentPeriod != null;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,59 +0,0 @@
-package org.chorem.lima;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Les actions appellables via {@link Main}.
- *
- * @author tony
- */
-public class LimaAction {
-
- /**
- * to use log facility, just put in your code: log.info(\"...\");
- */
- static private Log log = LogFactory.getLog(LimaAction.class);
- /**
- * La configuration de l'application.
- */
- protected LimaConfig config;
-
- public LimaAction() {
- }
-
- public LimaAction(LimaConfig config) {
- this.config = config;
- }
-
- public void help() {
- System.out.println("observe.message.help.usage");
- System.out.println("Options (set with --option <key> <value>:");
- for (LimaConfig.Option o : LimaConfig.Option.values()) {
- System.out.println("\t" + o.key + "(" + o.defaultValue + "):" + o.description);
- }
-
- System.out.println("Actions:");
- for (LimaConfig.Action a : LimaConfig.Action.values()) {
- System.out.println("\t" + java.util.Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description);
- }
- }
-
- /**
- * Désactiver la possiblite de lancer l'ui principale.
- */
- public void disableMainUI() {
- if (log.isDebugEnabled()) {
- log.debug(this);
- }
- getConfig().setDisplayMainUI(false);
- }
-
- protected LimaConfig getConfig() {
- if (config == null) {
- LimaContext context = LimaContext.getContext();
- config = context.getConfig();
- }
- return config;
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,155 +1,177 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
package org.chorem.lima;
+import static org.nuiton.i18n.I18n._;
+
import java.beans.PropertyChangeListener;
-import java.io.IOException;
-import java.io.InputStream;
+import java.util.Locale;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.nuiton.i18n.I18n._;
-import org.nuiton.util.FileUtil;
+import org.chorem.lima.actions.MiscAction;
+import org.nuiton.util.ApplicationConfig;
+import org.nuiton.util.ArgumentsParserException;
+import org.nuiton.util.ConverterUtil;
import org.nuiton.util.Version;
-
-import java.io.File;
-import java.util.Locale;
-import java.util.Properties;
-
-import org.nuiton.util.ConverterUtil;
import org.nuiton.util.VersionUtil;
/**
* La configuration de l'application.
- * <p/>
- * TODO ajouter d'autres propriete pour controler quel storage est utilise
- * et quel est son type (local ou pas).
*
* @author chemit
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
*/
-public class LimaConfig extends org.nuiton.util.ApplicationConfig {
+public class LimaConfig extends ApplicationConfig {
/**
* to use log facility, just put in your code: log.info(\"...\");
*/
static private Log log = LogFactory.getLog(LimaConfig.class);
+
/**
- * La version du logiciel constitue de l.d.r
- * <li>l: le numero de version du logiciel
- * <li>d: le numero de version du schema de la base de donnees
- * <li>r: le numero de version de de l'interface graphique ou autre modif mineur
- * <p/>
- * lors de l'increment de l, d et r sont remis a 0
- * lors de l'increment de d et r sont remis a 0
- * lors de l'increment de r est remis a 0
- * <p/>
- * Un changement d'UI ne modifie jamais le numero de version de database
- * Un changement de schema de base pour lequel on ne peut pas faire de
- * migration de donnees demande automatiquement un changement de version
- * d'application.
+ * La version du logiciel.
*/
- protected final Version version;
- public static final String APPLICATION_PROPERTIES = "/lima.properties";
- public static final String USER_DIRECTORY_FILENAME = ".lima";
+ protected Version version;
+
/**
- * le repertoire utilisateur principale
+ * Get copyrighy text (include version).
+ *
+ * @return copyright text
*/
- protected static File observeUserDirectory;
-
public String getCopyrightText() {
return "Version " + getVersion() + " Codelutin @ 2008-2010";
}
/**
+ * Version as string.
+ *
* @return le nombre global ex: 3.2.0.0
*/
public String getVersion() {
return version.toString();
}
- public static File getLimaUserDirectory() {
- if (observeUserDirectory == null) {
- observeUserDirectory = new File(new File(LimaConfig.getUserHome()), USER_DIRECTORY_FILENAME);
- }
- return observeUserDirectory;
- }
-
/**
- * un drepeau pour savoir s'il faut lancer l'interface graphique.
- * Cette valeur peut être programmées lors des actions.
+ * Lima config constructor.
+ *
+ * Define all default options and action alias.
*/
- private boolean displayMainUI = true;
- /**
- * drapeau pour savoir si on peut utiliser des ui dans l'environnement.
- * <p/>
- * Par defaut, on suppose qu'on peut utiliser l'environnement graphique
- * et si on désactive explicitement si pas d'environnement graphique trouvé.
- */
- private boolean canUseUI = true;
-
public LimaConfig() {
- setConfigFileName(Option.CONFIG_FILE.defaultValue);
-
- // chargement de la configuration interne
-
- InputStream stream = getClass().getResourceAsStream(APPLICATION_PROPERTIES);
-
- Properties p = new Properties();
- try {
- p.load(stream);
- for (Object k : p.keySet()) {
- String key = k + "";
- Object value = p.get(k);
- if (log.isDebugEnabled()) {
- log.debug("install properties " + k + " : " + value);
- }
- setDefaultOption(key, "" + value);
- }
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
-
+ // set defaut option (included configuration file name : important)
for (Option o : Option.values()) {
setDefaultOption(o.key, o.defaultValue);
}
- // on supprime tout ce qui est apres - (-SNAPSHOT, -rc-1 ,...)
- //TODO Il faut que VersionNumber gère les versions plus évoluée (alpha-x beta-x rc-x,...)
- String sVersion = VersionUtil.removeSnapshot(getOption("application.version"));
- version = VersionUtil.valueOf(sVersion);
-
- // initialisation des répertoires
- FileUtil.setCurrentDirectory(getLimaUserDirectory());
-
- getLimaUserDirectory().mkdirs();
-
+ // set action alias
for (Action a : Action.values()) {
for (String alias : a.aliases) {
addActionAlias(alias, a.action);
}
}
- log.info(_("lima.message.config.loaded", version));
+ // ajout des alias (can be set in option enum ?)
+ addAlias("--disableui", "--launchui false");
+
+ // initialisation des répertoires
+ // TODO what is it for ?
+ //FileUtil.setCurrentDirectory(getLimaUserDirectory());
+ //getLimaUserDirectory().mkdirs();
}
- public boolean isFullScreen() {
- Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
- return result != null && result;
+ /*
+ * @see org.nuiton.util.ApplicationConfig#parse(java.lang.String[])
+ */
+ @Override
+ public void parse(String[] args) throws ArgumentsParserException {
+
+ // super parse, read config file etc...
+ super.parse(args);
+
+ // on ne peut pas connaitre la version avant la lecture du fichier
+ // on supprime tout ce qui est apres - (-SNAPSHOT, -rc-1 ,...)
+ String sVersion = VersionUtil.removeSnapshot(getOption("application.version"));
+ version = VersionUtil.valueOf(sVersion);
+
}
+ /**
+ * Get application locale.
+ *
+ * @return configuration application locale
+ */
public Locale getLocale() {
String local = getOption(Option.LOCALE.key);
Locale result = ConverterUtil.convert(Locale.class, local);
return result;
}
- public boolean isDisplayMainUI() {
- return displayMainUI;
+ /**
+ * Locale setter for command line parameters.
+ *
+ * @param locale new locale
+ */
+ public void setLocale(String locale) {
+ setOption(Option.LOCALE.key, locale);
}
- public boolean isCanUseUI() {
- return canUseUI;
+ /**
+ * Change locale (not command line version).
+ * Save user file.
+ *
+ * @param newLocale new locale
+ */
+ public void setLocale(Locale newLocale) {
+ setOption(Option.LOCALE.key, newLocale.toString());
+ saveForUser();
+ firePropertyChange("locale", null, newLocale);
}
+ /**
+ * Launch ui configuration value.
+ *
+ * @return {@code true} if ui must be displayed
+ */
+ public boolean isLaunchui() {
+ boolean launchUI = getOptionAsBoolean(Option.LAUNCH_UI.key);
+ return launchUI;
+ }
+
+ /**
+ * Launch ui setter for command line parameters.
+ *
+ * @param launchui new lauch ui value
+ */
+ public void setLaunchui(String launchui) {
+ setOption(Option.LAUNCH_UI.key, launchui);
+ }
+
+ /**
+ * Change full screen mode.
+ * Save user file.
+ *
+ * @param fullscreen new fullscreen mode
+ */
public void setFullscreen(boolean fullscreen) {
boolean oldValue = isFullScreen();
setOption(Option.FULL_SCREEN.key, fullscreen + "");
@@ -157,38 +179,40 @@
firePropertyChange("fullscreen", oldValue, fullscreen);
}
- public void setDisplayMainUI(boolean b) {
- displayMainUI = b;
+ public boolean isFullScreen() {
+ Boolean result = getOptionAsBoolean(Option.FULL_SCREEN.key);
+ return result != null && result;
}
- public void setCanUseUI(boolean canUseUI) {
- this.canUseUI = canUseUI;
- if (!canUseUI) {
- // on ne pourra pas lancer l'ui principale
- setDisplayMainUI(false);
- }
+ /**
+ * Get support email address.
+ *
+ * @return support email
+ */
+ public String getSupportEmail() {
+ return getOption(Option.SUPPORT_EMAIL.key);
}
- public void setLocale(Locale newLocale) {
- setOption(Option.LOCALE.key, newLocale.toString());
- saveForUser();
- firePropertyChange("locale", null, newLocale);
+ /**
+ * Return true if ejb mode is configured as remote.
+ *
+ * @return {@code true} if remote mode should be used
+ */
+ public boolean isEJBRemoteMode() {
+ boolean result = getOptionAsBoolean(Option.OPENEJB_REMOTEMODE.key);
+ return result;
}
/**
- * Save configuration, in user home directory using the
- * {@link #getConfigFileName}. Default, env and commande line note saved
+ * Used in ????
*/
- public void saveForUser() {
- super.saveForUser();
- }
+ public static final String[] DEFAULT_JAXX_PCS = { "fullScreen", "locale" };
- public static final String[] DEFAULT_JAXX_PCS = {
- "fullScreen", "locale"
- };
-
+ /**
+ * Used in ????
+ */
public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = jaxx.runtime.Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ PropertyChangeListener[] toRemove = jaxx.runtime.JAXXUtil.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
if (toRemove == null || toRemove.length == 0) {
return;
}
@@ -205,17 +229,22 @@
}
}
- //////////////////////////////////////////////////
- // Toutes les options disponibles
- //////////////////////////////////////////////////
+ /**
+ * Lima option definition.
+ *
+ * Contains all lima configuration key, with defaut value and
+ * information for jaxx configuration frame ({@link #type},
+ * {@link #_transient}, {@link #_final}...)
+ */
public static enum Option implements OptionDef {
- CONFIG_FILE(CONFIG_FILE_NAME, _("lima.config.configFileName.description"), "lima-config", String.class, true, true),
- // directories
+ CONFIG_FILE(CONFIG_FILE_NAME, _("lima.config.configFileName.description"), "lima-config.properties", String.class, true, true),
+ LOCALE("locale", _("lima.config.locale.description"), "fr_FR", Locale.class, false, false),
+ FULL_SCREEN("lima.ui.fullscreen", _("lima.config.ui.fullscreen.description"), "false", Boolean.class, false, false),
+ LAUNCH_UI("lima.ui.launchui", _("lima.config.ui.flaunchui.description"), "true", Boolean.class, true, true),
+ SUPPORT_EMAIL("lima.misc.supportemail", _("lima.misc.supportemail.description"), "", String.class, false, false),
+ OPENEJB_REMOTEMODE("lima.openejb.remotemode", _("lima.openejb.remotemode.description"), "false", String.class, false, false);
- LOCALE("locale", _("lima.config.locale.description"), "fr_FR", Locale.class, false, false),
- // ui config
- FULL_SCREEN("ui.fullscreen", _("lima.config.ui.fullscreen"), "false", Boolean.class, false, false);
public final String key;
public final String description;
public final String defaultValue;
@@ -223,7 +252,8 @@
public final boolean _transient;
public final boolean _final;
- private Option(String key, String description, String defaultValue, Class<?> type, boolean _transient, boolean _final) {
+ private Option(String key, String description, String defaultValue,
+ Class<?> type, boolean _transient, boolean _final) {
this.key = key;
this.description = description;
this.defaultValue = defaultValue;
@@ -262,14 +292,19 @@
return type;
}
}
-
- public static final int AFTER_INIT_STEP = 0;
- public static final int BEFORE_EXIT_STEP = 1;
+ /**
+ * Lima action definition.
+ */
public static enum Action {
- HELP(_("lima.action.commandline.help"), LimaAction.class.getName() + "#help", "-h", "--help"),
- NO_MAIN_UI(_("lima.action.commandline.disable.main.ui"), LimaAction.class.getName() + "#disableMainUI", "-n", "--no-main");
+ HELP(_("lima.action.commandline.help"), MiscAction.class.getName() + "#help", "-h", "--help");
+
+ /** Before init action step. */
+ public static final int BEFORE_EXIT_STEP = 0;
+ /** After init action step. */
+ public static final int AFTER_INIT_STEP = 1;
+
public String description;
public String action;
public String[] aliases;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,33 +1,29 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
package org.chorem.lima;
-import jaxx.runtime.Util;
+import jaxx.runtime.JAXXUtil;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.service.ServiceFactory;
import org.chorem.lima.ui.MainView;
import org.chorem.lima.ui.MainViewHandler;
-import org.chorem.lima.ui.MainViewImpl;
import org.nuiton.i18n.I18n;
import java.util.Locale;
@@ -41,13 +37,15 @@
* to use log facility, just put in your code: log.info(\"...\");
*/
static private Log log = LogFactory.getLog(LimaContext.class);
+
/**
* l'intance partagée accessible après un appel à la méthode
* {@link #init()}
*/
protected static LimaContext instance;
- public static JAXXContextEntryDef<MainView> MAIN_UI_ENTRY_DEF = Util.newContextEntryDef("mainUI", MainView.class);
+ public static JAXXContextEntryDef<MainView> MAIN_UI_ENTRY_DEF = JAXXUtil.newContextEntryDef("mainUI", MainView.class);
+
/**
* @return <code>true</code> si le context a été initialisé via la méthode
* {@link #init()}, <ocde>false</code> autrement.
@@ -90,16 +88,6 @@
return instance;
}
- /**
- * neogia factory
- */
- protected ServiceFactory neogiaFactory;
-
- /**
- * Data manager*
- */
- protected DataManager dataManager;
-
public LimaConfig getConfig() {
return getContextValue(LimaConfig.class);
}
@@ -108,29 +96,14 @@
Locale locale = getConfig().getLocale();
I18n.init(locale);
- /** Default Locale for DatePicker **/
+ // Default Locale for DatePicker
Locale.setDefault(locale);
- DTOHelper.setLocale(locale);
}
- public ServiceFactory getNeogiaFactory() {
- if (neogiaFactory == null) {
- neogiaFactory = ServiceFactory.getServiceFactory();
- }
- return neogiaFactory;
+ public MainView getMainUI() {
+ return (MainView) MAIN_UI_ENTRY_DEF.getContextValue(this);
}
- public MainViewImpl getMainUI() {
- return (MainViewImpl) MAIN_UI_ENTRY_DEF.getContextValue(this);
- }
-
- public DataManager getDataManager() {
- if (dataManager == null) {
- dataManager = new DataManager();
- }
- return dataManager;
- }
-
/**
* close the application's context.
*
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/Main.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -0,0 +1,272 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+import java.util.Locale;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import jaxx.runtime.SwingUtil;
+
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.beanutils.Converter;
+import org.apache.commons.beanutils.converters.DateConverter;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.MainView;
+import org.chorem.lima.ui.MainViewHandler;
+import org.chorem.lima.util.ErrorHelper;
+import org.nuiton.i18n.I18n;
+import org.nuiton.util.ConverterUtil;
+import org.nuiton.util.StringUtil;
+
+/**
+ * Lima main.
+ *
+ * @author ore
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class LimaMain {
+
+ /** Log. */
+ private static final Log log = LogFactory.getLog(LimaMain.class);
+
+ /** Lima configuration. */
+ public static LimaConfig config;
+
+ /**
+ * Lima main method.
+ *
+ * @param args program args
+ */
+ public static void main(String[] args) {
+
+ if (log.isInfoEnabled()) {
+ log.info("Lima start at " + new java.util.Date());
+ log.info("Args: " + java.util.Arrays.toString(args));
+ }
+
+ try {
+ // init root context
+ final LimaContext context = init(args);
+
+ // do actions
+ config = context.getContextValue(LimaConfig.class);
+ config.doAction(LimaConfig.Action.AFTER_INIT_STEP);
+
+ // display main ui
+ if (config.isLaunchui()) {
+ launch(context);
+ }
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error(_("Global lima exception"), ex);
+ }
+ ErrorHelper.showErrorDialog(_("Global lima exception"), ex);
+ System.exit(1);
+ }
+ }
+
+ /**
+ * initialisation de l'application :
+ * <p/>
+ * chargement du context
+ *
+ * @param args les arguments passes a l'application
+ * @return le context de l'application
+ * @throws Exception pour toute erreur pendant l'init
+ */
+ public static synchronized LimaContext init(String... args) throws Exception {
+
+ // to enable javassist on webstart, must remove any securityManager,
+ // see if this can be dangerous (should not be since jnlp is signed ?)
+ // moreover it speeds up the loading :)
+ System.setSecurityManager(null);
+
+ // init i18n
+ long t0 = System.nanoTime();
+
+ // FIXME cause NPE
+ // I18n.setInitializer(new DefaultI18nInitializer("lima-swing-i18n"));
+
+ I18n.init(Locale.FRANCE);
+ if (log.isDebugEnabled()) {
+ log.debug("i18n loading time : " + (StringUtil.convertTime(t0, System.nanoTime())));
+ }
+
+ Runtime.getRuntime().addShutdownHook(new ShutdownHook());
+
+ // init root context
+ LimaContext context = LimaContext.init();
+ LimaConfig config = context.getContextValue(LimaConfig.class);
+ config.parse(args);
+
+ context.initI18n();
+
+ // prepare ui look&feel and load ui properties
+ try {
+ SwingUtil.initNimbusLoookAndFeel();
+ } catch (Exception e) {
+ // could not find nimbus look-and-feel
+ if (log.isWarnEnabled()) {
+ log.warn(_("lima.warning.nimbus.landf"));
+ }
+ }
+
+ // init date converter
+ Converter converter = ConverterUtil.getConverter(java.util.Date.class);
+ if (converter != null) {
+ ConvertUtils.deregister(java.util.Date.class);
+ DateConverter dateConverter = new DateConverter();
+ dateConverter.setUseLocaleFormat(true);
+ ConvertUtils.register(dateConverter, java.util.Date.class);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Context init done in " + (StringUtil.convertTime(t0, System.nanoTime())));
+ }
+ return context;
+ }
+
+ protected static void launch(LimaContext context) throws Exception {
+
+ // update splash
+ LimaSplash splash = new LimaSplash();
+ splash.initSplash(config.getVersion());
+
+ // do init ui
+ MainViewHandler uiHandler = context.getContextValue(MainViewHandler.class);
+ final MainView ui = uiHandler.initUI(context, context.getConfig().isFullScreen());
+ ui.setLocationRelativeTo(null);
+
+ // defaut display home view (not closeable, but might be !)
+ uiHandler.showHomeView(context);
+
+ // put services into context (or not...)
+ //context.setContextValue(LimaServiceFactory.getInstance().getAccountService());
+ //context.setContextValue(LimaServiceFactory.getInstance().getAccountService());
+
+ // TODO EC-20100409 load accounts and test if there is an account plan defined
+ // if not, call #loadDefaultAccount()
+ splash.updateProgression(0.5, _("Loading accounting..."));
+ AccountService accountService = LimaServiceFactory.getInstance().getAccountService();
+ List<Account> account = accountService.getChildrenAccounts(null);
+ if (CollectionUtils.isEmpty(account)) {
+ if (log.isInfoEnabled()) {
+ log.info("TODO : Propose for defaut account loading");
+ }
+ }
+
+ /*try {
+ if (log.isInfoEnabled()) {
+ log.info("Loading lima data...");
+ }
+ loadData(context);
+ }
+ catch (Exception eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Error durring data loading", eee);
+ }
+ }*/
+
+ // show ui
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ ui.setVisible(true);
+ }
+ });
+ }
+
+ public static class ShutdownHook extends Thread {
+
+ public ShutdownHook() {
+ super("Shutdown Lima");
+ }
+
+ @Override
+ public void run() {
+ try {
+ super.run();
+
+ LimaContext.get().close();
+ LimaServiceFactory.getInstance().destroy();
+ // force to kill main thread
+
+ if (log.isInfoEnabled()) {
+ log.info(_("lima.init.closed", new java.util.Date()));
+ }
+ Runtime.getRuntime().halt(0);
+ } catch (Exception ex) {
+ if (log.isErrorEnabled()) {
+ log.error(_("lima.init.errorclosing"), ex);
+ }
+ Runtime.getRuntime().halt(1);
+ }
+ }
+ }
+
+ /**
+ * This method ask for user to load a default account plan.
+ *
+ * @param accountRoot database accounts
+ */
+ public static void loadDefaultAccount(Account accountRoot) {
+ if (log.isDebugEnabled()) {
+ log.debug("Account root : " + accountRoot);
+ }
+ if (accountRoot.getSubAccounts().isEmpty()) {
+ if (log.isDebugEnabled()) {
+ log.debug("No existing accounts");
+ }
+
+ String[] response = {_("lima.response.yes"), _("lima.response.no")};
+ int n = JOptionPane.showOptionDialog(null,
+ _("lima.question.load.accounts"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ null, //do not use a custom Icon
+ response, //the titles of buttons
+ response[1]); //default button title
+ if (n == JOptionPane.YES_OPTION) {
+ /*XMLImport imports = new XMLImport();
+ URL urlFile = LimaMain.class.getResource("/import/default_pcg.xml");
+ try {
+ imports.importAccount(urlFile.openStream());
+ } catch (IOException eee) {
+ log.error("Erreur chargement du fichier 'default_pcg.xml'", eee);
+ }*/
+ } else {
+ //LimaContext.getContext().getDataManager().resetAccountModel();
+ }
+ }
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,3 +1,21 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
package org.chorem.lima;
import java.awt.AlphaComposite;
@@ -7,7 +25,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.service.util.ProgressListener;
/**
* Utility class used to manage information on slash screen.
@@ -25,7 +42,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class LimaSplash implements ProgressListener {
+public class LimaSplash {
/** Log. */
static private Log log = LogFactory.getLog(LimaSplash.class);
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/Main.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/Main.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/Main.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,286 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-package org.chorem.lima;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.chorem.lima.ui.MainView;
-import org.chorem.lima.ui.MainViewHandler;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.imports.XMLImport;
-import org.chorem.lima.service.ServiceFactory;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Locale;
-
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.ErrorDialogUI;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.beanutils.Converter;
-import org.apache.commons.beanutils.converters.DateConverter;
-import org.chorem.lima.tree.model.AccountTreeTableModel;
-import org.nuiton.i18n.I18n;
-import org.nuiton.i18n.init.DefaultI18nInitializer;
-import org.nuiton.util.ConverterUtil;
-import org.nuiton.util.StringUtil;
-
-/**
- * @author ore
- */
-public class Main {
-
- private static final Log log = LogFactory.getLog(Main.class);
-
- /**
- * @param args les arguments passes au programme
- */
- public static void main(String[] args) {
-
- long startingTime = System.nanoTime();
- log.info("Lima start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
-
- try {
-
- // init root context
- final LimaContext context = init(args);
-
- log.info(_("lima.init.context.done", StringUtil.convertTime(startingTime, System.nanoTime())));
-
- LimaConfig config = context.getContextValue(LimaConfig.class);
-
- config.doAction(LimaConfig.AFTER_INIT_STEP);
-
- if (config.isDisplayMainUI()) {
- // on affiche l'ui principale
-
- launch(context);
- }
- } catch (Exception e) {
- ErrorDialogUI.showError(e);
- log.error(e.getMessage(), e);
- System.exit(1);
- }
- }
-
- /**
- * initialisation de l'application :
- * <p/>
- * chargement du context
- *
- * @param args les arguments passes a l'application
- * @return le context de l'application
- * @throws Exception pour toute erreur pendant l'init
- */
- public static synchronized LimaContext init(String... args) throws Exception {
-
- // to enable javassist on webstart, must remove any securityManager,
- // see if this can be dangerous (should not be since jnlp is signed ?)
- // moreover it speeds up the loading :)
- System.setSecurityManager(null);
-
- long t0 = System.nanoTime();
-
- I18n.setInitializer(new DefaultI18nInitializer("lima-main-i18n"));
-
- I18n.init(Locale.FRANCE);
-
- if (log.isDebugEnabled()) {
- log.debug("i18n loading time : " + (StringUtil.convertTime(t0, System.nanoTime())));
- }
-
- Runtime.getRuntime().addShutdownHook(new ShutdownHook());
-
- // init root context
- LimaContext context = LimaContext.init();
-
- LimaConfig config = context.getContextValue(LimaConfig.class);
-
- config.parse(args);
-
- context.initI18n();
-
- // prepare ui look&feel and load ui properties
- try {
- SwingUtil.initNimbusLoookAndFeel();
- } catch (Exception e) {
- // could not find nimbus look-and-feel
- log.warn(_("lima.warning.nimbus.landf"));
- } catch (Throwable e) {
- log.warn(_("lima.warning.no.ui"));
- // pas d'environnement d'ui
- config.setCanUseUI(false);
- }
-
- // init date converter
- Converter converter = ConverterUtil.getConverter(java.util.Date.class);
- if (converter != null) {
- ConvertUtils.deregister(java.util.Date.class);
-
- DateConverter dateConverter = new DateConverter();
- dateConverter.setUseLocaleFormat(true);
- ConvertUtils.register(dateConverter, java.util.Date.class);
- }
-
-// if (config.isCanUseUI()) {
-// // chargement de la configuration des uis
-// SwingUtil.loadUIConfig(LimaConfig.APPLICATION_PROPERTIES, null);
-// }
-
- ServiceFactory.init(null);
-
- if (log.isDebugEnabled()) {
- log.debug("init done in " + (StringUtil.convertTime(t0, System.nanoTime())));
- }
- return context;
- }
-
- public static void launch(LimaContext context) throws Exception {
-
- MainViewHandler uiHandler = context.getContextValue(MainViewHandler.class);
-
- // do init ui
- final MainView ui = uiHandler.initUI(context, context.getConfig().isFullScreen());
-
- if (log.isInfoEnabled()) {
- log.info(_("lima.init.ui.done"));
- }
-
- try {
- if (log.isInfoEnabled()) {
- log.info("Loading lima data...");
- }
- loadData(context);
- }
- catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error("Error durring data loading", eee);
- }
- }
-
- // show ui
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- ui.setVisible(true);
- }
- });
- }
-
- /**
- * Load datas and update progression into splash screen.
- *
- * @param context application context
- */
- protected static void loadData(LimaContext context) {
- LimaSplash splash = new LimaSplash();
- splash.initSplash(context.getConfig().getVersion());
-
- // Chargement des journaux
- splash.updateProgression(0.05, _("lima.progressBar.load.etape1"));
- DataManager dataManager = context.getDataManager();
- dataManager.getJournalModel();
-
- // Chargement des comptes
- splash.updateProgression(0.30, _("lima.progressBar.load.etape2"));
- AccountTreeTableModel accountModel = dataManager.getAccountModel();
- loadDefaultAccount(accountModel.getData());
-
- // Chargement des status
- splash.updateProgression(0.50, _("lima.progressBar.load.etape3"));
- dataManager.getStatus();
-
- // Chargement des periodes
- splash.updateProgression(0.60, _("lima.progressBar.load.etape4"));
- dataManager.getPeriodes();
-
- // Chargement des transactions
- splash.updateProgression(0.70, _("lima.progressBar.load.etape5"));
- dataManager.getTransactionModel(splash);
-
- // TODO needed or closed by UI ?
- // splash.closeSplash();
- }
-
- public static class ShutdownHook extends Thread {
-
- public ShutdownHook() {
- super("shutdown lima");
- }
-
- @Override
- public void run() {
- try {
- super.run();
-
- LimaContext.get().close();
- // force to kill main thread
-
- log.info(_("lima.init.closed", new java.util.Date()));
- Runtime.getRuntime().halt(0);
- } catch (Exception ex) {
- log.error("error while closing " + ex.getMessage(), ex);
- Runtime.getRuntime().halt(1);
- }
- }
- }
-
- /**
- * This method ask for user to laod a default account plan.
- *
- * @param accountRoot database accounts
- */
- public static void loadDefaultAccount(AccountDTO accountRoot) {
- if (log.isDebugEnabled()) {
- log.debug("Account root : " + accountRoot);
- }
- if (accountRoot.getChildren().isEmpty()) {
- if (log.isDebugEnabled()) {
- log.debug("No existing accounts");
- }
-
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(null,
- _("lima.question.load.accounts"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- XMLImport imports = new XMLImport();
- URL urlFile = Main.class.getResource("/import/default_pcg.xml");
- try {
- imports.importAccount(urlFile.openStream());
- } catch (IOException eee) {
- log.error("Erreur chargement du fichier 'default_pcg.xml'", eee);
- }
- } else {
- LimaContext.getContext().getDataManager().resetAccountModel();
- }
- }
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/LimaAction.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -0,0 +1,56 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.actions;
+
+import static org.nuiton.i18n.I18n._;
+
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.LimaMain;
+
+/**
+ * Les actions appellables via {@link LimaMain}.
+ *
+ * @author tony
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MiscAction {
+
+ /** La configuration de l'application. */
+ protected LimaConfig config;
+
+ public MiscAction(LimaConfig config) {
+ this.config = config;
+ }
+
+ public void help() {
+ System.out.println(_("lima.message.help.usage"));
+ System.out.println("Options (set with --option <key> <value>:");
+ for (LimaConfig.Option o : LimaConfig.Option.values()) {
+ System.out.println("\t" + o.key + "(" + o.defaultValue + "):" + o.description);
+ }
+
+ System.out.println("Actions:");
+ for (LimaConfig.Action a : LimaConfig.Action.values()) {
+ System.out.println("\t" + java.util.Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description);
+ }
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -0,0 +1,160 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.util;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.Component;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.MultiPartEmail;
+import org.chorem.lima.LimaMain;
+import org.jdesktop.swingx.JXErrorPane;
+import org.jdesktop.swingx.error.ErrorInfo;
+import org.jdesktop.swingx.error.ErrorReporter;
+
+/**
+ * Error helper.
+ *
+ * Used to easily switch real exception interface. Currently used : swingx.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ErrorHelper implements ErrorReporter {
+
+ /** Log. */
+ private static final Log log = LogFactory.getLog(ErrorHelper.class);
+
+ /**
+ * Display a user friendly error frame.
+ *
+ * @param parent parent component
+ * @param message message for user
+ * @param cause exception cause
+ */
+ public static void showErrorDialog(Component parent, String message,
+ Throwable cause) {
+ JXErrorPane pane = new JXErrorPane();
+ ErrorInfo info = new ErrorInfo(_("lima.error.errorpane.title"),
+ _("lima.error.errorpane.htmlmessage", message), null, null,
+ cause, null, null);
+ pane.setErrorInfo(info);
+ pane.setErrorReporter(new ErrorHelper());
+ JXErrorPane.showDialog(parent, pane);
+ }
+
+ /**
+ * Display a user friendly error frame.
+ *
+ * @param message message for user
+ */
+ public static void showErrorDialog(String message) {
+ showErrorDialog(message, null);
+ }
+
+ /**
+ * Display a user friendly error frame.
+ *
+ * @param message message for user
+ * @param cause exception cause
+ */
+ public static void showErrorDialog(String message, Throwable cause) {
+ showErrorDialog(null, message, cause);
+ }
+
+ /*
+ * @see org.jdesktop.swingx.error.ErrorReporter#reportError(org.jdesktop.swingx.error.ErrorInfo)
+ */
+ @Override
+ public void reportError(ErrorInfo errorInfo) throws NullPointerException {
+
+ try {
+ String emailTo = LimaMain.config.getSupportEmail();
+
+ MultiPartEmail email = new MultiPartEmail();
+ // smtp
+ email.setHostName("smtp");
+ // to
+ email.addTo(emailTo, "Support");
+ // from
+ email.setFrom("no-reply(a)nuiton.org", "Lima");
+ // subject
+ email.setSubject("Project error notification : Lima");
+
+ // message description
+ String message = formatMessage("Project", "Lima " + LimaMain.config.getVersion());
+ message += formatMessage("Date", new Date().toString());
+ message += formatMessage("Title", errorInfo.getTitle());
+ message += formatMessage("Description", errorInfo.getBasicErrorMessage().replaceAll("<[^>]+>", ""));
+
+ // message configuration
+ message += formatMessage("Configuration", null);
+ List<String> propertiesNames = new ArrayList<String>(LimaMain.config.getOptions().stringPropertyNames());
+ Collections.sort(propertiesNames);
+ for (String propertyName : propertiesNames) {
+ // security, don't send string containing password :
+ if (!propertyName.contains("pass")) {
+ message += "\t" + propertyName + " : " + LimaMain.config.getOptions().getProperty(propertyName) + "\n";
+ }
+ }
+
+ // message exception
+ StringWriter out = new StringWriter();
+ PrintWriter writer = new PrintWriter(out);
+ errorInfo.getErrorException().printStackTrace(writer);
+ message += formatMessage("Exception", out.toString());
+
+ // TODO EC-20100409 i18n files are iso encoded ?
+ email.setContent(message, "text/plain; charset=ISO-8859-9");
+
+ // send mail
+ email.send();
+
+ JOptionPane.showMessageDialog(null, "A report message has been sent to " + emailTo);
+ } catch (EmailException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't send report email" ,ex);
+ }
+ }
+ }
+
+ protected String formatMessage(String category, String content) {
+ String formatted = category + " :\n";
+ if (StringUtils.isNotEmpty(content)) {
+ formatted += "\t" + content + "\n";
+ }
+ return formatted;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java 2010-04-09 16:19:40 UTC (rev 2850)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ServiceHelper.java 2010-04-09 16:21:50 UTC (rev 2851)
@@ -1,354 +0,0 @@
-/**
- * *##% Lima service
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * @author chemit
- * @author Rémi Chapelet
- */
-public class ServiceHelper {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ServiceHelper.class);
- /**
- * Transaction status type
- */
- public static final String TR_FINALIZED = "TR_FINALIZED";
- public static final String TR_BALANCED = "TR_BALANCED";
- public static final String TR_WIP = "TR_WIP";
- /**
- * Period status type
- */
- public static final String PE_OPEN = "PE_OPEN";
- public static final String PE_CLOSETMP = "PE_CLOSETMP";
- public static final String PE_CLOSE = "PE_CLOSE";
- /**
- * Responses
- */
- public static final String RESPOND_SUCCESS = "success";
- public static final String RESPOND_ERROR = "error";
-
- /**
- * Account Error
- */
- public static final String ACCOUNT_DOUBLE = "account_double";
- public static final String ACCOUNT_NOT_MASTER = "account_not_master";
- public static final String ACCOUNT_NOT_EXIST = "account_not_exist";
- public static final String ACCOUNT_WITH_ENTRIES = "account_with_entries";
-
- /**
- * Entries Error
- */
- public static final String ENTRY_NOT_EXIST = "entry_not_exist";
-
- /**
- * Journal
- */
- public static final String JOURNAL_DOUBLE = "journal_double";
- public static final String JOURNAL_NOT_EXIST = "journal_not_exist";
- public static final String JOURNAL_WITH_TRANSACTIONS = "journal_with_transactions";
-
- /**
- * Period
- */
- public static final String PERIOD_CREATE_TIMESPANS = "period_create_timespan";
- public static final String PERIOD_TIMESPAN_NOT_BLOCK = "period_timespan_not_block";
- public static final String PERIOD_TIMESPAN_BLOCK = "period_timespan_block";
- public static final String PERIOD_ALL_TIMESPAN = "period_all_timespan";
- public static final String PERIOD_NOT_EXIST = "period_not_exist";
-
- public static final String PERIOD_PREC_NOT_BLOCK = "period_prec_not_block";
- public static final String PERIOD_NEXT_NOT_BLOCK = "period_next_not_block";
-
- /**
- * Transaction
- */
- public static final String TRANSACTION_NOT_JOURNAL = "transaction_not_journal";
- public static final String TRANSACTION_NOT_TIMESPAN = "transaction_not_timespan";
- public static final String TRANSACTION_TIMESPAN_BLOCKED = "transaction_timespan_blocked";
- public static final String TRANSACTION_NOT_EXIST = "transaction_not_exist";
- public static final String TRANSACTION_NOT_BALANCED = "transaction_not_balanced";
-
- protected ServiceHelper() {
- // no instance
- }
-
- /**
- * TODO
- *
- * @param accounts TODO
- * @return TODO
- */
- public static List<Account> getAllFlatAccount(Account accounts) {
- List<Account> flatList = new LinkedList<Account>();
- concatListAccount(flatList, accounts.getChildren());
- return flatList;
- }
-
- /**
- * TODO
- *
- * @param res TODO
- * @param add TODO
- */
- private static void concatListAccount(List<Account> res, List<Account> add) {
- res.addAll(add);
- for (Account acc : add) {
- if (acc.getChildren() != null) {
- concatListAccount(res, acc.getChildren());
- }
- }
- }
-
- /**
- * TODO
- *
- * @param periods TODO
- * @return TODO
- */
- public static List<PeriodDTO> getAllFlatPeriod(List<PeriodDTO> periods) {
- List<PeriodDTO> flatList = new LinkedList<PeriodDTO>();
- for (PeriodDTO period : periods) {
- flatList.add(period);
- flatList.addAll(period.getChildren());
- }
- return flatList;
- }
-
- /**
- * @param date
- * @return
- */
- public static String dateToMonth(Date date) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- switch (cal.get(Calendar.MONTH)) {
- case Calendar.JANUARY:
- return _("lima.date.january");
- case Calendar.FEBRUARY:
- return _("lima.date.february");
- case Calendar.MARCH:
- return _("lima.date.march");
- case Calendar.APRIL:
- return _("lima.date.april");
- case Calendar.MAY:
- return _("lima.date.may");
- case Calendar.JUNE:
- return _("lima.date.june");
- case Calendar.JULY:
- return _("lima.date.july");
- case Calendar.AUGUST:
- return _("lima.date.august");
- case Calendar.SEPTEMBER:
- return _("lima.date.september");
- case Calendar.OCTOBER:
- return _("lima.date.october");
- case Calendar.NOVEMBER:
- return _("lima.date.november");
- case Calendar.DECEMBER:
- return _("lima.date.december");
- }
- return null;
- }
- /**
- * @param date the date to inspect
- * @return the year of the given date
- */
- public static String dateToYear(Date date) {
- Calendar cal = Calendar.getInstance();
- cal.setTime(date);
- return "" + cal.get(Calendar.YEAR);
- }
-
- /**
- * @param trans
- * @return
- */
- public static boolean isEditable(TransactionDTO trans) {
- String finalizedKey = ServiceHelper.PE_CLOSE;
- return !trans.getPeriod().getStatus().getIdType().equals(finalizedKey);
- }
-
- /**
- * @param entry
- * @return
- */
- public static boolean isEditable(EntryDTO entry) {
- return isEditable(entry.getTransaction());
- }
-
- public static StatusDTO findStatusByType(List<StatusDTO> list, String id) {
- if (id == null || list == null) {
- return null;
- }
- for (StatusDTO status : list) {
- if (id.equals(status.getIdType())) {
- return status;
- }
- }
- log.warn("Status " + id + " couldn't be found.");
- return null;
- }
-
- public static JournalDTO findJournalById(List<JournalDTO> list, String id) {
- if (id == null || list == null) {
- return null;
- }
- for (JournalDTO journal : list) {
- if (id.equalsIgnoreCase(journal.getIdName()) || id.equalsIgnoreCase(journal.getPrefix()) || id.equals(journal.getIdSeq())) {
- return journal;
- }
- }
- log.warn("Journal " + id + " couldn't be found.");
- return null;
- }
-
- public static StatusDTO findStatusById(List<StatusDTO> list, String id) {
- if (id == null || list == null) {
- return null;
- }
- for (StatusDTO Status : list) {
- if (id.equals(Status.getIdName())) {
- return Status;
- }
- }
- log.warn("Status " + id + " couldn't be found.");
- return null;
- }
-
- public static AccountDTO findAccountById(List<AccountDTO> list, String id) {
- if (id == null || list == null) {
- return null;
- }
- for (AccountDTO account : list) {
- if (id.equals(account.getIdNumber())) {
- return account;
- }
- }
- log.warn("Account " + id + " couldn't be found.");
- return null;
- }
-
- public static PeriodDTO findPeriodById(List<PeriodDTO> list, String id) {
- if (id == null || list == null) {
- return null;
- }
- for (PeriodDTO period : list) {
- if (id.equals(period.getIdSeq())) {
- return period;
- }
- }
- log.warn("Period " + id + " couldn't be found.");
- return null;
- }
-
- public static PeriodDTO findPeriodByDate(List<PeriodDTO> list, Date d) {
- if (d == null || list == null) {
- return null;
- }
- PeriodDTO periodSearch = null;
- for (PeriodDTO period : list) {
- if ( betweenDate(d,period.getBegin(),period.getEnd()) ) {
- periodSearch = period;
- }
- }
- if ( periodSearch == null)
- {
- log.warn("Period with this date " + d + " couldn't be found.");
- }
- return periodSearch;
- }
-
- /**
- * Permet de rechercher toutes les transactions appartenant à une période
- * donnée.
- * @param period
- * @param listTransactions
- * @return
- */
- public static List<TransactionDTO> findTransactionByPeriod(PeriodDTO period,List<TransactionDTO> listTransactions)
- {
- if (period == null || listTransactions == null) {
- return null;
- }
- List<TransactionDTO> ListTransactionSearch = new LinkedList<TransactionDTO>();
- // Si période annuelle
- if ( period.getParent() == null )
- {
- for (TransactionDTO transaction : listTransactions)
- {
- if ( transaction.getPeriod().getParent().equals(period) )
- {
- ListTransactionSearch.add(transaction);
- }
- }
- } else {
- // Si période mensuelle
- for (TransactionDTO transaction : listTransactions)
- {
- if ( transaction.getPeriod().equals(period) )
- {
- ListTransactionSearch.add(transaction);
- }
- }
- }
- return ListTransactionSearch;
- }
-
- /**
- * Permet de renvoyer vrai si une date d donnée est entre deux dates.
- * @param d date se trouvant ou non dans la période
- * @param dateBegin date de début de période
- * @param dateEnd date de fin de période
- * @return
- */
- public static boolean betweenDate (Date d, Date dateBegin, Date dateEnd)
- {
- boolean result = false;
- if ( ( (compareDate(d,dateBegin) == 0) || (compareDate(d,dateBegin) == 1) )
- && ( (compareDate(d,dateEnd) == 0) || (compareDate(d,dateEnd) == -1) ) )
- {
- result = true;
- }
- return result;
- }
-
- /**
- * Implémentation de compareTO. Si il y a besoin, il est possible de la modifier.
- * @param d1
- * @param d2
- * @return
- */
- public static int compareDate(Date d1, Date d2)
- {
- return d1.compareTo(d2);
- }
-}
1
0
r2850 - trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:19:40 +0200 (Fri, 09 Apr 2010)
New Revision: 2850
Log:
Move class
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java 2010-04-09 16:19:17 UTC (rev 2849)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java 2010-04-09 16:19:40 UTC (rev 2850)
@@ -1,91 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.combobox.model;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.dto.AccountDTO;
-
-import javax.swing.*;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class AccountComboBoxModel extends DefaultComboBoxModel implements PropertyChangeListener {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(AccountComboBoxModel.class);
-
- /**
- * @param v
- */
- public AccountComboBoxModel(Vector<?> v) {
- super(v);
- }
-
- /**
- * @param items
- */
- public AccountComboBoxModel(Object[] items) {
- super(items);
- }
-
- /**
- * @param evt
- */
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- if (evt.getPropertyName().equals("add")) {
- addElement(evt.getNewValue());
- if (log.isDebugEnabled()) {
- log.debug("add : ");
- }
- }
- if (evt.getPropertyName().equals("update")) {
- int index = getIndexOf(evt.getNewValue());
- fireContentsChanged(evt.getNewValue(), index, index);
- if (log.isDebugEnabled()) {
- log.debug("update : ");
- }
- }
- if (evt.getPropertyName().equals("remove")) {
- removeChildren((AccountDTO) evt.getOldValue());
- removeElement(evt.getOldValue());
- if (log.isDebugEnabled()) {
- log.debug("remove : ");
- }
- }
- }
-
- /**
- * @param parent
- */
- public void removeChildren(AccountDTO parent) {
- for (AccountDTO acc : parent.getChildren()) {
- removeElement(acc);
- removeChildren(acc);
- }
- }
-}
1
0
Author: echatellier
Date: 2010-04-09 18:19:17 +0200 (Fri, 09 Apr 2010)
New Revision: 2849
Log:
Rename lima.properties (must be corrected , conflict with business one)
Added:
trunk/lima-swing/src/main/resources/lima-config.properties
Removed:
trunk/lima-swing/src/main/resources/lima.properties
Copied: trunk/lima-swing/src/main/resources/lima-config.properties (from rev 2802, trunk/lima-swing/src/main/resources/lima.properties)
===================================================================
--- trunk/lima-swing/src/main/resources/lima-config.properties (rev 0)
+++ trunk/lima-swing/src/main/resources/lima-config.properties 2010-04-09 16:19:17 UTC (rev 2849)
@@ -0,0 +1,26 @@
+application.name=${project.name}
+application.version=${project.version}
+application.site.url=http://maven-site.chorem.org/lima/
+
+#licence.name=${project.licenses[0].license.name}
+#licence.url=${project.licenses.0.url}
+application.organisation.name=${project.organization.name}
+application.organisation.url=${project.organization.url}
+
+lima.misc.supportemail=support(a)codelutin.com
+
+
+########################
+# Open EJB Configuration
+########################
+
+# Embedded mode
+lima.openejb.remotemode=false
+java.naming.factory.initial=org.openejb.client.LocalInitialContextFactory
+
+# Remote mode
+#lima.openejb.remotemode=true
+#java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
+#java.naming.provider.url=ejbd://127.0.0.1:4201
+#java.naming.security.principal=jonathan
+#java.naming.security.credentials=secret
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/resources/lima.properties
===================================================================
--- trunk/lima-swing/src/main/resources/lima.properties 2010-04-09 16:18:10 UTC (rev 2848)
+++ trunk/lima-swing/src/main/resources/lima.properties 2010-04-09 16:19:17 UTC (rev 2849)
@@ -1,11 +0,0 @@
-application.name=${project.name}
-application.version=${project.version}
-
-# le lien suivant pointe sur le module qui n'a pas de site associ�
-#application.site.url=${project.url}
-application.site.url=http://maven-site.chorem.org/lima/
-
-#licence.name=${project.licenses[0].license.name}
-#licence.url=${project.licenses.0.url}
-application.organisation.name=${project.organization.name}
-application.organisation.url=${project.organization.url}
1
0
Author: echatellier
Date: 2010-04-09 18:18:10 +0200 (Fri, 09 Apr 2010)
New Revision: 2848
Log:
Reformat log4j.properties
Modified:
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2010-04-09 16:17:30 UTC (rev 2847)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2010-04-09 16:18:10 UTC (rev 2848)
@@ -1,17 +1,16 @@
# Global logging configuration
log4j.rootLogger=ERROR, stdout, file
-# Console output...
+
+# Console output
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+#�File ouptut
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.file=lima.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-#log4j.appender.stdout.layout.ConversionPattern=%%c=%c %%C=%C %%d=%d %%F=%F %%l=%l %%L=%L %%m=%m %%M=%M %%p=%p %%r=%r %%t=%t %%x=%x %%X=%X
# package level
-log4j.logger.org.chorem.lima=DEBUG
-#log4j.logger.org.codelutin.jaxx.action=DEBUG
-#log4j.logger.org.codelutin.jaxx=DEBUG
-#log4j.logger.org.codelutin=INFO
+log4j.logger.org.chorem.lima=INFO
\ No newline at end of file
1
0
r2847 - trunk/lima-swing/src/main/java/org/chorem/lima/ui
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:17:30 +0200 (Fri, 09 Apr 2010)
New Revision: 2847
Log:
Modification of mainview (remove impl)
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-09 16:17:30 UTC (rev 2847)
@@ -14,7 +14,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
-<JFrame abstract='true' title="lima.title" onWindowClosing="getHandler().close(this)"
+<JFrame title="lima.title" onWindowClosing="getHandler().close(this)"
defaultCloseOperation="do_nothing_on_close"
undecorated='{getConfig().isFullScreen()}'
resizable="true" width="800" height="600"
@@ -36,42 +36,62 @@
return l != null && l.toString().equals(expected);
}
-protected abstract void onChangeView();
-protected abstract void showHomeView();
-protected abstract void showAccountView();
-protected abstract void showAddPeriod();
-protected abstract void showBalanceView();
-protected abstract void showBilanView();
-protected abstract void showClosurePeriodView();
-protected abstract void showClosureTimeSpanView();
-protected abstract void showClosureView();
-protected abstract void showExportView(String type);
-protected abstract void showImportView(String type);
-protected abstract void showJournalView();
-protected abstract void showLetteringView();
-protected abstract void showReportsView();
-protected abstract void showResultView();
-protected abstract void showSearchView();
-protected abstract void showTransactionView();
- ]]>
+/**
+ * Show a new closable tab.
+ *
+ * @param name name of tab to show
+ * @param container the tab container
+ * @param canClose {@code false} if tab can't be closed
+ */
+protected void showTab(String name, Component container, boolean canClose) {
+ // if contentTabbedPane doesnot yet contains tab
+ if (contentTabbedPane.indexOfTab(name) == -1) {
+ ClosableTabHeader closableHeader = new ClosableTabHeader();
+ closableHeader.setTitle(name);
+ closableHeader.setCanClose(canClose);
+ contentTabbedPane.addTab(name, container);
+ contentTabbedPane.setSelectedComponent(container);
+ contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
+ closableHeader.getCloseTab().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ JButton button = (JButton) e.getSource();
+ ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent();
+ String name = closableTab.getTitle();
+ contentTabbedPane.remove(contentTabbedPane.indexOfTab(name));
+ }
+ });
+ }
+}
+
+/**
+ * Show a new closable tab.
+ *
+ * @param name name of tab to show
+ * @param container the tab container
+ */
+protected void showTab(String name, Component container) {
+ showTab(name, container, true);
+}
+ ]]>
</script>
<JMenuBar>
<JMenu text="lima.menu.file">
<JMenu text="lima.import" actionIcon='import-element'>
- <JMenuItem text="lima.import.all" onActionPerformed='showImportView("all")'/>
- <JMenuItem text="lima.import.all.csv" onActionPerformed='showImportView("all_csv")'/>
- <JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='showImportView("all_csv_ebp")'/>
- <JMenuItem text="lima.import.account" onActionPerformed='showImportView("account")'/>
- <JMenuItem text="lima.import.journal" onActionPerformed='showImportView("journal")'/>
+ <JMenuItem text="lima.import.all" onActionPerformed='getHandler().showImportView("all")'/>
+ <JMenuItem text="lima.import.all.csv" onActionPerformed='getHandler().showImportView("all_csv")'/>
+ <JMenuItem text="lima.import.all.csv.ebp" onActionPerformed='getHandler().showImportView("all_csv_ebp")'/>
+ <JMenuItem text="lima.import.account" onActionPerformed='getHandler().showImportView("account")'/>
+ <JMenuItem text="lima.import.journal" onActionPerformed='getHandler().showImportView("journal")'/>
</JMenu>
<JMenu text="lima.export" actionIcon='export-element'>
- <JMenuItem text="lima.export.all" onActionPerformed='showExportView("all")'/>
- <JMenuItem text="lima.export.all.csv" onActionPerformed='showExportView("all_csv")'/>
- <JMenuItem text="lima.export.account" onActionPerformed='showExportView("account")'/>
+ <JMenuItem text="lima.export.all" onActionPerformed='getHandler().showExportView("all")'/>
+ <JMenuItem text="lima.export.all.csv" onActionPerformed='getHandler().showExportView("all_csv")'/>
+ <JMenuItem text="lima.export.account" onActionPerformed='getHandler().showExportView("account")'/>
</JMenu>
<JSeparator/>
- <JMenuItem text="lima.print" actionIcon='print'/>
+ <JMenuItem text="lima.common.print" actionIcon='print'/>
<JSeparator/>
<JMenuItem id='menuFileFullscreen'
text="lima.action.fullscreen"
@@ -92,44 +112,45 @@
<JSeparator/>
<JMenuItem mnemonic="{'Q'}"
actionIcon='quit'
- text="lima.quit" onActionPerformed='getHandler().close(this)'/>
+ text="lima.common.quit" onActionPerformed='getHandler().close(this)'/>
</JMenu>
<JMenu text="lima.chartofaccounts">
- <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='showAccountView()'
+ <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='getHandler().showAccountView(this)'
actionIcon='account'/>
- <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='showJournalView()'
+ <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='getHandler().showJournalView(this)'
actionIcon='journal'/>
</JMenu>
<JMenu text="lima.fiscalyear">
- <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='showAddPeriod()'/>
- <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='showClosureTimeSpanView()'
+ <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='getHandler().showAddPeriod(this)'/>
+ <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='getHandler().showClosureTimeSpanView(this)'
actionIcon='closure-timespan'/>
- <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='showClosurePeriodView()'/>
- <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='showClosureView()'
+ <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='getHandler().showClosurePeriodView(this)'/>
+ <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='getHandler().showFiscalPeriodView(this)'
actionIcon='closure'/>
</JMenu>
<JMenu text="lima.entries">
- <JMenuItem text="lima.entries.addtransaction" onActionPerformed='showTransactionView()'
+ <JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)'
actionIcon='transaction'/>
- <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='showSearchView()'
+ <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='getHandler().showSearchView(this)'
actionIcon='search'/>
- <JMenuItem text="lima.entries.lettering" onActionPerformed='showLetteringView()'
+ <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)'
actionIcon='lettering'/>
</JMenu>
<JMenu text="lima.view">
- <JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten" onItemStateChanged='onChangeView()'
- selected="false" actionIcon='view'/>
+ <JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten"
+ onItemStateChanged='getHandler().onChangeView(this)'
+ selected="false" actionIcon='view'/>
</JMenu>
<JMenu text="lima.reports">
- <JMenuItem text="lima.reports" onActionPerformed='showReportsView()' actionIcon='rapport'/>
- <JMenuItem text="lima.balance" onActionPerformed='showBalanceView()'/>
- <JMenuItem text="lima.bilan" onActionPerformed='showBilanView()'/>
- <JMenuItem text="lima.result" onActionPerformed='showResultView()'/>
+ <JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/>
+ <JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
+ <JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/>
+ <JMenuItem text="lima.result" onActionPerformed='getHandler().showResultView(this)'/>
</JMenu>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-09 16:17:30 UTC (rev 2847)
@@ -1,4 +1,4 @@
-/* *##% Lima Main
+/* *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
@@ -36,11 +36,28 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
+import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.ui.entrybook.EntryBookView;
+import org.chorem.lima.ui.period.FiscalPeriodView;
+import org.chorem.lima.ui.report.BalanceView;
+import org.chorem.lima.ui.report.BilanView;
+import org.chorem.lima.ui.report.ReportsView;
+import org.chorem.lima.ui.report.ResultView;
+import org.chorem.lima.ui.transaction.LetteringView;
+import org.chorem.lima.ui.transaction.TransactionView;
+import org.chorem.lima.util.ErrorHelper;
/**
- * User: chemit
+ * Handler for main view.
+ *
* Date: 8 nov. 2009
* Time: 09:59:54
+ *
+ * @author chemit
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
*/
public class MainViewHandler {
@@ -59,12 +76,10 @@
public MainView initUI(LimaContext rootContext, boolean fullscreen) {
// show main ui
- MainView ui = new MainViewImpl(rootContext);
+ MainView ui = new MainView(rootContext);
LimaContext.MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
- //ErrorDialogUI.init(ui);
-
// set fullscreen propery on main ui
ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
@@ -90,7 +105,9 @@
* @param ui l'ui principale de l'application
*/
public void close(MainView ui) {
- log.info("Vradi quitting...");
+ if (log.isInfoEnabled()) {
+ log.info("Lima quitting...");
+ }
boolean canContinue = ensureModification(ui);
if (!canContinue) {
return;
@@ -101,7 +118,9 @@
Runtime.getRuntime().halt(0);
} catch (Exception ex) {
- log.error("error while closing " + ex.getMessage(), ex);
+ if (log.isErrorEnabled()) {
+ log.error("error while closing " + ex.getMessage(), ex);
+ }
Runtime.getRuntime().halt(1);
}
}
@@ -169,25 +188,27 @@
try {
Desktop.getDesktop().browse(siteURL.toURI());
} catch (Exception ex) {
- log.error(ex.getMessage(), ex);
- ErrorDialogUI.showError(ex);
+ if (log.isDebugEnabled()) {
+ log.error("Can't open lima website", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't open lima website", ex);
}
}
}
public void showAbout(MainView ui) {
- AboutPanel about = new AboutPanel() {
+ AboutPanel about = new AboutPanel()/* {
@Override
public void buildTopPanel() {
setIconPath("/icons/lima.png");
super.buildTopPanel();
}
- };
+ }*/;
about.setTitle(_("lima.title.about"));
about.setAboutText(_("lima.about.message"));
about.setBottomText(ui.getConfig().getCopyrightText());
-// about.setIconPath("/icons/lima.png");
+ about.setIconPath("/icons/lima.png");
about.setLicenseFile("META-INF/lima-main-LICENSE.txt");
about.setThirdpartyFile("META-INF/lima-main-THIRD-PARTY.txt");
about.init();
@@ -209,9 +230,6 @@
MainView ui = getUI(rootContext);
if (ui != null) {
-
- //ErrorDialogUI.init(null);
-
LimaContext.MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
ui.dispose();
@@ -245,7 +263,7 @@
return true;
}
- MainView getUI(JAXXContext context) {
+ protected MainView getUI(JAXXContext context) {
if (context instanceof MainView) {
return (MainView) context;
}
@@ -253,4 +271,134 @@
return ui;
}
+ public void showHomeView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ HomeView homeView = new HomeView(mainView);
+ mainView.showTab(_("lima.tab.home"), homeView, false);
+ }
+
+ public void showBilanView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ BilanView bilanView = new BilanView(mainView);
+ mainView.showTab(_("lima.tab.bilan"), bilanView);
+ }
+
+ public void showBalanceView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ BalanceView balanceView = new BalanceView(mainView);
+ mainView.showTab(_("lima.tab.balance"), balanceView);
+ }
+
+ public void showFiscalPeriodView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
+ mainView.showTab(_("lima.tab.period"), fiscalPeriodView);
+ }
+
+ public void showClosurePeriodView(JAXXContext rootContext) {
+
+ }
+
+ public void showClosureTimeSpanView(JAXXContext rootContext) {
+ //getClosureView().initBlockForm();
+ }
+
+ public void showAddPeriod(JAXXContext rootContext) {
+ //getClosureView().initAddPeriod();
+ }
+
+ public void showImportView(String type) {
+ /*if (!getImportView(type).isEnabled()) {
+ getImportView(type).setEnabled(true);
+ }*/
+ }
+
+ public void showExportView(String type) {
+ /*if (!getExportView(type).isEnabled()) {
+ getExportView(type).setEnabled(true);
+ }*/
+ }
+
+ public void showLetteringView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ LetteringView letteringView = new LetteringView(mainView);
+ mainView.showTab(_("lima.tab.lettering"), letteringView);
+ }
+
+ public void showSearchResultView(JAXXContext rootContext) {
+ /*MainView mainView = getUI(rootContext);
+ SearchResultView searchResultView = new SearchResultView(mainView);
+ mainView.showTab(_("lima.tab.search.result"), searchResultView);*/
+ }
+
+ public void showAccountView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ AccountView accountView = new AccountView(mainView);
+ mainView.showTab(_("lima.tab.account"), accountView);
+ }
+
+ public void showTransactionView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ TransactionView transactionView = new TransactionView(mainView);
+ mainView.showTab(_("lima.tab.transaction"), transactionView);
+ }
+
+ public void showJournalView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ EntryBookView entryBookView = new EntryBookView(mainView);
+ mainView.showTab(_("lima.tab.journal"), entryBookView);
+ }
+
+ public void showSearchView(JAXXContext rootContext) {
+ /*if (!getSearchView().isEnabled()) {
+ getSearchView().setEnabled(true);
+ }
+ getSearchView().setVisible(true);*/
+ }
+
+ public void showReportsView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ ReportsView reportsView = new ReportsView(mainView);
+ mainView.showTab(_("lima.tab.reports"), reportsView);
+ }
+
+ public void showResultView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ ResultView resultView = new ResultView(mainView);
+ mainView.showTab(_("lima.tab.result"), resultView);
+ }
+
+ /**
+ * Called by menuitem "Vue a plat".
+ *
+ * Mais le fonctionnement est a revoir, car un peu trop de code...
+ *
+ * @param rootContext
+ */
+ protected void onChangeView(JAXXContext rootContext) {
+ /*if (log.isDebugEnabled()) {
+ log.debug("onChangeView : ");
+ }
+ transactionView = getTransactionView();
+ searchResultView = getSearchResultView();
+ if (viewFlatten.getState()) {
+ // View not flatten
+ if (log.isDebugEnabled()) {
+ log.debug("onChangeView : setModel : getSortedModel");
+ }
+ transactionView.getTransactionTable().setModel(transactionView.getSortedModel());
+ searchResultView.getTransactionTable().setModel(searchResultView.getSortedModel());
+ } else {
+ // View Flatten
+ if (log.isDebugEnabled()) {
+ log.debug("onChangeView : setModel : getFlattenModel");
+ }
+ transactionView.getTransactionTable().setModel(transactionView.getFlattenModel());
+ searchResultView.getTransactionTable().setModel(searchResultView.getFlattenModel());
+ }
+ // Pack all columns
+ transactionView.getTransactionTable().packAll();
+ searchResultView.getTransactionTable().packAll();*/
+ }
+
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-09 16:16:58 UTC (rev 2846)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-09 16:17:30 UTC (rev 2847)
@@ -1,417 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.Component;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JTabbedPane;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import jaxx.runtime.JAXXContext;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.table.model.TransactionFlattenTableModel;
-import org.chorem.lima.ui.account.AccountView;
-import org.chorem.lima.ui.entrybook.EntryBookView;
-import org.chorem.lima.ui.period.AddPeriod;
-import org.chorem.lima.ui.period.ClosureTimeSpanForm;
-import org.chorem.lima.ui.period.FiscalPeriodView;
-import org.chorem.lima.ui.report.BalanceViewImpl;
-import org.chorem.lima.ui.report.BilanViewImpl;
-import org.chorem.lima.ui.report.ReportsView;
-import org.chorem.lima.ui.report.ReportsViewImpl;
-import org.chorem.lima.ui.report.ResultViewImpl;
-import org.chorem.lima.ui.transaction.LetteringViewImpl;
-import org.chorem.lima.ui.transaction.SearchTransactionViewImpl;
-import org.chorem.lima.ui.transaction.TransactionViewImpl;
-
-/**
- * @author ore
- */
-public class MainViewImpl extends MainView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 5339665516073792117L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(MainViewImpl.class);
-
- private HomeViewImpl homeView;
-
- private FiscalPeriodView closureView;
-
- private TransactionViewImpl transactionView;
-
- private TransactionViewImpl searchResultView;
-
- private EntryBookView journalView;
-
- private AccountView accountView;
-
- private SearchTransactionViewImpl searchView;
-
- private ReportsViewImpl reportsView;
-
- private ResultViewImpl resultView;
-
- private LetteringViewImpl letteringView;
-
- private ClosureTimeSpanForm closureTimeSpanForm;
-
- private BilanViewImpl bilanView;
-
- private BalanceViewImpl balanceView;
-
- private AddPeriod addPeriod;
-
- public MainViewImpl(JAXXContext c) {
- super(c);
-
- showHomeView();
-
- // Register a change listener
- contentTabbedPane.addChangeListener(new ChangeListener() {
- // This method is called whenever the selected tab changes
-
- @Override
- public void stateChanged(ChangeEvent evt) {
- JTabbedPane pane = (JTabbedPane) evt.getSource();
-
- // Get current tab
- int sel = pane.getSelectedIndex();
- if (sel != -1) {
- Component component = pane.getComponentAt(sel);
- // if TransactionViewImpl
- if (component instanceof TransactionViewImpl) {
- TransactionJXTable table = ((TransactionViewImpl) component).getTransactionTable();
- // if model is TransactionFlattenTableModel
- if (table.getModel() instanceof TransactionFlattenTableModel) {
- ((TransactionFlattenTableModel) table.getModel()).initFlattenModel();
- table.addColorEmptyLine();
- }
- }
- }
- }
- });
- }
-
- public HomeViewImpl getHomeView() {
- if (homeView == null) {
- homeView = new HomeViewImpl(this);
- }
- return homeView;
- }
-
- public AccountView getAccountView() {
- if (accountView == null) {
- accountView = new AccountView(this);
- }
- return accountView;
- }
-
- public AddPeriod getAddPeriod() {
- if (addPeriod == null) {
- addPeriod = new AddPeriod(this);
- }
- return addPeriod;
- }
-
- public BalanceViewImpl getBalanceView() {
- if (balanceView == null) {
- balanceView = new BalanceViewImpl(this);
- }
- return balanceView;
- }
-
- public BilanViewImpl getBilanView() {
- if (bilanView == null) {
- bilanView = new BilanViewImpl(this);
- }
- return bilanView;
- }
-
- public ClosureTimeSpanForm getClosureTimeSpanForm() {
- if (closureTimeSpanForm == null) {
- closureTimeSpanForm = new ClosureTimeSpanForm(this);
- }
- return closureTimeSpanForm;
- }
-
- public FiscalPeriodView getClosureView() {
- if (closureView == null) {
- closureView = new FiscalPeriodView(this);
- }
- return closureView;
- }
-
- /*public ExportViewImpl getExportView(String type) {
- ExportViewImpl exportView = new ExportViewImpl(type);
- return exportView;
- }
-
- public ImportViewImpl getImportView(String type) {
- ImportViewImpl importView = new ImportViewImpl(this, type);
- return importView;
- }*/
-
- public EntryBookView getEntryBookView() {
- if (journalView == null) {
- journalView = new EntryBookView(this);
- }
- return journalView;
- }
-
- public LetteringViewImpl getLetteringView() {
- if (letteringView == null) {
- letteringView = new LetteringViewImpl(this);
- }
- return letteringView;
- }
-
- public ReportsView getReportsView() {
- if (reportsView == null) {
- reportsView = new ReportsViewImpl(this);
- }
- return reportsView;
- }
-
- public ResultViewImpl getResultView() {
- if (resultView == null) {
- resultView = new ResultViewImpl(this);
- }
- return resultView;
- }
-
- public SearchTransactionViewImpl getSearchView() {
- if (searchView == null) {
- searchView = new SearchTransactionViewImpl(this);
- }
- return searchView;
- }
-
- public TransactionViewImpl getSearchResultView() {
- if (searchResultView == null) {
- searchResultView = new TransactionViewImpl(this);
- }
- return searchResultView;
- }
-
- public TransactionViewImpl getTransactionView() {
- if (transactionView == null) {
- transactionView = new TransactionViewImpl(this);
- }
- return transactionView;
- }
-
- /**
- * Show a new closable tab.
- *
- * @param name name of tab to show
- * @param container the tab container
- * @param canClose {@code false} if tab can't be closed
- */
- protected void showTab(String name, Component container, boolean canClose) {
- // if contentTabbedPane doesnot yet contains tab
- if (contentTabbedPane.indexOfTab(name) == -1) {
- ClosableTabHeader closableHeader = new ClosableTabHeader();
- closableHeader.setTitle(name);
- closableHeader.setCanClose(canClose);
- contentTabbedPane.addTab(name, container);
- contentTabbedPane.setSelectedComponent(container);
- contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
- closableHeader.getCloseTab().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JButton button = (JButton) e.getSource();
- ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent();
- String name = closableTab.getTitle();
- contentTabbedPane.remove(contentTabbedPane.indexOfTab(name));
- }
- });
- }
- }
-
- /**
- * Show a new closable tab.
- *
- * @param name name of tab to show
- * @param container the tab container
- */
- protected void showTab(String name, Component container) {
- showTab(name, container, true);
- }
-
- @Override
- protected void showHomeView() {
- showTab(_("lima.tab.home"), getHomeView(), false);
- }
-
- @Override
- protected void showBilanView() {
- showTab(_("lima.tab.bilan"), getBilanView());
- }
-
- @Override
- protected void showBalanceView() {
- showTab(_("lima.tab.balance"), getBalanceView());
- }
-
- @Override
- protected void showClosureView() {
- showTab(_("lima.tab.period"), getClosureView());
- }
-
- /*
- * @see org.chorem.lima.ui.MainView#showClosurePeriodView()
- */
- @Override
- protected void showClosurePeriodView() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- protected void showClosureTimeSpanView() {
- //getClosureView().initBlockForm();
- }
-
- @Override
- protected void showAddPeriod() {
- //getClosureView().initAddPeriod();
- }
-
- @Override
- protected void showImportView(String type) {
- /*if (!getImportView(type).isEnabled()) {
- getImportView(type).setEnabled(true);
- }*/
- }
-
- @Override
- protected void showExportView(String type) {
- /*if (!getExportView(type).isEnabled()) {
- getExportView(type).setEnabled(true);
- }*/
- }
-
- @Override
- protected void showLetteringView() {
- showTab(_("lima.tab.lettering"), getLetteringView());
- }
-
- /**
- *
- */
- protected void showSearchResultView() {
- log.debug("showSearchResultView : ");
- showTab(_("lima.tab.search.result"), getSearchResultView());
- }
-
- @Override
- protected void showAccountView() {
- showTab(_("lima.tab.account"), getAccountView());
- }
-
- @Override
- protected void showTransactionView() {
- showTab(_("lima.tab.transaction"), getTransactionView());
- }
-
- @Override
- protected void showJournalView() {
- showTab(_("lima.tab.journal"), getEntryBookView());
- }
-
- @Override
- protected void showSearchView() {
- if (!getSearchView().isEnabled()) {
- getSearchView().setEnabled(true);
- }
- getSearchView().setVisible(true);
- }
-
- @Override
- protected void showReportsView() {
- showTab(_("lima.tab.reports"), getReportsView());
- }
-
- @Override
- protected void showResultView() {
- showTab(_("lima.tab.result"), getResultView());
- }
-
- @Override
- public void dispose() {
- // Disposing other windows before main view
- //disposeWindow(searchView);
- //disposeWindow(journalForm);
- //disposeWindow(accountForm);
- //disposeWindow(closureTimeSpanForm);
- super.dispose();
- }
-
- /**
- * @param window the windows to dispose
- */
- public void disposeWindow(JFrame window) {
- if (window != null) {
- if (window.isVisible()) {
- window.setVisible(false);
- window.dispose();
- }
- }
- }
-
- @Override
- protected void onChangeView() {
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : ");
- }
- transactionView = getTransactionView();
- searchResultView = getSearchResultView();
- if (viewFlatten.getState()) {
- // View not flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getSortedModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getSortedModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getSortedModel());
- } else {
- // View Flatten
- if (log.isDebugEnabled()) {
- log.debug("onChangeView : setModel : getFlattenModel");
- }
- transactionView.getTransactionTable().setModel(transactionView.getFlattenModel());
- searchResultView.getTransactionTable().setModel(searchResultView.getFlattenModel());
- }
- // Pack all columns
- transactionView.getTransactionTable().packAll();
- searchResultView.getTransactionTable().packAll();
- }
-
-}
1
0
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:16:58 +0200 (Fri, 09 Apr 2010)
New Revision: 2846
Log:
Update i18n files
Modified:
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-09 16:15:11 UTC (rev 2845)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-09 16:16:58 UTC (rev 2846)
@@ -4,6 +4,7 @@
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Exercice=
Global\ lima\ exception=
+Loading\ accounting...=
lima.about.message=
lima.account=Account
lima.account.label=
@@ -49,8 +50,11 @@
lima.closure.period.begin=Period from
lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
lima.common.add=
+lima.common.all=
lima.common.cancel=
lima.common.ok=
+lima.common.print=
+lima.common.quit=
lima.common.remove=
lima.common.update=
lima.config.category.directories=
@@ -152,6 +156,15 @@
lima.journal=Journal
lima.lettered=Lettered
lima.lettering=Lettering
+lima.lettering.add=
+lima.lettering.entries=
+lima.lettering.from=
+lima.lettering.lettered=
+lima.lettering.letteredall=
+lima.lettering.not.lettered=
+lima.lettering.notlettered=
+lima.lettering.remove=
+lima.lettering.to=
lima.loading=Loading
lima.menu.file=File
lima.menu.help=Help
@@ -189,6 +202,7 @@
lima.not.lettered=Not lettered
lima.number=Number
lima.ok=OK
+lima.openejb.remotemode.description=
lima.passif=Liability
lima.period=Period
lima.period.addFiscalPeriod=
@@ -259,6 +273,17 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
lima.to=To
+lima.transaction.column.account=
+lima.transaction.column.balance=
+lima.transaction.column.credit=
+lima.transaction.column.date=
+lima.transaction.column.debit=
+lima.transaction.column.description=
+lima.transaction.column.document=
+lima.transaction.column.entrybook=
+lima.transaction.column.period=
+lima.transaction.column.status=
+lima.transaction.confirmdelete=
lima.transaction.entrybook=
lima.transaction.period=
lima.ui.add.account=Add account
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-09 16:15:11 UTC (rev 2845)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-09 16:16:58 UTC (rev 2846)
@@ -4,6 +4,7 @@
Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
Exercice=
Global\ lima\ exception=
+Loading\ accounting...=
lima.about.message=\u00C0 propos de Lima
lima.account=Compte
lima.account.label=Libell\u00E9
@@ -17,7 +18,6 @@
lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
lima.action.normalscreen=Ecran normal
lima.action.normalscreen.tip=Revenir en \u00E9cran normal
-lima.add=
lima.add.entry=Ajouter une entr\u00E9e
lima.add.lettering=
lima.add.transaction=
@@ -41,7 +41,6 @@
lima.bilan.passif=Passif
lima.bilan.total=Total
lima.block=Bloquer
-lima.cancel=
lima.charge=Charge
lima.chartofaccounts=Plan des comptes
lima.chartofaccounts.journal=Journal
@@ -51,8 +50,11 @@
lima.common.add=Ajout
lima.common.cancel=Annuler
lima.common.ok=OK
+lima.common.print=
+lima.common.quit=Quitter
lima.common.remove=Supprimer
lima.common.update=Modifier
+lima.comon.print=Imprimer
lima.config.category.directories=R\u00E9pertoires
lima.config.category.directories.description=R\u00E9pertoires utilis\u00E9s par Lima
lima.config.category.other=Autre
@@ -81,7 +83,7 @@
lima.description=Description
lima.edit=Editer
lima.edit.transaction=Editer une transaction
-lima.entries=Op\u00E9ration de Saisie
+lima.entries=
lima.entries.addtransaction=Ajouter une transaction
lima.entries.lettering=Ajouter une lettre
lima.entries.searchtransaction=Recherche les transactions
@@ -152,10 +154,18 @@
lima.journal=Journal
lima.lettered=Lettr\u00E9
lima.lettering=Lettrage
+lima.lettering.add=Ajouter une lettre
+lima.lettering.entries=Op\u00E9ration de saisie
+lima.lettering.from=De
+lima.lettering.lettered=Lettr\u00E9e
+lima.lettering.letteredall=Toutes
+lima.lettering.notlettered=Non lettr\u00E9e
+lima.lettering.remove=Supprimer
+lima.lettering.to=\u00C0
lima.loading=Chargement
lima.menu.file=Fichier
lima.menu.help=Aide
-lima.menu.help.about=A Propos
+lima.menu.help.about=\u00C0 Propos
lima.menu.help.help=Afficher l'aide
lima.menu.help.i18n=Langue
lima.menu.help.i18n.fr=Fran\u00E7ais
@@ -184,7 +194,7 @@
lima.non.valids.transactions=Ecritures non valides
lima.not.lettered=Non lettr\u00E9
lima.number=Num\u00E9ro
-lima.ok=
+lima.openejb.remotemode.description=
lima.passif=Passif
lima.period=P\u00E9riode
lima.period.addFiscalPeriod=Nouvel exercice
@@ -193,12 +203,11 @@
lima.period.close=Ferm\u00E9
lima.period.enddate=Fin de l'exercice \:
lima.period.filter=Filtre
-lima.period.menu=Exercice
+lima.period.menu=
lima.period.open=Ouvert
-lima.period.periodFilterLabel=Exercice
+lima.period.periodFilterLabel=
lima.preferences=Pr\u00E9f\u00E9rences
lima.prefix=Pr\u00E9fixe
-lima.print=Imprimer
lima.produit=Produit
lima.progressBar.export.etape1=Cr\u00E9ation base du fichier
lima.progressBar.export.etape2=Cr\u00E9ation informations
@@ -219,7 +228,6 @@
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
-lima.quit=Quitter
lima.remove=
lima.remove.lettering=Supprimer la lettre
lima.remove.transaction=Supprimer une transaction
@@ -247,7 +255,7 @@
lima.tab.home=Accueil
lima.tab.journal=Journal
lima.tab.lettering=Lettrage
-lima.tab.period=Exercice
+lima.tab.period=
lima.tab.reports=Rapports
lima.tab.result=Compte de r\u00E9sultat
lima.tab.search.result=Recherche
@@ -255,6 +263,17 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
lima.to=A
+lima.transaction.column.account=
+lima.transaction.column.balance=
+lima.transaction.column.credit=
+lima.transaction.column.date=
+lima.transaction.column.debit=
+lima.transaction.column.description=
+lima.transaction.column.document=
+lima.transaction.column.entrybook=
+lima.transaction.column.period=
+lima.transaction.column.status=
+lima.transaction.confirmdelete=
lima.transaction.entrybook=Journal
lima.transaction.period=
lima.ui.add.account=Ajouter un compte
1
0
r2845 - in trunk/lima-swing/src/main/java/org/chorem/lima: . combobox widgets
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:15:11 +0200 (Fri, 09 Apr 2010)
New Revision: 2845
Log:
Move wide combo box into widgets package
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/widgets/
trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-04-09 16:14:25 UTC (rev 2844)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java 2010-04-09 16:15:11 UTC (rev 2845)
@@ -1,114 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.combobox;
-
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicComboPopup;
-import javax.swing.plaf.basic.ComboPopup;
-import javax.swing.plaf.metal.MetalComboBoxUI;
-import java.awt.*;
-import java.util.Vector;
-
-/**
- * Cette combo box surcharge quelques methodes de l'UI par defaut
- * pour que le composant popup soit plus grand que la combobox
- * elle même.
- *
- * @author ore
- */
-public class JWideComboBox extends JComboBox {
-
- private boolean layingOut = false;
-
- /**
- *
- */
- public JWideComboBox() {
- setUI(new ScrollMetalComboUI());
- }
-
- /**
- * @param items
- */
- public JWideComboBox(final Object items[]) {
- super(items);
- }
-
- /**
- * @param items
- */
- public JWideComboBox(Vector items) {
- super(items);
- }
-
- /**
- * @param aModel
- */
- public JWideComboBox(ComboBoxModel aModel) {
- super(aModel);
- }
-
- /**
- *
- */
- @Override
- public void doLayout() {
- try {
- layingOut = true;
- super.doLayout();
- } finally {
- layingOut = false;
- }
- }
-
- /**
- * @return
- */
- @Override
- public Dimension getSize() {
- Dimension dim = super.getSize();
- if (!layingOut) {
- int max = Math.max(dim.width, getPreferredSize().width);
- dim.width = max > 600 ? 600 : max;
- }
- return dim;
- }
-}
-
-class ScrollMetalComboUI extends MetalComboBoxUI {
-
- @Override
- protected ComboPopup createPopup() {
- return new ScrollBasicComboPopup(comboBox);
- }
-}
-
-class ScrollBasicComboPopup extends BasicComboPopup {
-
- public ScrollBasicComboPopup(JComboBox combo) {
- super(combo);
- }
-
- @Override
- protected JScrollPane createScroller() {
- return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
- JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java (from rev 2836, trunk/lima-swing/src/main/java/org/chorem/lima/combobox/JWideComboBox.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2010-04-09 16:15:11 UTC (rev 2845)
@@ -0,0 +1,100 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.widgets;
+
+import javax.swing.*;
+import javax.swing.plaf.basic.BasicComboPopup;
+import javax.swing.plaf.basic.ComboPopup;
+import javax.swing.plaf.metal.MetalComboBoxUI;
+import java.awt.*;
+import java.util.Vector;
+
+// put it at begin, otherwise jaxx complains again !!!
+class ScrollMetalComboUI extends MetalComboBoxUI {
+
+ @Override
+ protected ComboPopup createPopup() {
+ return new ScrollBasicComboPopup(comboBox);
+ }
+}
+
+//put it at begin, otherwise jaxx complains again !!!
+class ScrollBasicComboPopup extends BasicComboPopup {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 2353523521723292218L;
+
+ public ScrollBasicComboPopup(JComboBox combo) {
+ super(combo);
+ }
+
+ @Override
+ protected JScrollPane createScroller() {
+ return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+ JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+ }
+}
+
+/**
+ * Cette combo box surcharge quelques methodes de l'UI par defaut
+ * pour que le composant popup soit plus grand que la combobox
+ * elle même.
+ *
+ * @author ore
+ */
+public class JWideComboBox extends JComboBox {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6715271536163434385L;
+
+ private boolean layingOut = false;
+
+ public JWideComboBox() {
+ super();
+ setUI(new ScrollMetalComboUI());
+ }
+
+ public JWideComboBox(final Object items[]) {
+ super(items);
+ }
+
+ public JWideComboBox(ComboBoxModel aModel) {
+ super(aModel);
+ }
+
+ @Override
+ public void doLayout() {
+ try {
+ layingOut = true;
+ super.doLayout();
+ } finally {
+ layingOut = false;
+ }
+ }
+
+ @Override
+ public Dimension getSize() {
+ Dimension dim = super.getSize();
+ if (!layingOut) {
+ int max = Math.max(dim.width, getPreferredSize().width);
+ dim.width = max > 600 ? 600 : max;
+ }
+ return dim;
+ }
+}
1
0
r2844 - trunk/lima-swing/src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:14:25 +0200 (Fri, 09 Apr 2010)
New Revision: 2844
Log:
Remove DTO specific code
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-04-09 16:13:25 UTC (rev 2843)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-04-09 16:14:25 UTC (rev 2844)
@@ -19,19 +19,23 @@
package org.chorem.lima.util;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.item.PeriodItem;
import static org.nuiton.i18n.I18n._;
-import org.nuiton.util.Resource;
-import javax.swing.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.Resource;
+
/**
* @author ore
* @author Rémi Chapelet
@@ -88,34 +92,6 @@
}
/**
- * @param period
- * @return
- */
- public static List<PeriodItem> createMonthItems(PeriodDTO period) {
- if (period != null) {
- List<PeriodItem> list = new LinkedList<PeriodItem>();
- Calendar cal = new GregorianCalendar();
- cal.setTime(period.getBegin());
- for (int i = 0; i < 12; i++) {
- Date begin = cal.getTime();
-
- int last_day_month = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
- cal.set(Calendar.DAY_OF_MONTH, last_day_month);
- Date end = cal.getTime();
-
- PeriodItem item = new PeriodItem(period, begin, end, true);
- list.add(item);
- cal.set(Calendar.DAY_OF_MONTH, 1);
- cal.add(Calendar.MONTH, 1);
- }
-
- return list;
- } else {
- throw new NullPointerException();
- }
- }
-
- /**
* Adds all of the elements in the second collection to the first collection if they're not already present.
*
* @param c1 collection who receives elements
1
0
r2843 - trunk/lima-swing/src/main/java/org/chorem/lima/util
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:13:25 +0200 (Fri, 09 Apr 2010)
New Revision: 2843
Log:
Remove swingx auto complete class (just use code when needed)
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,48 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * @author ore
- */
-public class AccountToStringConverter extends ObjectToStringConverter {
-
- private static AccountToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- AccountDTO account = (AccountDTO) item;
- return account.getIdNumber() + " : " + account.getDescription();
- }
-
- public static AccountToStringConverter getInstance() {
- if (converter == null) {
- converter = new AccountToStringConverter();
- }
- return converter;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/JournalToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,50 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * Converts a journal to string for AutoCompleteDecorator
- *
- * @author ore
- */
-public class JournalToStringConverter extends ObjectToStringConverter {
-
- private static JournalToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- JournalDTO journal = (JournalDTO) item;
- return journal.getIdName() + " : " + journal.getDescription();
- }
-
- public static JournalToStringConverter getInstance() {
- if (converter == null) {
- converter = new JournalToStringConverter();
- }
- return converter;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java 2010-04-09 16:12:37 UTC (rev 2842)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/PeriodToStringConverter.java 2010-04-09 16:13:25 UTC (rev 2843)
@@ -1,49 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
-
-/**
- * @author ore
- */
-public class PeriodToStringConverter extends ObjectToStringConverter {
-
- private static PeriodToStringConverter converter;
-
- @Override
- public String getPreferredStringForItem(Object item) {
- if (item == null) {
- return DTOHelper.EMPTY_STRING;
- }
- PeriodDTO period = (PeriodDTO) item;
- return period.getIdName();
- }
-
-
- public static PeriodToStringConverter getInstance() {
- if (converter == null) {
- converter = new PeriodToStringConverter();
- }
- return converter;
- }
-}
1
0
r2842 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction: model table
by echatellier@users.chorem.org 09 Apr '10
by echatellier@users.chorem.org 09 Apr '10
09 Apr '10
Author: echatellier
Date: 2010-04-09 18:12:37 +0200 (Fri, 09 Apr 2010)
New Revision: 2842
Log:
Migration of transaction and lettering UI.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java (from rev 2836, trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/AccountComboBoxModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -0,0 +1,52 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.model;
+
+import javax.swing.DefaultComboBoxModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Account combo box model.
+ *
+ * Used in:
+ * - lettering view
+ *
+ * @author ore
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountComboBoxModel extends DefaultComboBoxModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6914345613508897515L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountComboBoxModel.class);
+
+ /**
+ * @param items
+ */
+ public AccountComboBoxModel() {
+ super();
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -36,11 +36,11 @@
*/
public class EntryBookComboBoxModel implements ComboBoxModel {
- protected Object selectedMonth;
+ protected Object selectedEntryBook;
protected EntryBookService entryBookService;
- public EntryBookComboBoxModel(Object selectedMonth) {
+ public EntryBookComboBoxModel() {
entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
}
@@ -99,7 +99,7 @@
*/
@Override
public void setSelectedItem(Object anItem) {
- selectedMonth = anItem;
+ selectedEntryBook = anItem;
}
/*
@@ -107,6 +107,6 @@
*/
@Override
public Object getSelectedItem() {
- return selectedMonth;
+ return selectedEntryBook;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -24,7 +24,6 @@
import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.service.LimaServiceFactory;
-import org.nuiton.util.MonthEnum;
/**
* Opened financial period combo box model.
@@ -37,11 +36,11 @@
*/
public class FinancialPeriodComboBoxModel implements ComboBoxModel {
- protected Object selectedMonth;
+ protected Object selectedFinancialPeriod;
protected FinancialPeriodService financialPeriodService;
- public FinancialPeriodComboBoxModel(Object selectedMonth) {
+ public FinancialPeriodComboBoxModel() {
financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
}
@@ -100,7 +99,7 @@
*/
@Override
public void setSelectedItem(Object anItem) {
- selectedMonth = anItem;
+ selectedFinancialPeriod = anItem;
}
/*
@@ -108,6 +107,6 @@
*/
@Override
public Object getSelectedItem() {
- return selectedMonth;
+ return selectedFinancialPeriod;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -1,127 +1,98 @@
-/*
- * *##% Lima Main
+/* *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
package org.chorem.lima.ui.transaction.table;
import java.awt.Color;
import java.awt.Component;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.Date;
-import javax.swing.ListSelectionModel;
-import javax.swing.table.TableColumnModel;
-import javax.swing.table.TableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.entity.Transaction;
import org.chorem.lima.listener.EmptyLineSelectionListener;
-import org.chorem.lima.listener.TransactionHeaderListener;
-import org.chorem.lima.listener.TransactionKeyListener;
-import org.chorem.lima.table.editor.AccountTableCellEditor;
import org.chorem.lima.table.editor.DateTableCellEditor;
-import org.chorem.lima.table.editor.JournalTableCellEditor;
-import org.chorem.lima.table.editor.NumberTableCellEditor;
-import org.chorem.lima.table.editor.PeriodTableCellEditor;
-import org.chorem.lima.table.editor.TextTableCellEditor;
-import org.chorem.lima.table.model.TransactionFlattenTableModel;
import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
import org.chorem.lima.table.model.TransactionTableModel;
-import org.chorem.lima.table.renderer.AccountTableCellRenderer;
-import org.chorem.lima.table.renderer.AmountTableCellRenderer;
-import org.chorem.lima.table.renderer.DateTableCellRenderer;
-import org.chorem.lima.table.renderer.JournalTableCellRenderer;
-import org.chorem.lima.table.renderer.PeriodTableCellRenderer;
-import org.chorem.lima.table.renderer.StatusTableCellRenderer;
-import org.chorem.lima.table.renderer.TextTableCellRenderer;
-import org.chorem.lima.table.renderer.TransactionHeaderRenderer;
+import org.chorem.lima.ui.transaction.TransactionHelper;
+import org.chorem.lima.ui.transaction.TransactionViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
* @author ore
* @author Rémi Chapelet
*/
-public class TransactionTable extends JXTable {
+public class TransactionTable extends JXTable implements KeyListener {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
-
+
/** log. */
private static final Log log = LogFactory.getLog(TransactionTable.class);
+ protected TransactionViewHandler handler;
+
private ColorHighlighter colorEmptyLine;
-
+
private ColorHighlighter colorTransaction;
-
+
private ColorHighlighter colorBalance;
-
+
private EmptyLineSelectionListener emptyLineSelectionListener;
-
- private TransactionKeyListener keyListener;
/**
- * @param model
- * @param columnModel
*/
- public TransactionTable(TransactionTableModel model, TransactionSortedTableColumnModel columnModel) {
- super(model, columnModel);
- createDefaultColumnsFromModel();
-
- //setSelectionBackground(new Color(250,250,250));
- //setSelectionForeground(new Color(0,0,0));
-
- setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250)));
- setColumnControlVisible(true);
- getColumnExt(TransactionEnum.LETTERING.ordinal()).setVisible(false);
- /**
+ public TransactionTable(TransactionViewHandler handler/*,
+ TransactionTableModel model,
+ TransactionSortedTableColumnModel columnModel*/) {
+ //super(model, columnModel);
+
+ this.handler = handler;
+
+ /*
* New Table Header
*/
- getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
- getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+ // header renderer getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ //getTableHeader().addMouseListener(new TransactionHeaderListener(this));
- /**
+ /*
* Mod : il est possible d'activer cette option.
* Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
* automatiquement une nouvelle ligne (une entrée comptable)
*/
- //addMouseListener(getEmptyLineSelectionListener());
- /**
- * Fin mod
- */
+ addMouseListener(getEmptyLineSelectionListener());
- /**
+ /*
* Mod : il est possible d'activer cette option.
* Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
* programme insère une ligne comptable.
*/
- addKeyListener(getKeyListener());
+ addKeyListener(this);
-
- /**
- * Editing true
- */
- setTransactionEditable(true);
-
// cell rendering
- TableColumnModel tcm = getColumnModel();
+ /*TableColumnModel tcm = getColumnModel();
tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
@@ -141,37 +112,23 @@
tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
- tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());
- packAll();
- /**
- * Color transactions
- */
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/
+
+ setDefaultEditor(Date.class, new DateTableCellEditor());
+
+
+ // Color transactions
addColorTransaction();
- addColorBalance();
+ addColorNonBalancedTransaction();
}
/**
- * @param editable
- */
- public void setTransactionEditable(boolean editable) {
- if (editable) {
- addMouseListener(emptyLineSelectionListener);
- addKeyListener(keyListener);
- } else {
- removeMouseListener(emptyLineSelectionListener);
- removeKeyListener(keyListener);
- }
- TransactionTableModel model = (TransactionTableModel) getModel();
- model.setEditable(editable);
- }
-
- /**
*
*/
public void addColorEmptyLine() {
- /*
- * Renvoie une couleur jaune pour chaque nouvelle ligne créée
- removeColorEmptyLine();
+
+ // Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ /*removeColorEmptyLine();
if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
HighlightPredicate predicate = new HighlightPredicate() {
@@ -199,59 +156,50 @@
* Cette méthode permet de colorer toutes les transactions dans le tableau
* afin de bien distinguer les transactions et entrées comptables.
*/
- public void addColorTransaction() {
+ protected void addColorTransaction() {
if (colorTransaction != null) {
removeHighlighter(colorTransaction);
}
HighlightPredicate predicate = new HighlightPredicate() {
-
@Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
- return DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) ? true : false;
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return getModel().getElementAt(adapter.row) instanceof Transaction;
}
};
- colorTransaction = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null);
+ colorTransaction = new ColorHighlighter(predicate, new Color(222, 222,
+ 222), null, null, null);
addHighlighter(colorTransaction);
}
-
/**
* Permet de surligner une transaction dans le tableau lorsque cette dernière
* n'est pas équilibrée.
*/
- public void addColorBalance() {
+ protected void addColorNonBalancedTransaction() {
if (colorBalance != null) {
removeHighlighter(colorBalance);
}
HighlightPredicate predicate = new HighlightPredicate() {
-
@Override
- public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
boolean isHighlighted = false;
- // Si c'est une transaction
- if ( DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) )
- {
- if ( !DTOHelper.isBalanced((TransactionDTO) getModel().getElementAt(adapter.row)) )
- {
+ Object value = getModel().getElementAt(adapter.row);
+ if (value instanceof Transaction) {
+ Transaction currentTransaction = (Transaction) value;
+ if (!TransactionHelper.isBalanced(currentTransaction)) {
isHighlighted = true;
}
}
return isHighlighted;
}
};
- colorTransaction = new ColorHighlighter(predicate, new Color(255,198,209),null,null,null);
+ colorTransaction = new ColorHighlighter(predicate, new Color(255, 198,
+ 209), null, null, null);
addHighlighter(colorTransaction);
}
- /**
- *
- */
- public void removeColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- }
-
@Override
public TransactionTableModel getModel() {
return (TransactionTableModel) this.dataModel;
@@ -269,27 +217,165 @@
return emptyLineSelectionListener;
}
- /**
- * @return
- */
- public TransactionKeyListener getKeyListener() {
- if (keyListener == null) {
- return new TransactionKeyListener();
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ // VK_DELETE suppression de la transaction en cours
+ // ou de l'entree
+ if (e.getKeyCode() == KeyEvent.VK_DELETE) {
+ handler.deleteSelectedRow();
}
- return keyListener;
+
+ // Touche : insert ou ctrl+I
+ // Ajoute une transaction
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT)
+ || (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+
+ // TODO EC 20100408 String result = table.getModel().addEmptyTransaction();
+ }
+
+ // Touche '+' OU 'ctrl+Entr'
+ // Ajoute une entrée comptable ou transaction
+ if (e.getKeyCode() == KeyEvent.VK_PLUS
+ || (e.getKeyCode() == KeyEvent.VK_ENTER && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ /*int max_y = table.getRowCount();
+ addLine(table);
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y, max_y);*/
+ }
+
+ /**
+ * Touche tab
+ * Ajoute une entrée comptable ou transaction seulement si tab est sur
+ * la dernière cellule.
+ */
+ if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ // Vérifie si la cellule sélectionnée est la dernière
+ /*int x = table.getSelectedColumn();
+ int y = table.getSelectedRow();
+ int max_x = table.getColumnCount() - 1;
+ int max_y = table.getRowCount() - 1;
+ if (x == max_x && y == max_y) {
+ boolean result = addLine(table);
+ // positionne la sélection sur la nouvelle ligne créée
+ if (result) {
+ table.setColumnSelectionInterval(0, 0);
+ table.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }*/
+ }
+
}
- /**
- * @param model
- * @return
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
*/
- public boolean isFlattenModel(TableModel model) {
- return TransactionFlattenTableModel.isFlattenModel(model);
+ @Override
+ public void keyTyped(KeyEvent e) {
+
}
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
@Override
- public void setModel(TableModel arg0) {
- super.setModel(arg0);
- removeColorEmptyLine();
+ public void keyReleased(KeyEvent e) {
+
}
+
+ /**
+ * Permet d'ajouter une nouvelle ligne : transaction ou entrée
+ * @param table la table
+ * @return
+ */
+ /*private boolean addLine(TransactionJXTable table) {
+ if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) {
+ // Vérifie si le tableau est vide, alors ajout d'une transaction
+ if (table.getRowCount() == 0) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table
+ .getModel();
+ int selectedRow = 0;
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ selectedRow = table.getRowCount() - 1;
+ } else {
+ // Line selected
+ selectedRow = table.getSelectedRow();
+ }
+ // Récupère la position de la transaction rattachée
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+
+ // Is transaction editable ?
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ return false;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ return false;
+ }
+ }
+
+ // Vérifie si la transaction est équilibrée ou non (et qu'elle posséde des entrées)
+ TransactionDTO transaction = (TransactionDTO) flattenModel
+ .getElementAt(parentIndex);
+ if (DTOHelper.isBalanced(transaction)
+ && !transaction.getEntries().isEmpty()) {
+ String result = table.getModel().addEmptyTransaction();
+ ErrorMessage.showMessage(result);
+ return true;
+ }
+
+ // Vérifie si une ligne est sélectionnée ou non
+ if (table.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = selectedRow + 1;
+ flattenModel.createEmptyLine();
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ } else {
+ // Line selected
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+
+ // Once traitement for transaction
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = table.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel
+ .emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+
+ // New Line Color
+ table.addColorEmptyLine();
+ }
+ return true;
+ }
+ return false;
+ }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-09 16:12:23 UTC (rev 2841)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-09 16:12:37 UTC (rev 2842)
@@ -1,51 +1,57 @@
-/*
- * *##% Lima Main
+/* *##% Lima Swing
* Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
package org.chorem.lima.ui.transaction.table;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import static org.nuiton.i18n.I18n._;
+
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
import javax.swing.table.AbstractTableModel;
-import javax.xml.rpc.ServiceFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.RecordService;
import org.chorem.lima.business.TransactionService;
-import org.chorem.lima.comparator.JournalComparator;
-import org.chorem.lima.comparator.PeriodComparator;
-import org.chorem.lima.comparator.StatusComparator;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.Transaction;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.ServiceHelper;
+import org.chorem.lima.ui.transaction.TransactionHelper;
+import org.chorem.lima.util.ErrorHelper;
/**
* Basic transaction table model.
*
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * TODO EC20100408 revoir le modele, avoir des transactions et des entries
+ * c'est pas gérables.
+ * Le mieux serait d'avoir un "mega component transaction par ligne" et
+ * que ce composant puisse editer les entries.
+ * Ou autre chose.
+ *
* @author ore
* @author chatellier
* @version $Revision$
@@ -57,16 +63,20 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3914954536809622358L;
-
+
/** log. */
- private static final Log log = LogFactory.getLog(TransactionTableModel.class);
+ private static final Log log = LogFactory
+ .getLog(TransactionTableModel.class);
- /**
- * Services
- */
+ /** Transaction service. */
+ protected final TransactionService transactionService;
+ /** Record service. */
protected final RecordService recordService;
- protected final TransactionService transactionService;
+ protected EntryBook selectedEntryBook;
+
+ protected FinancialPeriod selectedFinancialPeriod;
+
/**
* Model constructor.
*
@@ -75,130 +85,336 @@
public TransactionTableModel() {
/* Services */
recordService = LimaServiceFactory.getInstance().getRecordService();
- transactionService = LimaServiceFactory.getInstance().getTransactionService();
+ transactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
}
- @Override
- public int getRowCount() {
- return model.getRowCount();
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ * TODO EC20100408 c'est pas evident a manipuler via une table
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+ List<Transaction> transactions =
+ transactionService.getAllTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod);
+
+ for (Transaction transaction : transactions) {
+ results.add(transaction);
+ // TODO EC20100408 warn about lazy exception here
+ // TODO EC20100408 warn about non ordonned transaction.getEntry()
+ results.addAll(transaction.getEntry());
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
}
@Override
public int getColumnCount() {
- return model.getColumnCount();
+ return 10;
}
@Override
- public Object getValueAt(int row, int column) {
- return model.getValueAt(getSortedRow(row), column);
- }
+ public Class<?> getColumnClass(int column) {
- @Override
- public Object getElementAt(int row) {
- return model.getElementAt(getSortedRow(row));
- }
+ Class<?> result = null;
- @Override
- public boolean isEditable() {
- return model.isEditable();
- }
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = Account.class;
+ break;
+ case 2:
+ result = EntryBook.class;
+ break;
+ case 3:
+ result = FinancialPeriod.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = Double.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = String.class;
+ break;
+ case 8:
+ result = String.class;
+ break;
+ case 9:
+ result = String.class;
+ break;
+ }
- @Override
- public Class<?> getColumnClass(int column) {
- return model.getColumnClass(column);
+ return result;
}
@Override
public String getColumnName(int column) {
- return model.getColumnName(column);
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.account");
+ break;
+ case 2:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 3:
+ result = _("lima.transaction.column.period");
+ break;
+ case 4:
+ result = _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 6:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.balance");
+ break;
+ case 8:
+ result = _("lima.transaction.column.description");
+ break;
+ case 9:
+ result = _("lima.transaction.column.document");
+ break;
+ }
+
+ return result;
}
@Override
- public boolean isCellEditable(int row, int column) {
- return model.isCellEditable(getSortedRow(row), column);
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ List<Object> datas = getDataList();
+ result = datas.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
}
@Override
- public void setValueAt(Object value, int row, int col) {
- row = getSortedRow(row);
- String response;
- /**
- * TransactionDTO
- */
- TransactionDTO trans = (TransactionDTO) getElementAt(row);
- TransactionDTO cloneTrans = DTOHelper.cloneTransaction(trans);
- switch (TransactionEnum.values()[col]) {
- case PERIOD:
- cloneTrans.setPeriod((PeriodDTO) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setPeriod(cloneTrans.getPeriod());
- trans.setStatus(cloneTrans.getStatus());
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ result = datas.get(row);
+
+ if (result instanceof Transaction) {
+ Transaction currentRow = (Transaction)result;
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = TransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = TransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
+ break;
+ case 8:
+ result = currentRow.getDescription();
+ break;
+ case 9:
+ result = currentRow.getVoucherRef();
+ break;
}
- break;
- case JOURNAL:
- cloneTrans.setJournal((JournalDTO) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setJournal(cloneTrans.getJournal());
- trans.setStatus(cloneTrans.getStatus());
+ }
+ else if (result instanceof Entry) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1:
+ result = currentEntry.getAccount(); // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 7:
+ result = null;
+ break;
+ case 8:
+ result = currentEntry.getDescription();
+ break;
+ case 9:
+ result = null;
+ break;
}
- break;
- case DATE:
- cloneTrans.setEntryDate((Date) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setEntryDate(cloneTrans.getEntryDate());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
- case DOCUMENT:
- cloneTrans.setVoucherRef((String) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setVoucherRef(cloneTrans.getVoucherRef());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
- case DESCRIPTION:
- cloneTrans.setDescription((String) value);
- response = transactionServ.updateTransaction(
- LimaContext.getContext().getDataManager().getStatus(),
- trans,
- cloneTrans);
- if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
- trans.setDescription(cloneTrans.getDescription());
- trans.setStatus(cloneTrans.getStatus());
- }
- break;
+ }
}
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
+
+ return result;
}
- /**
- *
- */
@Override
- public String addEmptyTransaction() {
- return model.addEmptyTransaction();
- }
+ public void setValueAt(Object value, int row, int column) {
- /**
- * @param trans
- */
- @Override
- public String removeTransaction(TransactionDTO trans) {
- return model.removeTransaction(trans);
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ // TODO EC-20100407 remove this ugly code
+ List<Object> datas = getDataList();
+ Object currentRow = datas.get(row);
+
+ if (currentRow instanceof Transaction) {
+ Transaction currentTransaction = (Transaction)currentRow;
+ switch (column) {
+ case 0:
+ currentTransaction.setTransactionDate((Date)value);
+ break;
+ /*case 1:
+ result = null; // account ?
+ break;
+ case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;
+ case 5:
+ result = TransactionHelper.getDebit(currentRow);
+ break;
+ case 6:
+ result = TransactionHelper.getCredit(currentRow);
+ break;
+ case 7:
+ result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow);
+ break;*/
+ case 8:
+ currentTransaction.setDescription((String)value);
+ break;
+ case 9:
+ currentTransaction.setVoucherRef((String)value);
+ break;
+ }
+
+ // notify service for modification
+ try {
+ transactionService.updateTransaction(currentTransaction);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //fireTableRowsUpdated(row, row); // to update what ???
+
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ /*case 0:
+ result = null; // date
+ break;*/
+ case 1:
+ currentEntry.setAccount((Account)value); // account ?
+ break;
+ /*case 2:
+ result = null; // entry book
+ break;
+ case 3:
+ result = null; //currentRow.getFinancialPeriod();
+ break;
+ case 4:
+ result = null; // what is status ? _("lima.transaction.column.status");
+ break;*/
+ case 5:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 6:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(false);
+ break;
+ /*case 7:
+ result = null;
+ break;*/
+ case 8:
+ currentEntry.setDescription((String)value);
+ break;
+ /*case 9:
+ result = null;
+ break;*/
+ }
+
+ //transactionService.updateEntry(currentEntry);
+ // fire modification of all transaction
+ // see here, table is not adapted :)
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No entry book selected skip table model update");
+ }
+ }
}
}
1
0