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
June 2013
- 3 participants
- 24 discussions
Author: athimel
Date: 2013-06-21 18:27:25 +0200 (Fri, 21 Jun 2013)
New Revision: 3685
Url: http://chorem.org/projects/lima/repository/revisions/3685
Log:
Remove presentation.rst as now merged in index.rst
Removed:
trunk/src/site/rst/presentation.rst
Deleted: trunk/src/site/rst/presentation.rst
===================================================================
--- trunk/src/site/rst/presentation.rst 2013-06-21 16:17:07 UTC (rev 3684)
+++ trunk/src/site/rst/presentation.rst 2013-06-21 16:27:25 UTC (rev 3685)
@@ -1,122 +0,0 @@
-.. -
-.. * #%L
-.. * Lima
-.. *
-.. * $Id$
-.. * $HeadURL$
-.. * %%
-.. * 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 3 of the
-.. * License, or (at your option) any later version.
-.. *
-.. * This program is distributed in the hope that it will be useful,
-.. * but WITHOUT ANY WARRANTY; without even the implied warranty of
-.. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.. * GNU General Public License for more details.
-.. *
-.. * You should have received a copy of the GNU General Public
-.. * License along with this program. If not, see
-.. * <http://www.gnu.org/licenses/gpl-3.0.html>.
-.. * #L%
-.. -
-
-====================
-Présentation de Lima
-====================
-
-Introduction
-------------
-
-Acronyme de Lutin Invoice Monitoring and Accounting, l’application de comptabilité
-Lima est un logiciel libre pensé pour être la plus ergonomique possible et facile
-d’accès à tout utilisateur quelque soit leur niveau en comptabilité : débutant
-comme confirmé.
-La particularité de Lima est qu’il s’agit d’un produit évolutif permettant de
-répondre aux besoins spécifiques de toute entreprise ou organisation, tout en
-garantissant le maintien des données comptables.
-
-Le logiciel est écrit en Java ce qui assure une compatibilité multiplateforme :
-Windows, Mac OS X, Linux. Il peut-être installé en fonctionnement client monoposte,
-ou en configuration client <–> serveur.
-Lors d'une installation en client serveur, le moteur de persistence de donnée est
-installé coté serveur, et l'interface est installée sur autant de poste client que
-désiré.
-
-Historique
-----------
-
-Ce projet est né d'un besoin d'adapter l'ergonomie d'OFBiz Neogia qui
-proposait un système de comptabilité générale.
-
-OFBiz Neogia n'étant pas un simple système de comptablitié a part entière, mais
-un ERP complet.
-Son interface n'était pas adaptée au besoin d'un logiciel de comptabilité indépendant.
-Code Lutin à donc décidé de remplacer cette interface tout en gardant la possibilité
-d'utiliser le moteur d'OFBiz Neogia. La première étape a donc été d’adapter une
-interface autonome avec la technologie de bibliothèque graphique Java Swing.
-
-L'interface de Lima est indépendant du moteur gérant la comptabilité. Il a donc
-été décidé de développer un moteur propre à Code Lutin : Callao.
-
-En 2010, l'application a été réécrite en majeur partie pour d'une part répondre le
-plus fidèlement aux normes comptables, et d'autre part correspondre aux normes de
-programmation de Code Lutin. Lima s'appuie notamment sur les projets internes Topia,
-EuGene et JAXX.
-
-Architecture
-------------
-
-Lima est un projet MAVEN multi-module, il est en réalité composé de trois projets Java :
-lima-business, lima-callao, lima-swing.
-
-Lima-callao
-~~~~~~~~~~~
-
-Ce projet permet de définir les entités appelées objets (données informatiques
-regroupant les principales caractéristiques des éléments du monde réel) nécessaires
-au métier du logiciel de comptabilité. Toutes les classes java correspondantes
-sont générées à l’aide d’un modèle UML (langage de modélisation unifié). Ce modèle
-est contenu dans un seul fichier au format zargo éditable avec le logiciel Argouml.
-Ce principe permet d’utiliser avantageusement la langue UML et ces normes. L’ensemble
-du schéma est ensuite généré via les projets internes à Code Lutin :
-EUGene et ToPIA grâce à Maven.
-Outre la définition des entités, le projet lima-callao permet via ToPIA- persistence
-de définir les méthodes associées à la base de données pour le stockage de ces
-entités : ajout, modification, suppression.
-
-lima-business
-~~~~~~~~~~~~~
-
-Ce projet permet d’implémenter/de définir le métier en utilisant des entités issues
-du projet lima-callao. Des services EJB qui ont un rôle précis y sont programmés.
-Ce sont ces services qui sont appelés par l’utilisateur lorsqu’il appelle des
-fonctions. Les services sont programmés avec un système de session afin de pouvoir
-être exécuté en mode client serveur. En effet, les services sont exécutés côté
-serveur et ainsi le client appelle les services en ouvrant une transaction.
-Il existe une multitude de services relatifs aux besoins du métier :
-service des comptes, service des journaux, service des périodes fiscales,
-service des périodes financières, service des entrées, services des rapports, etc...
-On peut ajouter, modifier et supprimer des services selon les besoins de l'activité.
-
-lima-swing
-~~~~~~~~~~
-
-Il s’agit du projet qui permet d’exécuter l’UI (interface utilisateur) de LIMA.
-Le design de l’application y est défini : fenêtres, boutons, tableaux,...
-L’interface est programmée selon la méthode de conception MVC (modèle-vue-
-contrôleur). Le modèle est le couple lima-callao - lima-business. La partie
-vue-contrôleur se trouve donc dans lima-swing. La partie vue, ce qui s’affiche à
-l’utilisateur, est programmée en JAXX. Toutes les actions des éléments de la vue
-(fenêtres, boutons, menus, tableaux) sont définies dans le contrôleur. Le
-contrôleur est implémenté sous forme de classes Java qui s’occupent d’afficher
-les bons messages, d’appeler les services correspondants, et de retourner les
-données, par exemple : le remplissage d’un tableau.
-
-Licence
--------
-
-Lima est développé sous licence GPL :
-GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007
\ No newline at end of file
1
0
21 Jun '13
Author: athimel
Date: 2013-06-21 18:17:07 +0200 (Fri, 21 Jun 2013)
New Revision: 3684
Url: http://chorem.org/projects/lima/repository/revisions/3684
Log:
Mise ?\195?\160 jour de la documentation
Modified:
trunk/src/site/rst/assistant.rst
trunk/src/site/rst/callao/callao.rst
trunk/src/site/rst/callao/contact.rst
trunk/src/site/rst/callao/developpement.rst
trunk/src/site/rst/callao/index.rst
trunk/src/site/rst/callao/lexique.rst
trunk/src/site/rst/callao/news.rst
trunk/src/site/rst/callao/roadmap.rst
trunk/src/site/rst/callao/usecases.rst
trunk/src/site/rst/contact.rst
trunk/src/site/rst/devel/glossary.rst
trunk/src/site/rst/devel/modificationarchitecture.rst
trunk/src/site/rst/devel/openejb.rst
trunk/src/site/rst/devel/server.rst
trunk/src/site/rst/features.rst
trunk/src/site/rst/importexport.rst
trunk/src/site/rst/index.rst
trunk/src/site/rst/lexique.rst
trunk/src/site/rst/presentation.rst
trunk/src/site/rst/rapports.rst
trunk/src/site/site_fr.xml
Modified: trunk/src/site/rst/assistant.rst
===================================================================
--- trunk/src/site/rst/assistant.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/assistant.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,11 +27,12 @@
Assistant
=========
-Au premier démarrage de LIMA un assistant vous guide pour créer votre comptabilité.
-Il est également possible de charger une précédente sauvegarde de LIMA au format CSV.
+Au premier démarrage de Lima un assistant vous guide pour créer votre comptabilité.
+Il est également possible de charger une précédente sauvegarde de Lima au format CSV.
Dans le cas par exemple d'une réinstallation du logiciel.
Ou de fermer l'assistant pour créer sa comptabilité sans l'assistant.
+
Les différentes étapes de l'assistant
-------------------------------------
@@ -40,7 +41,7 @@
Vous pouvez renseigner les coordonnées de votre entreprise dans les champs
correspondants. Ces informations permettent de personnalisé vos documents lors
-de l'impression des rapports PDF ou HTML : journaux, grand-livre, balance, …
+de l'impression des rapports PDF ou HTML : journaux, grand-livre, balance, ...
Ces coordonnées sont modifiables par la suite dans le menu Fichier -> Identité
.. image:: screens/lima_open_identity.png
@@ -49,7 +50,7 @@
Plan comptable
~~~~~~~~~~~~~~
-Par défaut LIMA propose les trois plans comptables de la norme française :
+Par défaut Lima propose les trois plans comptables de la norme française :
- abrégé ;
- de base ;
@@ -59,15 +60,13 @@
Ce plan comptable est modifiable à volonté : ajout, modification, suppression de compte.
Menu Structure -> Plan comptable
-Il est également possible d'importer un plan comptable au format LIMA CSV, ou provenant
+Il est également possible d'importer un plan comptable au format Lima CSV, ou provenant
du logiciel EBP. Pour plus d'information sur le format d'import/export EBP.
-Cf. (`IMPORT-EXPORT`_)
+(Cf. `IMPORT-EXPORT`_)
-.. _`IMPORT-EXPORT`: ../importexport.rst
-
Lors de l'import d'un plan comptable abregé, de base, ou développé. Le générateur
de bilan / compte de résultat, charge le plan de passage des compte au poste
-correspondant (appelé BCR dans lima). Pour un import externe, le plan BCR chargé
+correspondant (appelé BCR dans Lima). Pour un import externe, le plan BCR chargé
par défaut est celui de base.
.. image:: screens/lima_open_account.png
@@ -93,4 +92,10 @@
Séléctionner la date et fin du nouvel exercice, une fois crée un exercice ne
peut-être supprimé ou sa date modifiée.
-.. image:: screens/lima_open_fiscalperiod.png
\ No newline at end of file
+.. image:: screens/lima_open_fiscalperiod.png
+
+
+
+.. _`IMPORT-EXPORT`: ../importexport.rst
+
+
Modified: trunk/src/site/rst/callao/callao.rst
===================================================================
--- trunk/src/site/rst/callao/callao.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/callao.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -24,7 +24,7 @@
.. -
======================
-Présentation de CALLAO
+Présentation de Callao
======================
(Computing Active Layer for Lutin's Accounting Organization)
@@ -52,33 +52,33 @@
----------------
Issu du projet Chorem_,
-CALLAO_ est un moteur de comptabilité `libre de droits`_ respectant les conventions
+Callao_ est un moteur de comptabilité `libre de droits`_ respectant les conventions
ainsi que les normes comptables imposées aux entreprises par la législation
française.
-Bien que créé pour fonctionner avec l'interface graphique LIMA_, CALLAO_ a été
+Bien que créé pour fonctionner avec l'interface graphique Lima_, Callao_ a été
conçu pour pouvoir être utilisé par différentes interfaces graphiques. Il est
donc possible de créer une interface Web de comptabilité reposant sur le moteur
-CALLAO_
+Callao_
``3. Architecture``
-------------------
-Les utilisateurs de l'interface utilisateur LIMA_ effectuaient jusqu'alors cette gestion
-des données gràce au moteur de comptabilité d'OFBiz-Neogia. CALLAO_ doit pouvoir se
-substituer à ce moteur mais sans nécessité une refonte de LIMA_ afin de laisser aux
+Les utilisateurs de l'interface utilisateur Lima_ effectuaient jusqu'alors cette gestion
+des données gràce au moteur de comptabilité d'OFBiz-Neogia. Callao_ doit pouvoir se
+substituer à ce moteur mais sans nécessité une refonte de Lima_ afin de laisser aux
utilisateurs de ce dernier le choix du moteur de comptabilité qu'ils
utilisent ou de faciliter les migrations d'un moteur à l'autre [#]_.
Ainsi notre couche de DTO se substituera à toute la partie exterieure à
-l'interface de LIMA_ comme suit :
+l'interface de Lima_ comme suit :
.. image:: resources/schemas/schema-architecture.png
On peut voir que le DTO utilise le modèle définit par le design pattern du même
-nom pour décrire le moteur CALLAO de l’application comptable finale.
+nom pour décrire le moteur Callao de l’application comptable finale.
L’architecture est elle même composée de deux couches : une de persistance pour
la gestion des données, et une autre métier pour la gestion des flux entre la
persistance et les interfaces d’entrées/sorties véhiculées par des objets
@@ -90,5 +90,5 @@
.. _`libre de droits`: licence.html
.. [#] A cet effet des fonctions d'import et d'export seront mises en place.
.. _ChoreM: http://chorem.org/
-.. _LIMA: http://maven-site.chorem.org/lima/
-.. _CALLAO: callao.html
+.. _Lima: http://maven-site.chorem.org/lima/
+.. _Callao: callao.html
Modified: trunk/src/site/rst/callao/contact.rst
===================================================================
--- trunk/src/site/rst/callao/contact.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/contact.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -30,9 +30,9 @@
Pour contacter les membres du projet ou suivre son évolution, vous pouvez
utiliser les listes de diffusion du projet :
-- Liste utilisateurs : (..USERS_) Liste de discussions des utilisateurs de CALLAO_
-- Liste développeurs : (..DEVEL_) Liste de discussions des développeurs de CALLAO_
-- Liste des commits : (..COMMITS_) Liste des modifications du code de CALLAO_
+- Liste utilisateurs : (..USERS_) Liste de discussions des utilisateurs de Callao_
+- Liste développeurs : (..DEVEL_) Liste de discussions des développeurs de Callao_
+- Liste des commits : (..COMMITS_) Liste des modifications du code de Callao_
=======
Support
@@ -97,4 +97,4 @@
.. _USERS: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-users
.. _DEVEL: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-devel
.. _COMMITS: http://list.chorem.org/cgi-bin/mailman/listinfo/callao-commits
-.. _CALLAO: http://maven-site.chorem.org/callao/
\ No newline at end of file
+.. _Callao: http://maven-site.chorem.org/callao/
\ No newline at end of file
Modified: trunk/src/site/rst/callao/developpement.rst
===================================================================
--- trunk/src/site/rst/callao/developpement.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/developpement.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -49,15 +49,15 @@
''callao-entity''. Le modèle quant à lui est stocké dans un fichier ''zargo'',
toujours dans le module ''callao-entity'' et peut être consulté à l'aide
d' ArgoUML_ .
-LIMA propose un certain nombre de services disponibles via des interfaces, le but
-initial de CALLAO et de pouvoir implémenter ces services de manière locale ou
+Lima propose un certain nombre de services disponibles via des interfaces, le but
+initial de Callao et de pouvoir implémenter ces services de manière locale ou
distante. L'utilisation de Web Services, comme mis en place pour effectuer la
-communication entre LIMA et OFBiz constitue la solution à cette problématique.
+communication entre Lima et OFBiz constitue la solution à cette problématique.
Néanmoins, pour le moment, les implémentation s'effectuent uniquement de manière
-locale. CALLAO s'occupe uniquement d'implémenter les interfaces de LIMA situées
+locale. Callao s'occupe uniquement d'implémenter les interfaces de Lima situées
dans le module ''lima-service'' de manière locale, et les échanges de Web Services
n'ont pas encore été mis en place.
@@ -67,9 +67,9 @@
par services a tout de même été effectuée via l'utilisation de ToPIA-soa_ . A ce
titre, un modèle des services est présent en parallèle du modèle entité dans le
module ''callao-entity''. Ce modèle décrit l'ensemble des services fournissant
-l'application des règles métiers définies pour l'application CALLAO. Couplé à
+l'application des règles métiers définies pour l'application Callao. Couplé à
ToPIA-soa_ , il permet la génération de cette couche et de ses interfaces associées.
-Cependant une problèmatique de connection aux services de LIMA reste encore non
+Cependant une problèmatique de connection aux services de Lima reste encore non
résolue.
@@ -84,19 +84,19 @@
L'implémentation des interfaces
-------------------------------
-Les implémentations des interfaces services de LIMA dans CALLAO représentent les
+Les implémentations des interfaces services de Lima dans Callao représentent les
fragments de code source de l'application qui vont définir les règles métiers.
L'ensemble de ce code source se situent dans le module ''callao-service'' et
s'occupe à l'heure actuelle d'implémenter uniquement localement les interfaces
-services de LIMA.
+services de Lima.
L'état d'avancement actuel de ces implémentations est inachevé. En effet, il
reste encore des améliorations à fournir à celles effectuées et à compléter
celles des classes ''Period'' et ''Journal'' pour pouvoir au moins répondre aux
-interfaces services existantes de LIMA. De plus, notre modèle de services ne
-reflétant pas entièrement celui de LIMA, il est fort à penser que LIMA aura à
+interfaces services existantes de Lima. De plus, notre modèle de services ne
+reflétant pas entièrement celui de Lima, il est fort à penser que Lima aura à
intégrer de nouvelles fonctionnalités notamment au niveau de l'intégration à
Chorem, de la gestion des Imports Exports de sauvegardes et de la génération des
états comptables.
Modified: trunk/src/site/rst/callao/index.rst
===================================================================
--- trunk/src/site/rst/callao/index.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/index.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,13 +27,13 @@
Callao
==================
-Issu du projet Chorem_, et créé pour fonctionner en collaboration avec LIMA_,
-CALLAO_ est *un moteur de comptabilité générale* respectant les conventions
+Issu du projet Chorem_, et créé pour fonctionner en collaboration avec Lima_,
+Callao_ est *un moteur de comptabilité générale* respectant les conventions
ainsi que normes imposées par la législation française aux entreprises.
Ce rôle était jusqu'à alors remplis via le moteur de comptabilité d'OfBiz-Neogia,
-CALLAO_ doit pouvoir se substituer à ce moteur mais sans refondre LIMA_ afin de
-laisser aux utilisateurs de LIMA_ le choix du moteur de comptabilité qu'ils
+Callao_ doit pouvoir se substituer à ce moteur mais sans refondre Lima_ afin de
+laisser aux utilisateurs de Lima_ le choix du moteur de comptabilité qu'ils
utilisent ou de faciliter les migrations d'un moteur à l'autre [#]_.
@@ -41,5 +41,5 @@
.. [#] A cet effet des fonctions d'import et d'export seront mises en place.
.. _ChoreM: http://chorem.labs.libre-entreprise.org
-.. _LIMA: http://maven-site.chorem.org/lima
-.. _CALLAO: http://maven-site.chorem.org/callao
+.. _Lima: http://maven-site.chorem.org/lima
+.. _Callao: http://maven-site.chorem.org/callao
Modified: trunk/src/site/rst/callao/lexique.rst
===================================================================
--- trunk/src/site/rst/callao/lexique.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/lexique.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -28,7 +28,7 @@
==========================
Nous définirons ici les quelques notions de comptabilité d'entreprise nécessaires
-à l'appréhension du fonctionnement de CALLAO.
+à l'appréhension du fonctionnement de Callao.
``Actif :``
-----------
@@ -130,7 +130,7 @@
l'opération inverse en première opération du nouvel exercice. On appelle cette
opération un report à nouveau.
Dans notre cas, comme dans tous les logiciels de comptabilité, le report à
-nouveau ne sera que partiellement effectué. Si CALLAO reportera bien le solde
+nouveau ne sera que partiellement effectué. Si Callao reportera bien le solde
des différents comptes sur l'exercice suivant, nous ne solderons pas l'exercice
précédent.
Modified: trunk/src/site/rst/callao/news.rst
===================================================================
--- trunk/src/site/rst/callao/news.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/news.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,7 +27,7 @@
News
====
-Quoi de neuf sur le projet CALLAO ?
+Quoi de neuf sur le projet Callao ?
Mise en Ligne du site
=====================
Modified: trunk/src/site/rst/callao/roadmap.rst
===================================================================
--- trunk/src/site/rst/callao/roadmap.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/roadmap.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -28,7 +28,7 @@
=======
+-----------------------------------------------------------------------------------------+
-| **A venir** |
+| **À venir** |
+-------------------+---------------------------------------------------------------------+
| *Release* | Release d'une version packagée exécutable comprenant Lima et Callao |
+-------------------+---------------------------------------------------------------------+
Modified: trunk/src/site/rst/callao/usecases.rst
===================================================================
--- trunk/src/site/rst/callao/usecases.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/callao/usecases.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,7 +27,7 @@
Les Cas d'Utilisation
=====================
-| Cette section présente les cas d'utilisation du moteur CALLAO couplé à LIMA.
+| Cette section présente les cas d'utilisation du moteur Callao couplé à Lima.
``Cas d'utilisation``
=====================
@@ -46,7 +46,7 @@
- Gérer Comptes : Ajout et modification des comptes.
- Gérer Fichiers : Import et export des données.
- Générer Etats : Génération d'états comptables sous forme imprimable, ainsi que des journaux et du grand livre.
-- Synchronier Chorem : Cette fonctionnalité ne correspond pas vraiment à un cas d'utilisation inhérent à LIMA-CALLAO, mais plus à une possibilité d'accès à certaines données qui doit être prévue pour une synchronisation entre CALLAO et Chorem via un logiciel tiers (qui est néanmoins détaillé ici).
+- Synchronier Chorem : Cette fonctionnalité ne correspond pas vraiment à un cas d'utilisation inhérent à Lima-Callao, mais plus à une possibilité d'accès à certaines données qui doit être prévue pour une synchronisation entre Callao et Chorem via un logiciel tiers (qui est néanmoins détaillé ici).
``Gérer Ecritures``
-------------------
Modified: trunk/src/site/rst/contact.rst
===================================================================
--- trunk/src/site/rst/contact.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/contact.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -23,44 +23,50 @@
.. * #L%
.. -
-============
-Contact list
-============
+==============
+Contactez-nous
+==============
Pour contacter les membres du projet ou suivre son évolution, vous pouvez
utiliser les listes de diffusion du projet :
-Liste utilisateurs : (..USERS_) Liste de discussions des utilisateurs de LIMA
-Liste développeurs : (..DEVEL_) Liste de discussions des développeurs de LIMA
-Liste des commits : (..COMMITS_) Liste des modifications du code de LIMA
+ * `Liste utilisateurs`_ : Liste de discussions pour les utilisateurs de Lima
+ * `Liste développeurs`_ : Liste de discussions autour du développement de Lima
+ * `Liste des commits`_ : Liste des modifications du code de Lima
+Il est préférable de vous inscrire à la liste qui vous intéresse pour échanger
+sur vos questions, mais ce n'est pas obligatoire (vous pouvez simplement envoyer
+un email à la(es) liste(s)).
+
+
Support
~~~~~~~
-
-Code Lutin est une société de services en logiciels libres spécialisée dans les
+`Code Lutin`_ est une `Société de Services en Logiciels Libres`_ spécialisée dans les
technologies Java/J2EE, XML, UML. Son offre s'étend à l'audit, au conseil, à la
-tierce maintenance applicative et à la formation.
+Tierce Maintenance Applicative et à la formation.
-SARL Code Lutin
-12, avenue Jules Verne
-44230 Saint-Sébastien-Sur-Loire
-France
+ SARL Code Lutin
-Contact : Benjamin Poussin, gérant et chef de projet.
+ 12, avenue Jules Verne
-Tél : 02 40 50 29 28
+ 44230 Saint-Sébastien-Sur-Loire
+ France
-Code Lutin participe activement au mouvement du logiciel libre et fait partie du
-consortium ObjectWeb, d'Alliance Libre et du réseau Libre-entreprise
+ Tél : 02 40 50 29 28
-Plus_.
+Code Lutin participe activement au mouvement du Logiciel Libre et fait partie du
+consortium ObjectWeb, d'`Alliance Libre`_ et du réseau `Libre-entreprise`_.
-.. _Plus: http://www.codelutin.com
-.. _USERS: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-users
-.. _DEVEL: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-devel
-.. _COMMITS: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-commits
-.. _CALLAO: http://maven-site.chorem.org/lima/
+.. _`Liste utilisateurs`: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-users
+.. _`Liste développeurs`: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-devel
+.. _`Liste des commits`: http://list.chorem.org/cgi-bin/mailman/listinfo/lima-commits
+.. _`Code Lutin`: http://www.codelutin.com
+.. _`Société de Services en Logiciels Libres`: http://fr.wikipedia.org/wiki/Soci%C3%A9t%C3%A9_de_services_en_logiciels_lib…
+.. _`Alliance Libre`: http://www.alliance-libre.org/
+.. _`Libre-entreprise`: http://www.libre-entreprise.org
+
+
Modified: trunk/src/site/rst/devel/glossary.rst
===================================================================
--- trunk/src/site/rst/devel/glossary.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/devel/glossary.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,8 +27,8 @@
Lexique des objets manipulés dans Lima
======================================
-Ce lexique vise à clarifier les termes utilisé dans les objets de Lima (entités
-beans...) par rapport à leur traduction francaise.
+Ce lexique vise à clarifier les termes utilisés dans les objets de Lima (entités
+beans...) par rapport à leur traduction française.
+------------------+--------------------------+-------------------------------+
| Anglais | Français | Description |
@@ -48,4 +48,5 @@
| Balance trial | Balance | |
+------------------+--------------------------+-------------------------------+
| Balance Sheet | Bilan | |
-+------------------+--------------------------+-------------------------------+
\ No newline at end of file
++------------------+--------------------------+-------------------------------+
+
Modified: trunk/src/site/rst/devel/modificationarchitecture.rst
===================================================================
--- trunk/src/site/rst/devel/modificationarchitecture.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/devel/modificationarchitecture.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -24,43 +24,48 @@
.. -
=============================================
-Modification de l'architecture de LIMA/CALLAO
+Modification de l'architecture de Lima/Callao
=============================================
-Voici le résumé de la modification de l'architecture de LIMA/CALLAO.
+Voici le résumé de la modification de l'architecture de Lima/Callao.
Points majeurs :
- - Intégration de callao dans lima en tant que moteur par défaut
- - Conservation de la possibilité de changer de moteur ou d'interface
- - Suppression des DTO (utilisation des interfaces des entités metier
- générées)
+- Intégration de callao dans Lima en tant que moteur par défaut ;
+- Conservation de la possibilité de changer de moteur ou d'interface ;
+- Suppression des DTO (utilisation des interfaces des entités métier générées).
+
Nouvelle architecture
---------------------
Trois couches (voir schéma) :
- - UI
- - Métier (indépendant de ToPIA)
- - Persistance (généré sur ToPIA)
+- UI ;
+- Métier (indépendant de ToPIA) ;
+- Persistance (généré sur ToPIA).
+
UI
~~
+
Dans un premier temps, une interface de type Swing.
-Mais une autre interface pourra être utilisé par la suite.
+Mais une autre interface pourra être utilisée par la suite.
Pas de DTO manipulé dans l'UI, utilisation des interfaces des beans métier
(sans utiliser de spécificités de TopiaEntity).
L'interface graphique contiendrait les fonctionnalités suivantes :
- - import/export des données
+- import/export des données.
+
+
Métier
~~~~~~
+
Se manipule via les interfaces des DAO.
L'implémentation des DAO étant sur ToPIA.
-Problèmes lié au transaction. L'utilisation du TopiaContext n'est
+Problèmes liés aux transaction. L'utilisation du TopiaContext n'est
pas envisageable et rendrait trop dépendant de Topia.
Solution 1 : JTA
@@ -78,14 +83,16 @@
code annexe pour wrapper sur les DAO.
Le métier contiendrait également les fonctionnalités métier suivantes:
- - les règles métier / cohérence de comptabilité (???)
- - génération des bilan
- - génération des impressions
+- les règles métier / cohérence de comptabilité (???) ;
+- génération des bilan ;
+- génération des impressions.
Persistance
~~~~~~~~~~~
-Pour callao : génération entièrement sur ToPIA.
+Pour Callao : génération entièrement sur ToPIA.
+
Pour ofbiz, SAP : nouvelle implémentation sur les interfaces des DAO.
-Les modules pour ofbiz (etc...) dépendront donc de la persistance
-générées.
+Les modules pour OFBiz (etc...) dépendront donc de la persistance
+générée.
+
Modified: trunk/src/site/rst/devel/openejb.rst
===================================================================
--- trunk/src/site/rst/devel/openejb.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/devel/openejb.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,6 +27,7 @@
OpenEJB
=======
+
Définition des EJB
------------------
@@ -36,6 +37,7 @@
Point à verifier pour les annotations @Webservice et @Local, @Remote
sur les interfaces.
+
Embedded mode
-------------
@@ -117,4 +119,4 @@
Les jar "javaee-api-5.0-3-SNAPSHOT.jar" et "openejb-client-3.1.3-SNAPSHOT.jar"
doivent être EXACTEMENT les mêmes entre le serveur et le client (sinon
-une NPE exception survient tout le temps).
\ No newline at end of file
+une NPE exception survient tout le temps).
Modified: trunk/src/site/rst/devel/server.rst
===================================================================
--- trunk/src/site/rst/devel/server.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/devel/server.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -33,11 +33,14 @@
Télécharger et lancer le module serveur de lima :
http://www.chorem.org/projects/lima/files
+
Client
------
Configurer le client pour se connecter au serveur via le fichier de
-configuration : $HOME/.config/lima-config.properties::
+configuration : ``$HOME/.config/lima-config.properties``
java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
+
java.naming.provider.url=ejbd://192.168.99.9:4201
+
Modified: trunk/src/site/rst/features.rst
===================================================================
--- trunk/src/site/rst/features.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/features.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -40,7 +40,7 @@
.. image:: screens/lima_charts_entrybooks.png
-- Exercices
+- Éxercices
.. image:: screens/lima_charts_fiscalperiod.png
@@ -80,7 +80,7 @@
Rapports
~~~~~~~~
-Permet de visualiser les documents usuelles de la comptabilité :
+Permet de visualiser les documents usuels de la comptabilité :
- Journal
@@ -107,13 +107,14 @@
.. image:: screens/lima_reports_vat.png
-Les documents sont atteignables par les menu de LIMA et via un site internet embarqué.
+Les documents sont atteignables par les menu de Lima et via un site internet embarqué.
Import / Export
~~~~~~~~~~~~~~~
-Toutes les données de LIMA sont exportables et importables à volontés au format CSV.
-L'utilisation de ce format permet d'être exploité par un tableur.
+Toutes les données de Lima sont exportables et importables à volonté au format CSV.
+L'utilisation de ce format permet l'exploitation des données dans un tableur.
-Actuellement LIMA permet l'import et l'export pour EBP. Il est possible d'ajouté
+Actuellement Lima permet l'import et l'export pour EBP. Il est possible d'ajouter
à la demande l'import / export pour des formats de fichiers d'autres logiciels.
+
Modified: trunk/src/site/rst/importexport.rst
===================================================================
--- trunk/src/site/rst/importexport.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/importexport.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -27,21 +27,22 @@
Import / Export
===============
-LIMA supporte actuellement deux formats d'import export.
-Le CSV avec un modèle de donnée spécifique à LIMA ; et le format EBP.
+Lima supporte actuellement deux formats d'import export :
+- Le CSV avec un modèle de donnée spécifique à Lima ;
+- et le format EBP.
--------------------------
+
Format CSV
--------------------------
+----------
-La comptabilité de LIMA peut-être sauvegarder en intégralité via la fonction
+La comptabilité de Lima peut-être sauvegardée en intégralité via la fonction
Import -> Tout. Ou seulement le plan des comptes, le plan BCR ou les journaux.
.. image:: screens/lima_import_limaall.png
+-----------------------------------------------------------------------------------------------+
-| Structure des champs correspondant à chaque entité au format CSV LIMA |
+| Structure des champs correspondant à chaque entité au format CSV Lima |
+================+==============================================================================+
| Compte | "ACCN";"AccountNumber";"Label";"ThirdParty";"MasterAccount";"GeneralLedger" |
+----------------+------------------------------------------------------------------------------+
@@ -77,15 +78,11 @@
en respectant bien le système Transaction / Entrées.
-Une sauvegarde de démonstration au format CSV est (..disponible_) au téléchargement.
+Une sauvegarde de démonstration au format CSV est `disponible au téléchargement`_.
-.. _disponible: http://chorem.org/projects/lima/files
-
-
--------------------------
Format EBP
--------------------------
+----------
La procédure est identique pour l'export des comptes ou des écritures.
@@ -126,4 +123,7 @@
L'export est effectué !
-
+
+.. _`disponible au téléchargement`: http://chorem.org/projects/lima/files
+
+
Modified: trunk/src/site/rst/index.rst
===================================================================
--- trunk/src/site/rst/index.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/index.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -24,15 +24,113 @@
.. -
============
-Introduction
+Présentation
============
.. image:: extras/puzzle_icon.png
-Acronyme de Lutin Invoice Monitoring and Accounting, l'application de comptabilité
-LIMA est un logiciel libre pensé pour être la plus ergonomique possible et facile
-d'accès à tout utilisateur quelque soit leur niveau en comptabilité : débutant
-comme confirmé.
-La particularité de LIMA est qu'il s'agit d'un produit évolutif permettant de
-répondre aux besoins spécifiques de toute entreprise ou organisation, tout en
-garantissant le maintien des données comptables.
+Acronyme de *Lutin Invoice Monitoring and Accounting*, l'application de comptabilité *Lima* est un logiciel libre pensé
+pour être le plus ergonomique possible et facile d'accès à tout utilisateur, quelque soit son niveau en comptabilité :
+débutant comme confirmé.
+La particularité de Lima est qu'il s'agit d'un produit évolutif permettant de répondre aux besoins spécifiques de toute
+entreprise ou organisation, tout en garantissant le maintien des données comptables.
+
+Le logiciel est écrit en Java ce qui assure une compatibilité multiplateforme :
+Windows, Mac OS X, Linux. Il peut-être installé en fonctionnement client monoposte,
+ou en configuration client <–> serveur.
+Lors d'une installation en client serveur, le moteur de persistence de données est
+installé coté serveur, et l'interface est installée sur autant de postes client que
+désiré.
+
+Historique
+----------
+
+Lima était initialiement basé sur `OFBiz Néogia`_ qui proposait un système de
+comptabilité générale.
+
+Cependant, `OFBiz Néogia`_ n'est pas seulement un système de comptablitié, mais
+un ERP complet.
+Son interface n'étant pas adaptée au besoin d'un logiciel de comptabilité indépendant,
+Code Lutin a donc décidé de remplacer cette interface tout en gardant la possibilité
+d'utiliser le moteur d'OFBiz Neogia. La première étape a donc été d'adapter une
+interface autonome avec la technologie de bibliothèque graphique *Java Swing*.
+
+L'interface de Lima est indépendante du moteur gérant la comptabilité. Il a donc
+été décidé de développer un moteur propre à Code Lutin : Callao.
+
+En 2010, l'application a été réécrite en majeur partie pour - d'une part - répondre le
+plus fidèlement aux normes comptables, et - d'autre part - correspondre aux normes de
+programmation de Code Lutin. Lima s'appuie notamment sur les projets
+`Topia`_, `EUGene`_ et `JAXX`_.
+
+Architecture
+------------
+
+Lima est un projet `Maven`_ multi-module, il est en
+réalité composé de trois projets Java :
+
+ * lima-business ;
+ * lima-callao ;
+ * lima-swing.
+
+Lima-callao
+~~~~~~~~~~~
+
+Ce projet permet de définir les entités - appelées objets (données informatiques
+regroupant les principales caractéristiques des éléments du monde réel) - nécessaires
+au métier du logiciel de comptabilité. Toutes les classes java correspondantes
+sont générées à l'aide d'un modèle `UML`_ (Unified Modeling Language). Ce modèle
+est contenu dans un seul fichier au format *zargo* éditable avec le logiciel `ArgoUML`_.
+Ce principe permet d'utiliser avantageusement la langue UML et ses normes. L'ensemble
+du schéma est ensuite généré via les projets internes à Code Lutin :
+`EUGene`_ et `Topia`_ grâce à Maven.
+Outre la définition des entités, le projet *lima-callao* permet - via `Topia-persistence`_ -
+de définir les méthodes associées à la base de données pour le stockage de ces
+entités : ajout, modification, suppression.
+
+lima-business
+~~~~~~~~~~~~~
+
+Ce projet permet d'implémenter/de définir le métier en utilisant des entités issues
+du projet *lima-callao*. Des services EJB qui ont un rôle précis y sont disponibles
+et appelés par l'utilisateur lorsqu'il appelle des
+fonctions. Les services sont programmés avec un système de session afin de pouvoir
+être exécutés en mode client serveur. En effet, les services sont exécutés côté
+serveur et ainsi le client appelle les services en ouvrant une transaction.
+Il existe une multitude de services relatifs aux besoins du métier :
+service des comptes, service des journaux, service des périodes fiscales,
+service des périodes financières, service des entrées, services des rapports, etc...
+On peut ajouter, modifier et supprimer des services selon les besoins de l'activité.
+
+lima-swing
+~~~~~~~~~~
+
+Il s'agit du projet qui permet d'exécuter l'UI (interface utilisateur) de Lima.
+Le design de l'application y est défini : fenêtres, boutons, tableaux,...
+L'interface est programmée selon la méthode de conception MVC (Modèle-Vue-
+Contrôleur). Le modèle est le couple *lima-callao - lima-business*. La partie
+vue-contrôleur se trouve donc dans *lima-swing*. La partie vue, ce qui s'affiche à
+l'utilisateur, est programmée en `JAXX`_. Toutes les actions des éléments de la vue
+(fenêtres, boutons, menus, tableaux) sont définies dans le contrôleur. Le
+contrôleur est implémenté sous forme de classes Java qui s'occupent d'afficher
+les bons messages, d'appeler les services correspondants, et de retourner les
+données, par exemple : le remplissage d'un tableau.
+
+Licence
+-------
+
+Lima est développé sous licence GPL :
+
+ GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007
+
+
+.. _`OFBiz Néogia`: http://neogia.org/wiki/index.php/Accueil
+.. _`Topia`: http://maven-site.nuiton.org/topia/
+.. _`Topia-persistence`: http://maven-site.nuiton.org/topia/topia-persistence/index.html
+.. _`EUGene`: http://maven-site.nuiton.org/eugene/
+.. _`JAXX`: http://maven-site.nuiton.org/jaxx/
+.. _`Maven`: http://maven.apache.org/
+.. _`UML`: http://fr.wikipedia.org/wiki/Unified_Modeling_Language
+.. _`ArgoUML`: http://argouml.tigris.org/
+
+
Modified: trunk/src/site/rst/lexique.rst
===================================================================
--- trunk/src/site/rst/lexique.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/lexique.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -28,13 +28,13 @@
==========================
Nous définirons ici les quelques notions de comptabilité d'entreprise nécessaires
-à l'appréhension du fonctionnement de LIMA.
+à l'appréhension du fonctionnement de Lima.
Transaction
~~~~~~~~~~~
-Ce que nous appelons ici transaction désigne une opération comptable,
+Ce que nous appelons ici *transaction* désigne une opération comptable,
c'est-à-dire l'inscription au journal, à une date donnée, d'un certain nombre
d'écritures au débit et au crédit. Pour que l'opération soit équilibrée, il faut
que la somme des écritures au crédit soit égale à celle des écritures au débit.
@@ -42,19 +42,21 @@
Une transaction peut, par exemple, représenter une opération d'achat à un
fournisseur (Crédit du compte de "Achat", débit du compte "Fournisseur"), une
-opération de vente à un client...
+opération de vente à un client, ...
Historiquement, une transaction est inscrite au Journal (ou, pour la comptabilité
multi-journaux au journal concerné : journal des ventes, journal des achats...)
et ses écritures sont reportées au Grand Livre.
-Ecriture
+
+Écriture
~~~~~~~~
Une écriture comptable représente tout simplement le débit ou le crédit d'un
compte. Elles sont passées par compte dans le Grand Livre, et rassemblées par
opérations dans le Journal.
+
Compte
~~~~~~
@@ -78,7 +80,8 @@
passées respectivement au débit et au crédit du compte. Cela leur donne une forme
de T, ce qui a donné naissance à l'appellation de compte en T.
-Exercice
+
+Éxercice
~~~~~~~~
Un exercice est une période, généralement de un an, pour laquelle l'entreprise
@@ -88,36 +91,41 @@
exercice, une fois fini, doit être clôturé, ce qui interdit alors toutes
modifications sur les informations comptables concernant cet exercice.
+
Journal
~~~~~~~
Historiquement, le journal est le cahier où l'entreprise consigne par ordre
chronologique la trace de ses opérations comptables (transactions). Parfois,
celle-ci utilise plusieurs journaux (journal des achats, journal des stocks,
-journal des ventes...) afin de séparer les différents types d'opération et de
+journal des ventes, ...) afin de séparer les différents types d'opérations et de
mieux s'y retrouver, ou de diviser la responsabilité de la consignation des
transactions entre différentes personnes, chacune responsable d'un domaine
-précis (achat, vente, stock...). On parle alors de comptabilité multi-journaux.
+précis (achat, vente, stock, ...). On parle alors de comptabilité multi-journaux.
+
Grand Livre
~~~~~~~~~~~
Historiquement, le Grand Livre est le cahier où sont consignés tous les comptes
-en T de l'entreprises (tableaux de deux colonnes, débit et crédit, consignant
+en T de l'entreprise (tableaux de deux colonnes, débit et crédit, consignant
les diverses écritures passées sur le compte), à raison d'un par page.
+
Actif
~~~~~
L'actif d'une entreprise est l'ensemble de son patrimoine. Il comporte notamment
-la trésorerie, les immobilisations et les créances (sommes dues par des tiers).
+la trésorerie, les immobilisations et les créances (sommes dûes par des tiers).
+
Passif
~~~~~~
Le passif d'une entreprise est l'ensemble des ressources de l'entreprise, sous
la forme de capitaux et de dettes.
+
Bilan
~~~~~
@@ -128,6 +136,7 @@
On peut également établir un bilan provisoire avant la fin de l'exercice.
+
Compte de résultat
~~~~~~~~~~~~~~~~~~
Modified: trunk/src/site/rst/presentation.rst
===================================================================
--- trunk/src/site/rst/presentation.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/presentation.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -24,17 +24,17 @@
.. -
====================
-Présentation de LIMA
+Présentation de Lima
====================
Introduction
------------
Acronyme de Lutin Invoice Monitoring and Accounting, l’application de comptabilité
-LIMA est un logiciel libre pensé pour être la plus ergonomique possible et facile
+Lima est un logiciel libre pensé pour être la plus ergonomique possible et facile
d’accès à tout utilisateur quelque soit leur niveau en comptabilité : débutant
comme confirmé.
-La particularité de LIMA est qu’il s’agit d’un produit évolutif permettant de
+La particularité de Lima est qu’il s’agit d’un produit évolutif permettant de
répondre aux besoins spécifiques de toute entreprise ou organisation, tout en
garantissant le maintien des données comptables.
@@ -63,13 +63,13 @@
En 2010, l'application a été réécrite en majeur partie pour d'une part répondre le
plus fidèlement aux normes comptables, et d'autre part correspondre aux normes de
-programmation de Code Lutin. LIMA s'appuie notamment sur les projets internes Topia,
+programmation de Code Lutin. Lima s'appuie notamment sur les projets internes Topia,
EuGene et JAXX.
Architecture
------------
-LIMA est un projet MAVEN multi-module, il est en réalité composé de trois projets Java :
+Lima est un projet MAVEN multi-module, il est en réalité composé de trois projets Java :
lima-business, lima-callao, lima-swing.
Lima-callao
Modified: trunk/src/site/rst/rapports.rst
===================================================================
--- trunk/src/site/rst/rapports.rst 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/rst/rapports.rst 2013-06-21 16:17:07 UTC (rev 3684)
@@ -19,7 +19,7 @@
.. *
.. * You should have received a copy of the GNU General Public
.. * License along with this program. If not, see
-.. * <http://www.gnu.org/licenses/gpl-3.0.html>.
+.. * <http://www.gnu.org/licenses/gpl-3.0.HTML>.
.. * #L%
.. -
@@ -30,18 +30,18 @@
Les rapports peuvent être affichés depuis le menu Rapports. Vous avez le choix
entre:
-* Edition compte
-* Edition journal
-* Balance
-* Grand livre
-* Bilan et Compte de résultat
-* Edition TVA
+* Édition compte ;
+* Édition journal ;
+* Balance ;
+* Grand livre ;
+* Bilan et Compte de résultat ;
+* Édition TVA.
-Edition compte
+Édition compte
--------------
-Il est possible de visionner au format html les mouvements d'un compte sur un
+Il est possible de visionner au format HTML les mouvements d'un compte sur un
exercice, une période financière ou une période (i.e. un intervalle de date).
Choisissez ensuite le compte à visualiser.
Une foix ces choix effectués et validés, les mouvements du compte sélectionné
@@ -49,13 +49,14 @@
.. image:: screens/lima_reports_accounts.png
-Edition journal
+Édition journal
---------------
-Il est possible de visionner au format html les mouvements d'un ou plusieurs
+Il est possible de visionner au format HTML les mouvements d'un ou plusieurs
journaux sur un exercice, une période financière ou une période (i.e. un intervalle de date).
Une foix le choix effectué et validé, vont alors être affichés, dans votre
navigateur, deux rapports :
+
* Le journal général, contenant le total de chaque journal pour chaque mois.
* Les journaux, avec le détail, par journal, de chaque écriture par mois.
@@ -64,7 +65,7 @@
Balance
-------
-Il est possible de visionner au format html la balance sur un exercice, une
+Il est possible de visionner au format HTML la balance sur un exercice, une
période financière ou une période (i.e. un intervalle de date).
Une foix le choix effectué et validé, la balance de la période va alors
être générée et affichée dans votre navigateur.
@@ -74,7 +75,7 @@
Grand livre
-----------
-Il est possible de visionner au format html le Grand livre sur un exercice, une
+Il est possible de visionner au format HTML le Grand livre sur un exercice, une
période financière ou une période (i.e. un intervalle de date).
Une foix le choix effectué et validé, le Grand livre de la période va alors
être généré et affiché dans votre navigateur.
@@ -84,22 +85,23 @@
Bilan et Compte de résultat
---------------------------
-Il est possible de visionner au format html le Bilan et le Compte de Résultat
+Il est possible de visionner au format HTML le Bilan et le Compte de Résultat
sur un exercice, une période financière ou une période (i.e. un intervalle de date).
Une foix le choix effectué et validé, le Bilan et le Compte de Résultat
de la période vont alors être générés et affichés dans votre navigateur.
.. image:: screens/lima_reports_financialstatement.png
-Edition TVA
+Édition TVA
------------
-Il est possible de visionner au format pdf la déclaration de tva
+Il est possible de visionner au format PDF la déclaration de TVA
sur un exercice, une période financière ou une période (i.e. un intervalle de date).
Par ailleurs, il est possible de remplir automatiquement ce document,
à condition de cocher la case 'autocomplétion', et d'avoir remplis
-le plan de tva (Cf. 'Structure->Plan TVA').
-Une foix le choix effectué et validé, la déclaration de tva
+le plan de TVA (Cf. 'Structure->Plan TVA').
+Une foix le choix effectué et validé, la déclaration de TVA
de la période va alors être générée et affichée dans votre navigateur.
-.. image:: screens/lima_reports_vat.png
\ No newline at end of file
+.. image:: screens/lima_reports_vat.png
+
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2013-06-19 07:42:34 UTC (rev 3683)
+++ trunk/src/site/site_fr.xml 2013-06-21 16:17:07 UTC (rev 3684)
@@ -90,7 +90,7 @@
</links>
<menu name="Le projet" inherit="top">
- <item name="Présentation" href="presentation.html"/>
+ <!--<item name="Présentation" href="presentation.html"/>-->
<item name="Fonctionnalités" href="features.html"/>
<!--item name="Lancer Lima en ligne" href="lima-swing/jnlp/launch.jnlp" TODO jcouteau 24/08/2012 reactivate this when webstart is working/-->
<item name="Téléchargements"
@@ -108,6 +108,7 @@
</menu>
<menu name="Développeur" inherit="top">
<item name="Mode serveur" href="devel/server.html"/>
+ <item name="Lexique des objets Lima" href="devel/glossary.html"/>
</menu>
<menu ref="reports"/>
1
0
Author: Bavencoff
Date: 2013-06-19 09:42:34 +0200 (Wed, 19 Jun 2013)
New Revision: 3683
Url: http://chorem.org/projects/lima/repository/revisions/3683
Log:
user experience
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-account.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-amount.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-date.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-description.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-entrybook.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-letter.png
trunk/lima-swing/src/main/resources/icons/action-filter-transaction-voucher.png
Modified:
trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/pom.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -614,8 +614,8 @@
}
@Override
- public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException {
- List<Object> result = new ArrayList<Object>();
+ public List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException {
+ List<FinancialTransaction> result;
try {
// first search on account dao
@@ -628,17 +628,10 @@
// next on financial transaction dao
FinancialTransactionDAO financialTransactionDAO = getDaoHelper().getFinancialTransactionDAO();
- List<FinancialTransaction> financialTransactions = financialTransactionDAO.searchFinancialTransaction(
+ result = financialTransactionDAO.searchFinancialTransaction(
financialTransactionSearch, accounts);
- // merge result with sub entries
- EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- for (FinancialTransaction financialTransaction : financialTransactions) {
- result.add(financialTransaction);
- List<Entry> entries = entryDAO.findAllByFinancialTransaction(financialTransaction);
- result.addAll(entries);
- }
} catch (Exception ex) {
throw new LimaException("Can't search financial transaction", ex);
}
Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java
===================================================================
--- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -68,7 +68,7 @@
List<FinancialTransaction> getAllFinancialTransactions(FiscalPeriod period) throws LimaException;
- List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException;
+ List<FinancialTransaction> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException;
Entry createEntry(Entry entry) throws LimaException;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -73,7 +73,10 @@
border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusCellHighlightBorder");
}
myCell.setBorder(border);
-
+ if (table.getModel().isCellEditable(row, column)) {
+ background = Color.WHITE;
+ foreground = Color.BLACK;
+ }
} else {
Border border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.cellNoFocusBorder");
if (border == null) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -11,6 +11,7 @@
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
+import java.awt.event.KeyEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -62,6 +63,14 @@
runEdition();
}
});
+
+ // remove input Ctrl + Del
+ InputMap inputMap= getComponent().getInputMap(JComponent.WHEN_FOCUSED);
+ while (inputMap != null) {
+ inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
+ inputMap = inputMap.getParent();
+ }
+
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LeafAccountComboBoxModel.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,21 +25,21 @@
package org.chorem.lima.ui.combobox;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
/**
* Account combo box model containing only leaf account (without sub accounts).
*/
@@ -93,6 +93,7 @@
log.debug("Can't get list subaccounts", eee);
}
}
+ Collections.sort(result, new AccountComparator());
return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -66,7 +66,6 @@
editor.stopCellEditing();
}
table.changeSelection(getRow(), getColumn(), false, false);
- table.editCellAt(getRow(), getColumn());
}
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,24 @@
+package org.chorem.lima.ui.common;
+
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public interface Column {
+
+ public Class<?> getColumnClass();
+
+ public String getColumnName();
+
+ public Object getValueAt(int row);
+
+ public boolean isCellEditable(int row);
+
+ public boolean setValueAt(Object value, int row);
+
+ public TableCellRenderer getCellRenderer(int row);
+
+ public TableCellEditor getCellEditor(int row);
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,56 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AccountColumn extends FinancialTransactionColumn {
+
+ public AccountColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new AccountTableCellRenderer();
+ editor = new AccountTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return Account.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.account");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getAccount();
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ Account account = (Account) value;
+ boolean update = ((entry.getAccount()) == null != (account == null))
+ || (entry.getAccount() != null
+ && account != null
+ && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
+ if (update) {
+ entry.setAccount(account);
+ tableModel.updateEntry(entry);
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,52 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class BalanceColumn extends FinancialTransactionColumn {
+
+
+ public BalanceColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new BigDecimalTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return BigDecimal.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.balance");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ BigDecimal result;
+ FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ result = transaction.getAmountDebit().subtract(transaction.getAmountCredit());
+ } else {
+ result = BigDecimal.ZERO;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return false;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ return false;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,56 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class CreditColumn extends FinancialTransactionColumn {
+
+ public CreditColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new BigDecimalTableCellRenderer();
+ editor = new BigDecimalTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return BigDecimal.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.credit");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ BigDecimal credit= (BigDecimal) value;
+ boolean update = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
+ if (update) {
+ entry.setAmount(credit);
+ entry.setDebit(false);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,63 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.celleditor.DateTableCellEditor;
+import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
+
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DateColumn extends FinancialTransactionColumn {
+
+
+ public DateColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new DateTableCellRenderer();
+ editor = new DateTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return Date.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.date");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Date result;
+ Entry entry = tableModel.getEntryAt(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ result = transaction.getTransactionDate(); // date
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return row == 0
+ || tableModel.getEntryAt(row).getFinancialTransaction() != tableModel.getEntryAt(row - 1).getFinancialTransaction();
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ boolean update = (transaction.getTransactionDate().compareTo((Date) value) != 0);
+ if (update) {
+ transaction.setTransactionDate((Date) value);
+ tableModel.updateTransaction(transaction);
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,56 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DebitColumn extends FinancialTransactionColumn {
+
+ public DebitColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new BigDecimalTableCellRenderer();
+ editor = new BigDecimalTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return BigDecimal.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.debit");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ BigDecimal debit = (BigDecimal) value;
+ boolean update = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
+ if (update) {
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ tableModel.updateEntry(entry);
+ tableModel.fireTransaction(entry.getFinancialTransaction());
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,53 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DescriptionColumn extends FinancialTransactionColumn {
+
+ public DescriptionColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new EntryTableCellRenderer();
+ editor = new StringTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.description");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getDescription();
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ String description = ((String) value).trim();
+
+ boolean update = (entry.getDescription() == null ||entry.getDescription().compareTo(description) != 0);
+ if (update) {
+ entry.setDescription(description);
+ tableModel.updateEntry(entry);
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,63 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryBookColumn extends FinancialTransactionColumn {
+
+
+ public EntryBookColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new EntryBookTableCellRender();
+ editor = new EntryBookTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return EntryBook.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.entrybook");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ EntryBook result;
+ Entry entry = tableModel.getEntryAt(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ result = transaction.getEntryBook(); // date
+ } else {
+ result = null;
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return row == 0
+ || tableModel.getEntryAt(row).getFinancialTransaction() != tableModel.getEntryAt(row - 1).getFinancialTransaction();
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ EntryBook entryBook = (EntryBook) value;
+ boolean update = (transaction.getEntryBook().getCode().compareTo(entryBook.getCode()) != 0);
+ if (update) {
+ transaction.setEntryBook(entryBook);
+ tableModel.updateTransaction(transaction);
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,35 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.ui.common.Column;
+
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class FinancialTransactionColumn implements Column {
+
+ protected FinancialTransactionTableModel tableModel;
+
+ protected TableCellRenderer renderer;
+
+ protected TableCellEditor editor;
+
+
+ public FinancialTransactionColumn(FinancialTransactionTableModel tableModel) {
+ this.tableModel = tableModel;
+ this.renderer = null;
+ this.editor = null;
+ }
+
+ @Override
+ public TableCellRenderer getCellRenderer(int row) {
+ return renderer;
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row) {
+ return editor;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,93 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.ui.common.CellRouteHorizontalAction;
+import org.chorem.lima.ui.common.CellRouteVerticalAction;
+import org.chorem.lima.ui.common.Column;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionDefaultTable extends JTable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
+
+ public FinancialTransactionDefaultTable() {
+
+ setShowHorizontalLines(true);
+ setShowVerticalLines(true);
+ setGridColor(new Color(210,210,210));
+
+ initNavigation();
+
+ addMouseListener(new MyMouseAdapter());
+ }
+
+ protected void initNavigation() {
+ InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = getActionMap();
+
+ // action on Tab
+ Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+ actionMap.put(binding, new CellRouteHorizontalAction(this, true));
+
+ // action on Shift + Tab
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteHorizontalAction(this, false));
+
+ // action on Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
+ actionMap.put(binding, new CellRouteVerticalAction(this, true));
+
+ // action on Shift + Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteVerticalAction(this, false));
+
+ }
+
+ @Override
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ TableCellRenderer renderer;
+ FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
+ Column columnTable = tableModel.getColumn(column);
+ renderer = columnTable.getCellRenderer(row);
+ if (renderer == null) {
+ renderer = super.getCellRenderer(row, column);
+ }
+ return renderer;
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row, int column) {
+ TableCellEditor editor;
+ FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
+ Column columnTable = tableModel.getColumn(column);
+ editor = columnTable.getCellEditor(row);
+ if (editor == null) {
+ editor = super.getCellEditor(row, column);
+ }
+ return editor;
+ }
+
+ private class MyMouseAdapter extends MouseAdapter {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if (rowAtPoint(e.getPoint()) == -1) {
+ clearSelection();
+ }
+ }
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -27,28 +27,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
-import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
-import org.chorem.lima.ui.celleditor.StringTableCellEditor;
-import org.chorem.lima.ui.common.CellRouteHorizontalAction;
-import org.chorem.lima.ui.common.CellRouteVerticalAction;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
-import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
import java.math.BigDecimal;
-import java.util.Date;
/**
* Table des transaction qui ajoute des comportement (keys).
@@ -61,7 +46,7 @@
* @author jpepin
* @author echatellier
*/
-public class FinancialTransactionTable extends JTable {
+public class FinancialTransactionTable extends FinancialTransactionDefaultTable {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
@@ -71,38 +56,13 @@
protected final FinancialTransactionViewHandler handler;
public FinancialTransactionTable(final FinancialTransactionViewHandler handler) {
+ super();
this.handler = handler;
+ }
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
- //Get new String editor
-
- StringTableCellEditor stringTableCellEditor = new StringTableCellEditor();
- setDefaultEditor(String.class, stringTableCellEditor);
-
- //Get new account editor
- setDefaultEditor(Account.class, new AccountTableCellEditor());
-
- //Get new amount editor
- setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
-
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
- //get new Date renderer for empty cells
- setDefaultRenderer(Date.class, new DateTableCellRenderer());
-
- //get new String renderer for empty cells
- setDefaultRenderer(String.class, new EntryTableCellRenderer());
-
- //get new Account renderer for empty cells
- setDefaultRenderer(Account.class, new AccountTableCellRenderer());
-
- setShowHorizontalLines(true);
- setShowVerticalLines(true);
- setGridColor(new Color(210,210,210));
-
+ @Override
+ protected void initNavigation() {
+ super.initNavigation();
InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = getActionMap();
@@ -110,136 +70,11 @@
Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
actionMap.put(binding, new NextCellAction());
- // action on Shift + Tab
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteHorizontalAction(this, false));
-
- // action on Enter
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
- actionMap.put(binding, new CellRouteVerticalAction(this, true));
-
- // action on Shift + Enter
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteVerticalAction(this, false));
-
- // add action on Ctrl + Shift + N
- binding = "new-transaction";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.addFinancialTransaction();
- }
- });
-
- // add action on Ctrl + Shift + Delete
- binding = "delete-transaction";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.deleteSelectedTransaction();
- }
- });
-
- // add action on Ctrl + Shift + C
- binding = "copy-transaction";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.copyTransaction();
- }
- });
-
- // add action on Ctrl + Shift + V
- binding = "paste-transaction";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.pasteTransaction();
- }
- });
-
- // add action on Ctrl + N
- binding = "new-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.addEntry();
- }
- });
-
- // add action on Ctrl + Delete
- binding = "delete-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.deleteSelectedEntry();
- }
- });
-
- // add action on Ctrl + Alt + C
- binding = "copy-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.copyEntry();
- }
- });
-
- // add action on Ctrl + Alt + V
- binding = "paste-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.pasteEntry();
- }
- });
-
- // add action on Ctrl + B
- binding = "balance";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.balanceTransaction();
- }
- });
-
- // add action on Ctrl + Alt + A
- binding = "assign-all";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.assignAllEntries();
- }
- });
-
- // remove input Ctrl + Del
- inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED);
- while (inputMap != null) {
- inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
- inputMap = inputMap.getParent();
- }
-
- addMouseListener(new MyMouseAdapter());
}
- public FinancialTransactionViewHandler getHandler() {
- return handler;
- }
-
private class NextCellAction extends AbstractAction {
FinancialTransactionTable table = FinancialTransactionTable.this;
- FinancialTransactionTableModel tableModel = table.handler.view.getFinancialTransactionTableModel();
@Override
public void actionPerformed(ActionEvent e) {
@@ -261,8 +96,7 @@
boolean end = false;
-
-
+ FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
FinancialTransaction transaction = tableModel.getTransactionAt(row);
do {
if (column >= nbColumn - 1) {
@@ -292,25 +126,8 @@
}
} while (!end && !tableModel.isCellEditable(row,column));
changeSelection(row, column, false, false);
- editCellAt(row, column);
}
}
}
- private class MyMouseAdapter extends MouseAdapter {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
- }
-
- private class DeleteEntryAction extends AbstractAction {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.deleteSelectedEntry();
- }
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -30,12 +30,12 @@
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FinancialTransactionComparator;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.common.Column;
import org.chorem.lima.ui.common.TableModelWithGroup;
import javax.swing.table.AbstractTableModel;
@@ -43,11 +43,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
-
/**
* Basic transaction table model.
*
@@ -65,17 +62,35 @@
/** Service (just to update setValueAt(). */
protected FinancialTransactionService financialTransactionService;
+ protected List<Column> columns;
+
protected List<Entry> entries;
protected List<FinancialTransaction> transactions;
public FinancialTransactionTableModel() {
+ columns = new ArrayList<Column>();
+ initColumns();
+
financialTransactionService =
LimaServiceFactory.getService(FinancialTransactionService.class);
entries = new ArrayList<Entry>();
transactions = new ArrayList<FinancialTransaction>();
}
+ protected void initColumns() {
+ columns.add(new DateColumn(this));
+ columns.add(new VoucherColumn(this));
+ columns.add(new AccountColumn(this));
+ columns.add(new DescriptionColumn(this));
+ columns.add(new DebitColumn(this));
+ columns.add(new CreditColumn(this));
+ }
+
+ public Column getColumn(int column) {
+ return columns.get(column);
+ }
+
public void setTransactions(List<FinancialTransaction> transactions) {
this.transactions.clear();
this.transactions.addAll(transactions);
@@ -104,33 +119,19 @@
@Override
public int getColumnCount() {
- return 6;
+ return columns.size();
}
@Override
- public Class<?> getColumnClass(int column) {
+ public int getRowCount() {
+ return entries.size();
+ }
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = String.class;
- break;
- case 2:
- result = Account.class;
- break;
- case 3:
- result = String.class;
- break;
- case 4:
- result = BigDecimal.class;
- break;
- case 5:
- result = BigDecimal.class;
- break;
+ @Override
+ public Class<?> getColumnClass(int column) {
+ Class result = null;
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).getColumnClass();
}
return result;
}
@@ -138,69 +139,19 @@
@Override
public String getColumnName(int column) {
String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.ui.financialtransaction.date");
- break;
- case 1:
- result = _("lima.ui.financialtransaction.voucher");
- break;
- case 2:
- result = _("lima.ui.financialtransaction.account");
- break;
- case 3:
- result = _("lima.ui.financialtransaction.description");
- break;
- case 4:
- result = _("lima.ui.financialtransaction.debit");
- break;
- case 5:
- result = _("lima.ui.financialtransaction.credit");
- break;
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).getColumnName();
}
- return result;
+ return result;
}
@Override
- public int getRowCount() {
- int result = 0;
-
- if (entries != null) {
- result = entries.size();
- }
-
- return result;
- }
-
- @Override
public Object getValueAt(int row, int column) {
- Entry entry = entries.get(row);
- FinancialTransaction transaction = entry.getFinancialTransaction();
Object result = null;
- switch (column) {
- case 0:
- if (row == 0 || entries.get(row - 1).getFinancialTransaction() != transaction) {
- result = transaction.getTransactionDate(); // date
- }
- break;
- case 1:
- result = entry.getVoucher();
- break;
- case 2: // account
- result = entry.getAccount();
- break;
- case 3:
- result = entry.getDescription();
- break;
- case 4:
- result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
- break;
- case 5:
- result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
- break;
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).getValueAt(row);
}
- return result;
+ return result;
}
/**
@@ -208,99 +159,25 @@
* different condition for entry or financial transaction
*/
@Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return columnIndex > 0
- || rowIndex == 0
- || entries.get(rowIndex).getFinancialTransaction() != entries.get(rowIndex - 1).getFinancialTransaction();
+ public boolean isCellEditable(int row, int column) {
+ boolean result = false;
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).isCellEditable(row);
+ }
+ return result;
}
/** to modifiy financialtransaction or entry */
@Override
public void setValueAt(Object value, int row, int column) {
-
- Entry entry = entries.get(row);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- boolean updateEntry = false;
- boolean updateTransaction = false;
- boolean updateBalance = false;
- switch (column) {
- case 0:
- //update
- updateTransaction = (transaction.getTransactionDate().compareTo((Date) value) != 0);
- if (updateTransaction) {
- transaction.setTransactionDate((Date) value);
- }
- break;
- case 1:
- String voucher = ((String) value).trim();
-
- updateEntry = (entry.getVoucher().compareTo(voucher) != 0);
- if (updateEntry) {
- entry.setVoucher(voucher);
- }
- break;
- case 2:
- Account account = (Account) value;
- updateEntry = ((entry.getAccount()) == null != (account == null))
- || (entry.getAccount() != null
- && account != null
- && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
- if (updateEntry) {
- entry.setAccount(account);
- }
- break;
- case 3:
- String description = ((String) value).trim();
-
- updateEntry = (entry.getDescription().compareTo(description) != 0);
- if (updateEntry) {
- entry.setDescription(description);
- }
- break;
- case 4:
- BigDecimal debit = (BigDecimal) value;
- updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
- if (updateEntry) {
- entry.setAmount(debit);
- entry.setDebit(true);
- updateBalance = true;
- }
- break;
- case 5:
- BigDecimal credit= (BigDecimal) value;
- updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
- if (updateEntry) {
- entry.setAmount(credit);
- entry.setDebit(false);
- updateBalance = true;
- }
- break;
+ boolean update = false;
+ if (column >= 0 && column < columns.size()) {
+ update = columns.get(column).setValueAt(value, row);
}
-
// some modification must update all other
// first row modification update following rows
- if (updateEntry) {
- financialTransactionService.updateEntry(entry);
- if (updateBalance) {
- int firstRow = indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- fireTableRowsUpdated(firstRow, lastRow);
- } else {
- fireTableCellUpdated(row, column);
- }
- if (log.isDebugEnabled()) {
- log.debug("Update Entry");
- }
- } else if (updateTransaction) {
- financialTransactionService.updateFinancialTransaction(transaction);
+ if (update) {
fireTableCellUpdated(row, column);
- if (log.isDebugEnabled()) {
- log.debug("Update transaction");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No Update");
- }
}
}
@@ -446,6 +323,22 @@
}
public void updateEntry(Entry entry) {
+ if (log.isDebugEnabled()) {
+ log.debug("Update Entry");
+ }
financialTransactionService.updateEntry(entry);
}
+
+ public void updateTransaction(FinancialTransaction transaction) {
+ if (log.isDebugEnabled()) {
+ log.debug("Update transaction");
+ }
+ financialTransactionService.updateFinancialTransaction(transaction);
+ }
+
+ public void fireTransaction(FinancialTransaction transaction) {
+ int firstRow = indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ fireTableRowsUpdated(firstRow, lastRow);
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -51,7 +51,9 @@
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;
+import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
@@ -94,6 +96,7 @@
LimaServiceFactory.addServiceListener(FinancialPeriodService.class, this);
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
LimaServiceFactory.addServiceListener(ImportService.class, this);
+ initShortCuts();
}
/**
@@ -125,7 +128,113 @@
FinancialTransactionTable table = view.getFinancialTransactionTable();
table.getColumnModel().addColumnModelListener(this);
}
+ protected void initShortCuts() {
+ InputMap inputMap= view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = view.getActionMap();
+ Object binding;
+
+ // add action on Ctrl + Shift + N
+ binding = "new-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addFinancialTransaction();
+ }
+ });
+
+ // add action on Ctrl + Shift + Delete
+ binding = "delete-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ deleteSelectedTransaction();
+ }
+ });
+
+ // add action on Ctrl + Shift + C
+ binding = "copy-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ copyTransaction();
+ }
+ });
+
+ // add action on Ctrl + Shift + V
+ binding = "paste-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ pasteTransaction();
+ }
+ });
+
+ // add action on Ctrl + N
+ binding = "new-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addEntry();
+ }
+ });
+
+ // add action on Ctrl + Delete
+ binding = "delete-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ deleteSelectedEntry();
+ }
+ });
+
+ // add action on Ctrl + Alt + C
+ binding = "copy-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ copyEntry();
+ }
+ });
+
+ // add action on Ctrl + Alt + V
+ binding = "paste-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ pasteEntry();
+ }
+ });
+
+ // add action on Ctrl + B
+ binding = "balance";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ balanceTransaction();
+ }
+ });
+
+ // add action on Ctrl + Alt + A
+ binding = "assign-all";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ assignAllEntries();
+ }
+ });
+ }
+
/**
* New fiscal period selection.
*
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,53 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LetterColumn extends FinancialTransactionColumn {
+
+ public LetterColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new EntryTableCellRenderer();
+ editor = new StringTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.letter");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getLettering();
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ String letter = ((String) value).trim();
+
+ boolean update = (entry.getLettering() == null || entry.getLettering().compareTo(letter) != 0);
+ if (update) {
+ entry.setLettering(letter);
+ tableModel.updateEntry(entry);
+ }
+ return update;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -0,0 +1,53 @@
+package org.chorem.lima.ui.financialtransaction;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class VoucherColumn extends FinancialTransactionColumn {
+
+ public VoucherColumn(FinancialTransactionTableModel tableModel) {
+ super(tableModel);
+ renderer = new EntryTableCellRenderer();
+ editor = new StringTableCellEditor();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.voucher");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ return entry.getVoucher();
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return true;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ Entry entry = tableModel.getEntryAt(row);
+ String voucher = ((String) value).trim();
+
+ boolean update = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
+ if (update) {
+ entry.setVoucher(voucher);
+ tableModel.updateEntry(entry);
+ }
+ return update;
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,219 +25,24 @@
package org.chorem.lima.ui.financialtransactionsearch;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.EmptyCellRenderer;
-import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
-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.Highlighter;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.math.BigDecimal;
-import java.util.Date;
-
/**
* Table des transaction qui ajoute des comportement (keys).
*
* @author ore
* @author Rémi Chapelet
*/
-public class FinancialTransactionSearchTable extends JXTable
- implements KeyListener, MouseListener {
+public class FinancialTransactionSearchTable extends FinancialTransactionDefaultTable {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected FinancialTransactionSearchViewHandler handler;
-
- private Highlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- public FinancialTransactionSearchTable(FinancialTransactionSearchViewHandler handler) {
-
- this.handler = handler;
-
- addKeyListener(this);
- addMouseListener(this);
-
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
- //Get new entry book editor
- setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
- //Get new account editor
- setDefaultEditor(Account.class, new AccountTableCellEditor());
- //Get new amount editor
- setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
- //get new String renderer for empty cells
- setDefaultRenderer(String.class, new EmptyCellRenderer());
- //get new Account renderer for empty cells
- setDefaultRenderer(Account.class, new EmptyCellRenderer());
- //get new EntryBook renderer for empty cells
- setDefaultRenderer(EntryBook.class, new EmptyCellRenderer());
-
- //highlight financial financial transactions
- addColorTransaction();
- // highlight unbalanced financial transactions
- addColorNonBalancedTransaction();
-
- /*TODO : 'setEnabled' a supprimer, lors de la refonte du système de
- * recherche et de saisie*/
- setEnabled(false);
- }
-
- /**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- * On récupère la première cellule, on vérifie que c'est une date
- */
- protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return adapter.getValueAt(adapter.row, 0) instanceof Date;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(222, 222, 222), null);
- addHighlighter(colorTransaction);
+ public FinancialTransactionSearchTable() {
+ super();
}
- /**
- * Permet de surligner une transaction dans le tableau lorsque
- * cette dernière n'est pas équilibrée.
- * On récupère la dernière cellule de la ligne
- * et on vérifie si la valeur est différente de 0
- */
- protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = adapter.getValueAt(adapter.row, 8);
- if (value instanceof BigDecimal) {
- BigDecimal currentBalance = (BigDecimal) value;
- // can compare two BigDecimals with different scales
- // e.g: 3.1 == 3.10
- if (currentBalance.compareTo(BigDecimal.ZERO) != 0) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(255, 198, 209), null);
- addHighlighter(colorTransaction);
- }
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
-
- //TODO combinaison de touches dans la config
-
- // delete selected row with the key : delete or ctrl + clear
- // ou de l'entree
- if (e.getKeyCode() == KeyEvent.VK_DELETE
- || e.getKeyCode() == KeyEvent.VK_CLEAR
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.deleteSelectedRow();
- }
-
- // add entry with the key combination : insert or ctrl + enter
- if (e.getKeyCode() == KeyEvent.VK_INSERT
- || e.getKeyCode() == KeyEvent.VK_ENTER
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.addEmptyEntry();
- }
-
- // paste : ctrl + c
-
- // add financial transaction with the key combination : ctrl + c
- if (e.getKeyCode() == KeyEvent.VK_C
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.copyRow();
- }
-
- // copy : ctrl + v
-
- // add financial transaction with the key combination : ctrl + v
- if (e.getKeyCode() == KeyEvent.VK_V
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.pasteRow();
- }
-
- // add financial transaction with the key combination : ctrl + tab
- if (e.getKeyCode() == KeyEvent.VK_TAB
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.addFinancialTransaction();
- }
-
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,35 +25,24 @@
package org.chorem.lima.ui.financialtransactionsearch;
-import static org.nuiton.i18n.I18n._;
-
-import java.math.BigDecimal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
import org.chorem.lima.beans.FinancialTransactionSearch;
-import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.DecoratorProvider;
+import org.chorem.lima.ui.financialtransaction.AccountColumn;
+import org.chorem.lima.ui.financialtransaction.BalanceColumn;
+import org.chorem.lima.ui.financialtransaction.CreditColumn;
+import org.chorem.lima.ui.financialtransaction.DateColumn;
+import org.chorem.lima.ui.financialtransaction.DebitColumn;
+import org.chorem.lima.ui.financialtransaction.DescriptionColumn;
+import org.chorem.lima.ui.financialtransaction.EntryBookColumn;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
+import org.chorem.lima.ui.financialtransaction.LetterColumn;
+import org.chorem.lima.ui.financialtransaction.VoucherColumn;
+import java.util.List;
+
/**
* Basic transaction table model.
* <p/>
@@ -66,18 +55,11 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialTransactionSearchTableModel extends AbstractTableModel implements ServiceListener {
+public class FinancialTransactionSearchTableModel extends FinancialTransactionTableModel {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(FinancialTransactionSearchTableModel.class);
-
- /** Transaction service. */
- protected final FinancialTransactionService financialTransactionService;
-
/** Financial service */
protected final FinancialPeriodService financialPeriodService;
@@ -87,510 +69,45 @@
/** data cache */
protected FinancialTransactionSearch financialTransactionSearch;
- protected List<Object> cacheDataList;
-
/**
- * To decorate account objects.
- */
- protected final Decorator<Account> accountDecorator;
-
-
- /**
* Model constructor.
* <p/>
* Just init service proxies.
*/
public FinancialTransactionSearchTableModel() {
- /* Services */
- financialTransactionService =
- LimaServiceFactory.getService(
- FinancialTransactionService.class);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
+ super();
financialPeriodService =
LimaServiceFactory.getService(
FinancialPeriodService.class);
- DecoratorProvider decoratorProvider =
- LimaContext.get().getDecoratorProvider();
- accountDecorator = decoratorProvider.getDecoratorByType(Account.class);
}
- /**
- * Le model est une combinaison de Transaction/entries.
- *
- * @return
- */
- protected List<Object> getDataList(FinancialTransactionSearch financialTransactionSearch) {
- List<Object> results = null;
-
- if (financialTransactionSearch != null) {
- results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch);
- }
-
- return results;
- }
-
-
protected void refresh(FinancialTransactionSearch financialTransactionSearch) {
this.financialTransactionSearch = financialTransactionSearch;
- cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
+ List<FinancialTransaction> transactions = financialTransactionService.searchFinancialTransaction(financialTransactionSearch);
+ setTransactions(transactions);
}
-
- @Override
- public int getColumnCount() {
- return 9;
+ protected void initColumns() {
+ columns.add(new DateColumn(this));
+ columns.add(new EntryBookColumn(this));
+ columns.add(new VoucherColumn(this));
+ columns.add(new AccountColumn(this));
+ columns.add(new DescriptionColumn(this));
+ columns.add(new LetterColumn(this));
+ columns.add(new DebitColumn(this));
+ columns.add(new CreditColumn(this));
+ columns.add(new BalanceColumn(this));
}
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class; //Date
- break;
- case 1:
- result = EntryBook.class; //EntryBook
- break;
- case 2:
- result = String.class; //Voucher
- break;
- case 3:
- result = Account.class; //Account
- break;
- case 4:
- result = String.class; //Description
- break;
- case 5:
- result = String.class; //Letter
- break;
- case 6:
- result = BigDecimal.class; //Debit
- break;
- case 7:
- result = BigDecimal.class; //Credit
- break;
- case 8:
- result = BigDecimal.class; //Balance
- break;
-
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.table.date");
- break;
- case 1:
- result = _("lima.table.entrybook");
- break;
- case 2:
- result = _("lima.table.voucher");
- break;
- case 3:
- result = _("lima.table.account");
- break;
- case 4:
- result = _("lima.table.description");
- break;
- case 5:
- result = _("lima.table.letter");
- break;
- case 6:
- result = _("lima.table.debit");
- break;
- case 7:
- result = _("lima.table.credit");
- break;
- case 8:
- result = _("lima.table.balance");
- break;
-
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.size();
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- // just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.get(row);
-
- if (result instanceof FinancialTransaction) {
- FinancialTransaction currentRow = (FinancialTransaction) result;
- BigDecimal amountDebit = currentRow.getAmountDebit();
- BigDecimal amountCredit = currentRow.getAmountCredit();
-
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- if (currentRow.getEntryBook() != null) {
- result = currentRow.getEntryBook().getCode();
- } else {
- result = null;
- }
- break;
- case 2:
- result = null; //EntryBook
- break;
- case 3:
- result = null; //Account
- break;
- case 4:
- result = null; //Description
- break;
- case 5:
- result = null; //Letter
- break;
- case 6:
- result = amountDebit; //Debit
- break;
- case 7:
- result = amountCredit; //Credit
- break;
- case 8:
- result = amountDebit.subtract(amountCredit); //Balance
- break;
-
- }
- } else if (result instanceof Entry) {
- Entry currentEntry = (Entry) result;
- switch (column) {
- case 0:
- result = null; //Date
- break;
- case 1: //EntryBook
- result = null;
- break;
- case 2:
- result = currentEntry.getVoucher(); //Voucher
- break;
- case 3: // account
- if (currentEntry.getAccount() == null) {
- result = null;
- } else {
- Account acc = currentEntry.getAccount();
- result = accountDecorator.toString(acc);
- }
- break;
- case 4:
- result = currentEntry.getDescription(); //Description
- break;
- case 5:
- result = currentEntry.getLettering();
- break;
- case 6: //Debit
- result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO;
- break;
- case 7: //Credit
- result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount();
- break;
- case 8:
- result = null; //Balance
- break;
- }
-
- }
- }
-
- return result;
- }
-
public void setFiscalPeriod(FiscalPeriod fiscalPeriod) {
selectedFiscalPeriod = fiscalPeriod;
}
- /**
- * To set cells editable or not
- * different condition for entry or financial transaction
- */
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- boolean editableCell = false;
- Object currentRow = cacheDataList.get(rowIndex);
- // cells editable for the entry row, all cells exclude the date
- if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1)) {
- editableCell = true;
- }
- // cells editable for the financialtransaction row, no cells exclude the date
- if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) {
- editableCell = true;
- }
- return editableCell;
- }
-
-
- /**
- * @return int: indexOf new FianancialTransaction
- */
- public int addFinancialTransaction() {
- /* Calling transaction service */
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
-
- int index = -1;
- //if a period is selected
- if (selectedFiscalPeriod != null) {
- List<FinancialPeriod> financialPeriodsList =
- financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(),
- selectedFiscalPeriod.getEndDate());
- FinancialPeriod financialPeriod = financialPeriodsList.get(0);
-
- // get today
- Calendar actualCalendar = Calendar.getInstance();
- // get the financial period date
- Date transactionDate = financialPeriod.getBeginDate();
-
- Calendar calEnd = Calendar.getInstance();
- calEnd.setTime(financialPeriod.getEndDate());
- int dayMax = calEnd.get(Calendar.DAY_OF_MONTH);
- Calendar calBegin = Calendar.getInstance();
- calBegin.setTime(financialPeriod.getBeginDate());
- int dayMin = calBegin.get(Calendar.DAY_OF_MONTH);
- int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH);
-
- if (toDay > dayMax || toDay < dayMin) {
- // change the day
- transactionDate = DateUtils.setDays(transactionDate, dayMax);
- } else {
- // change the day
- transactionDate = DateUtils.setDays(transactionDate, toDay);
- }
-
-
- // set date to the financial transaction
- financialTransaction.setTransactionDate(transactionDate);
- // create it
- FinancialTransaction fTransaction =
- financialTransactionService.createFinancialTransaction(financialTransaction);
-
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- index = cacheDataList.indexOf(fTransaction);
- fireTableRowsInserted(index, index);
- }
- return index;
- }
-
- /**
- * @param value
- * @param row
- * @return int: indexOf new Entry
- */
- public int addEmptyEntry(Object value, int row) {
- FinancialTransaction currentTransaction = null;
- Object currentRow = cacheDataList.get(row);
- Entry entry = new EntryImpl();
- entry.setAmount(BigDecimal.ZERO);
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction) currentRow;
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- int newrow = cacheDataList.indexOf(newEntry);
- fireTableRowsInserted(newrow, newrow);
- return newrow;
- }
-
- /** to modifiy financialtransaction or entry */
- @Override
- public void setValueAt(Object value, int row, int column) {
- int financialTransactionRow;
- // just prevent too much result
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentFinancialTransaction =
- (FinancialTransaction) currentRow;
- switch (column) {
- case 0:
- //update
- currentFinancialTransaction.setTransactionDate((Date) value);
- break;
- case 1:
- currentFinancialTransaction.setEntryBook((EntryBook) value);
- break;
- }
- // notify service for modification
- financialTransactionService.
- updateFinancialTransaction(currentFinancialTransaction);
- //update the financial transaction in entire
- financialTransactionRow =
- cacheDataList.indexOf(currentRow);
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- switch (column) {
- case 2:
- currentEntry.setVoucher((String) value);
- break;
- case 3:
- currentEntry.setAccount((Account) value);
- break;
- case 4:
- currentEntry.setDescription((String) value);
- break;
- case 5:
- currentEntry.setAmount((BigDecimal) value);
- currentEntry.setDebit(true);
- break;
- case 6:
- currentEntry.setAmount((BigDecimal) value);
- currentEntry.setDebit(false);
- break;
- case 8:
- currentEntry.setLettering((String) value);
- break;
- }
-
- financialTransactionService.updateEntry(currentEntry);
-
- //update the financial transaction in entire
- financialTransactionRow =
- cacheDataList.indexOf(((Entry) currentRow).
- getFinancialTransaction());
- }
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
- }
-
- public Object getElementAt(int row) {
- Object currentRow = cacheDataList.get(row);
- return currentRow;
- }
-
-
- /**
- * Delete selected row in table (could be transaction or entry).
- * <p/>
- * Called by model.
- *
- * @param object
- * @param row
- */
- public void removeObject(Object object, int row) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentTransaction =
- (FinancialTransaction) currentRow;
- financialTransactionService.removeFinancialTransaction(currentTransaction);
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- financialTransactionService.removeEntry(currentEntry);
- }
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
- }
-
- /**
- * @param value
- * @param description
- * @param row
- * @return int: indexOf new Entry
- */
- public int addEmptyEntry(Object value, String description, int row) {
- FinancialTransaction currentTransaction = null;
- Object currentRow = cacheDataList.get(row);
- Entry entry = new EntryImpl();
- entry.setAmount(BigDecimal.ZERO);
- if (description != null) {
- entry.setDescription(description);
- }
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction) currentRow;
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
-
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- int newrow = cacheDataList.indexOf(newEntry);
- fireTableRowsInserted(newrow, newrow);
- return newrow;
- }
-
- /**
- * @param value
- * @param entry
- * @param row
- * @return int: indexOf new Entry
- */
- public int addEntry(Object value, Entry entry, int row) {
- FinancialTransaction currentTransaction = null;
- int financialTransactionRow = 0;
- Object currentRow = cacheDataList.get(row);
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction) currentRow;
- //update the financial transaction in entire
- financialTransactionRow =
- getDataList(financialTransactionSearch).indexOf(currentRow);
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- //update the financial transaction in entire
- financialTransactionRow =
- getDataList(financialTransactionSearch).indexOf(((Entry) currentRow).
- getFinancialTransaction());
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
- fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1);
-
- //on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- int newrow = cacheDataList.indexOf(newEntry);
- fireTableRowsInserted(newrow, newrow);
- return newrow;
- }
-
- @Override
public void notifyMethod(String serviceName, String methodeName) {
if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries")
|| methodeName.contains("importAll")) && !methodeName.contains("search")) {
//on recharge la liste
- cacheDataList = getDataList(financialTransactionSearch);
- fireTableDataChanged();
+ refresh(financialTransactionSearch);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2013-06-19 07:42:34 UTC (rev 3683)
@@ -34,6 +34,7 @@
org.chorem.lima.enums.ComboBoxLetterEnum
org.chorem.lima.FinancialStatementWayEnum
org.chorem.lima.enums.ComboBoxOperatorsEnum
+ org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable
org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTableModel
org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTable
</import>
@@ -58,8 +59,37 @@
]]>
</script>
-
<row>
+ <cell fill="both">
+ <JToolBar floatable="false">
+ <JButton toolTipText="lima.filter.date"
+ actionIcon='filter-transaction-date'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.entrybook"
+ actionIcon='filter-transaction-entrybook'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.voucher"
+ actionIcon='filter-transaction-voucher'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.account"
+ actionIcon='filter-transaction-account'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.description"
+ actionIcon='filter-transaction-description'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.letter"
+ actionIcon='filter-transaction-letter'
+ onActionPerformed="getHandler().refresh()"/>
+ <JButton toolTipText="lima.filter.amount"
+ actionIcon='filter-transaction-amount'
+ onActionPerformed="getHandler().refresh()"/>
+ <JToolBar.Separator/>
+ <JButton toolTipText="{ _("lima.ui.common.refresh") + " (F5)"}" actionIcon='refresh'
+ onActionPerformed="getHandler().refresh()"/>
+ </JToolBar>
+ </cell>
+ </row>
+ <row>
<cell fill='both'>
<Table>
<row>
@@ -177,9 +207,8 @@
<JScrollPane>
<FinancialTransactionSearchTableModel
id="financialTransactionSearchTableModel"/>
- <FinancialTransactionSearchTable
- id="financialTransactionSearchTable" sortable="false" rowHeight="22"
- constructorParams="getHandler()"
+ <FinancialTransactionDefaultTable
+ id="financialTransactionSearchTable" rowHeight="22"
model="{getFinancialTransactionSearchTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
<ListSelectionModel
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,13 +25,6 @@
package org.chorem.lima.ui.financialtransactionsearch;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.Date;
-
-import javax.swing.JOptionPane;
-import javax.swing.ListSelectionModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.FinancialStatementWayEnum;
@@ -39,11 +32,11 @@
import org.chorem.lima.beans.FinancialTransactionSearchImpl;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
+import java.util.Date;
+
/**
* Handler associated with financial transaction view.
*
@@ -189,7 +182,7 @@
* <p/>
* Called by model.
*/
- public void deleteSelectedRow() {
+ /*public void deleteSelectedRow() {
table = view.getFinancialTransactionSearchTable();
tableModel = view.getFinancialTransactionSearchTableModel();
@@ -302,7 +295,7 @@
//focus on first column
table.changeSelection(index, 0, false, false);
table.requestFocusInWindow();
- }
+ } */
public void refresh() {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,31 +25,21 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
-import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
-import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
-import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
-import org.chorem.lima.ui.celleditor.StringTableCellEditor;
import org.chorem.lima.ui.common.CellRouteHorizontalAction;
import org.chorem.lima.ui.common.CellRouteVerticalAction;
+import org.chorem.lima.ui.common.Column;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.Highlighter;
import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.math.BigDecimal;
-import java.util.Date;
/**
* Table des transaction qui ajoute des comportement (keys).
@@ -72,37 +62,6 @@
this.handler = handler;
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
- //Get new entry book editor
- setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
-
- //Get new String editor
- StringTableCellEditor stringTableCellEditor = new StringTableCellEditor();
- setDefaultEditor(String.class, stringTableCellEditor);
-
- //Get new account editor
- setDefaultEditor(Account.class, new AccountTableCellEditor());
-
- //Get new amount editor
- setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
-
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
- //get new Date renderer for empty cells
- setDefaultRenderer(Date.class, new DateTableCellRenderer());
-
- //get new String renderer for empty cells
- setDefaultRenderer(String.class, new EntryTableCellRenderer());
-
- //get new Account renderer for empty cells
- setDefaultRenderer(Account.class, new AccountTableCellRenderer());
-
- //get new EntryBook renderer for empty cells
- setDefaultRenderer(EntryBook.class, new EntryBookTableCellRender());
-
setShowHorizontalLines(true);
setShowVerticalLines(true);
setGridColor(new Color(210,210,210));
@@ -166,17 +125,34 @@
}
});
- // remove input Ctrl + Del
- inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED);
- while (inputMap != null) {
- inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
- inputMap = inputMap.getParent();
- }
-
addMouseListener(new MyMouseAdapter());
}
+ @Override
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ TableCellRenderer renderer;
+ FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
+ Column columnTable = tableModel.getColumn(column);
+ renderer = columnTable.getCellRenderer(row);
+ if (renderer == null) {
+ renderer = super.getCellRenderer(row, column);
+ }
+ return renderer;
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row, int column) {
+ TableCellEditor editor;
+ FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
+ Column columnTable = tableModel.getColumn(column);
+ editor = columnTable.getCellEditor(row);
+ if (editor == null) {
+ editor = super.getCellEditor(row, column);
+ }
+ return editor;
+ }
+
private class MyMouseAdapter extends MouseAdapter {
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -25,22 +25,20 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.financialtransaction.AccountColumn;
+import org.chorem.lima.ui.financialtransaction.CreditColumn;
+import org.chorem.lima.ui.financialtransaction.DateColumn;
+import org.chorem.lima.ui.financialtransaction.DebitColumn;
+import org.chorem.lima.ui.financialtransaction.DescriptionColumn;
+import org.chorem.lima.ui.financialtransaction.EntryBookColumn;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.DecoratorProvider;
+import org.chorem.lima.ui.financialtransaction.LetterColumn;
+import org.chorem.lima.ui.financialtransaction.VoucherColumn;
-import java.math.BigDecimal;
-import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
-
/**
* Basic transaction table model.
* <p/>
@@ -57,18 +55,15 @@
/** selected financial period */
protected FiscalPeriod selectedFiscalPeriod;
- /**
- * To decorate account objects.
- */
- protected final Decorator<Account> accountDecorator;
-
- public FinancialTransactionUnbalancedTableModel() {
- super();
- //LimaServiceFactory.addServiceListener(financialTransactionService, this);
-
- DecoratorProvider decoratorProvider =
- LimaContext.get().getDecoratorProvider();
- accountDecorator = decoratorProvider.getDecoratorByType(Account.class);
+ protected void initColumns() {
+ columns.add(new DateColumn(this));
+ columns.add(new EntryBookColumn(this));
+ columns.add(new VoucherColumn(this));
+ columns.add(new AccountColumn(this));
+ columns.add(new DescriptionColumn(this));
+ columns.add(new DebitColumn(this));
+ columns.add(new CreditColumn(this));
+ columns.add(new LetterColumn(this));
}
/**
@@ -87,257 +82,7 @@
}
}
- @Override
- public int getColumnCount() {
- return 8;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = EntryBook.class;
- break;
- case 2:
- result = String.class;
- break;
- case 3:
- result = Account.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = BigDecimal.class;
- break;
- case 6:
- result = BigDecimal.class;
- break;
- case 7:
- result = String.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.table.date");
- break;
- case 1:
- result = _("lima.table.entrybook");
- break;
- case 2:
- result = _("lima.table.voucher");
- break;
- case 3:
- result = _("lima.table.account");
- break;
- case 4:
- result = _("lima.table.description");
- break;
- case 5:
- result = _("lima.table.debit");
- break;
- case 6:
- result = _("lima.table.credit");
- break;
- case 7:
- result = _("lima.table.letter");
- break;
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Entry entry = entries.get(row);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- Object result = null;
-
-
- switch (column) {
- case 0:
- if (row == 0 || entries.get(row - 1).getFinancialTransaction() != transaction) {
- result = transaction.getTransactionDate();
- }
- break;
- case 1:
- if ((row == 0 || entries.get(row - 1).getFinancialTransaction() != transaction) && transaction.getEntryBook() != null) {
- result = transaction.getEntryBook();
- }
- break;
- case 2:
- result = entry.getVoucher();
- break;
- case 3: // account
- if (entry.getAccount() == null) {
- result = null;
- } else {
- Account acc = entry.getAccount();
- result = accountDecorator.toString(acc);
- }
- break;
- case 4:
- result = entry.getDescription();
- break;
- case 5:
- result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
- break;
- case 6:
- result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
- break;
- case 7:
- result = entry.getLettering();
- break;
- }
- return result;
- }
-
public void setFiscalPeriod(FiscalPeriod fiscalPeriod) {
selectedFiscalPeriod = fiscalPeriod;
}
-
- /**
- * To set cells editable or not
- * different condition for entry or financial transaction
- */
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return columnIndex > 1
- || rowIndex == 0
- || entries.get(rowIndex).getFinancialTransaction() != entries.get(rowIndex - 1).getFinancialTransaction();
- }
-
-
- /** to modifiy financialtransaction or entry */
- @Override
- public void setValueAt(Object value, int row, int column) {
-
- Entry entry = entries.get(row);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- boolean updateEntry = false;
- boolean updateTransaction = false;
- boolean updateBalance = false;
- switch (column) {
- case 0:
- //update
- updateTransaction = (transaction.getTransactionDate().compareTo((Date) value) != 0);
- if (updateTransaction) {
- transaction.setTransactionDate((Date) value);
- }
- break;
- case 1:
- EntryBook entryBook = (EntryBook) value;
- updateTransaction = ((transaction.getEntryBook()) == null != (entryBook == null))
- || (transaction.getEntryBook() != null
- && entryBook != null
- && !transaction.getEntryBook().getCode().equals(entryBook.getCode()));
- if (updateTransaction) {
- transaction.setEntryBook(entryBook);
- }
- break;
- case 2:
- String voucher = ((String) value).trim();
-
- updateEntry = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
- if (updateEntry) {
- entry.setVoucher(voucher);
- }
- break;
- case 3:
- Account account = (Account) value;
- updateEntry = ((entry.getAccount()) == null != (account == null))
- || (entry.getAccount() != null
- && account != null
- && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
- if (updateEntry) {
- entry.setAccount(account);
- }
- break;
- case 4:
- String description = ((String) value).trim();
-
- updateEntry = (entry.getDescription() == null || entry.getDescription().compareTo(description) != 0);
- if (updateEntry) {
- entry.setDescription(description);
- }
- break;
- case 5:
- BigDecimal debit = (BigDecimal) value;
- updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
- if (updateEntry) {
- entry.setAmount(debit);
- entry.setDebit(true);
- updateBalance = true;
- }
- break;
- case 6:
- BigDecimal credit= (BigDecimal) value;
- updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
- if (updateEntry) {
- entry.setAmount(credit);
- entry.setDebit(false);
- updateBalance = true;
- }
- break;
- case 8:
- String lettering = ((String) value).trim();
-
- updateEntry = (entry.getLettering().compareTo(lettering) != 0);
- if (updateEntry) {
- entry.setLettering(lettering);
- }
- break;
- }
-
- // some modification must update all other
- // first row modification update following rows
- if (updateEntry) {
- financialTransactionService.updateEntry(entry);
- if (updateBalance) {
- int firstRow = indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- fireTableRowsUpdated(firstRow, lastRow);
- } else {
- fireTableCellUpdated(row, column);
- }
- if (log.isDebugEnabled()) {
- log.debug("Update Entry");
- }
- } else if (updateTransaction) {
- financialTransactionService.updateFinancialTransaction(transaction);
- fireTableCellUpdated(row, column);
- if (log.isDebugEnabled()) {
- log.debug("Update transaction");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No Update");
- }
- }
- }
-
-
-
- /*@Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") ||
- methodeName.contains("importEntries") ||
- methodeName.contains("importAll")) {
- refresh();
- }
- }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-06-19 07:42:34 UTC (rev 3683)
@@ -29,6 +29,7 @@
javax.swing.DefaultListSelectionModel
org.chorem.lima.entity.FiscalPeriod
org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel
+ org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable
</import>
<FinancialTransactionUnbalancedViewHandler id="handler"
javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/>
@@ -90,10 +91,9 @@
<JScrollPane>
<FinancialTransactionUnbalancedTableModel
id="financialTransactionUnbalancedTableModel"/>
- <FinancialTransactionUnbalancedTable
+ <FinancialTransactionDefaultTable
id="financialTransactionUnbalancedTable"
rowHeight="22"
- constructorParams="getHandler()"
selectionModel='{selectionModel}'
model="{getFinancialTransactionUnbalancedTableModel()}"/>
</JScrollPane>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-06-19 07:42:34 UTC (rev 3683)
@@ -31,6 +31,7 @@
import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@@ -75,7 +76,7 @@
//add a new entry to the selected transaction
public void addEntry() {
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
@@ -114,7 +115,7 @@
*/
public void deleteSelectedEntry() {
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
@@ -160,7 +161,7 @@
*/
public void deleteSelectedTransaction() {
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
@@ -199,7 +200,7 @@
}
public void selectionChanged() {
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int selectedRow = table.getSelectedRow();
@@ -215,7 +216,7 @@
}
public void balanceTransaction() {
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int rowSelected = table.getSelectedRow();
@@ -255,7 +256,7 @@
public void refresh() {
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
- FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionDefaultTable table = view.getFinancialTransactionUnbalancedTable();
if (table.isEditing()) {
TableCellEditor editor = table.getCellEditor();
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 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-06-19 07:42:34 UTC (rev 3683)
@@ -1,5 +1,8 @@
=
-=
+Date=
+Fitre=
+Piece=
lima-business.document.entrybooks=
lima-business.document.generalentrybook=
lima.about.translate.content=<h3>How to translate Lima</h3>You can help us to translate or improve label in Lima.<br/><ul><li>Get the <strong>lima-i18n.csv</strong> file in the <strong>i18n</strong> directory</li><li>open it in Libre office (separator caracter is <strong>Tab</strong>)</li><li>Do you work \:)</li><li>At last, send us back the modified file</li></ul><br/>We will apply the patch before next release.
@@ -133,11 +136,18 @@
lima.enum.comboboxoperator.notequal=Not equal
lima.enum.comboboxoperator.superior=Superior
lima.enum.comboboxoperator.superiororequal=Superior or equal
-lima.enum.comboboxperiod.date=Date
+lima.enum.comboboxperiod.date=
lima.enum.comboboxperiod.financialperiod=Financial period
lima.enum.comboboxperiod.fiscalperiod=Fiscal period
lima.enum.comboboxperiod.period=Period
lima.error.errorpane.htmlmessage=<html><body><b>An application error happened</b>\:<br/>%s</body></html>
+lima.filter.account=
+lima.filter.amount=
+lima.filter.date=
+lima.filter.description=
+lima.filter.entrybook=
+lima.filter.letter=
+lima.filter.voucher=
lima.financialstatement.accounts=Account list on debit and on credit
lima.financialstatement.addfinancialStatementHeadererror=Can't add financialStatementHeader
lima.financialstatement.check=Check accounts passing to movement
@@ -203,7 +213,7 @@
lima.table.account=Account
lima.table.balance=Balance
lima.table.credit=Credit
-lima.table.date=Date
+lima.table.date=
lima.table.debit=Debit
lima.table.debitcredit=Debit and credit
lima.table.description=Description
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 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-06-19 07:42:34 UTC (rev 3683)
@@ -1,5 +1,8 @@
=
-=
+Date=
+Fitre=
+Piece=
lima-business.document.entrybooks=
lima-business.document.generalentrybook=
lima.about.translate.content=<h2>Comment traduire Lima</h2>Vous pouvez nous aider à traduire Lima.<hr/><br/><ul><li>Récupérer le fichier <strong>lima-i18n.csv</strong> dans le répertoire <strong>i18n</strong></li><li>ouvrez le avec un tableur (le caractère séprateur est une Tabultation)</li><li>Traduisez, Améliorer, ...</li><li>Enfin renvoyez-le nous</li></ul><br/>Nous intégrerons vos modifications avant la prochaine version.
@@ -137,6 +140,13 @@
lima.enum.comboboxperiod.fiscalperiod=Exercice
lima.enum.comboboxperiod.period=Période
lima.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html>
+lima.filter.account=Ajouter un filtre sur les comptes
+lima.filter.amount=Ajouter un filtre sur les montants
+lima.filter.date=Ajouter un filtre sur les dates
+lima.filter.description=Ajouter un filtre sur les descriptions
+lima.filter.entrybook=Ajouter un filtre sur les journaux
+lima.filter.letter=Ajouter un filtre sur les lettres
+lima.filter.voucher=Ajouter un filtre sur les pièces comptables
lima.financialstatement.accounts=Liste de comptes au crédit et au débit
lima.financialstatement.addfinancialStatementHeadererror=Erreur lors de l'ajout de l'entête sur la déclaration financière
lima.financialstatement.check=Vérification des comptes aux postes
@@ -201,7 +211,7 @@
lima.table.account=Compte
lima.table.balance=Solde
lima.table.credit=Crédit
-lima.table.date=Date
+lima.table.date=
lima.table.debit=Débit
lima.table.debitcredit=Débit et Crédit
lima.table.description=Description
@@ -268,7 +278,7 @@
lima.ui.financialtransaction.buttonback=←
lima.ui.financialtransaction.buttonnext=→
lima.ui.financialtransaction.credit=Crédit
-lima.ui.financialtransaction.date=Date
+lima.ui.financialtransaction.date=
lima.ui.financialtransaction.debit=Débit
lima.ui.financialtransaction.description=Description
lima.ui.financialtransaction.entrybook=Journal
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-account.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-account.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-amount.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-amount.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-date.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-date.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-description.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-description.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-entrybook.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-entrybook.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-letter.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-letter.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-voucher.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-filter-transaction-voucher.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-06-17 13:08:18 UTC (rev 3682)
+++ trunk/pom.xml 2013-06-19 07:42:34 UTC (rev 3683)
@@ -371,6 +371,16 @@
<role>Développeur</role>
</roles>
</contributor>
+ <contributor>
+ <name>bavencoff</name>
+ <email>bavencoff(a)codelutin.com</email>
+ <organization>Code Lutin</organization>
+ <organizationUrl>http://www.codelutin.com</organizationUrl>
+ <timezone>Europe/Paris</timezone>
+ <roles>
+ <role>Développeur</role>
+ </roles>
+ </contributor>
</contributors>
<!-- ************************************************************* -->
1
0
17 Jun '13
Author: Bavencoff
Date: 2013-06-17 15:08:18 +0200 (Mon, 17 Jun 2013)
New Revision: 3682
Url: http://chorem.org/projects/lima/repository/revisions/3682
Log:
user experience
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialTransactionComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteVerticalAction.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialTransactionComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialTransactionComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialTransactionComparator.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -0,0 +1,20 @@
+package org.chorem.lima.business.utils;
+
+import org.chorem.lima.entity.FinancialTransaction;
+
+import java.util.Comparator;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionComparator implements Comparator<FinancialTransaction> {
+
+ @Override
+ public int compare(FinancialTransaction o1, FinancialTransaction o2) {
+ int result = o1.getTransactionDate().compareTo(o2.getTransactionDate());
+ if (result == 0) {
+ result = o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
+ }
+ return result;
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -5,7 +5,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class AccountTableCellRenderer extends EntryTableCellRenderer {
+public class AccountTableCellRenderer extends EntryTableCellRenderer {
@Override
public void setValue(Object value) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -135,7 +135,7 @@
}
// Remet à faux pour la premiere lettre tapée au clavier
keyPressed = false;
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 1;
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -0,0 +1,20 @@
+package org.chorem.lima.ui.celleditor;
+
+import org.chorem.lima.entity.EntryBook;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryBookTableCellRender extends EntryTableCellRenderer {
+
+ @Override
+ public void setValue(Object value) {
+ Object result = value;
+ if (value != null && value instanceof EntryBook) {
+ EntryBook entryBook= (EntryBook) value;
+ result = entryBook.getCode() + " - " + entryBook.getLabel();
+ }
+ super.setValue(result);
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -1,5 +1,6 @@
package org.chorem.lima.ui.celleditor;
+import org.chorem.lima.ui.common.TableModelWithGroup;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
import sun.swing.DefaultLookup;
@@ -36,9 +37,10 @@
} else {
Color alternateColor = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.alternateRowColor");
if (alternateColor != null) {
- if (table instanceof FinancialTransactionTable) {
- FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
- if (model.getIndexTransaction(row) % 2 != 0) {
+
+ if (table.getModel() instanceof TableModelWithGroup) {
+ TableModelWithGroup model = (TableModelWithGroup) table.getModel();
+ if (model.indexGroupAt(row) % 2 != 0) {
background = alternateColor;
}
} else if (row % 2 == 0) {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteHorizontalAction.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -0,0 +1,72 @@
+package org.chorem.lima.ui.common;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.event.ActionEvent;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class CellRouteHorizontalAction extends AbstractAction{
+
+ JTable table;
+
+ protected int step;
+ protected int route1;
+ protected int route2;
+ protected int nbCell1;
+ protected int nbCell2;
+
+ public CellRouteHorizontalAction(JTable table, boolean nextCell) {
+ this.table = table;
+ step = nextCell ? +1 : -1;
+ }
+
+ protected void init() {
+ route1 = table.getSelectedColumn();
+ route2 = table.getSelectedRow();
+ nbCell1 = table.getColumnCount();
+ nbCell2 = table.getRowCount();
+ }
+
+ protected int getRow() {
+ return route2;
+ }
+
+ protected int getColumn() {
+ return route1;
+ }
+
+ protected boolean isEditable() {
+ return table.getModel().isCellEditable(getRow(), getColumn());
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ init();
+ if (route1 >= 0 && route2 >= 0) {
+ do {
+ route1 = route1 + step;
+ if (route1 < 0 || route1 >= nbCell1) {
+ route1 = route1 % nbCell1;
+ if (route1 < 0) {
+ route1 = route1 + nbCell1;
+ }
+ route2 = route2 + step;
+ if (route2 < 0 || route2 >= nbCell2) {
+ route2 = route2 % nbCell2;
+ if (route2 < 0) {
+ route2 = route2 + nbCell2;
+ }
+ }
+ }
+ } while (!isEditable());
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+ table.changeSelection(getRow(), getColumn(), false, false);
+ table.editCellAt(getRow(), getColumn());
+ }
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteVerticalAction.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteVerticalAction.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/CellRouteVerticalAction.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -0,0 +1,29 @@
+package org.chorem.lima.ui.common;
+
+import javax.swing.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class CellRouteVerticalAction extends CellRouteHorizontalAction {
+
+ public CellRouteVerticalAction(JTable table, boolean nextCell) {
+ super(table, nextCell);
+ }
+
+ protected void init() {
+ route1 = table.getSelectedRow();
+ route2 = table.getSelectedColumn();
+ nbCell1 = table.getRowCount();
+ nbCell2 = table.getColumnCount();
+ }
+
+ protected int getRow() {
+ return route1;
+ }
+
+ protected int getColumn() {
+ return route2;
+ }
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -0,0 +1,9 @@
+package org.chorem.lima.ui.common;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public interface TableModelWithGroup {
+
+ public int indexGroupAt(int row);
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -37,6 +37,8 @@
import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import org.chorem.lima.ui.common.CellRouteHorizontalAction;
+import org.chorem.lima.ui.common.CellRouteVerticalAction;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
@@ -110,15 +112,15 @@
// action on Shift + Tab
binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteHorizontalFirstAction(false));
+ actionMap.put(binding, new CellRouteHorizontalAction(this, false));
// action on Enter
binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
- actionMap.put(binding, new CellRouteVerticalFirstAction(true));
+ actionMap.put(binding, new CellRouteVerticalAction(this, true));
// action on Shift + Enter
binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteVerticalFirstAction(false));
+ actionMap.put(binding, new CellRouteVerticalAction(this, false));
// add action on Ctrl + Shift + N
binding = "new-transaction";
@@ -146,9 +148,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- if (getSelectedRow() >= 0) {
- handler.copyTransaction(getSelectedRow());
- }
+ handler.copyTransaction();
}
});
@@ -158,9 +158,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- if (getSelectedRow() >= 0) {
- handler.pasteTransaction(getSelectedRow());
- }
+ handler.pasteTransaction();
}
});
@@ -190,9 +188,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- if (getSelectedRow() >= 0) {
- handler.copyEntry(getSelectedRow());
- }
+ handler.copyEntry();
}
});
@@ -202,9 +198,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- if (getSelectedRow() >= 0) {
- handler.pasteEntry(getSelectedRow());
- }
+ handler.pasteEntry();
}
});
@@ -214,9 +208,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- if (getSelectedRow() >= 0) {
- handler.balanceTransaction(getSelectedRow());
- }
+ handler.balanceTransaction();
}
});
@@ -236,6 +228,8 @@
inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
inputMap = inputMap.getParent();
}
+
+ addMouseListener(new MyMouseAdapter());
}
public FinancialTransactionViewHandler getHandler() {
@@ -303,92 +297,6 @@
}
}
- private class CellRouteHorizontalFirstAction extends AbstractAction {
-
- FinancialTransactionTable table = FinancialTransactionTable.this;
- FinancialTransactionTableModel tableModel = table.handler.view.getFinancialTransactionTableModel();
-
- protected int step;
- protected int route1;
- protected int route2;
- protected int nbCell1;
- protected int nbCell2;
-
- public CellRouteHorizontalFirstAction(boolean nextCell) {
- step = nextCell ? +1 : -1;
- }
-
- protected void init() {
- route1 = getSelectedColumn();
- route2 = getSelectedRow();
- nbCell1 = getColumnCount();
- nbCell2 = getRowCount();
- }
-
- protected int getRow() {
- return route2;
- }
-
- protected int getColumn() {
- return route1;
- }
-
- protected boolean isEditable() {
- return tableModel.isCellEditable(getRow(), getColumn());
- }
-
- @Override
- public void actionPerformed(ActionEvent e) {
- init();
- if (route1 >= 0 && route2 >= 0) {
- do {
- route1 = route1 + step;
- if (route1 < 0 || route1 >= nbCell1) {
- route1 = route1 % nbCell1;
- if (route1 < 0) {
- route1 = route1 + nbCell1;
- }
- route2 = route2 + step;
- if (route2 < 0 || route2 >= nbCell2) {
- route2 = route2 % nbCell2;
- if (route2 < 0) {
- route2 = route2 + nbCell2;
- }
- }
- }
- } while (!isEditable());
- if (isEditing()) {
- TableCellEditor editor = getCellEditor();
- editor.stopCellEditing();
- }
- changeSelection(getRow(), getColumn(), false, false);
- editCellAt(getRow(), getColumn());
- }
- }
- }
-
- private class CellRouteVerticalFirstAction extends CellRouteHorizontalFirstAction {
-
- public CellRouteVerticalFirstAction(boolean nextCell) {
- super(nextCell);
- }
-
- protected void init() {
- route1 = getSelectedRow();
- route2 = getSelectedColumn();
- nbCell1 = getRowCount();
- nbCell2 = getColumnCount();
- }
-
- protected int getRow() {
- return route1;
- }
-
- protected int getColumn() {
- return route2;
- }
- }
-
private class MyMouseAdapter extends MouseAdapter {
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -28,17 +28,21 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.business.utils.FinancialTransactionComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.common.TableModelWithGroup;
import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -51,12 +55,12 @@
* @author chatellier
* @version $Revision$
*/
-public class FinancialTransactionTableModel extends AbstractTableModel {
+public class FinancialTransactionTableModel extends AbstractTableModel implements TableModelWithGroup {
/** serialVersionUID. */
private static final long serialVersionUID = -7495388454688562991L;
- private static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class);
+ protected static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class);
/** Service (just to update setValueAt(). */
protected FinancialTransactionService financialTransactionService;
@@ -68,32 +72,32 @@
public FinancialTransactionTableModel() {
financialTransactionService =
LimaServiceFactory.getService(FinancialTransactionService.class);
+ entries = new ArrayList<Entry>();
+ transactions = new ArrayList<FinancialTransaction>();
}
- public void setEntries(List<Entry> entries) {
- this.entries = entries;
- transactions = new ArrayList<FinancialTransaction>();
- for (Entry entry :entries) {
- FinancialTransaction transaction = entry.getFinancialTransaction();
- if (!transactions.contains(transaction)) {
- transactions.add(transaction);
- }
- }
- fireTableDataChanged();
+ public void setTransactions(List<FinancialTransaction> transactions) {
+ this.transactions.clear();
+ this.transactions.addAll(transactions);
+ sortEntries();
}
public void sortEntries() {
- Comparator<FinancialTransaction> comparator = new Comparator<FinancialTransaction>() {
- @Override
- public int compare(FinancialTransaction o1, FinancialTransaction o2) {
- return o1.getTransactionDate().compareTo(o2.getTransactionDate());
- }
- };
-
- Collections.sort(transactions, comparator);
+ Collections.sort(transactions, new FinancialTransactionComparator());
entries.clear();
for (FinancialTransaction transaction : transactions) {
- entries.addAll(transaction.getEntry());
+ if (transaction.sizeEntry() > 0) {
+ List<Entry> entries = new ArrayList<Entry>(transaction.getEntry());
+ Collections.sort(entries, new EntryComparator());
+ this.entries.addAll(entries);
+ } else {
+ Entry entry = new EntryImpl();
+ entry.setFinancialTransaction(transaction);
+ entry = financialTransactionService.createEntry(entry);
+ transaction.addEntry(entry);
+ financialTransactionService.updateFinancialTransaction(transaction);
+ this.entries.add(entry);
+ }
}
fireTableDataChanged();
}
@@ -149,10 +153,10 @@
result = _("lima.ui.financialtransaction.description");
break;
case 4:
- result = _("lima.ui.financialtransaction.credit");
+ result = _("lima.ui.financialtransaction.debit");
break;
case 5:
- result = _("lima.ui.financialtransaction.debit");
+ result = _("lima.ui.financialtransaction.credit");
break;
}
return result;
@@ -190,10 +194,10 @@
result = entry.getDescription();
break;
case 4:
- result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
+ result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
break;
case 5:
- result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
+ result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
break;
}
return result;
@@ -218,6 +222,7 @@
FinancialTransaction transaction = entry.getFinancialTransaction();
boolean updateEntry = false;
boolean updateTransaction = false;
+ boolean updateBalance = false;
switch (column) {
case 0:
//update
@@ -233,26 +238,9 @@
if (updateEntry) {
entry.setVoucher(voucher);
}
- /*int firstEntryRow = indexOf(transaction);
- if (row == firstEntryRow) {
-
- // let's update the voucher of all entries of
- // the transaction
- for (Entry entryNext : transaction.getEntry()) {
- entryNext.setVoucher(voucher);
- }
-
- updateEntries = true;
- } else {
-
- // not on first row, just update this entry voucher
- entry.setVoucher(voucher);
- } */
break;
case 2:
Account account = (Account) value;
-
-
updateEntry = ((entry.getAccount()) == null != (account == null))
|| (entry.getAccount() != null
&& account != null
@@ -260,26 +248,6 @@
if (updateEntry) {
entry.setAccount(account);
}
-
- /*entry.setAccount(account);
- if (account != null) {
-
- // let's copy the account description
- description = account.getLabel();
- firstEntryRow = indexOf(transaction);
- if (row == firstEntryRow) {
- // let's update the description of all entries of
- // the transaction
-
- for (Entry entryNext : transaction.getEntry()) {
- entryNext.setDescription(description);
- }
- updateEntries = true;
- } else {
- // not on first row, just update this entry description
- entry.setDescription(description);
- }
- } */
break;
case 3:
String description = ((String) value).trim();
@@ -288,46 +256,38 @@
if (updateEntry) {
entry.setDescription(description);
}
-
- /*firstEntryRow = indexOf(transaction);
- if (row == firstEntryRow) {
-
- // let's update the description of all entries of
- // the transaction
-
- for (Entry entryNext : transaction.getEntry()) {
- entryNext.setDescription(description);
- }
- updateEntries = true;
- } else {
-
- // not on first row, just update this entry description
- entry.setDescription(description);
- } */
break;
case 4:
+ BigDecimal debit = (BigDecimal) value;
+ updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
+ if (updateEntry) {
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ updateBalance = true;
+ }
+ break;
+ case 5:
BigDecimal credit= (BigDecimal) value;
updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
if (updateEntry) {
entry.setAmount(credit);
entry.setDebit(false);
+ updateBalance = true;
}
break;
- case 5:
- BigDecimal debit = (BigDecimal) value;
- updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
- if (updateEntry) {
- entry.setAmount(debit);
- entry.setDebit(true);
- }
- break;
}
// some modification must update all other
// first row modification update following rows
if (updateEntry) {
financialTransactionService.updateEntry(entry);
- fireTableCellUpdated(row, column);
+ if (updateBalance) {
+ int firstRow = indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ fireTableRowsUpdated(firstRow, lastRow);
+ } else {
+ fireTableCellUpdated(row, column);
+ }
if (log.isDebugEnabled()) {
log.debug("Update Entry");
}
@@ -370,59 +330,96 @@
return index;
}
- public int getIndexTransaction(int row) {
- FinancialTransaction transaction = getTransactionAt(row);
- int index = transactions.indexOf(transaction);
- return index;
- }
-
/**
* Insert new entry.
*
* @param entry entry to insert
- * @param newRow position
*/
- public void addEntry(Entry entry, int newRow) {
+ public void addEntry(Entry entry) {
FinancialTransaction transaction = entry.getFinancialTransaction();
if (transactions.contains(transaction)) {
- entries.add(newRow, entry);
- fireTableRowsInserted(newRow, newRow);
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(transaction);
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setAccount(entry.getAccount());
+ newEntry.setDescription(entry.getDescription());
+ newEntry.setAmount(entry.getAmount());
+ newEntry.setDebit(entry.getDebit());
+ newEntry = financialTransactionService.createEntry(newEntry);
+
+ transaction.addEntry(newEntry);
+ financialTransactionService.updateFinancialTransaction(transaction);
+ int row = indexOf(transaction) + transaction.sizeEntry() - 1;
+ entries.add(row, newEntry);
+ fireTableRowsInserted(row, row);
}
}
/**
- * Delete entry.
+ * Delete selected row in table (could be transaction or entry).
+ * <p/>
+ * Called by model.
*
- * @param entry entry to delete
+ * @param row
*/
- public void deleteEntry(Entry entry) {
- int row = entries.indexOf(entry);
- entries.remove(entry);
+ public void removeTransaction(int row) {
+ FinancialTransaction transaction = getTransactionAt(row);
+ int firstRow = indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ financialTransactionService.removeFinancialTransaction(transaction);
+ entries.removeAll(transaction.getEntry());
+ transactions.remove(transaction);
+ fireTableRowsDeleted(firstRow, lastRow);
+ }
+
+ public void removeEntry(int row) {
+ Entry entry = getEntryAt(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ if (transaction.sizeEntry() > 1) {
+ financialTransactionService.removeEntry(entry);
+ transaction.removeEntry(entry);
+ entries.remove(entry);
+ } else {
+ financialTransactionService.removeFinancialTransaction(transaction);
+ entries.removeAll(transaction.getEntry());
+ transactions.remove(transaction);
+ }
fireTableRowsDeleted(row, row);
}
public void addTransaction(FinancialTransaction transaction) {
+ FinancialTransaction newTransaction = new FinancialTransactionImpl();
+ newTransaction.setEntryBook(transaction.getEntryBook());
+ newTransaction.setTransactionDate(transaction.getTransactionDate());
+ newTransaction = financialTransactionService.createFinancialTransaction(newTransaction);
+
+ if (transaction.getEntry() == null || transaction.getEntry().isEmpty()) {
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(newTransaction);
+ newEntry = financialTransactionService.createEntry(newEntry);
+ newTransaction.addEntry(newEntry);
+ } else {
+ for (Entry entry : transaction.getEntry()) {
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(newTransaction);
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setAccount(entry.getAccount());
+ newEntry.setDescription(entry.getDescription());
+ newEntry.setAmount(entry.getAmount());
+ newEntry.setDebit(entry.getDebit());
+ newEntry = financialTransactionService.createEntry(newEntry);
+ newTransaction.addEntry(newEntry);
+ }
+ financialTransactionService.updateFinancialTransaction(newTransaction);
+ }
+
int indexFirstEntry = entries.size();
- if (!transactions.contains(transaction)) {
- transactions.add(transaction);
- entries.addAll(transaction.getEntry());
- }
+ transactions.add(newTransaction);
+ entries.addAll(newTransaction.getEntry());
int indexLastEntry = entries.size() - 1;
fireTableRowsInserted(indexFirstEntry, indexLastEntry - 1);
}
- public void deleteTransaction(FinancialTransaction transaction) {
- if (transactions.contains(transaction)) {
- int indexFirst = indexOf(transaction);
- int indexLast = indexFirst + transaction.sizeEntry() - 1;
- entries.removeAll(transaction.getEntry());
- transactions.remove(transaction);
- if (indexFirst <= indexLast) {
- fireTableRowsDeleted(indexFirst, indexFirst);
- }
- }
- }
-
public BigDecimal getBalanceTransactionInRow(int row) {
FinancialTransaction transaction = getTransactionAt(row);
BigDecimal debit = transaction.getAmountDebit();
@@ -440,4 +437,15 @@
}
+ @Override
+ public int indexGroupAt(int row) {
+ FinancialTransaction transaction = getTransactionAt(row);
+ int index = transactions.indexOf(transaction);
+ return index;
+
+ }
+
+ public void updateEntry(Entry entry) {
+ financialTransactionService.updateEntry(entry);
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-17 13:08:18 UTC (rev 3682)
@@ -69,10 +69,10 @@
onActionPerformed="handler.deleteSelectedTransaction()" />
<JButton toolTipText="{ _("lima.entries.copy.transaction") + " (Ctrl+Shift+C)"}" actionIcon='copy'
enabled="{isSelectedRow()}"
- onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())" />
+ onActionPerformed="handler.copyTransaction()" />
<JButton toolTipText="{ _("lima.entries.paste.transaction") + " (Ctrl+Shift+V)"}" actionIcon='paste'
enabled="{isTransactionInClipBoard()}"
- onActionPerformed="handler.pasteTransaction(financialTransactionTable.getSelectedRow())" />
+ onActionPerformed="handler.pasteTransaction()" />
<JToolBar.Separator/>
@@ -84,17 +84,17 @@
onActionPerformed="handler.deleteSelectedEntry()" />
<JButton toolTipText="{ _("lima.entries.copy.entry") + " (Ctrl+Alt+C)"}" actionIcon='copy'
enabled="{isSelectedRow()}"
- onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())" />
+ onActionPerformed="handler.copyEntry()" />
<JButton toolTipText="{ _("lima.entries.paste.entry") + " (Ctrl+Alt+V)"}" actionIcon='paste'
enabled="{isEntryInClipBoard() && isSelectedRow()}"
- onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())" />
+ onActionPerformed="handler.pasteEntry()" />
<JButton toolTipText="{ _("lima.entries.assign.entries") + " (Ctrl+Alt+A)"}" actionIcon='assign-all-entries-in-transaction'
enabled="{isAssignableInAllEntries() && isSelectedRow()}"
onActionPerformed="handler.assignAllEntries()" />
<JToolBar.Separator/>
<JButton toolTipText="{ _("lima.entries.balance") + " (Ctrl+B)"}" actionIcon='balance'
enabled="{!isBalance()}"
- onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())" />
+ onActionPerformed="handler.balanceTransaction()" />
<JToolBar.Separator/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -34,7 +34,6 @@
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
@@ -56,8 +55,6 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -98,6 +95,7 @@
LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this);
LimaServiceFactory.addServiceListener(ImportService.class, this);
}
+
/**
* Init all combo box in view.
*/
@@ -196,15 +194,7 @@
transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook);
}
- // move it to unique collection for table rendering
- for (FinancialTransaction transaction : transactions) {
- //transAndEntries.add(transaction);
- List<Entry> entries = (List<Entry>) transaction.getEntry();
- Collections.sort(entries, new EntryComparator());
- transAndEntries.addAll(entries);
- }
-
- view.getFinancialTransactionTableModel().setEntries(transAndEntries);
+ view.getFinancialTransactionTableModel().setTransactions(transactions);
}
public void selectionChanged() {
@@ -222,115 +212,104 @@
}
}
- public void balanceTransaction(int rowSelected) {
+ public void balanceTransaction() {
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
FinancialTransactionTable table = view.getFinancialTransactionTable();
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
- }
+ int rowSelected = table.getSelectedRow();
+ if (rowSelected != -1) {
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
- Entry entry = tableModel.getEntryAt(rowSelected);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (entry.isDebit()) {
- debit = debit.subtract(entry.getAmount());
- } else {
- credit = credit.subtract(entry.getAmount());
- }
+ Entry entry = tableModel.getEntryAt(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
- BigDecimal balance = credit.subtract(debit);
- entry.setAmount(balance.abs());
- entry.setDebit(balance.signum() > 0);
- financialTransactionService.updateEntry(entry);
- tableModel.fireTableRowsUpdated(rowSelected, rowSelected);
- view.setBalance(true);
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+ }
}
/**
* Copy selected Transaction
- *
- * @param indexSelectedRow selected row to copy a transaction
+ *
*/
- public void copyTransaction(int indexSelectedRow){
- clipBoard = view.getFinancialTransactionTableModel().getTransactionAt(indexSelectedRow);
- view.setTransactionInClipBoard(true);
- view.setEntryInClipBoard(false);
+ public void copyTransaction(){
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ clipBoard = view.getFinancialTransactionTableModel().getTransactionAt(indexSelectedRow);
+ view.setTransactionInClipBoard(true);
+ view.setEntryInClipBoard(false);
+ }
}
/**
* Copy selected Entry
*
- * @param indexSelectedRow selected row to copy a entry
*/
- public void copyEntry(int indexSelectedRow){
+ public void copyEntry(){
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
clipBoard = view.getFinancialTransactionTableModel().getEntryAt(indexSelectedRow);
view.setTransactionInClipBoard(false);
view.setEntryInClipBoard(true);
+ }
}
/**
* Paste Transaction.
- *
- * @param indexSelectedRow selected row to paste
+ *
*/
- public void pasteTransaction(int indexSelectedRow){
+ public void pasteTransaction(){
FinancialTransactionTable table = view.getFinancialTransactionTable();
//select the new line
ListSelectionModel selectionModel = table.getSelectionModel();
- if (clipBoard != null && clipBoard instanceof FinancialTransaction) {
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1 && clipBoard != null && clipBoard instanceof FinancialTransaction) {
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- FinancialTransaction transactionTemp = (FinancialTransaction) clipBoard;
+ FinancialTransaction transaction = (FinancialTransaction) clipBoard;
- //need to know number of entries of copied transaction
- //to select the new transaction
- Collection<Entry> entriesTmp = transactionTemp.getEntry();
- int nbentries = entriesTmp.size()+1;
-
- //new transaction with only entrybook and date
- FinancialTransaction transaction = new FinancialTransactionImpl();
- EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
- transaction.setEntryBook(entryBook);
- transaction.setTransactionDate(transactionTemp.getTransactionDate());
- transaction = financialTransactionService.createFinancialTransaction(transaction);
-
- for (Entry entryTmp : entriesTmp) {
- Entry entry = new EntryImpl();
- entry.setFinancialTransaction(transaction);
- entry.setVoucher(entryTmp.getVoucher());
- entry.setAccount(entryTmp.getAccount());
- entry.setDescription(entryTmp.getDescription());
- entry.setAmount(entryTmp.getAmount());
- entry.setDebit(entryTmp.getDebit());
- entry = financialTransactionService.createEntry(entry);
- transaction.addEntry(entry);
- }
-
tableModel.addTransaction(transaction);
+
if (table.isEditing()) {
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
int index = tableModel.indexOf(transaction);
selectionModel.setSelectionInterval(index, index);
+ table.editCellAt(index, 1);
}
}
/**
* Paste row.
*
- * @param indexSelectedRow selected row to paste
*/
- public void pasteEntry(int indexSelectedRow){
+ public void pasteEntry(){
+
FinancialTransactionTable table = view.getFinancialTransactionTable();
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
//select the new line
ListSelectionModel selectionModel = table.getSelectionModel();
-
- if (clipBoard != null && clipBoard instanceof Entry) {
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1 && clipBoard != null && clipBoard instanceof Entry) {
Entry entryTmp = (Entry) clipBoard;
FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
Entry entry = new EntryImpl();
@@ -341,53 +320,22 @@
entry.setAmount(entryTmp.getAmount());
entry.setDebit(entryTmp.getDebit());
- entry = financialTransactionService.createEntry(entry);
-
- transaction.addEntry(entry);
-
-
if (table.isEditing()) {
TableCellEditor editor = table.getCellEditor();
editor.stopCellEditing();
}
- int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- tableModel.addEntry(entry, index);
+ tableModel.addEntry(entry);
+
+ int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
selectionModel.setSelectionInterval(index, index);
//focus on second column
table.changeSelection(index, 1, false, false);
- table.requestFocusInWindow();
+ table.editCellAt(index, 1);
}
}
- /**
- * @param entry
- * @param row
- * @return int: indexOf new Entry
- */
- protected int addEntry(Entry entry, int row) {
- FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- FinancialTransactionTable table = view.getFinancialTransactionTable();
- FinancialTransaction currentTransaction = tableModel.getTransactionAt(row);
- int financialTransactionRow = 0;
-
- //create it
- entry.setFinancialTransaction(currentTransaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
- currentTransaction.addEntry(entry);
-
- // on met a jour l'ui
- if (table.isEditing()) {
- TableCellEditor editor = table.getCellEditor();
- editor.stopCellEditing();
- }
- int newRow = row + 1;
- tableModel.addEntry(newEntry, newRow);
- table.addRowSelectionInterval(newRow, newRow);
- return newRow;
- }
-
- /**
+ /**
* Add new transaction.
*/
public void addFinancialTransaction() {
@@ -425,15 +373,8 @@
// set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
// create it
- FinancialTransaction fTransaction = financialTransactionService.createFinancialTransaction(financialTransaction);
+ tableModel.addTransaction(financialTransaction);
- // create first entry of this transaction
- Entry entry = new EntryImpl();
- entry.setFinancialTransaction(fTransaction);
- entry = financialTransactionService.createEntry(entry);
- fTransaction.addEntry(entry);
- // add it in ui
- tableModel.addTransaction(fTransaction);
int addIndex = tableModel.size() - 1;
//select the new line
@@ -444,6 +385,7 @@
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionInterval(addIndex, addIndex);
table.changeSelection(addIndex, 1, false, false);
+ table.editCellAt(addIndex, 1);
}
/**
@@ -458,14 +400,17 @@
// real selected row or selected transaction row ?
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
-
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
//First case, where line selected is an entry : take its transaction
//to select the last entry of the transaction
Entry entryAt = tableModel.getEntryAt(indexSelectedRow);
- Entry lastEntry = financialTransactionService.getLastEntry(entryAt.getFinancialTransaction());
+ FinancialTransaction transaction = entryAt.getFinancialTransaction();
+ int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
+ Entry lastEntry = tableModel.getEntryAt(rowLasEntry);
- FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
-
if (log.isDebugEnabled()) {
log.debug("Selected row : " + indexSelectedRow);
}
@@ -514,20 +459,18 @@
entry.setDebit(credit.compareTo(debit) > 0);
entry.setAmount(credit.subtract(debit).abs());
- // create it in service
entry.setFinancialTransaction(transaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
- transaction.addEntry(newEntry);
- // add it in ui
- int addIndex = tableModel.indexOf(lastEntry) + 1;
- tableModel.addEntry(newEntry, addIndex);
+ // create it in service
+ tableModel.addEntry(entry);
//select the new line
+ int row = rowLasEntry + 1;
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionInterval(
- addIndex, addIndex);
- table.changeSelection(addIndex, 1, false, false);
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
} else {
if (log.isWarnEnabled()) {
@@ -543,7 +486,6 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow >= 0) {
- FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
TableCellEditor cellEditor = table.getCellEditor();
if (cellEditor != null) {
cellEditor.cancelCellEditing();
@@ -554,11 +496,8 @@
if (response == JOptionPane.YES_OPTION) {
- financialTransactionService.removeFinancialTransaction(transaction);
+ tableModel.removeTransaction(indexSelectedRow);
- //must delete the entries of the deleted transaction
- tableModel.deleteTransaction(transaction);
-
if (tableModel.size() > 0) {
if (indexSelectedRow >= tableModel.size()) {
indexSelectedRow = tableModel.size() - 1;
@@ -566,6 +505,7 @@
selectionModel.setSelectionInterval(
indexSelectedRow, indexSelectedRow);
table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
}
@@ -590,16 +530,9 @@
_("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- FinancialTransaction transaction = entry.getFinancialTransaction();
- if (transaction.sizeEntry() > 1) {
- financialTransactionService.removeEntry(entry);
- transaction.removeEntry(entry);
- tableModel.deleteEntry(entry);
- } else {
- financialTransactionService.removeFinancialTransaction(transaction);
- tableModel.deleteTransaction(transaction);
- }
+ tableModel.removeEntry(indexSelectedRow);
+
if (tableModel.size() > 0) {
if (indexSelectedRow >= tableModel.size()) {
indexSelectedRow = tableModel.size() - 1;
@@ -607,6 +540,7 @@
selectionModel.setSelectionInterval(
indexSelectedRow, indexSelectedRow);
table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -115,7 +115,7 @@
}
/**
- * Le model est une combinaison de Transaction/Entries.
+ * Le model est une combinaison de Transaction/entries.
*
* @return
*/
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -28,23 +28,26 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.EmptyCellRenderer;
+import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
-import org.jdesktop.swingx.JXTable;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import org.chorem.lima.ui.common.CellRouteHorizontalAction;
+import org.chorem.lima.ui.common.CellRouteVerticalAction;
import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
-import java.awt.Color;
-import java.awt.Component;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
+import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
import java.math.BigDecimal;
import java.util.Date;
@@ -54,190 +57,134 @@
* @author ore
* @author Rémi Chapelet
*/
-public class FinancialTransactionUnbalancedTable extends JXTable
- implements KeyListener, MouseListener {
+public class FinancialTransactionUnbalancedTable extends JTable {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected FinancialTransactionUnbalancedViewHandler handler;
+ protected final FinancialTransactionUnbalancedViewHandler handler;
private Highlighter colorTransaction;
private ColorHighlighter colorBalance;
- public FinancialTransactionUnbalancedTable(FinancialTransactionUnbalancedViewHandler handler) {
+ public FinancialTransactionUnbalancedTable(final FinancialTransactionUnbalancedViewHandler handler) {
this.handler = handler;
- addKeyListener(this);
- addMouseListener(this);
-
//Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
+
//Get new entry book editor
setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
+
+ //Get new String editor
+ StringTableCellEditor stringTableCellEditor = new StringTableCellEditor();
+ setDefaultEditor(String.class, stringTableCellEditor);
+
//Get new account editor
setDefaultEditor(Account.class, new AccountTableCellEditor());
+
//Get new amount editor
setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
+
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
+
+ //get new Date renderer for empty cells
+ setDefaultRenderer(Date.class, new DateTableCellRenderer());
+
//get new String renderer for empty cells
- setDefaultRenderer(String.class, new EmptyCellRenderer());
+ setDefaultRenderer(String.class, new EntryTableCellRenderer());
+
//get new Account renderer for empty cells
- setDefaultRenderer(Account.class, new EmptyCellRenderer());
+ setDefaultRenderer(Account.class, new AccountTableCellRenderer());
+
//get new EntryBook renderer for empty cells
- setDefaultRenderer(EntryBook.class, new EmptyCellRenderer());
+ setDefaultRenderer(EntryBook.class, new EntryBookTableCellRender());
- //highlight financial financial transactions
- addColorTransaction();
- // highlight unbalanced financial transactions
- addColorNonBalancedTransaction();
- }
+ setShowHorizontalLines(true);
+ setShowVerticalLines(true);
+ setGridColor(new Color(210,210,210));
- /**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- * On récupère la première cellule, on vérifie que c'est une date
- */
- protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return adapter.getValueAt(adapter.row, 0) instanceof Date;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(222, 222, 222), null);
- addHighlighter(colorTransaction);
- }
+ InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = getActionMap();
+ // action on Tab
+ Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+ actionMap.put(binding, new CellRouteHorizontalAction(this, true));
- /**
- * Permet de surligner une transaction dans le tableau lorsque
- * cette dernière n'est pas équilibrée.
- * On récupère la dernière cellule de la ligne
- * et on vérifie si la valeur est différente de 0
- */
- protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = adapter.getValueAt(adapter.row, 8);
- if (value instanceof BigDecimal) {
- BigDecimal currentBalance = (BigDecimal) value;
- // can compare two BigDecimals with different scales
- // e.g: 3.1 == 3.10
- if (currentBalance.compareTo(BigDecimal.ZERO) != 0) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(255, 198, 209), null);
- addHighlighter(colorTransaction);
- }
+ // action on Shift + Tab
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteHorizontalAction(this, false));
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
+ // action on Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
+ actionMap.put(binding, new CellRouteVerticalAction(this, true));
- //TODO combinaison de touches dans la config
+ // action on Shift + Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteVerticalAction(this, false));
- // delete selected row with the key : delete or ctrl clear
- // ou de l'entree
- if (e.getKeyCode() == KeyEvent.VK_DELETE
- || e.getKeyCode() == KeyEvent.VK_CLEAR
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.deleteSelectedRow();
- }
+ // add action on Ctrl + Shift + Delete
+ binding = "delete-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.deleteSelectedTransaction();
+ }
+ });
- // add entry with the key combination : insert or ctrl + enter
- if (e.getKeyCode() == KeyEvent.VK_INSERT
- || e.getKeyCode() == KeyEvent.VK_ENTER
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.addEmptyEntry();
- }
+ // add action on Ctrl + N
+ binding = "new-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.addEntry();
+ }
+ });
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
+ // add action on Ctrl + Delete
+ binding = "delete-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.deleteSelectedEntry();
}
- }
+ });
- /**
- * Touche tab
- * Ajoute une entrée comptable si tab est sur
- * la dernière cellule.
- */
-
- //TODO 2010-08-19 verifier si la transaction est équilibré
- // cf. FinancialTransactionTable.java comme modèle
- if (e.getKeyChar() == KeyEvent.VK_TAB) {
- // Vérifie si la cellule sélectionnée est la dernière
-
- int x = getSelectedColumn();
- int y = getSelectedRow();
- int max_x = getColumnCount() - 1;
- int max_y = getRowCount() - 1;
- if (x == max_x && y == max_y) {
- handler.addEmptyEntry();
- // positionne la sélection sur la nouvelle ligne créée
- setColumnSelectionInterval(0, 0);
- setRowSelectionInterval(max_y + 1, max_y + 1);
+ // add action on Ctrl + B
+ binding = "balance";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.balanceTransaction();
}
+ });
+
+ // remove input Ctrl + Del
+ inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED);
+ while (inputMap != null) {
+ inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
+ inputMap = inputMap.getParent();
}
- }
+ addMouseListener(new MyMouseAdapter());
- /*
- * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
- */
- @Override
- public void keyTyped(KeyEvent e) {
-
}
- @Override
- public void keyReleased(KeyEvent e) {
- }
+ private class MyMouseAdapter extends MouseAdapter {
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if (rowAtPoint(e.getPoint()) == -1) {
+ clearSelection();
+ }
}
}
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -25,30 +25,22 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
-import static org.nuiton.i18n.I18n._;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
import org.chorem.lima.LimaContext;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
import org.nuiton.util.decorator.Decorator;
import org.nuiton.util.decorator.DecoratorProvider;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Basic transaction table model.
* <p/>
@@ -57,30 +49,22 @@
* @author ore
* @author chatellier
*/
-public class FinancialTransactionUnbalancedTableModel extends AbstractTableModel implements ServiceListener {
+public class FinancialTransactionUnbalancedTableModel extends FinancialTransactionTableModel {
/** serialVersionUID. */
private static final long serialVersionUID = 3914954536809622358L;
- /** Transaction service. */
- protected final FinancialTransactionService financialTransactionService;
-
/** selected financial period */
protected FiscalPeriod selectedFiscalPeriod;
- /** data cache */
- protected List<Object> cacheDataList;
-
/**
* To decorate account objects.
*/
protected final Decorator<Account> accountDecorator;
public FinancialTransactionUnbalancedTableModel() {
- financialTransactionService =
- LimaServiceFactory.getService(
- FinancialTransactionService.class);
- LimaServiceFactory.addServiceListener(financialTransactionService, this);
+ super();
+ //LimaServiceFactory.addServiceListener(financialTransactionService, this);
DecoratorProvider decoratorProvider =
LimaContext.get().getDecoratorProvider();
@@ -88,34 +72,24 @@
}
/**
- * Le model est une combinaison de Transaction/Entries.
+ * Le model est une combinaison de Transaction/entries.
*
* @return
*/
- protected List<Object> getDataList() {
- List<Object> results = new ArrayList<Object>();
+ protected void refresh() {
+ transactions.clear();
+
if (selectedFiscalPeriod != null) {
- List<FinancialTransaction> financialtransactions =
+ List<FinancialTransaction> financialTransactions =
financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- results.add(financialtransaction);
- List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
- Collections.sort(entries, new EntryComparator());
- results.addAll(entries);
- }
+ transactions.addAll(financialTransactions);
+ sortEntries();
}
-
- return results;
}
- public void refresh() {
- cacheDataList = getDataList();
- fireTableDataChanged();
- }
-
@Override
public int getColumnCount() {
- return 9;
+ return 8;
}
@Override
@@ -146,9 +120,6 @@
result = BigDecimal.class;
break;
case 7:
- result = BigDecimal.class;
- break;
- case 8:
result = String.class;
break;
}
@@ -183,9 +154,6 @@
result = _("lima.table.credit");
break;
case 7:
- result = _("lima.table.balance");
- break;
- case 8:
result = _("lima.table.letter");
break;
}
@@ -194,105 +162,47 @@
}
@Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.size();
- }
-
- return result;
- }
-
- @Override
public Object getValueAt(int row, int column) {
+ Entry entry = entries.get(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
Object result = null;
- // just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.get(row);
- if (result instanceof FinancialTransaction) {
- // Values for a transaction "header"
- FinancialTransaction currentRow = (FinancialTransaction) result;
- BigDecimal amountDebit = currentRow.getAmountDebit();
- BigDecimal amountCredit = currentRow.getAmountCredit();
-
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- if (currentRow.getEntryBook() != null) {
- result = currentRow.getEntryBook().getCode();
- } else {
- result = null;
- }
- break;
- case 2:
- result = null; //entrybook
- break;
- case 3:
- result = null; // account
- break;
- case 4:
- result = null; // description
- break;
- case 5:
- result = amountDebit;
- break;
- case 6:
- result = amountCredit;
- break;
- case 7:
- result = amountDebit.subtract(amountCredit);
- break;
- case 8:
- result = null;
- break;
+ switch (column) {
+ case 0:
+ if (row == 0 || entries.get(row - 1).getFinancialTransaction() != transaction) {
+ result = transaction.getTransactionDate();
}
- } else if (result instanceof Entry) {
- // Values for transaction content
- Entry currentEntry = (Entry) result;
- switch (column) {
- case 0:
- result = null; // date, set in header
- break;
- case 1: // entry book, set in header
- result = null;
- break;
- case 2:
- result = currentEntry.getVoucher();
- break;
- case 3: // account
- if (currentEntry.getAccount() == null) {
- result = null;
- } else {
- Account acc = currentEntry.getAccount();
- result = accountDecorator.toString(acc);
- }
- break;
- case 4:
- result = currentEntry.getDescription();
- break;
- case 5:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO;
- break;
- case 6:
- result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount();
- break;
- case 7:
- result = null;
- break;
- case 8:
- result = currentEntry.getLettering();
- break;
+ break;
+ case 1:
+ if ((row == 0 || entries.get(row - 1).getFinancialTransaction() != transaction) && transaction.getEntryBook() != null) {
+ result = transaction.getEntryBook();
}
-
- }
+ break;
+ case 2:
+ result = entry.getVoucher();
+ break;
+ case 3: // account
+ if (entry.getAccount() == null) {
+ result = null;
+ } else {
+ Account acc = entry.getAccount();
+ result = accountDecorator.toString(acc);
+ }
+ break;
+ case 4:
+ result = entry.getDescription();
+ break;
+ case 5:
+ result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
+ break;
+ case 6:
+ result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
+ break;
+ case 7:
+ result = entry.getLettering();
+ break;
}
-
return result;
}
@@ -306,150 +216,128 @@
*/
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
- boolean editableCell = false;
- Object currentRow = cacheDataList.get(rowIndex);
- // cells editable for the entry row, all cells exclude the date
- if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1)) {
- editableCell = true;
- }
- // cells editable for the financialtransaction row, no cells exclude the date
- if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) {
- editableCell = true;
- }
- return editableCell;
+ return columnIndex > 1
+ || rowIndex == 0
+ || entries.get(rowIndex).getFinancialTransaction() != entries.get(rowIndex - 1).getFinancialTransaction();
}
- /**
- * @param value
- * @param description
- * @param row
- * @return int: indexOf new Entry
- */
- public int addEmptyEntry(Object value, String description, int row) {
- FinancialTransaction currentTransaction = null;
- Object currentRow = cacheDataList.get(row);
- Entry entry = new EntryImpl();
- entry.setAmount(BigDecimal.ZERO);
- if (description != null) {
- entry.setDescription(description);
- }
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction) currentRow;
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- Entry newEntry = financialTransactionService.createEntry(entry);
- //on recharge la liste
- int newrow = cacheDataList.indexOf(newEntry);
- fireTableRowsInserted(row, row);
- return newrow;
- }
-
/** to modifiy financialtransaction or entry */
@Override
public void setValueAt(Object value, int row, int column) {
- int financialTransactionRow = 0;
- // just prevent too much result
- if (selectedFiscalPeriod != null) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentFinancialTransaction =
- (FinancialTransaction) currentRow;
- switch (column) {
- case 0:
- //update
- currentFinancialTransaction.setTransactionDate((Date) value);
- break;
- case 1:
- currentFinancialTransaction.setEntryBook((EntryBook) value);
- break;
+
+ Entry entry = entries.get(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ boolean updateEntry = false;
+ boolean updateTransaction = false;
+ boolean updateBalance = false;
+ switch (column) {
+ case 0:
+ //update
+ updateTransaction = (transaction.getTransactionDate().compareTo((Date) value) != 0);
+ if (updateTransaction) {
+ transaction.setTransactionDate((Date) value);
}
- // notify service for modification
- financialTransactionService.
- updateFinancialTransaction(currentFinancialTransaction);
+ break;
+ case 1:
+ EntryBook entryBook = (EntryBook) value;
+ updateTransaction = ((transaction.getEntryBook()) == null != (entryBook == null))
+ || (transaction.getEntryBook() != null
+ && entryBook != null
+ && !transaction.getEntryBook().getCode().equals(entryBook.getCode()));
+ if (updateTransaction) {
+ transaction.setEntryBook(entryBook);
+ }
+ break;
+ case 2:
+ String voucher = ((String) value).trim();
- //update the financial transaction in entire
-// financialTransactionRow =
-// cacheDataList.indexOf(currentRow);
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- switch (column) {
- case 2:
- currentEntry.setVoucher((String) value);
- break;
- case 3:
- currentEntry.setAccount((Account) value);
- break;
- case 4:
- currentEntry.setDescription((String) value);
- break;
- case 5:
- currentEntry.setAmount((BigDecimal) value);
- currentEntry.setDebit(true);
- break;
- case 6:
- currentEntry.setAmount((BigDecimal) value);
- currentEntry.setDebit(false);
- break;
- case 8:
- currentEntry.setLettering((String) value);
- break;
+ updateEntry = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
+ if (updateEntry) {
+ entry.setVoucher(voucher);
}
+ break;
+ case 3:
+ Account account = (Account) value;
+ updateEntry = ((entry.getAccount()) == null != (account == null))
+ || (entry.getAccount() != null
+ && account != null
+ && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
+ if (updateEntry) {
+ entry.setAccount(account);
+ }
+ break;
+ case 4:
+ String description = ((String) value).trim();
- financialTransactionService.updateEntry(currentEntry);
+ updateEntry = (entry.getDescription() == null || entry.getDescription().compareTo(description) != 0);
+ if (updateEntry) {
+ entry.setDescription(description);
+ }
+ break;
+ case 5:
+ BigDecimal debit = (BigDecimal) value;
+ updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
+ if (updateEntry) {
+ entry.setAmount(debit);
+ entry.setDebit(true);
+ updateBalance = true;
+ }
+ break;
+ case 6:
+ BigDecimal credit= (BigDecimal) value;
+ updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
+ if (updateEntry) {
+ entry.setAmount(credit);
+ entry.setDebit(false);
+ updateBalance = true;
+ }
+ break;
+ case 8:
+ String lettering = ((String) value).trim();
- //update the financial transaction in entire
-// financialTransactionRow =
-// cacheDataList.indexOf(((Entry) currentRow).
-// getFinancialTransaction());
+ updateEntry = (entry.getLettering().compareTo(lettering) != 0);
+ if (updateEntry) {
+ entry.setLettering(lettering);
+ }
+ break;
+ }
+
+ // some modification must update all other
+ // first row modification update following rows
+ if (updateEntry) {
+ financialTransactionService.updateEntry(entry);
+ if (updateBalance) {
+ int firstRow = indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ fireTableRowsUpdated(firstRow, lastRow);
+ } else {
+ fireTableCellUpdated(row, column);
}
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableDataChanged();
+ if (log.isDebugEnabled()) {
+ log.debug("Update Entry");
+ }
+ } else if (updateTransaction) {
+ financialTransactionService.updateFinancialTransaction(transaction);
+ fireTableCellUpdated(row, column);
+ if (log.isDebugEnabled()) {
+ log.debug("Update transaction");
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No Update");
+ }
}
}
- public Object getElementAt(int row) {
- Object currentRow = cacheDataList.get(row);
- return currentRow;
- }
-
- /**
- * Delete selected row in table (could be transaction or entry).
- * <p/>
- * Called by model.
- *
- * @param object
- * @param row
- */
- public void removeObject(Object object, int row) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentTransaction =
- (FinancialTransaction) currentRow;
- financialTransactionService.removeFinancialTransaction(currentTransaction);
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- financialTransactionService.removeEntry(currentEntry);
- }
- //on recharge la liste
- refresh();
- }
-
- @Override
+ /*@Override
public void notifyMethod(String serviceName, String methodeName) {
if (serviceName.contains("FinancialTransaction") ||
methodeName.contains("importEntries") ||
methodeName.contains("importAll")) {
refresh();
}
- }
+ }*/
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-06-17 13:08:18 UTC (rev 3682)
@@ -26,61 +26,76 @@
<Table>
<import>
javax.swing.ListSelectionModel
+ javax.swing.DefaultListSelectionModel
org.chorem.lima.entity.FiscalPeriod
org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel
</import>
<FinancialTransactionUnbalancedViewHandler id="handler"
javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/>
+
+ <ListSelectionModel
+ id='selectionModel'
+ initializer="new DefaultListSelectionModel()"
+ selectionMode='{ListSelectionModel.SINGLE_SELECTION}'
+ onValueChanged="handler.selectionChanged()"/>
+
<Boolean id="selectedRow" javaBean="false"/>
+ <Boolean id="balance" javaBean="true"/>
<org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/>
<script>
<![CDATA[
void $afterCompleteSetup() {
- getHandler().refresh();
+ getHandler().init();
}
]]>
</script>
+ <row>
+ <cell fill="horizontal">
+ <JToolBar floatable="false">
+ <JButton toolTipText="{ _("lima.entries.remove.transaction") + " (Ctrl+Shift+Del)"}"
+ actionIcon='delete-financial-transaction'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().deleteSelectedTransaction()" />
+ <JButton toolTipText ="{ _("lima.entries.addEntry") + " (Ctrl+N)"}" actionIcon='add-entry'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().addEntry()" />
+ <JButton toolTipText="{ _("lima.entries.remove.entry") + " (Ctrl+Del)"}" actionIcon='delete-entry'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().deleteSelectedEntry()" />
+ <JToolBar.Separator/>
+ <JButton toolTipText="{ _("lima.entries.balance") + " (Ctrl+B)"}" actionIcon='balance'
+ enabled="{!isBalance()}"
+ onActionPerformed="handler.balanceTransaction()" />
+ <JToolBar.Separator/>
- <row weightx="1" weighty="0" anchor="center">
- <cell anchor="west">
- <JButton text="lima.ui.common.refresh" onActionPerformed="getHandler().refresh()"/>
- </cell>
- <cell anchor="east">
- <JLabel id="fiscalPeriodLabel" text="lima.ui.financialtransaction.fiscalyear"/>
- </cell>
- <cell anchor="west">
- <JComboBox id="fiscalPeriodComboBox"
- model="{modelFiscalPeriod}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem());
+ <JLabel id="fiscalPeriodLabel"
+ actionIcon='choose-fiscal-year'
+ labelFor='{fiscalPeriodComboBox}'/>
+ <JComboBox id="fiscalPeriodComboBox" model="{modelFiscalPeriod}"
+ toolTipText="lima.ui.financialtransaction.fiscalyear"
+ renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
+ onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem());
getHandler().refresh()"
- editable="false"/>
+ editable="false"/>
+ <JToolBar.Separator/>
+ <JButton toolTipText="{ _("lima.ui.common.refresh") + " (F5)"}" actionIcon='refresh'
+ onActionPerformed="getHandler().refresh()"/>
+
+ </JToolBar>
</cell>
- <cell>
- <JButton text="lima.entries.addEntry"
- onActionPerformed="getHandler().addEmptyEntry()"
- enabled="{isSelectedRow()}"/>
- </cell>
- <cell>
- <JButton text="lima.common.remove"
- onActionPerformed="getHandler().deleteSelectedRow()"
- enabled="{isSelectedRow()}"/>
- </cell>
</row>
+
<row>
- <cell fill="both" weightx="1" weighty="1" rows="1" columns="9">
+ <cell fill="both" weightx="1" weighty="1" rows="1" >
<JScrollPane>
<FinancialTransactionUnbalancedTableModel
id="financialTransactionUnbalancedTableModel"/>
<FinancialTransactionUnbalancedTable
- id="financialTransactionUnbalancedTable" sortable="false"
+ id="financialTransactionUnbalancedTable"
rowHeight="22"
constructorParams="getHandler()"
- model="{getFinancialTransactionUnbalancedTableModel()}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <ListSelectionModel
- javaBean="getFinancialTransactionUnbalancedTable().getSelectionModel()"
- onValueChanged="setSelectedRow(financialTransactionUnbalancedTable.getSelectedRow() != -1)"/>
+ selectionModel='{selectionModel}'
+ model="{getFinancialTransactionUnbalancedTableModel()}"/>
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-06-14 09:26:25 UTC (rev 3681)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-06-17 13:08:18 UTC (rev 3682)
@@ -25,16 +25,19 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.JOptionPane;
-import javax.swing.ListSelectionModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler associated with financial transaction view.
*
@@ -56,26 +59,47 @@
this.view = view;
}
+
+ /**
+ * Init all combo box in view.
+ */
+ public void init() {
+
+ if (view.getFiscalPeriodComboBox().getModel().getSize() > 0) {
+ view.getFiscalPeriodComboBox().setSelectedIndex(0);
+ }
+ refresh();
+ }
+
//implement new transaction button
//add a new entry to the selected transaction
- public void addEmptyEntry() {
+ public void addEntry() {
FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = tableModel.getElementAt(indexSelectedRow);
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
+
+ Entry entry = tableModel.getEntryAt(indexSelectedRow);
//copy + paste the description
- String description = (String) tableModel.getValueAt(indexSelectedRow, 4);
- int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow);
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(entry.getFinancialTransaction());
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setDescription(entry.getDescription());
+
+ tableModel.addEntry(newEntry);
//select the new line
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1);
- //focus on second column
- table.changeSelection(index, 1, false, false);
- table.requestFocusInWindow();
+ int row = tableModel.indexOf(newEntry.getFinancialTransaction()) + newEntry.getFinancialTransaction().sizeEntry() - 1;
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ row, row);
+ table.changeSelection(row, 1, false, false);
+ table.editCellAt(row, 1);
} else {
if (log.isWarnEnabled()) {
log.warn("Call addentry selected transaction without selection");
@@ -88,7 +112,7 @@
* <p/>
* Called by tableModel.
*/
- public void deleteSelectedRow() {
+ public void deleteSelectedEntry() {
FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
@@ -96,23 +120,76 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = tableModel.getElementAt(indexSelectedRow);
- String message;
- if (selectedValue instanceof FinancialTransaction) {
- message = _("lima.charts.financialtransaction.question.removetransaction");
- } else {
- message = _("lima.charts.financialtransaction.question.removeentry");
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
}
+ String message = _("lima.charts.financialtransaction.question.removeentry");
+
int response = JOptionPane.showConfirmDialog(view, message,
_("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- tableModel.removeObject(selectedValue, indexSelectedRow);
+
+ tableModel.removeEntry(indexSelectedRow);
+
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
+ }
+ }
+ } else {
+ if (log.isWarnEnabled()) {
+ log.warn("Call delete selected row without selection");
+ }
+ }
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ * <p/>
+ * Called by tableModel.
+ */
+ public void deleteSelectedTransaction() {
+
+ FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
+
+ int indexSelectedRow = table.getSelectedRow();
+ if (indexSelectedRow != -1) {
+
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
+
+ String message = _("lima.charts.financialtransaction.question.removetransaction");
+
+ int response = JOptionPane.showConfirmDialog(view, message,
+ _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION);
+
+ if (response == JOptionPane.YES_OPTION) {
+ tableModel.removeTransaction(indexSelectedRow);
//select the upper line
- ListSelectionModel selectionModel =
- table.getSelectionModel();
- selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1);
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ table.editCellAt(indexSelectedRow, 1);
+ }
}
} else {
if (log.isWarnEnabled()) {
@@ -121,9 +198,72 @@
}
}
+ public void selectionChanged() {
+ FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
+
+ int selectedRow = table.getSelectedRow();
+ view.setSelectedRow(selectedRow >= 0 && selectedRow < tableModel.size());
+ if (selectedRow >= 0 && selectedRow < tableModel.size()) {
+ FinancialTransaction transaction = tableModel.getTransactionAt(selectedRow);
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ view.setBalance(credit.compareTo(debit) == 0);
+ } else {
+ view.setBalance(true);
+ }
+ }
+
+ public void balanceTransaction() {
+ FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+ FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
+
+ int rowSelected = table.getSelectedRow();
+ if (rowSelected != -1) {
+
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+
+ Entry entry = tableModel.getEntryAt(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
+
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ tableModel.updateEntry(entry);
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ view.setBalance(true);
+
+ ListSelectionModel selectionModel = table.getSelectionModel();
+ selectionModel.setSelectionInterval(rowSelected, rowSelected);
+ table.changeSelection(rowSelected, 1, false, false);
+ table.editCellAt(rowSelected, 1);
+
+ }
+ }
+
public void refresh() {
FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel();
+ FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable();
+
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+
tableModel.refresh();
+ table.clearSelection();
FiscalPeriodComboBoxModel comboBoxModel = view.getModelFiscalPeriod();
comboBoxModel.refresh();
1
0
r3681 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/financialtransaction resources/i18n resources/icons
by Bavencoff@users.chorem.org 14 Jun '13
by Bavencoff@users.chorem.org 14 Jun '13
14 Jun '13
Author: Bavencoff
Date: 2013-06-14 11:26:25 +0200 (Fri, 14 Jun 2013)
New Revision: 3681
Url: http://chorem.org/projects/lima/repository/revisions/3681
Log:
user experience
Added:
trunk/lima-swing/src/main/resources/icons/action-add-entry.png
trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png
trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png
trunk/lima-swing/src/main/resources/icons/action-balance.png
trunk/lima-swing/src/main/resources/icons/action-choose-book.png
trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png
trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png
trunk/lima-swing/src/main/resources/icons/action-copy.png
trunk/lima-swing/src/main/resources/icons/action-delete-entry.png
trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png
trunk/lima-swing/src/main/resources/icons/action-delete.png
trunk/lima-swing/src/main/resources/icons/action-next.png
trunk/lima-swing/src/main/resources/icons/action-paste.png
trunk/lima-swing/src/main/resources/icons/action-previous.png
trunk/lima-swing/src/main/resources/icons/action-refresh.png
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
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/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-14 09:26:25 UTC (rev 3681)
@@ -1,6 +1,5 @@
package org.chorem.lima.ui.celleditor;
-import com.google.common.base.Preconditions;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
import sun.swing.DefaultLookup;
@@ -23,8 +22,6 @@
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
//Create a new JLabel to avoid colouring only when row is selected
- Preconditions.checkState(table instanceof FinancialTransactionTable);
-
JLabel myCell = new JLabel();
myCell.setOpaque(true);
myCell.setBorder(new EmptyBorder(1, 1, 1, 1));
@@ -33,28 +30,20 @@
Color background = Color.WHITE;
Color foreground = Color.BLACK;
- FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
-
- /*JTable.DropLocation dropLocation = table.getDropLocation();
- if (dropLocation != null
- && !dropLocation.isInsertRow()
- && !dropLocation.isInsertColumn()
- && dropLocation.getRow() == row
- && dropLocation.getColumn() == column) {
-
- background = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellForeground");
- foreground = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellBackground");
-
- isSelected = true;
- } */
-
if (isSelected) {
foreground = table.getSelectionForeground();
background = table.getSelectionBackground();
} else {
Color alternateColor = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.alternateRowColor");
- if (alternateColor != null && model.getIndexTransaction(row) % 2 != 0) {
- background = alternateColor;
+ if (alternateColor != null) {
+ if (table instanceof FinancialTransactionTable) {
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
+ if (model.getIndexTransaction(row) % 2 != 0) {
+ background = alternateColor;
+ }
+ } else if (row % 2 == 0) {
+ background = alternateColor;
+ }
}
}
@@ -66,13 +55,13 @@
background = new Color(255, 198, 209);
}
- if (model.getBalanceTransactionInRow(row).signum() != 0) {
- foreground = new Color(240, 30, 30);
+ if (table instanceof FinancialTransactionTable) {
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
+ if (model.getBalanceTransactionInRow(row).signum() != 0) {
+ foreground = new Color(240, 30, 30);
+ }
}
- myCell.setBackground(background);
- myCell.setForeground(foreground);
-
if (hasFocus) {
Border border = null;
if (isSelected) {
@@ -91,6 +80,8 @@
myCell.setBorder(border);
}
+ myCell.setBackground(background);
+ myCell.setForeground(foreground);
setValue(value);
myCell.setText(text);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-14 09:26:25 UTC (rev 3681)
@@ -23,8 +23,8 @@
public StringTableCellEditor() {
super(new JTextField());
- setClickCountToStart(1);Border border = BorderFactory.createLineBorder(new Color(123, 165, 205), 2);
- //Border border = BorderFactory.createLoweredBevelBorder();
+ setClickCountToStart(1);
+ Border border = BorderFactory.createLineBorder(new Color(123, 165, 205), 2);
getComponent().setBorder(border);
getComponent().addFocusListener(new FocusListener() {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-14 09:26:25 UTC (rev 3681)
@@ -120,6 +120,116 @@
binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
actionMap.put(binding, new CellRouteVerticalFirstAction(false));
+ // add action on Ctrl + Shift + N
+ binding = "new-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.addFinancialTransaction();
+ }
+ });
+
+ // add action on Ctrl + Shift + Delete
+ binding = "delete-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.deleteSelectedTransaction();
+ }
+ });
+
+ // add action on Ctrl + Shift + C
+ binding = "copy-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (getSelectedRow() >= 0) {
+ handler.copyTransaction(getSelectedRow());
+ }
+ }
+ });
+
+ // add action on Ctrl + Shift + V
+ binding = "paste-transaction";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (getSelectedRow() >= 0) {
+ handler.pasteTransaction(getSelectedRow());
+ }
+ }
+ });
+
+ // add action on Ctrl + N
+ binding = "new-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.addEntry();
+ }
+ });
+
+ // add action on Ctrl + Delete
+ binding = "delete-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.deleteSelectedEntry();
+ }
+ });
+
+ // add action on Ctrl + Alt + C
+ binding = "copy-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (getSelectedRow() >= 0) {
+ handler.copyEntry(getSelectedRow());
+ }
+ }
+ });
+
+ // add action on Ctrl + Alt + V
+ binding = "paste-entry";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (getSelectedRow() >= 0) {
+ handler.pasteEntry(getSelectedRow());
+ }
+ }
+ });
+
+ // add action on Ctrl + B
+ binding = "balance";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ if (getSelectedRow() >= 0) {
+ handler.balanceTransaction(getSelectedRow());
+ }
+ }
+ });
+
+ // add action on Ctrl + Alt + A
+ binding = "assign-all";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.assignAllEntries();
+ }
+ });
+
// remove input Ctrl + Del
inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED);
while (inputMap != null) {
@@ -142,6 +252,12 @@
if (log.isDebugEnabled()) {
log.debug("Key tab used");
}
+
+ if (isEditing()) {
+ TableCellEditor editor = getCellEditor();
+ editor.stopCellEditing();
+ }
+
int nbColumn = getColumnCount();
int nbRows = getRowCount();
int column = getSelectedColumn();
@@ -151,6 +267,8 @@
boolean end = false;
+
+
FinancialTransaction transaction = tableModel.getTransactionAt(row);
do {
if (column >= nbColumn - 1) {
@@ -179,13 +297,8 @@
column++;
}
} while (!end && !tableModel.isCellEditable(row,column));
- if (isEditing()) {
- TableCellEditor editor = getCellEditor();
- editor.stopCellEditing();
- }
- setRowSelectionInterval(row, row);
- setColumnSelectionInterval(column, column);
- //editCellAt(row, column);
+ changeSelection(row, column, false, false);
+ editCellAt(row, column);
}
}
}
@@ -248,11 +361,8 @@
TableCellEditor editor = getCellEditor();
editor.stopCellEditing();
}
- int row = getRow();
- int column = getColumn();
- setRowSelectionInterval(row, row);
- setColumnSelectionInterval(column, column);
- //editCellAt(row, column);
+ changeSelection(getRow(), getColumn(), false, false);
+ editCellAt(getRow(), getColumn());
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-14 09:26:25 UTC (rev 3681)
@@ -25,6 +25,8 @@
package org.chorem.lima.ui.financialtransaction;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -35,6 +37,8 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -52,6 +56,8 @@
/** serialVersionUID. */
private static final long serialVersionUID = -7495388454688562991L;
+ private static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class);
+
/** Service (just to update setValueAt(). */
protected FinancialTransactionService financialTransactionService;
@@ -76,6 +82,22 @@
fireTableDataChanged();
}
+ public void sortEntries() {
+ Comparator<FinancialTransaction> comparator = new Comparator<FinancialTransaction>() {
+ @Override
+ public int compare(FinancialTransaction o1, FinancialTransaction o2) {
+ return o1.getTransactionDate().compareTo(o2.getTransactionDate());
+ }
+ };
+
+ Collections.sort(transactions, comparator);
+ entries.clear();
+ for (FinancialTransaction transaction : transactions) {
+ entries.addAll(transaction.getEntry());
+ }
+ fireTableDataChanged();
+ }
+
@Override
public int getColumnCount() {
return 6;
@@ -194,19 +216,24 @@
Entry entry = entries.get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
- String description;
- boolean updateEntries = false;
+ boolean updateEntry = false;
boolean updateTransaction = false;
switch (column) {
case 0:
//update
- transaction.setTransactionDate((Date) value);
- updateTransaction = true;
+ updateTransaction = (transaction.getTransactionDate().compareTo((Date) value) != 0);
+ if (updateTransaction) {
+ transaction.setTransactionDate((Date) value);
+ }
break;
case 1:
String voucher = ((String) value).trim();
- int firstEntryRow = indexOf(transaction);
+ updateEntry = (entry.getVoucher().compareTo(voucher) != 0);
+ if (updateEntry) {
+ entry.setVoucher(voucher);
+ }
+ /*int firstEntryRow = indexOf(transaction);
if (row == firstEntryRow) {
// let's update the voucher of all entries of
@@ -220,11 +247,21 @@
// not on first row, just update this entry voucher
entry.setVoucher(voucher);
- }
+ } */
break;
case 2:
Account account = (Account) value;
- entry.setAccount(account);
+
+
+ updateEntry = ((entry.getAccount()) == null != (account == null))
+ || (entry.getAccount() != null
+ && account != null
+ && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber()));
+ if (updateEntry) {
+ entry.setAccount(account);
+ }
+
+ /*entry.setAccount(account);
if (account != null) {
// let's copy the account description
@@ -242,11 +279,17 @@
// not on first row, just update this entry description
entry.setDescription(description);
}
- }
+ } */
break;
case 3:
- description = ((String) value).trim();
- firstEntryRow = indexOf(transaction);
+ String description = ((String) value).trim();
+
+ updateEntry = (entry.getDescription().compareTo(description) != 0);
+ if (updateEntry) {
+ entry.setDescription(description);
+ }
+
+ /*firstEntryRow = indexOf(transaction);
if (row == firstEntryRow) {
// let's update the description of all entries of
@@ -260,17 +303,21 @@
// not on first row, just update this entry description
entry.setDescription(description);
- }
+ } */
break;
case 4:
- if (((BigDecimal) value).signum() > 0 ) {
- entry.setAmount((BigDecimal) value);
+ BigDecimal credit= (BigDecimal) value;
+ updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
+ if (updateEntry) {
+ entry.setAmount(credit);
entry.setDebit(false);
}
break;
case 5:
- if (((BigDecimal) value).signum() > 0 ) {
- entry.setAmount((BigDecimal) value);
+ BigDecimal debit = (BigDecimal) value;
+ updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
+ if (updateEntry) {
+ entry.setAmount(debit);
entry.setDebit(true);
}
break;
@@ -278,28 +325,23 @@
// some modification must update all other
// first row modification update following rows
- if (updateEntries) {
- // FIXME echatellier 20120413 make a single service call
- for (Entry entryTmp : transaction.getEntry()) {
- financialTransactionService.updateEntry(entryTmp);
+ if (updateEntry) {
+ financialTransactionService.updateEntry(entry);
+ fireTableCellUpdated(row, column);
+ if (log.isDebugEnabled()) {
+ log.debug("Update Entry");
}
+ } else if (updateTransaction) {
+ financialTransactionService.updateFinancialTransaction(transaction);
+ fireTableCellUpdated(row, column);
+ if (log.isDebugEnabled()) {
+ log.debug("Update transaction");
+ }
} else {
- financialTransactionService.updateEntry(entry);
+ if (log.isDebugEnabled()) {
+ log.debug("No Update");
+ }
}
- if (updateTransaction) {
- financialTransactionService.updateFinancialTransaction(transaction);
- }
- /*
- // FIXME echatellier 20120413 une modification des dates fait que l'ordre
- // devient faux
- int trIndex = indexOf(transaction);
- int endIndex = trIndex;
- if (transaction.getEntry() != null) {
- endIndex += transaction.getEntry().size();
- }
- fireTableRowsUpdated(trIndex, endIndex); */
- fireTableDataChanged();
-
}
public Entry getEntryAt(int row) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-14 09:26:25 UTC (rev 3681)
@@ -48,6 +48,7 @@
<Boolean id="transactionInClipBoard" javaBean="false"/>
<Boolean id="entryInClipBoard" javaBean="false"/>
<Boolean id="balance" javaBean="true"/>
+ <Boolean id="assignableInAllEntries" javaBean="false"/>
<script>
<![CDATA[
@@ -56,91 +57,84 @@
}
]]>
</script>
+ <row>
+ <cell fill="horizontal">
+ <JToolBar floatable="false">
+ <JButton toolTipText="{ _("lima.entries.addTransaction") + " (Ctrl+Shift+N)"}"
+ actionIcon='add-financial-transaction'
+ onActionPerformed="handler.addFinancialTransaction()" />
+ <JButton toolTipText="{ _("lima.entries.remove.transaction") + " (Ctrl+Shift+Del)"}"
+ actionIcon='delete-financial-transaction'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="handler.deleteSelectedTransaction()" />
+ <JButton toolTipText="{ _("lima.entries.copy.transaction") + " (Ctrl+Shift+C)"}" actionIcon='copy'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())" />
+ <JButton toolTipText="{ _("lima.entries.paste.transaction") + " (Ctrl+Shift+V)"}" actionIcon='paste'
+ enabled="{isTransactionInClipBoard()}"
+ onActionPerformed="handler.pasteTransaction(financialTransactionTable.getSelectedRow())" />
- <row >
- <cell fill="horizontal" columns="8">
- <JMenuBar >
- <JMenu text="lima.common.transaction" mnemonic="{'T'}">
- <JMenuItem text="lima.common.new"
- onActionPerformed="handler.addFinancialTransaction()"
- accelerator="{KeyStroke.getKeyStroke('N', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" />
- <JMenuItem text="lima.common.remove"
- enabled="{isSelectedRow()}"
- onActionPerformed="handler.deleteSelectedTransaction()"
- accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE , KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" />
- <JMenuItem text="lima.common.copy"
- enabled="{isSelectedRow()}"
- onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" />
- <JMenuItem text="lima.common.paste"
- enabled="{isTransactionInClipBoard()}"
- onActionPerformed="handler.pasteTransaction(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" />
- </JMenu>
- <JMenu text="lima.common.entry" mnemonic="{'E'}">
- <JMenuItem text="lima.common.new"
- enabled="{isSelectedRow()}"
- onActionPerformed="handler.addEntry()"
- accelerator="{KeyStroke.getKeyStroke('N', KeyEvent.CTRL_DOWN_MASK)}" />
- <JMenuItem text="lima.common.remove"
- enabled="{isSelectedRow()}"
- onActionPerformed="handler.deleteSelectedEntry()"
- accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK)}" />
- <JMenuItem text="lima.common.copy"
- enabled="{isSelectedRow()}"
- onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" />
- <JMenuItem text="lima.common.paste"
- enabled="{isEntryInClipBoard() && isSelectedRow()}"
- onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" />
- <JMenuItem text="lima.common.balance"
- enabled="{!isBalance()}"
- onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('B', KeyEvent.CTRL_DOWN_MASK)}" />
- </JMenu>
- </JMenuBar>
- </cell>
- </row>
+ <JToolBar.Separator/>
- <row >
- <cell anchor="east">
- <JLabel text="lima.ui.financialtransaction.fiscalyear" labelFor='{fiscalPeriodComboBox}'/>
- </cell>
- <cell anchor="west">
- <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/>
- <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onItemStateChanged="handler.fiscalPeriodSelected(event)"/>
- </cell>
- <cell anchor="east">
- <JLabel text="lima.ui.financialtransaction.financialperiod" labelFor='{financialPeriodComboBox}'/>
- </cell>
- <cell anchor="west">
- <JPanel>
+ <JButton toolTipText ="{ _("lima.entries.addEntry") + " (Ctrl+N)"}" actionIcon='add-entry'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="handler.addEntry()" />
+ <JButton toolTipText="{ _("lima.entries.remove.entry") + " (Ctrl+Del)"}" actionIcon='delete-entry'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="handler.deleteSelectedEntry()" />
+ <JButton toolTipText="{ _("lima.entries.copy.entry") + " (Ctrl+Alt+C)"}" actionIcon='copy'
+ enabled="{isSelectedRow()}"
+ onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())" />
+ <JButton toolTipText="{ _("lima.entries.paste.entry") + " (Ctrl+Alt+V)"}" actionIcon='paste'
+ enabled="{isEntryInClipBoard() && isSelectedRow()}"
+ onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())" />
+ <JButton toolTipText="{ _("lima.entries.assign.entries") + " (Ctrl+Alt+A)"}" actionIcon='assign-all-entries-in-transaction'
+ enabled="{isAssignableInAllEntries() && isSelectedRow()}"
+ onActionPerformed="handler.assignAllEntries()" />
+ <JToolBar.Separator/>
+ <JButton toolTipText="{ _("lima.entries.balance") + " (Ctrl+B)"}" actionIcon='balance'
+ enabled="{!isBalance()}"
+ onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())" />
+
+ <JToolBar.Separator/>
+
+ <JLabel actionIcon='choose-fiscal-year'
+ labelFor='{fiscalPeriodComboBox}'/>
+ <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/>
+ <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}"
+ toolTipText="lima.ui.financialtransaction.fiscalyear"
+ renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
+ onItemStateChanged="handler.fiscalPeriodSelected(event)"/>
+
+ <JLabel actionIcon='choose-fiscal-period'
+ labelFor='{financialPeriodComboBox}'/>
<org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/>
<JComboBox id="financialPeriodComboBox"
model="{financialPeriodComboBoxModel}"
+ toolTipText="lima.ui.financialtransaction.financialperiod"
renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
onItemStateChanged="handler.financialPeriodSelected(event)"/>
- <JButton id="back" text="lima.ui.financialtransaction.buttonback"
+ <JButton id="back" actionIcon="previous"
+ toolTipText="lima.ui.financialtransaction.previousfinancialperiod"
onActionPerformed="handler.back(financialPeriodComboBox)"/>
- <JButton id="next" text="lima.ui.financialtransaction.buttonnext"
+ <JButton id="next" actionIcon="next"
+ toolTipText="lima.ui.financialtransaction.nextfinancialperiod"
onActionPerformed="handler.next(financialPeriodComboBox)"/>
- </JPanel>
+
+ <JToolBar.Separator/>
+
+ <JLabel actionIcon="choose-book"
+ labelFor='{entryBookComboBox}'/>
+ <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/>
+ <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}"
+ toolTipText="lima.ui.financialtransaction.entrybook"
+ renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}"
+ onItemStateChanged="handler.entryBookSelected(event)"/>
+ </JToolBar>
</cell>
- <cell anchor="east">
- <JLabel text="lima.ui.financialtransaction.entrybook" labelFor='{entryBookComboBox}'/>
- </cell>
- <cell anchor="west">
- <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/>
- <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}"
- renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}"
- onItemStateChanged="handler.entryBookSelected(event)"/>
- </cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" columns="8">
+ <cell fill="both" weightx="1" weighty="1">
<JScrollPane>
<FinancialTransactionTableModel id="financialTransactionTableModel"/>
<FinancialTransactionTable
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-14 09:26:25 UTC (rev 3681)
@@ -44,9 +44,13 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListSelectionModel;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.TableColumnModelEvent;
+import javax.swing.event.TableColumnModelListener;
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
import javax.swing.table.TableCellEditor;
import java.awt.event.ItemEvent;
import java.math.BigDecimal;
@@ -68,7 +72,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialTransactionViewHandler implements ServiceListener {
+public class FinancialTransactionViewHandler implements ServiceListener, TableModelListener, TableColumnModelListener {
private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class);
@@ -116,6 +120,12 @@
if (log.isDebugEnabled()) {
log.debug(String.format("Loaded %d entry books", allEntryBooks.size()));
}
+
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ tableModel.addTableModelListener(this);
+
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ table.getColumnModel().addColumnModelListener(this);
}
/**
@@ -602,6 +612,46 @@
}
}
+ public void assignAllEntries() {
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ ListSelectionModel selectionModel = table.getSelectionModel();
+
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+
+ int selectedRow = table.getSelectedRow();
+ int selectedColumn = table.getSelectedColumn();
+ if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) {
+ Entry entrySource = tableModel.getEntryAt(selectedRow);
+ FinancialTransaction transaction = entrySource.getFinancialTransaction();
+ for (Entry entryTarget : transaction.getEntry()) {
+ if (entrySource != entryTarget) {
+ switch (selectedColumn) {
+ case 1 :
+ if (entryTarget.getVoucher().compareTo(entrySource.getVoucher()) != 0) {
+ entryTarget.setVoucher(entrySource.getVoucher());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ case 3 :
+ if (entryTarget.getDescription().compareTo(entrySource.getDescription()) != 0) {
+ entryTarget.setDescription(entrySource.getDescription());
+ financialTransactionService.updateEntry(entryTarget);
+ }
+ break;
+ }
+ }
+ }
+ int firstRow = tableModel.indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ tableModel.fireTableRowsUpdated(firstRow, lastRow);
+ table.editCellAt(selectedRow, selectedColumn);
+ }
+ }
+
/**
* Select previous value in combo box.
*
@@ -645,4 +695,57 @@
updateFinancialTransactions();
}
}
+
+ @Override
+ public void tableChanged(TableModelEvent e) {
+ if (e.getType() == TableModelEvent.UPDATE
+ && e.getColumn() == 0
+ && e.getFirstRow() >= 0) {
+ if (log.isDebugEnabled()) {
+ log.debug("Date changed");
+ }
+
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ Entry entry = tableModel.getEntryAt(e.getFirstRow());
+ tableModel.sortEntries();
+ int newRow = tableModel.indexOf(entry);
+ table.changeSelection(newRow, 0, false, false);
+ }
+ }
+
+ @Override
+ public void columnAdded(TableColumnModelEvent e) {
+ //nothing
+ }
+
+ @Override
+ public void columnRemoved(TableColumnModelEvent e) {
+ //nothing
+ }
+
+ @Override
+ public void columnMoved(TableColumnModelEvent e) {
+ //nothing
+ }
+
+ @Override
+ public void columnMarginChanged(ChangeEvent e) {
+ //nothing
+ }
+
+ @Override
+ public void columnSelectionChanged(ListSelectionEvent e) {
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+
+ int selectedRow = table.getSelectedRow();
+ int selectedColumn = table.getSelectedColumn();
+ if (selectedRow >= 0 && selectedRow < tableModel.size()) {
+ FinancialTransaction transaction = tableModel.getTransactionAt(selectedRow);
+ view.setAssignableInAllEntries(transaction.sizeEntry() > 1 && (selectedColumn == 1 || selectedColumn == 3));
+ } else {
+ view.setAssignableInAllEntries(false);
+ }
+ }
}
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 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-06-14 09:26:25 UTC (rev 3681)
@@ -52,6 +52,7 @@
lima.common.closed=Closed
lima.common.code=Code
lima.common.confirmation=Confirmation
+lima.common.cop=
lima.common.copy=Copy
lima.common.enddate=End
lima.common.entry=Entry
@@ -95,14 +96,22 @@
lima.config.ui.fullscreen.description=FullScreen
lima.documents=Documents…
lima.entries=Entries
-lima.entries.addEntry=Add entry
-lima.entries.addTransaction=Add transaction
+lima.entries.addEntry=New entry
+lima.entries.addTransaction=New transaction
+lima.entries.assign.entries=Assign this value in all entries in transaction
+lima.entries.balance=Balance transaction with this entry
+lima.entries.copy.entry=Copy entry
+lima.entries.copy.transaction=Copy transaction
lima.entries.lettering=Lettering
lima.entries.lettering.add=Add letter
lima.entries.lettering.noletterselected=Error \: No selected letter
lima.entries.lettering.radiobutton.list=Existing letters
lima.entries.lettering.radiobutton.new=New letter
lima.entries.lettering.remove=Remove letter
+lima.entries.paste.entry=Paste entry
+lima.entries.paste.transaction=Paste transaction
+lima.entries.remove.entry=Delete entry
+lima.entries.remove.transaction=Delete transaction
lima.entries.searchtransaction=Search transaction
lima.entries.searchunbalancedtransaction=Incorrect transactions
lima.entries.writetransaction=Write entries
@@ -270,6 +279,8 @@
lima.ui.financialtransaction.letter=
lima.ui.financialtransaction.messageremoveentry=
lima.ui.financialtransaction.messageremovetransaction=
+lima.ui.financialtransaction.nextfinancialperiod=Next period
+lima.ui.financialtransaction.previousfinancialperiod=previous period
lima.ui.financialtransaction.titleremoveentry=
lima.ui.financialtransaction.titleremovetransaction=
lima.ui.financialtransaction.voucher=
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 2013-06-12 16:03:34 UTC (rev 3680)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-06-14 09:26:25 UTC (rev 3681)
@@ -95,14 +95,22 @@
lima.config.ui.fullscreen.description=Plein écran
lima.documents=Documents…
lima.entries=Traitement
-lima.entries.addEntry=Ajouter entrée
-lima.entries.addTransaction=Ajouter transaction
+lima.entries.addEntry=Créer une entrée dans la transaction
+lima.entries.addTransaction=Créer une transaction
+lima.entries.assign.entries=Assigner cette valeur à toutes les entrées de la transaction
+lima.entries.balance=Équilibrer la transaction avec cette entrée
+lima.entries.copy.entry=Copier l'entrée
+lima.entries.copy.transaction=Copier la transaction
lima.entries.lettering=Lettrage
lima.entries.lettering.add=Ajouter une lettre
lima.entries.lettering.noletterselected=Erreur \: Aucune lettre sélectionnée.
lima.entries.lettering.radiobutton.list=Lettres existantes
lima.entries.lettering.radiobutton.new=Nouvelle lettre
lima.entries.lettering.remove=Supprimer une lettre
+lima.entries.paste.entry=Coller l'entrée
+lima.entries.paste.transaction=Coller la transaction
+lima.entries.remove.entry=Supprimer l'entrée
+lima.entries.remove.transaction=Supprimer la transaction
lima.entries.searchtransaction=Rechercher des écritures
lima.entries.searchunbalancedtransaction=Entrées incorrectes
lima.entries.writetransaction=Saisir des écritures
@@ -269,6 +277,8 @@
lima.ui.financialtransaction.letter=Lettre
lima.ui.financialtransaction.messageremoveentry=Voulez-vous supprimer cette ligne de transaction?
lima.ui.financialtransaction.messageremovetransaction=Voulez-vous supprimer cette transaction?
+lima.ui.financialtransaction.nextfinancialperiod=Période suivante
+lima.ui.financialtransaction.previousfinancialperiod=Période précédente
lima.ui.financialtransaction.titleremoveentry=Suppression
lima.ui.financialtransaction.titleremovetransaction=Suppression
lima.ui.financialtransaction.voucher=Pièce comptable
Added: trunk/lima-swing/src/main/resources/icons/action-add-entry.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-add-entry.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-balance.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-balance.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-choose-book.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-book.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-copy.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-copy.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-delete-entry.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete-entry.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-delete.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-next.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-next.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-paste.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-paste.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-previous.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-previous.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-refresh.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-refresh.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
Jenkins build became unstable: lima » Lima :: business #2612
by admin+hudson@codelutin.com 13 Jun '13
by admin+hudson@codelutin.com 13 Jun '13
13 Jun '13
r3680 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/financialtransaction resources/i18n
by Bavencoff@users.chorem.org 12 Jun '13
by Bavencoff@users.chorem.org 12 Jun '13
12 Jun '13
Author: Bavencoff
Date: 2013-06-12 18:03:34 +0200 (Wed, 12 Jun 2013)
New Revision: 3680
Url: http://chorem.org/projects/lima/repository/revisions/3680
Log:
user experience
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
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/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -117,7 +117,7 @@
}
}
keyPressed = false;
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 1;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -5,9 +5,8 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class AccountTableCellRenderer extends EmptyCellRenderer {
+public class AccountTableCellRenderer extends EntryTableCellRenderer {
-
@Override
public void setValue(Object value) {
Object result = value;
@@ -18,5 +17,4 @@
super.setValue(result);
}
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -29,33 +29,23 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
-import javax.swing.DefaultCellEditor;
-import javax.swing.JTextField;
-import javax.swing.SwingConstants;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import java.awt.event.FocusEvent;
-import java.awt.event.FocusListener;
+import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
import java.math.BigDecimal;
/**
* @author sletellier <letellier(a)codelutin.com>
* @author mallon <mallon(a)codelutin.com>
*/
-public class BigDecimalTableCellEditor extends DefaultCellEditor {
+public class BigDecimalTableCellEditor extends StringTableCellEditor {
- protected int row;
protected String comma = "";
private static final Log log = LogFactory.getLog(BigDecimalTableCellEditor.class);
public BigDecimalTableCellEditor() {
- super(new JTextField());
- setClickCountToStart(1);
+ super();
getComponent().setHorizontalAlignment(SwingConstants.RIGHT);
getComponent().addKeyListener(new KeyListener() {
@Override
@@ -73,62 +63,9 @@
limitComma(e);
}
});
- getComponent().addFocusListener(new FocusListener() {
-
- @Override
- public void focusGained(FocusEvent event) {
- runEdition();
- }
-
- @Override
- public void focusLost(FocusEvent event) {
- // nothing to do
- }
- });
- getComponent().addAncestorListener(new AncestorListener() {
-
- @Override
- public void ancestorAdded(AncestorEvent event) {
- runEdition();
- }
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- // nothing to do
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- // nothing to do
- }
- });
- getComponent().addPropertyChangeListener(new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- runEdition();
- }
- });
}
- @Override
- public JTextField getComponent() {
- return (JTextField) super.getComponent();
- }
-
/**
- * Two kinds of edition, with LimaConfig value
- * */
- public void runEdition() {
- String comportmentEditingCell = LimaConfig.getInstance().getComportmentEditingCell();
- if (comportmentEditingCell.equals("ALL")) {
- getComponent().selectAll();
- } else {
- int textFieldSize = getComponent().getText().length();
- getComponent().select(textFieldSize, textFieldSize);
- }
- }
-
- /**
* Split decimal with scale config
* @return bigDecimal value
* */
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -27,15 +27,13 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
-import javax.swing.JTable;
-import javax.swing.SwingConstants;
-import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.Component;
+import javax.swing.*;
+import java.awt.*;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-public class BigDecimalTableCellRenderer extends DefaultTableCellRenderer {
+public class BigDecimalTableCellRenderer extends EntryTableCellRenderer {
private static final long serialVersionUID = -2499433026151065390L;
@@ -46,11 +44,11 @@
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
- super.getTableCellRendererComponent(
+ JLabel myCell = (JLabel) super.getTableCellRendererComponent(
table, value, isSelected, hasFocus, row, column);
- setHorizontalAlignment(SwingConstants.RIGHT);
- setValue(value);
- return this;
+ myCell.setHorizontalAlignment(SwingConstants.RIGHT);
+
+ return myCell;
}
public void setValue(Object aValue) {
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -0,0 +1,19 @@
+package org.chorem.lima.ui.celleditor;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DateTableCellRenderer extends EntryTableCellRenderer {
+
+ protected void setValue(Object value) {
+ if (value instanceof Date) {
+ DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM);
+ super.setValue(format.format((Date) value));
+ } else {
+ super.setValue(value);
+ }
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -24,14 +24,9 @@
*/
package org.chorem.lima.ui.celleditor;
-import javax.swing.JLabel;
-import javax.swing.JTable;
-import javax.swing.UIManager;
-import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
+import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
+import java.awt.*;
/**
* Renderer qui affiche la valeur de la cellule (toString()) en permettant de
@@ -59,30 +54,21 @@
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
-
- //Create a new JLabel to avoid colouring only when row is selected
- JLabel mycell = new JLabel();
- mycell.setOpaque(true);
- setBorder(new EmptyBorder(1, 1, 1, 1));
- setName("Table.cellRenderer");
- mycell.setBackground(Color.WHITE);
- mycell.setForeground(Color.BLACK);
- //Setting default foreGround and backGround colours when isSelected
- if (isSelected) {
- mycell.setForeground(table.getSelectionForeground());
- mycell.setBackground(table.getSelectionBackground());
- }
- //Setting default foreGround and backGround colours when hasFocus
- if (hasFocus) {
- Border border = null;
+
+ Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ if (table.isCellEditable(row, column)
+ && (value == null
+ || (value instanceof String) && ((String) value).isEmpty()
+ )
+ ) {
+ setBackground(new Color(255, 198, 209));
+ } else {
if (isSelected) {
- border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
+ setForeground(new Color(0, 0, 0));
}
- if (border == null) {
- border = UIManager.getBorder("Table.focusCellHighlightBorder");
- }
- mycell.setBorder(border);
}
+
if (table.isCellEditable(row, column)) {
// true for voucher and description
// false for Account Class
@@ -90,14 +76,15 @@
// else setText
if (value instanceof String) {
if (String.valueOf(value) == null || String.valueOf(value).isEmpty()) {
- mycell.setBackground(new Color(255, 198, 209));
+ component.setBackground(new Color(255, 198, 209));
}
} else {
- mycell.setBackground(new Color(255, 198, 209));
+ if (value == null) {
+ component.setBackground(new Color(255, 198, 209));
+ }
}
}
- setValue(value);
- return mycell;
+ return this;
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -0,0 +1,104 @@
+package org.chorem.lima.ui.celleditor;
+
+import com.google.common.base.Preconditions;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
+import sun.swing.DefaultLookup;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+import java.io.Serializable;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EntryTableCellRenderer implements TableCellRenderer, Serializable {
+
+ private String text = null;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ //Create a new JLabel to avoid colouring only when row is selected
+
+ Preconditions.checkState(table instanceof FinancialTransactionTable);
+
+ JLabel myCell = new JLabel();
+ myCell.setOpaque(true);
+ myCell.setBorder(new EmptyBorder(1, 1, 1, 1));
+ myCell.setName("Table.entryCellRenderer");
+
+ Color background = Color.WHITE;
+ Color foreground = Color.BLACK;
+
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
+
+ /*JTable.DropLocation dropLocation = table.getDropLocation();
+ if (dropLocation != null
+ && !dropLocation.isInsertRow()
+ && !dropLocation.isInsertColumn()
+ && dropLocation.getRow() == row
+ && dropLocation.getColumn() == column) {
+
+ background = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellForeground");
+ foreground = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellBackground");
+
+ isSelected = true;
+ } */
+
+ if (isSelected) {
+ foreground = table.getSelectionForeground();
+ background = table.getSelectionBackground();
+ } else {
+ Color alternateColor = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.alternateRowColor");
+ if (alternateColor != null && model.getIndexTransaction(row) % 2 != 0) {
+ background = alternateColor;
+ }
+ }
+
+ if (table.isCellEditable(row, column)
+ && (value == null
+ || (value instanceof String) && ((String) value).isEmpty()
+ )
+ ) {
+ background = new Color(255, 198, 209);
+ }
+
+ if (model.getBalanceTransactionInRow(row).signum() != 0) {
+ foreground = new Color(240, 30, 30);
+ }
+
+ myCell.setBackground(background);
+ myCell.setForeground(foreground);
+
+ if (hasFocus) {
+ Border border = null;
+ if (isSelected) {
+ border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusSelectedCellHighlightBorder");
+ }
+ if (border == null) {
+ border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusCellHighlightBorder");
+ }
+ myCell.setBorder(border);
+
+ } else {
+ Border border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.cellNoFocusBorder");
+ if (border == null) {
+ border = new EmptyBorder(1, 1, 1, 1);
+ }
+ myCell.setBorder(border);
+ }
+
+ setValue(value);
+
+ myCell.setText(text);
+
+ return myCell;
+ }
+
+ protected void setValue(Object value) {
+ this.text = (value == null) ? "" : value.toString();
+ }
+ }
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -0,0 +1,95 @@
+package org.chorem.lima.ui.celleditor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.event.AncestorEvent;
+import javax.swing.event.AncestorListener;
+import java.awt.*;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class StringTableCellEditor extends DefaultCellEditor {
+
+ private static final Log log = LogFactory.getLog(BigDecimalTableCellEditor.class);
+
+ public StringTableCellEditor() {
+ super(new JTextField());
+ setClickCountToStart(1);Border border = BorderFactory.createLineBorder(new Color(123, 165, 205), 2);
+ //Border border = BorderFactory.createLoweredBevelBorder();
+
+ getComponent().setBorder(border);
+ getComponent().addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusGained(FocusEvent event) {
+ runEdition();
+ }
+
+ @Override
+ public void focusLost(FocusEvent event) {
+ // nothing to do
+ }
+ });
+ getComponent().addAncestorListener(new AncestorListener() {
+
+ @Override
+ public void ancestorAdded(AncestorEvent event) {
+ runEdition();
+ }
+
+ @Override
+ public void ancestorRemoved(AncestorEvent event) {
+ // nothing to do
+ }
+
+ @Override
+ public void ancestorMoved(AncestorEvent event) {
+ // nothing to do
+ }
+ });
+ getComponent().addPropertyChangeListener(new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ runEdition();
+ }
+ });
+ }
+
+ @Override
+ public JTextField getComponent() {
+ return (JTextField) super.getComponent();
+ }
+
+ /**
+ * Two kinds of edition, with LimaConfig value
+ * */
+ public void runEdition() {
+ String comportmentEditingCell = LimaConfig.getInstance().getComportmentEditingCell();
+ if (comportmentEditingCell.equals("ALL")) {
+ getComponent().selectAll();
+ } else {
+ int textFieldSize = getComponent().getText().length();
+ getComponent().select(textFieldSize, textFieldSize);
+ }
+ }
+
+ /**
+ * Split decimal with scale config
+ * @return bigDecimal value
+ * */
+ @Override
+ public Object getCellEditorValue() {
+ String stringValue = super.getCellEditorValue().toString();
+ return stringValue;
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -34,15 +34,14 @@
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.EmptyCellRenderer;
-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.Highlighter;
+import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
import java.awt.*;
-import java.awt.event.KeyAdapter;
+import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -60,7 +59,7 @@
* @author jpepin
* @author echatellier
*/
-public class FinancialTransactionTable extends JXTable {
+public class FinancialTransactionTable extends JTable {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
@@ -72,15 +71,14 @@
public FinancialTransactionTable(final FinancialTransactionViewHandler handler) {
this.handler = handler;
- addKeyListener(new MyKeyAdapter());
+ //Get new date editor
+ setDefaultEditor(Date.class, new DateTableCellEditor());
- addMouseListener(new MyMouseAdapter());
+ //Get new String editor
- //addListSelectionListener();
+ StringTableCellEditor stringTableCellEditor = new StringTableCellEditor();
+ setDefaultEditor(String.class, stringTableCellEditor);
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
//Get new account editor
setDefaultEditor(Account.class, new AccountTableCellEditor());
@@ -90,8 +88,11 @@
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
+ //get new Date renderer for empty cells
+ setDefaultRenderer(Date.class, new DateTableCellRenderer());
+
//get new String renderer for empty cells
- setDefaultRenderer(String.class, new EmptyCellRenderer());
+ setDefaultRenderer(String.class, new EntryTableCellRenderer());
//get new Account renderer for empty cells
setDefaultRenderer(Account.class, new AccountTableCellRenderer());
@@ -100,131 +101,182 @@
setShowVerticalLines(true);
setGridColor(new Color(210,210,210));
+ InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = getActionMap();
- // 1 transaction of 2
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- int index = handler.view.getFinancialTransactionTableModel().getIndexTransaction(adapter.row);
- return index % 2 == 1;
- }
- };
- Highlighter colorTransaction =
- new ColorHighlighter(predicate, new Color(242, 242, 242), null);
- addHighlighter(colorTransaction);
+ // action on Tab
+ Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
+ actionMap.put(binding, new NextCellAction());
- predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- int index = handler.view.getFinancialTransactionTableModel().getIndexTransaction(adapter.row);
- return index % 2 == 0;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, getBackground(), null);
- addHighlighter(colorTransaction);
+ // action on Shift + Tab
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteHorizontalFirstAction(false));
- // highlight unbalanced financial transactions
- predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
+ // action on Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
+ actionMap.put(binding, new CellRouteVerticalFirstAction(true));
- BigDecimal balance = handler.view.getFinancialTransactionTableModel().getBalanceTransactionInRow(adapter.row);
- return balance.compareTo(BigDecimal.ZERO) != 0;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, null, new Color(240, 30, 30));
- addHighlighter(colorTransaction);
+ // action on Shift + Enter
+ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
+ actionMap.put(binding, new CellRouteVerticalFirstAction(false));
+ // remove input Ctrl + Del
+ inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED);
+ while (inputMap != null) {
+ inputMap.remove(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK));
+ inputMap = inputMap.getParent();
+ }
}
public FinancialTransactionViewHandler getHandler() {
return handler;
}
- private class MyKeyAdapter extends KeyAdapter {
+ private class NextCellAction extends AbstractAction {
FinancialTransactionTable table = FinancialTransactionTable.this;
FinancialTransactionTableModel tableModel = table.handler.view.getFinancialTransactionTableModel();
@Override
- public void keyPressed(KeyEvent e) {
+ public void actionPerformed(ActionEvent e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Key tab used");
+ }
+ int nbColumn = getColumnCount();
+ int nbRows = getRowCount();
+ int column = getSelectedColumn();
+ int row = getSelectedRow();
- final FinancialTransactionViewHandler handler = getHandler();
+ if (column >= 0 && row >= 0) {
- /*Allow to block access to the first row when key enter pressed, if selection on
- * last row*/
- /* if (e.getKeyCode() == KeyEvent.VK_ENTER){
- int selectedRow = table.getSelectedRow();
- if( selectedRow == table.getRowCount()-1){
- *//*-2, cause we have a row count beginning at one and we want to back to the line before*//*
- table.setRowSelectionInterval(table.getRowCount()-2, table.getRowCount()-2);
- } else {
- table.setRowSelectionInterval(selectedRow, selectedRow);
- }
- }*/
+ boolean end = false;
- /*
- * Touche tab
- * Incrémente le curseur de case tant que la case n'est pas editable
- * Ajoute une entrée comptable si tab est sur
- * la dernière cellule et si la transaction est non équilibrée
- * sinon rajoute une transaction
- */
- if (e.getKeyChar() == KeyEvent.VK_TAB) {
- if (log.isDebugEnabled()) {
- log.debug("Key tab used");
- }
- int nbColumn = getColumnCount();
- int nbRows = getRowCount();
- int column = getSelectedColumn();
- int row = getSelectedRow();
-
- if (column >= 0 && row >= 0) {
-
- boolean end = false;
-
- FinancialTransaction transaction = tableModel.getTransactionAt(row);
- do {
- if (column >= nbColumn - 1) {
- if (row >= nbRows - 1 || transaction != tableModel.getTransactionAt(row + 1)) {
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (credit.compareTo(debit) != 0) {
- table.handler.addEntry();
- column = 1;
- row++;
- end = true;
- } else if (row >= nbRows - 1) {
- table.handler.addFinancialTransaction();
- column = 0;
- row++;
- end = true;
- } else {
- column = 0;
- row++;
- }
+ FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ do {
+ if (column >= nbColumn - 1) {
+ if (row >= nbRows - 1 || transaction != tableModel.getTransactionAt(row + 1)) {
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (credit.compareTo(debit) != 0) {
+ table.handler.addEntry();
+ column = 2;
+ row++;
+ end = true;
+ } else if (row >= nbRows - 1) {
+ table.handler.addFinancialTransaction();
+ column = 0;
+ row++;
+ end = true;
} else {
column = 0;
row++;
}
} else {
- column++;
+ column = 0;
+ row++;
}
- } while (!end && !tableModel.isCellEditable(row,column));
- setRowSelectionInterval(row, row);
- setColumnSelectionInterval(column, column);
- editCellAt(column, row);
+ } else {
+ column++;
+ }
+ } while (!end && !tableModel.isCellEditable(row,column));
+ if (isEditing()) {
+ TableCellEditor editor = getCellEditor();
+ editor.stopCellEditing();
+ }
+ setRowSelectionInterval(row, row);
+ setColumnSelectionInterval(column, column);
+ //editCellAt(row, column);
+ }
+ }
+ }
- e.consume();
+ private class CellRouteHorizontalFirstAction extends AbstractAction {
+
+ FinancialTransactionTable table = FinancialTransactionTable.this;
+ FinancialTransactionTableModel tableModel = table.handler.view.getFinancialTransactionTableModel();
+
+ protected int step;
+ protected int route1;
+ protected int route2;
+ protected int nbCell1;
+ protected int nbCell2;
+
+ public CellRouteHorizontalFirstAction(boolean nextCell) {
+ step = nextCell ? +1 : -1;
+ }
+
+ protected void init() {
+ route1 = getSelectedColumn();
+ route2 = getSelectedRow();
+ nbCell1 = getColumnCount();
+ nbCell2 = getRowCount();
+ }
+
+ protected int getRow() {
+ return route2;
+ }
+
+ protected int getColumn() {
+ return route1;
+ }
+
+ protected boolean isEditable() {
+ return tableModel.isCellEditable(getRow(), getColumn());
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ init();
+ if (route1 >= 0 && route2 >= 0) {
+ do {
+ route1 = route1 + step;
+ if (route1 < 0 || route1 >= nbCell1) {
+ route1 = route1 % nbCell1;
+ if (route1 < 0) {
+ route1 = route1 + nbCell1;
+ }
+ route2 = route2 + step;
+ if (route2 < 0 || route2 >= nbCell2) {
+ route2 = route2 % nbCell2;
+ if (route2 < 0) {
+ route2 = route2 + nbCell2;
+ }
+ }
+ }
+ } while (!isEditable());
+ if (isEditing()) {
+ TableCellEditor editor = getCellEditor();
+ editor.stopCellEditing();
}
+ int row = getRow();
+ int column = getColumn();
+ setRowSelectionInterval(row, row);
+ setColumnSelectionInterval(column, column);
+ //editCellAt(row, column);
}
+ }
+ }
+ private class CellRouteVerticalFirstAction extends CellRouteHorizontalFirstAction {
+
+ public CellRouteVerticalFirstAction(boolean nextCell) {
+ super(nextCell);
}
+
+ protected void init() {
+ route1 = getSelectedRow();
+ route2 = getSelectedColumn();
+ nbCell1 = getRowCount();
+ nbCell2 = getColumnCount();
+ }
+
+ protected int getRow() {
+ return route1;
+ }
+
+ protected int getColumn() {
+ return route2;
+ }
}
private class MyMouseAdapter extends MouseAdapter {
@@ -237,4 +289,10 @@
}
}
+ private class DeleteEntryAction extends AbstractAction {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ handler.deleteSelectedEntry();
+ }
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -25,16 +25,11 @@
package org.chorem.lima.ui.financialtransaction;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.DecoratorProvider;
import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
@@ -57,8 +52,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = -7495388454688562991L;
- private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class);
-
/** Service (just to update setValueAt(). */
protected FinancialTransactionService financialTransactionService;
@@ -66,18 +59,9 @@
protected List<FinancialTransaction> transactions;
- /**
- * To decorate account objects.
- */
- protected final Decorator<Account> accountDecorator;
-
public FinancialTransactionTableModel() {
financialTransactionService =
LimaServiceFactory.getService(FinancialTransactionService.class);
-
- DecoratorProvider decoratorProvider =
- LimaContext.get().getDecoratorProvider();
- accountDecorator = decoratorProvider.getDecoratorByType(Account.class);
}
public void setEntries(List<Entry> entries) {
@@ -143,10 +127,10 @@
result = _("lima.ui.financialtransaction.description");
break;
case 4:
- result = _("lima.ui.financialtransaction.debit");
+ result = _("lima.ui.financialtransaction.credit");
break;
case 5:
- result = _("lima.ui.financialtransaction.credit");
+ result = _("lima.ui.financialtransaction.debit");
break;
}
return result;
@@ -184,10 +168,10 @@
result = entry.getDescription();
break;
case 4:
- result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
+ result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
break;
case 5:
- result = entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
+ result = entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
break;
}
return result;
@@ -204,50 +188,6 @@
|| entries.get(rowIndex).getFinancialTransaction() != entries.get(rowIndex - 1).getFinancialTransaction();
}
- /**
- * Obtain the first entry book of the current transaction.
- *
- * @param selectedRow row selected
- * @return first entry index
- */
- public int getFirstEntry(int selectedRow) {
- int result = -1;
- int currentRow = selectedRow;
- while (currentRow > -1) {
- Object o = entries.get(currentRow);
- if (o instanceof Entry) {
-
- // current row is still a entry book
- currentRow--;
- continue;
- }
- if (o instanceof FinancialTransaction) {
- // got the begin of a transaction
- if (currentRow == selectedRow) {
-
- // the selected row is on the transaction
- //
- // look out if there is a next line and if then look out if
- // this is a entry book
- result = -1;
- } else {
-
- // the next row is an entry book row
- result = currentRow + 1;
- }
- break;
- }
- }
- return result;
- }
-
- public Entry getEntryAt(int row) {
- if (row == -1) {
- return null;
- }
- return entries.get(row);
- }
-
/** to modifiy financialtransaction or entry */
@Override
public void setValueAt(Object value, int row, int column) {
@@ -325,13 +265,13 @@
case 4:
if (((BigDecimal) value).signum() > 0 ) {
entry.setAmount((BigDecimal) value);
- entry.setDebit(true);
+ entry.setDebit(false);
}
break;
case 5:
if (((BigDecimal) value).signum() > 0 ) {
entry.setAmount((BigDecimal) value);
- entry.setDebit(false);
+ entry.setDebit(true);
}
break;
}
@@ -362,6 +302,15 @@
}
+ public Entry getEntryAt(int row) {
+ return entries.get(row);
+ }
+
+ public FinancialTransaction getTransactionAt(int row) {
+ Entry entry = entries.get(row);
+ return entry.getFinancialTransaction();
+ }
+
public int indexOf(Entry entry) {
return entries.indexOf(entry);
}
@@ -379,71 +328,65 @@
return index;
}
- public int indexOfEntryInTransaction(Entry entry) {
- FinancialTransaction transaction = entry.getFinancialTransaction();
- int result = -1;
- for (Entry entryTmp : entries) {
- if (entryTmp.getFinancialTransaction() == transaction) {
- result ++;
- }
- if (entry == entryTmp) {
- break;
- }
- }
- return result;
+ public int getIndexTransaction(int row) {
+ FinancialTransaction transaction = getTransactionAt(row);
+ int index = transactions.indexOf(transaction);
+ return index;
}
/**
- * Delete row.
+ * Insert new entry.
*
- * @param row row to delete
+ * @param entry entry to insert
+ * @param newRow position
*/
- public void deleteRow(int row) {
- Entry entry = entries.remove(row);
+ public void addEntry(Entry entry, int newRow) {
FinancialTransaction transaction = entry.getFinancialTransaction();
- if (transaction.sizeEntry() == 0) {
- transactions.remove(transaction);
+ if (transactions.contains(transaction)) {
+ entries.add(newRow, entry);
+ fireTableRowsInserted(newRow, newRow);
}
- fireTableRowsDeleted(row, row);
}
/**
- * Insert new row.
- *
- * @param entry entry to insert
- * @param newRow position
+ * Delete entry.
+ *
+ * @param entry entry to delete
*/
- public void addRow(Entry entry, int newRow) {
- entries.add(newRow, entry);
- fireTableRowsInserted(newRow, newRow);
+ public void deleteEntry(Entry entry) {
+ int row = entries.indexOf(entry);
+ entries.remove(entry);
+ fireTableRowsDeleted(row, row);
}
- /**
- * Insert new row.
- *
- * @param entry entry to insert
- */
- public void addRow(Entry entry) {
- entries.add(entry);
- fireTableRowsInserted(entries.size() - 1, entries.size() - 1);
-
+ public void addTransaction(FinancialTransaction transaction) {
+ int indexFirstEntry = entries.size();
+ if (!transactions.contains(transaction)) {
+ transactions.add(transaction);
+ entries.addAll(transaction.getEntry());
+ }
+ int indexLastEntry = entries.size() - 1;
+ fireTableRowsInserted(indexFirstEntry, indexLastEntry - 1);
}
- public FinancialTransaction getTransactionAt(int row) {
- Entry entry = entries.get(row);
- return entry.getFinancialTransaction();
+ public void deleteTransaction(FinancialTransaction transaction) {
+ if (transactions.contains(transaction)) {
+ int indexFirst = indexOf(transaction);
+ int indexLast = indexFirst + transaction.sizeEntry() - 1;
+ entries.removeAll(transaction.getEntry());
+ transactions.remove(transaction);
+ if (indexFirst <= indexLast) {
+ fireTableRowsDeleted(indexFirst, indexFirst);
+ }
+ }
}
- public int getIndexTransaction(int row) {
- FinancialTransaction transaction = getTransactionAt(row);
- return transactions.indexOf(transaction);
- }
-
public BigDecimal getBalanceTransactionInRow(int row) {
FinancialTransaction transaction = getTransactionAt(row);
BigDecimal debit = transaction.getAmountDebit();
BigDecimal credit = transaction.getAmountCredit();
- return debit.subtract(credit);
+ BigDecimal balance = debit.subtract(credit);
+ return balance;
}
public int size() {
@@ -454,21 +397,5 @@
return result;
}
- public void addTransaction(FinancialTransaction transaction) {
- int indexFirstEntry = entries.size();
- if (!transactions.contains(transaction)) {
- transactions.add(transaction);
- }
- int indexLastEntry = entries.size();
- Collection<Entry> entriesTransaction = transaction.getEntry();
- for (Entry entry : entriesTransaction) {
- if (!entries.contains(entry)) {
- entries.add(entry);
- indexLastEntry++;
- }
- }
- fireTableRowsInserted(indexFirstEntry, indexLastEntry - 1);
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-12 16:03:34 UTC (rev 3680)
@@ -41,12 +41,13 @@
id='selectionModel'
initializer="new DefaultListSelectionModel()"
selectionMode='{ListSelectionModel.SINGLE_SELECTION}'
- onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/>
+ onValueChanged="handler.selectionChanged()"/>
<Boolean id="selectedRow" javaBean="false"/>
<Boolean id="transactionInClipBoard" javaBean="false"/>
<Boolean id="entryInClipBoard" javaBean="false"/>
+ <Boolean id="balance" javaBean="true"/>
<script>
<![CDATA[
@@ -88,11 +89,15 @@
<JMenuItem text="lima.common.copy"
enabled="{isSelectedRow()}"
onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK)}" />
+ accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" />
<JMenuItem text="lima.common.paste"
- enabled="{isEntryInClipBoard()}"
+ enabled="{isEntryInClipBoard() && isSelectedRow()}"
onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())"
- accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK)}" />
+ accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" />
+ <JMenuItem text="lima.common.balance"
+ enabled="{!isBalance()}"
+ onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())"
+ accelerator="{KeyStroke.getKeyStroke('B', KeyEvent.CTRL_DOWN_MASK)}" />
</JMenu>
</JMenuBar>
</cell>
@@ -139,7 +144,7 @@
<JScrollPane>
<FinancialTransactionTableModel id="financialTransactionTableModel"/>
<FinancialTransactionTable
- id="financialTransactionTable" sortable="false" rowHeight="22"
+ id="financialTransactionTable" rowHeight="22"
constructorParams='handler'
selectionModel='{selectionModel}'
model='{financialTransactionTableModel}'/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-12 16:03:34 UTC (rev 3680)
@@ -170,7 +170,7 @@
public void updateFinancialTransactions() {
FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
-
+
// la selection de la financialPeriod est obligatoire
// sinon, tout un exercice, c'est trop lourd
// l'entry book par contre, est facultatif
@@ -197,10 +197,52 @@
view.getFinancialTransactionTableModel().setEntries(transAndEntries);
}
+ public void selectionChanged() {
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ int selectedRow = table.getSelectedRow();
+ view.setSelectedRow(selectedRow >= 0 && selectedRow < tableModel.size());
+ if (selectedRow >= 0 && selectedRow < tableModel.size()) {
+ FinancialTransaction transaction = tableModel.getTransactionAt(selectedRow);
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ view.setBalance(credit.compareTo(debit) == 0);
+ } else {
+ view.setBalance(true);
+ }
+ }
+
+ public void balanceTransaction(int rowSelected) {
+ FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ FinancialTransactionTable table = view.getFinancialTransactionTable();
+
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
+
+ Entry entry = tableModel.getEntryAt(rowSelected);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (entry.isDebit()) {
+ debit = debit.subtract(entry.getAmount());
+ } else {
+ credit = credit.subtract(entry.getAmount());
+ }
+
+ BigDecimal balance = credit.subtract(debit);
+ entry.setAmount(balance.abs());
+ entry.setDebit(balance.signum() > 0);
+ financialTransactionService.updateEntry(entry);
+ tableModel.fireTableRowsUpdated(rowSelected, rowSelected);
+ view.setBalance(true);
+ }
+
/**
* Copy selected Transaction
*
- * @param indexSelectedRow
+ * @param indexSelectedRow selected row to copy a transaction
*/
public void copyTransaction(int indexSelectedRow){
clipBoard = view.getFinancialTransactionTableModel().getTransactionAt(indexSelectedRow);
@@ -211,7 +253,7 @@
/**
* Copy selected Entry
*
- * @param indexSelectedRow
+ * @param indexSelectedRow selected row to copy a entry
*/
public void copyEntry(int indexSelectedRow){
clipBoard = view.getFinancialTransactionTableModel().getEntryAt(indexSelectedRow);
@@ -258,6 +300,10 @@
}
tableModel.addTransaction(transaction);
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
int index = tableModel.indexOf(transaction);
selectionModel.setSelectionInterval(index, index);
}
@@ -290,8 +336,12 @@
transaction.addEntry(entry);
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
int index = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- tableModel.addRow(entry, index);
+ tableModel.addEntry(entry, index);
selectionModel.setSelectionInterval(index, index);
//focus on second column
@@ -317,8 +367,12 @@
currentTransaction.addEntry(entry);
// on met a jour l'ui
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
int newRow = row + 1;
- tableModel.addRow(newEntry, newRow);
+ tableModel.addEntry(newEntry, newRow);
table.addRowSelectionInterval(newRow, newRow);
return newRow;
}
@@ -363,16 +417,20 @@
// create it
FinancialTransaction fTransaction = financialTransactionService.createFinancialTransaction(financialTransaction);
- // create 2 first entry of this transaction
+ // create first entry of this transaction
Entry entry = new EntryImpl();
entry.setFinancialTransaction(fTransaction);
entry = financialTransactionService.createEntry(entry);
fTransaction.addEntry(entry);
// add it in ui
- int addIndex = tableModel.size();
- tableModel.addRow(entry, addIndex);
+ tableModel.addTransaction(fTransaction);
+ int addIndex = tableModel.size() - 1;
//select the new line
+ if (table.isEditing()) {
+ TableCellEditor editor = table.getCellEditor();
+ editor.stopCellEditing();
+ }
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionInterval(addIndex, addIndex);
table.changeSelection(addIndex, 1, false, false);
@@ -453,7 +511,7 @@
// add it in ui
int addIndex = tableModel.indexOf(lastEntry) + 1;
- tableModel.addRow(newEntry, addIndex);
+ tableModel.addEntry(newEntry, addIndex);
//select the new line
ListSelectionModel selectionModel = table.getSelectionModel();
@@ -485,16 +543,12 @@
_("lima.ui.financialtransaction.titleremovetransaction"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- //must delete the entries of the deleted transaction
- Collection<Entry> entries = transaction.getEntry();
- if (entries != null){
- for (Entry entry : entries){
- tableModel.deleteRow(tableModel.indexOf(entry));
- }
- }
financialTransactionService.removeFinancialTransaction(transaction);
+ //must delete the entries of the deleted transaction
+ tableModel.deleteTransaction(transaction);
+
if (tableModel.size() > 0) {
if (indexSelectedRow >= tableModel.size()) {
indexSelectedRow = tableModel.size() - 1;
@@ -526,19 +580,19 @@
_("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION);
if (response == JOptionPane.YES_OPTION) {
- tableModel.deleteRow(indexSelectedRow);
- financialTransactionService.removeEntry(entry);
FinancialTransaction transaction = entry.getFinancialTransaction();
- transaction.removeEntry(entry);
- if (transaction.sizeEntry() == 0) {
+ if (transaction.sizeEntry() > 1) {
+ financialTransactionService.removeEntry(entry);
+ transaction.removeEntry(entry);
+ tableModel.deleteEntry(entry);
+ } else {
financialTransactionService.removeFinancialTransaction(transaction);
+ tableModel.deleteTransaction(transaction);
}
if (tableModel.size() > 0) {
if (indexSelectedRow >= tableModel.size()) {
indexSelectedRow = tableModel.size() - 1;
- } else {
- indexSelectedRow++;
}
selectionModel.setSelectionInterval(
indexSelectedRow, indexSelectedRow);
@@ -548,8 +602,6 @@
}
}
-
-
/**
* Select previous value in combo box.
*
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 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-06-12 16:03:34 UTC (rev 3680)
@@ -44,6 +44,7 @@
lima.common.amountcredit=Credit amount
lima.common.amountdebit=Debit amount
lima.common.autocomplete=Autocomplete
+lima.common.balance=Balance
lima.common.begindate=Begin
lima.common.buttonback=←
lima.common.buttonnext=→
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 2013-06-07 16:09:48 UTC (rev 3679)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-06-12 16:03:34 UTC (rev 3680)
@@ -44,6 +44,7 @@
lima.common.amountcredit=Total Crédit
lima.common.amountdebit=Total Débit
lima.common.autocomplete=Autocomplétion
+lima.common.balance=Équilibrer
lima.common.begindate=Début
lima.common.buttonback=←
lima.common.buttonnext=→
1
0
r3679 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/financialtransaction resources
by Bavencoff@users.chorem.org 07 Jun '13
by Bavencoff@users.chorem.org 07 Jun '13
07 Jun '13
Author: Bavencoff
Date: 2013-06-07 18:09:48 +0200 (Fri, 07 Jun 2013)
New Revision: 3679
Url: http://chorem.org/projects/lima/repository/revisions/3679
Log:
user experience
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/resources/log4j.properties
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -0,0 +1,22 @@
+package org.chorem.lima.ui.celleditor;
+
+import org.chorem.lima.entity.Account;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AccountTableCellRenderer extends EmptyCellRenderer {
+
+
+ @Override
+ public void setValue(Object value) {
+ Object result = value;
+ if (value != null && value instanceof Account) {
+ Account account = (Account) value;
+ result = account.getAccountNumber() + " - " + account.getLabel();
+ }
+ super.setValue(result);
+ }
+
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -26,28 +26,31 @@
package org.chorem.lima.ui.celleditor;
import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
import org.jdesktop.swingx.JXDatePicker;
-import javax.swing.AbstractCellEditor;
-import javax.swing.JFormattedTextField;
-import javax.swing.JTable;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.table.TableCellEditor;
-import java.awt.Component;
+import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
-import java.awt.event.MouseEvent;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
-import java.util.EventObject;
/** @author ore */
public class DateTableCellEditor extends AbstractCellEditor
implements TableCellEditor, FocusListener, AncestorListener {
+ private static final Log log = LogFactory.getLog(DateTableCellEditor.class);
+
private static final long serialVersionUID = 1L;
private final JXDatePicker datePicker;
@@ -61,6 +64,11 @@
datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
datePicker.getEditor().addFocusListener(this);
datePicker.getEditor().addAncestorListener(this);
+ datePicker.setFormats(
+ DateFormat.getDateInstance(DateFormat.SHORT),
+ new SimpleDateFormat("dd/MM/yyyy"),
+ new SimpleDateFormat("dd/MM")
+ );
//comportmentEditingCell = LimaConfig.getInstance().getComportmentEditingCell();
}
@@ -75,34 +83,35 @@
@Override
public Object getCellEditorValue() {
- if (!datePicker.getEditor().getText().isEmpty()) {
- String[] str = datePicker.getEditor().getText().split("/");
- //day
- if (str.length > 0) {
- if (str[0].contains(" ")) {
- String[] string = str[0].split(" ");
- date = DateUtils.setDays(date, Integer.valueOf(string[1]));
- } else {
- date = DateUtils.setDays(date, Integer.valueOf(str[0]));
- }
- }
- //month
- if (str.length > 1) {
- date = DateUtils.setMonths(date, Integer.valueOf(str[1]) - 1);
- }
- //year
- if (str.length > 2) {
- date = DateUtils.setYears(date, Integer.valueOf(str[2]));
- }
+ if (log.isDebugEnabled()) {
+ log.debug("getDate : input Date : " + datePicker.getDate() + "; text : " + datePicker.getEditor().getText());
}
- datePicker.setDate(date);
+ try {
+ datePicker.commitEdit();
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(datePicker.getDate());
+ int year = calendar.get(Calendar.YEAR);
+ if (year == 1970) {
+ calendar.setTime(date);
+ year = calendar.get(Calendar.YEAR);
+ Date newDate = DateUtils.setYears(datePicker.getDate(), year);
+ datePicker.setDate(newDate);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("getDate : output Date : " + datePicker.getDate());
+ }
return datePicker.getDate();
}
- @Override
+ /*@Override
public boolean isCellEditable(EventObject evt) {
return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
+ } */
@Override
public void focusGained(FocusEvent e) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -91,13 +91,12 @@
if (value instanceof String) {
if (String.valueOf(value) == null || String.valueOf(value).isEmpty()) {
mycell.setBackground(new Color(255, 198, 209));
- } else {
- mycell.setText(value.toString());
}
} else {
mycell.setBackground(new Color(255, 198, 209));
}
}
+ setValue(value);
return mycell;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -30,6 +30,7 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
import org.chorem.lima.ui.celleditor.DateTableCellEditor;
@@ -68,10 +69,6 @@
protected final FinancialTransactionViewHandler handler;
- private int x_tab;
-
- private int y_tab;
-
public FinancialTransactionTable(final FinancialTransactionViewHandler handler) {
this.handler = handler;
@@ -97,7 +94,7 @@
setDefaultRenderer(String.class, new EmptyCellRenderer());
//get new Account renderer for empty cells
- setDefaultRenderer(Account.class, new EmptyCellRenderer());
+ setDefaultRenderer(Account.class, new AccountTableCellRenderer());
setShowHorizontalLines(true);
setShowVerticalLines(true);
@@ -142,69 +139,7 @@
colorTransaction =
new ColorHighlighter(predicate, null, new Color(240, 30, 30));
addHighlighter(colorTransaction);
- /*//highlight financial financial transactions
- predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return adapter.getValueAt(adapter.row, 0) instanceof Date;
- }
- };
- Highlighter colorTransaction =
- new ColorHighlighter(predicate, new Color(222, 222, 222), null);
- addHighlighter(colorTransaction);
- // highlight unbalanced financial transactions
- predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object valueDebit = adapter.getValueAt(adapter.row, 4);
- Object valueCredit = adapter.getValueAt(adapter.row, 5);
- Object value = adapter.getValueAt(adapter.row, 6);
- if (value instanceof BigDecimal) {
- BigDecimal currentBalance = (BigDecimal) value;
- DecimalFormat decimalFormat = new DecimalFormat();
- Double currentBalanceDouble = decimalFormat.parse(currentBalance.toString(), new ParsePosition(0)).doubleValue();
- Double debitDouble = decimalFormat.parse(valueDebit.toString(), new ParsePosition(0)).doubleValue();
- Double creditDouble = decimalFormat.parse(valueCredit.toString(), new ParsePosition(0)).doubleValue();
-
- if (!currentBalanceDouble.toString().equals("0.0") || (valueDebit.equals(BigDecimal.ZERO) || debitDouble.toString().equals("0.0"))
- && (valueCredit.equals(BigDecimal.ZERO) || creditDouble.toString().equals("0.0"))) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
-
- //To color in red entry with debit and credit equals to zero
- colorTransaction =
- new ColorHighlighter(predicate, null , new Color(255, 0, 0));
- addHighlighter(colorTransaction);
-
- HighlightPredicate debitCreditZero = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
-
- Object valueDebit = adapter.getValueAt(adapter.row, 4);
- Object valueCredit = adapter.getValueAt(adapter.row, 5);
- boolean isEntry = !(adapter.getValueAt(adapter.row, 0) instanceof Date);
-
- DecimalFormat decimalFormat = new DecimalFormat();
- Double debitDouble = decimalFormat.parse(valueDebit.toString(), new ParsePosition(0)).doubleValue();
- Double creditDouble = decimalFormat.parse(valueCredit.toString(), new ParsePosition(0)).doubleValue();
- return (isEntry && (valueDebit.equals(BigDecimal.ZERO) || debitDouble.toString().equals("0.0"))
- && (valueCredit.equals(BigDecimal.ZERO) || creditDouble.toString().equals("0.0")));
- }
- };
-
- Highlighter entryDebitCreditZero =
- new ColorHighlighter(debitCreditZero, new Color(255, 198, 209), null);
- addHighlighter(entryDebitCreditZero);*/
-
}
public FinancialTransactionViewHandler getHandler() {
@@ -223,15 +158,15 @@
/*Allow to block access to the first row when key enter pressed, if selection on
* last row*/
- if (e.getKeyCode() == KeyEvent.VK_ENTER){
+ /* if (e.getKeyCode() == KeyEvent.VK_ENTER){
int selectedRow = table.getSelectedRow();
if( selectedRow == table.getRowCount()-1){
- /*-2, cause we have a row count beginning at one and we want to back to the line before*/
+ *//*-2, cause we have a row count beginning at one and we want to back to the line before*//*
table.setRowSelectionInterval(table.getRowCount()-2, table.getRowCount()-2);
} else {
table.setRowSelectionInterval(selectedRow, selectedRow);
}
- }
+ }*/
/*
* Touche tab
@@ -244,33 +179,49 @@
if (log.isDebugEnabled()) {
log.debug("Key tab used");
}
- int max_x = getColumnCount();
- int max_y = getRowCount();
- x_tab = getSelectedColumn();
- y_tab = getSelectedRow();
+ int nbColumn = getColumnCount();
+ int nbRows = getRowCount();
+ int column = getSelectedColumn();
+ int row = getSelectedRow();
- boolean end = false;
+ if (column >= 0 && row >= 0) {
- FinancialTransaction transaction = tableModel.getTransactionAt(y_tab);
- if (x_tab >= max_x - 1) {
- if (y_tab + 1 > max_y || transaction != tableModel.getTransactionAt(y_tab + 1)) {
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal debit = transaction.getAmountDebit();
- if (credit.compareTo(debit) != 0) {
- table.handler.addEntry();
- x_tab = 1;
- y_tab++;
- end = true;
- } else if (y_tab + 1 > max_y) {
- table.handler.addFinancialTransaction();
- x_tab = 0;
- y_tab++;
- end = true;
+ boolean end = false;
+
+ FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ do {
+ if (column >= nbColumn - 1) {
+ if (row >= nbRows - 1 || transaction != tableModel.getTransactionAt(row + 1)) {
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ if (credit.compareTo(debit) != 0) {
+ table.handler.addEntry();
+ column = 1;
+ row++;
+ end = true;
+ } else if (row >= nbRows - 1) {
+ table.handler.addFinancialTransaction();
+ column = 0;
+ row++;
+ end = true;
+ } else {
+ column = 0;
+ row++;
+ }
+ } else {
+ column = 0;
+ row++;
+ }
+ } else {
+ column++;
}
- }
+ } while (!end && !tableModel.isCellEditable(row,column));
+ setRowSelectionInterval(row, row);
+ setColumnSelectionInterval(column, column);
+ editCellAt(column, row);
+
+ e.consume();
}
- setRowSelectionInterval(y_tab, y_tab);
- setColumnSelectionInterval(x_tab, x_tab);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -178,12 +178,7 @@
result = entry.getVoucher();
break;
case 2: // account
- if (entry.getAccount() == null) {
- result = null;
- } else {
- Account acc = entry.getAccount();
- result = accountDecorator.toString(acc);
- }
+ result = entry.getAccount();
break;
case 3:
result = entry.getDescription();
@@ -260,16 +255,18 @@
Entry entry = entries.get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
String description;
+ boolean updateEntries = false;
boolean updateTransaction = false;
switch (column) {
case 0:
//update
transaction.setTransactionDate((Date) value);
+ updateTransaction = true;
break;
case 1:
String voucher = ((String) value).trim();
- int firstEntryRow = getFirstEntry(row);
+ int firstEntryRow = indexOf(transaction);
if (row == firstEntryRow) {
// let's update the voucher of all entries of
@@ -278,7 +275,7 @@
entryNext.setVoucher(voucher);
}
- updateTransaction = true;
+ updateEntries = true;
} else {
// not on first row, just update this entry voucher
@@ -288,25 +285,28 @@
case 2:
Account account = (Account) value;
entry.setAccount(account);
- // let's copy the account description
- description = account.getLabel();
- firstEntryRow = getFirstEntry(row);
- if (row == firstEntryRow) {
- // let's update the description of all entries of
- // the transaction
+ if (account != null) {
- for (Entry entryNext : transaction.getEntry()) {
- entryNext.setDescription(description);
+ // let's copy the account description
+ description = account.getLabel();
+ firstEntryRow = indexOf(transaction);
+ if (row == firstEntryRow) {
+ // let's update the description of all entries of
+ // the transaction
+
+ for (Entry entryNext : transaction.getEntry()) {
+ entryNext.setDescription(description);
+ }
+ updateEntries = true;
+ } else {
+ // not on first row, just update this entry description
+ entry.setDescription(description);
}
- updateTransaction = true;
- } else {
- // not on first row, just update this entry description
- entry.setDescription(description);
}
break;
case 3:
description = ((String) value).trim();
- firstEntryRow = getFirstEntry(row);
+ firstEntryRow = indexOf(transaction);
if (row == firstEntryRow) {
// let's update the description of all entries of
@@ -315,7 +315,7 @@
for (Entry entryNext : transaction.getEntry()) {
entryNext.setDescription(description);
}
- updateTransaction = true;
+ updateEntries = true;
} else {
// not on first row, just update this entry description
@@ -323,19 +323,22 @@
}
break;
case 4:
-
- entry.setAmount((BigDecimal) value);
- entry.setDebit(true);
+ if (((BigDecimal) value).signum() > 0 ) {
+ entry.setAmount((BigDecimal) value);
+ entry.setDebit(true);
+ }
break;
case 5:
- entry.setAmount((BigDecimal) value);
- entry.setDebit(false);
+ if (((BigDecimal) value).signum() > 0 ) {
+ entry.setAmount((BigDecimal) value);
+ entry.setDebit(false);
+ }
break;
}
// some modification must update all other
// first row modification update following rows
- if (updateTransaction) {
+ if (updateEntries) {
// FIXME echatellier 20120413 make a single service call
for (Entry entryTmp : transaction.getEntry()) {
financialTransactionService.updateEntry(entryTmp);
@@ -343,6 +346,9 @@
} else {
financialTransactionService.updateEntry(entry);
}
+ if (updateTransaction) {
+ financialTransactionService.updateFinancialTransaction(transaction);
+ }
/*
// FIXME echatellier 20120413 une modification des dates fait que l'ordre
// devient faux
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-07 16:09:48 UTC (rev 3679)
@@ -66,7 +66,7 @@
<JMenuItem text="lima.common.remove"
enabled="{isSelectedRow()}"
onActionPerformed="handler.deleteSelectedTransaction()"
- accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE , KeyEvent.SHIFT_DOWN_MASK)}" />
+ accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE , KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" />
<JMenuItem text="lima.common.copy"
enabled="{isSelectedRow()}"
onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())"
@@ -84,7 +84,7 @@
<JMenuItem text="lima.common.remove"
enabled="{isSelectedRow()}"
onActionPerformed="handler.deleteSelectedEntry()"
- accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)}" />
+ accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK)}" />
<JMenuItem text="lima.common.copy"
enabled="{isSelectedRow()}"
onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-07 16:09:48 UTC (rev 3679)
@@ -47,6 +47,7 @@
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
+import javax.swing.table.TableCellEditor;
import java.awt.event.ItemEvent;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -239,7 +240,8 @@
//new transaction with only entrybook and date
FinancialTransaction transaction = new FinancialTransactionImpl();
- transaction.setEntryBook(transactionTemp.getEntryBook());
+ EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem();
+ transaction.setEntryBook(entryBook);
transaction.setTransactionDate(transactionTemp.getTransactionDate());
transaction = financialTransactionService.createFinancialTransaction(transaction);
@@ -370,12 +372,6 @@
int addIndex = tableModel.size();
tableModel.addRow(entry, addIndex);
- entry = new EntryImpl();
- entry.setFinancialTransaction(fTransaction);
- entry = financialTransactionService.createEntry(entry);
- fTransaction.addEntry(entry);
- tableModel.addRow(entry, addIndex + 1);
-
//select the new line
ListSelectionModel selectionModel = table.getSelectionModel();
selectionModel.setSelectionInterval(addIndex, addIndex);
@@ -394,17 +390,14 @@
// real selected row or selected transaction row ?
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Entry lastEntryOfTransaction;
//First case, where line selected is an entry : take its transaction
//to select the last entry of the transaction
- Entry entryOrTransaction = tableModel.getEntryAt(indexSelectedRow);
- //if (entryOrTransaction instanceof Entry) {
- lastEntryOfTransaction = financialTransactionService.getLastEntry(entryOrTransaction.getFinancialTransaction());
- /*} else { //Second case, we have an instance of transaction, so select the last entry of it
- lastEntryOfTransaction = financialTransactionService.getLastEntry((FinancialTransaction)entryOrTransaction);
- } */
+ Entry entryAt = tableModel.getEntryAt(indexSelectedRow);
+ Entry lastEntry = financialTransactionService.getLastEntry(entryAt.getFinancialTransaction());
+ FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
+
if (log.isDebugEnabled()) {
log.debug("Selected row : " + indexSelectedRow);
}
@@ -412,9 +405,9 @@
String defaultVoucher = null;
String defaultDescription = null;
- if (lastEntryOfTransaction != null) {
- defaultVoucher = lastEntryOfTransaction.getVoucher();
- defaultDescription = lastEntryOfTransaction.getDescription();
+ if (lastEntry != null) {
+ defaultVoucher = lastEntry.getVoucher();
+ defaultDescription = lastEntry.getDescription();
}
// creates the new entry
@@ -431,10 +424,10 @@
BigDecimal tvaTax = null;
//Calculation of tva tax only if first entry is a sale
- if (lastEntryOfTransaction != null && lastEntryOfTransaction.getAccount()!= null){
- defaultAccount = lastEntryOfTransaction.getAccount().getAccountNumber();
+ if (lastEntry != null && lastEntry.getAccount()!= null){
+ defaultAccount = lastEntry.getAccount().getAccountNumber();
if (defaultAccount.equals("410") || defaultAccount.equals("418")){
- tvaTax = (lastEntryOfTransaction.getAmount()).multiply(tvaPercentAdd);
+ tvaTax = (lastEntry.getAmount()).multiply(tvaPercentAdd);
}
}
@@ -448,24 +441,18 @@
log.info("tva : " + tvaTax);
}
- // check if current row is a transaction or an entry
- FinancialTransaction currentTransaction = null;
- Object currentRow = tableModel.getEntryAt(indexSelectedRow);
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction) currentRow;
- } else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal debit = transaction.getAmountDebit();
+ entry.setDebit(credit.compareTo(debit) > 0);
+ entry.setAmount(credit.subtract(debit).abs());
// create it in service
- entry.setFinancialTransaction(currentTransaction);
+ entry.setFinancialTransaction(transaction);
Entry newEntry = financialTransactionService.createEntry(entry);
- currentTransaction.addEntry(newEntry);
+ transaction.addEntry(newEntry);
// add it in ui
- int addIndex = tableModel.indexOf(lastEntryOfTransaction) + 1;
+ int addIndex = tableModel.indexOf(lastEntry) + 1;
tableModel.addRow(newEntry, addIndex);
//select the new line
@@ -484,10 +471,15 @@
public void deleteSelectedTransaction() {
FinancialTransactionTable table = view.getFinancialTransactionTable();
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ ListSelectionModel selectionModel = table.getSelectionModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow >= 0) {
FinancialTransaction transaction = tableModel.getTransactionAt(indexSelectedRow);
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
int response = JOptionPane.showConfirmDialog(
view, _("lima.ui.financialtransaction.messageremovetransaction"),
_("lima.ui.financialtransaction.titleremovetransaction"), JOptionPane.YES_NO_OPTION);
@@ -503,6 +495,15 @@
financialTransactionService.removeFinancialTransaction(transaction);
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ }
+
}
}
@@ -511,10 +512,15 @@
public void deleteSelectedEntry() {
FinancialTransactionTable table = view.getFinancialTransactionTable();
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
+ ListSelectionModel selectionModel = table.getSelectionModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow >= 0) {
Entry entry = tableModel.getEntryAt(indexSelectedRow);
+ TableCellEditor cellEditor = table.getCellEditor();
+ if (cellEditor != null) {
+ cellEditor.cancelCellEditing();
+ }
int response = JOptionPane.showConfirmDialog(
view, _("lima.ui.financialtransaction.messageremoveentry"),
_("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION);
@@ -527,6 +533,17 @@
if (transaction.sizeEntry() == 0) {
financialTransactionService.removeFinancialTransaction(transaction);
}
+
+ if (tableModel.size() > 0) {
+ if (indexSelectedRow >= tableModel.size()) {
+ indexSelectedRow = tableModel.size() - 1;
+ } else {
+ indexSelectedRow++;
+ }
+ selectionModel.setSelectionInterval(
+ indexSelectedRow, indexSelectedRow);
+ table.changeSelection(indexSelectedRow, 1, false, false);
+ }
}
}
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2013-06-06 14:53:06 UTC (rev 3678)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2013-06-07 16:09:48 UTC (rev 3679)
@@ -62,4 +62,5 @@
log4j.logger.org.chorem.lima.business.ejb.ReportServiceImpl=DEBUG
log4j.logger.org.chorem.lima.ui.MainViewHandler=DEBUG
log4j.logger.org.chorem.lima.business.ejb.FinancialStatementServiceImpl=DEBUG
-log4j.logger.org.chorem.lima.ui.importexport.ImportExport=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.importexport.ImportExport=DEBUG
+log4j.logger.org.chorem.lima.ui.celleditor.DateTableCellEditor=DEBUG
\ No newline at end of file
1
0