Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
April 2010
- 5 participants
- 60 discussions
Author: echatellier
Date: 2010-04-06 19:04:18 +0200 (Tue, 06 Apr 2010)
New Revision: 2831
Log:
Petite doc sur openejb embarqu?\195?\169 et client/serveur
Added:
trunk/src/site/rst/devel/openejb.rst
Added: trunk/src/site/rst/devel/openejb.rst
===================================================================
--- trunk/src/site/rst/devel/openejb.rst (rev 0)
+++ trunk/src/site/rst/devel/openejb.rst 2010-04-06 17:04:18 UTC (rev 2831)
@@ -0,0 +1,94 @@
+OpenEJB
+=======
+
+Définition des EJB
+------------------
+
+Les implementations des services sont marqués avec l'annotation
+@Stateless.
+
+Point à verifier pour les annotations @Webservice et @Local, @Remote
+sur les interfaces.
+
+Embedded mode
+-------------
+
+Intantanciation et recherche dans un ``InitialContext`` local :
+
+::
+
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
+
+ InitialContext ctx = new InitialContext(properties);
+
+ AccountService ejbHome = (AccountService)ctx.lookup("AccountServiceImplLocal");
+
+Le nom "AccountServiceImplLocal" est ici une convention de nommage.
+
+TODO reference ? (EC : impossible à retrouver)
+
+
+Server mode
+-----------
+
+Tomcat
+~~~~~~
+
+Details : http://openejb.apache.org/tomcat.html
+
+
+OpenEJB server
+~~~~~~~~~~~~~~
+
+Details : http://openejb.apache.org/remote-server.html
+Testé avec : https://repository.apache.org/content/groups/snapshots/org/apache/openejb/o…
+
+Procedure:
+ - bin/openejb start &
+ - bin/openejb deploy lima-business-0.4.0-SNAPSHOT-jar-with-dependencies.jar
+
+Si le déploiment a réussi, openejb devrait afficher :
+
+::
+
+ Ejb(ejb-name=ReportServiceImpl, id=ReportServiceImpl)
+ Jndi(name=ReportServiceImplRemote)
+
+ Ejb(ejb-name=RecordServiceImpl, id=RecordServiceImpl)
+ Jndi(name=RecordServiceImplRemote)
+
+ Ejb(ejb-name=FinancialPeriodServiceImpl, id=FinancialPeriodServiceImpl)
+ Jndi(name=FinancialPeriodServiceImplRemote)
+
+ Ejb(ejb-name=FiscalPeriodServiceImpl, id=FiscalPeriodServiceImpl)
+ Jndi(name=FiscalPeriodServiceImplRemote)
+
+ Ejb(ejb-name=EntryBookServiceImpl, id=EntryBookServiceImpl)
+ Jndi(name=EntryBookServiceImplRemote)
+
+ Ejb(ejb-name=TransactionServiceImpl, id=TransactionServiceImpl)
+ Jndi(name=TransactionServiceImplRemote)
+
+ Ejb(ejb-name=AccountServiceImpl, id=AccountServiceImpl)
+ Jndi(name=AccountServiceImplRemote)
+
+Client
+~~~~~~
+
+ Properties properties = new Properties();
+ properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
+ properties.put("java.naming.provider.url", "ejbd://127.0.0.1:4201");
+ properties.put("java.naming.security.principal", "jonathan");
+ properties.put("java.naming.security.credentials", "secret");
+
+ InitialContext ctx = new InitialContext(properties);
+
+ AccountService ejbHome = (AccountService)ctx.lookup("AccountServiceImplRemote");
+
+Les identifiants "jonathan/secret" sont ceux par defaut définit dans le fishier
+OPENEJB_HOME/conf/users.properties
+
+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
1
0
Author: tchemit
Date: 2010-04-03 12:39:26 +0200 (Sat, 03 Apr 2010)
New Revision: 2830
Log:
Evolution #137: update to nuiton-i18n 1.2.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-02 17:04:31 UTC (rev 2829)
+++ trunk/pom.xml 2010-04-03 10:39:26 UTC (rev 2830)
@@ -236,7 +236,7 @@
<eugene.version>2.0.1-SNAPSHOT</eugene.version>
<topia.version>2.3.2-SNAPSHOT</topia.version>
<jaxx.version>2.0</jaxx.version>
- <i18n.version>1.2</i18n.version>
+ <i18n.version>1.2.1</i18n.version>
<!--axis.version>1.4.1</axis.version-->
<!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
1
0
r2829 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: . account account/model entrybook entrybook/model export period period/model report transaction transaction/model transaction/table
by echatellier@users.chorem.org 02 Apr '10
by echatellier@users.chorem.org 02 Apr '10
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:04:31 +0200 (Fri, 02 Apr 2010)
New Revision: 2829
Log:
Resctructuration des ui (package par function).
Mise ?\195?\160 jour des ui, periods, account, transaction, entrybook...
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/css/
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,43 +0,0 @@
-<JFrame locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
- <style source="css/lima.css"/>
- <Table insets='5,5,5,5'>
- <row>
- <cell>
- <JLabel text="lima.number"/>
- </cell>
- <cell>
- <JTextField id="numberTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.description"/>
- </cell>
- <cell>
- <JTextField id="descriptionTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.account.type"/>
- </cell>
- <cell>
- <JAXXComboBox id="typeComboBox">
- <item value='{null}' label=' ' selected="true"/>
- <item value='{_("lima.actif")}'/>
- <item value='{_("lima.passif")}'/>
- <item value='{_("lima.produit")}'/>
- <item value='{_("lima.charge")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,26 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <script>
- protected void initAddAccount() {};
- protected void initUpdateAccount() {};
- protected void removeAccount() {};
- </script>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
- <JScrollPane id="accountScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add" onActionPerformed="initAddAccount()" width="150"/>
- </cell>
- </row>
- <row>
- <cell >
- <JButton id="updateButton" text="lima.update" onActionPerformed="initUpdateAccount()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeAccount()" width="150"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,236 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.tree.model.AccountTreeTableModel;
-import org.jdesktop.swingx.JXTreeTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import javax.swing.*;
-import javax.swing.tree.TreePath;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.LinkedList;
-import java.awt.Color;
-
-/**
- * @author ore
- */
-public class AccountViewImpl extends AccountView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(AccountViewImpl.class);
- private final JXTreeTable table;
- private final AccountTreeTableModel model;
- private final AccountForm form;
- private boolean isAddForm;
-
- /**
- * Constructor
- */
- public AccountViewImpl() {
- // TreeTable
- model = LimaContext.getContext().getDataManager().getAccountModel();
- table = new JXTreeTable(model);
- table.setColumnControlVisible(true);
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- accountScrollPane.setViewportView(table);
- form = LimaContext.getContext().getMainUI().getAccountForm();
- form.getOkButton().addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(
- ActionEvent e) {
- if (isAddForm) {
- addAccount();
- } else {
- updateAccount();
- }
- }
- });
-
- // Default button OK
- form.getRootPane().setDefaultButton(form.getOkButton());
- // Coloration
- table.setBackground(Color.WHITE);
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- //,new Color(250,250,250) createAlternateStriping(Color.GRAY,Color.WHITE)
- }
-
- /**
- * Initialize account form
- */
- private void initForm() {
- form.getTypeComboBox().setSelectedIndex(0);
- }
-
- /**
- * Initialize form account to add accounts
- */
- @Override
- protected void initAddAccount() {
- initForm();
- isAddForm = true;
- form.setTitle(_("lima.ui.add.account"));
- form.getNumberTextField().setText(DTOHelper.EMPTY_STRING);
- form.getNumberTextField().setEditable(true);
- form.getDescriptionTextField().setText(DTOHelper.EMPTY_STRING);
- form.getTypeComboBox().setSelectedIndex(0);
- form.setVisible(true);
-
- }
-
- /**
- * Initialize form account to update accounts
- */
- @Override
- protected void initUpdateAccount() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- initForm();
- isAddForm = false;
- // Show journal data selected in the form
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- form.setTitle(_("lima.ui.update.account"));
- form.getNumberTextField().setText(account.getIdNumber());
- form.getNumberTextField().setEditable(false);
- form.getDescriptionTextField().setText(account.getDescription());
- // Type of account
- if (account.getType() == null) {
- form.getTypeComboBox().setSelectedIndex(0);
- } else {
- for (int i = 1; i < form.getTypeComboBox().getItemCount(); i++) {
- if (((String) form.getTypeComboBox().getItemAt(i)).equalsIgnoreCase(account.getType())) {
- form.getTypeComboBox().setSelectedIndex(i);
- break;
- }
- }
- }
- form.setVisible(true);
- }
- }
-
- /**
- * On performed action, allows to add an account
- */
- private void addAccount() {
- if (log.isDebugEnabled()) {
- log.debug("addAccount : ");
- // Getting form data
- }
- String number = form.getNumberTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String type = (String) form.getTypeComboBox().getSelectedItem();
- if (log.isDebugEnabled()) {
- log.debug("type : " + type); // Contrainte sur le type ??
- }
- form.dispose();
- AccountDTO account;
- TreePath treePath;
- AccountDTO parent;
- // Not row selected
- if (table.getSelectedRow() == -1) {
- /**
- * Class account can't be created
- */
- parent = model.getData(); // Root
- treePath = new TreePath(parent);
- } else {
- /**
- * Add account child
- */ // Get Parent
- int selectedRow = table.getSelectedRow();
- treePath = table.getPathForRow(selectedRow);
- parent = (AccountDTO) treePath.getLastPathComponent();
- }
- account = new AccountDTO("0", number, description, type, new LinkedList<AccountDTO>(), parent);
- String result = model.addAccount(treePath, account);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * On performed action, allows to update an account
- */
- private void updateAccount() {
- if (log.isDebugEnabled()) {
- log.debug("updateAccount : ");
- // Getting form data
- }
- String number = form.getNumberTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String type = (String) form.getTypeComboBox().getSelectedItem();
- form.dispose();
- // Setting new collected data
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- // Clone
- AccountDTO clone = DTOHelper.cloneAccount(account);
- clone.setIdNumber(number);
- clone.setDescription(description);
- clone.setType(type);
- String result = model.updateAccount(treePath, account, clone);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * On performed action, allows to remove an account
- */
- @Override
- protected void removeAccount() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(this,
- _("lima.question.remove.account"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- // update view of treetable
- int selectedRow = table.getSelectedRow();
- TreePath treePath = table.getPathForRow(selectedRow);
- AccountDTO account = (AccountDTO) treePath.getLastPathComponent();
- String result = model.removeAccount(treePath, account);
- /** Affichage des erreurs */
- ErrorMessage.showMessage(result);
- }
- }
- }
-
- public JXTreeTable getTable() {
- return table;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,8 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <row>
- <cell>
- <style source="css/lima.css" />
- <JLabel text="lima.home"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,36 +0,0 @@
-/**
- * *##% Lima-Callao AccueilViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-/**
- * @author Rémi Chapelet
- */
-public class AccueilViewImpl extends AccueilView {
-
-
- /**
- * Constructor
- */
- public AccueilViewImpl() {
-
-
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,35 +0,0 @@
-<JFrame width="300" height="150" locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
- <style source="css/lima.css" />
- <Table fill="both">
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginMonthPeriodPanel"/>
- </cell>
- <cell>
- <JPanel id="beginYearPeriodPanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endMonthPeriodPanel"/>
- </cell>
- <cell>
- <JPanel id="endYearPeriodPanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,32 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void updateBalance() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- <cell>
- <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="updateBalance()" />
- </cell>
- </row>
-
- <!-- Affichage de la balance -->
- <row columns="3" weightx="1" weighty="10" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tableBalance" />
- </cell>
- </row>
-
- <!-- Affichage du résultat -->
- <row columns="3" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tableBalanceRes" />
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,192 +0,0 @@
-/**
- * *##% Lima-Callao
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.model.BalanceTableModel;
-import org.chorem.lima.table.renderer.BalanceTableCellRenderer;
-import static org.nuiton.i18n.I18n._;
-
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import java.awt.event.*;
-import javax.swing.*;
-import javax.swing.table.DefaultTableModel;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * Cette classe permet l'affichage de la balance comptable.
- *
- * @author Rémi Chapelet
- */
-public class BalanceViewImpl extends BalanceView {
-
- private JComboBox comboBoxPeriod = new JComboBox();
- private JXTable table;
- private JXTable tableRes;
- private BalanceHelper balance = new BalanceHelper();
- private BalanceTableModel modelBalance;
- private DefaultTableModel model;
-
- /**
- * Constructor
- */
- public BalanceViewImpl() {
-
- //Initialise les périodes pour la combobox
- initComboBoxPeriod();
-
- /**
- * Création du model pour le tableau
- */
- // Création de la balance
- List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
- // Création de la table
- modelBalance = new BalanceTableModel(listBalance);
- table = new JXTable(modelBalance);
- /** Design de la table */
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
- // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
- for (int i = 0; i < table.getModel().getColumnCount(); i++) {
- table.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
- }
-
- // Affichage de la table
- tableBalance.setViewportView(table);
-
- /**
- * Calcul pour le total des soldes
- */
- model = new DefaultTableModel();
- String[] columnNames = {"1", "2", "3", "4", "5", "6"};
- model.setColumnIdentifiers(columnNames);
- tableRes = new JXTable(model);
- // On cache le header des colonnes
- tableRes.setColumnControlVisible(false);
- tableRes.getTableHeader().setVisible(false);
- // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
- for (int i = 0; i < tableRes.getModel().getColumnCount(); i++) {
- tableRes.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
- }
- // Initialise les valeurs pour le résultat total
- initTableBalanceRes(listBalance);
-
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Recherche la balance
- updateBalance();
- }
- });
- }
-
- /**
- * Permet de initialiser la table de résultat à chaque appel de cette
- * méthode.
- *
- * @param listBalance
- */
- private void initTableBalanceRes(List<BalanceDTO> listBalance) {
- // Déclaration des variables
- String TotalMoveDebit = "0";
- String TotalMoveCredit = "0";
- String TotalBalanceDebit = "0";
- String TotalBalanceCredit = "0";
- // Pour chaque ligne de la balance
- for (BalanceDTO balanceDTO : listBalance) {
- /** Calcul des mouvements */
- TotalMoveDebit = DTOHelper.AddNumbersString(TotalMoveDebit, balanceDTO.getDebit());
- TotalMoveCredit = DTOHelper.AddNumbersString(TotalMoveCredit, balanceDTO.getCredit());
- /** Calcul des soldes */
- if (balanceDTO.getType().equalsIgnoreCase("Actif") ||
- balanceDTO.getType().equalsIgnoreCase("Charge")) {
- String solde = DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit());
- TotalBalanceDebit = DTOHelper.AddNumbersString(solde, TotalBalanceDebit);
- } else {
- String solde = DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit());
- TotalBalanceCredit = DTOHelper.AddNumbersString(solde, TotalBalanceCredit);
- }
- }
- // Définition des données
- Object[] data =
- {"", _("lima.balance.total"), TotalMoveDebit, TotalMoveCredit, TotalBalanceDebit, TotalBalanceCredit};
- // Si il existe déja une ligne
- if (model.getRowCount() > 0) {
- model.removeRow(0);
- }
- // Ajout de la ligne
- model.addRow(data);
- tableRes.setModel(model);
- tableBalanceRes.setViewportView(tableRes);
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- v.addAll(period.getChildren());
- }
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
- /**
- * Permet de recharger la balance. Elle appelle la méthode createBalance, qui
- * va parcourir de nouveau les entrées comptables pour la période, et calculer
- * la balance.
- */
- @Override
- protected void updateBalance() {
- // Récupère la liste de la balance
- List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
- modelBalance.setData(listBalance);
- modelBalance.fireTableDataChanged();
- initTableBalanceRes(listBalance);
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,29 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void addLettering() {};
- protected void removeLettering() {};
- protected void precedentAccount() {};
- protected void nextAccount() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
-
- <!-- Affichage du bilan (actif et passif) -->
- <row weightx="1.0" weighty="1.0" anchor="center" fill="both">
- <cell weightx="0.5">
- <JScrollPane id="tabActif" />
- </cell>
- <cell weightx="0.5">
- <JScrollPane id="tabPassif" />
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,480 +0,0 @@
-/**
- * *##% Lima-Callao BilanViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.bilan.Bilan;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.balance.Category;
-import org.chorem.lima.table.BilanActifJXTable;
-import org.chorem.lima.table.BilanPassifJXTable;
-import org.chorem.lima.table.model.BilanActifTableModel;
-import org.chorem.lima.table.model.BilanPassifTableModel;
-
-import java.awt.event.*;
-import javax.swing.*;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Vector;
-
-/**
- * Cette classe permet de calculer le bilan. Elle utilise la balance et
- * le compte de résultat.
- *
- * @author Rémi Chapelet
- */
-public class BilanViewImpl extends BilanView {
-
- private JComboBox comboBoxPeriod = new JComboBox();
- private BilanActifJXTable tableActif;
- private BilanPassifJXTable tablePassif;
- private BilanActifTableModel modelBilanActif;
- private BilanPassifTableModel modelBilanPassif;
- Hashtable<String, Bilan> actifTab = new Hashtable<String, Bilan>();
- Hashtable<String, Bilan> passifTab = new Hashtable<String, Bilan>();
- Hashtable<String, List<BalanceDTO>> provisionMap;
- private BalanceHelper balance = new BalanceHelper();
- private ProgressBarImpl progressBar;
-
- /**
- * Constructor
- */
- public BilanViewImpl() {
-
- // Initialise la combobox pour les périodes
- initComboBoxPeriod();
-
- // Création des modèles
- modelBilanActif = new BilanActifTableModel(new LinkedList<Bilan>());
- modelBilanPassif = new BilanPassifTableModel(new LinkedList<Bilan>());
-
-
- // Chargement du bilan
- //updateBilan();
-
- /** ACTIF */
- tableActif = new BilanActifJXTable(modelBilanActif);
- // Ajout du tableau
- tabActif.setViewportView(tableActif);
-
- /** PASSIF */
- tablePassif = new BilanPassifJXTable(modelBilanPassif);
- // Ajout du tableau
- tabPassif.setViewportView(tablePassif);
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- updateBilan();
- }
- });
-
- }
-
- /**
- * Cette partie consiste à créer les catégories du bilan
- */
- public void createCategory() {
- /** ACTIF */
-
- actifTab.put("ACTIF", new Bilan("TOTAL (1) + (2)", "total", null));
- actifTab.put("ACTIF_IMMOBILISE", new Bilan("ACTIF IMMOBILISE", "title", null));
- actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
- actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
- actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier", "", null));
- actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
- actifTab.put("ACTIF_CIRCULANT", new Bilan("ACTIF CIRCULANT", "title", null));
- actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
- actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
- actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
- actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_VMP"));
- actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
- actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA", "", null));
- actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CCA"));
- actifTab.get("ACTIF").add(actifTab.get("ACTIF_IMMOBILISE"));
- actifTab.get("ACTIF").add(actifTab.get("ACTIF_CIRCULANT"));
- /** PASSIF */
- passifTab.put("PASSIF", new Bilan("TOTAL (1) + (2) + (3)", "total", null));
- passifTab.put("PASSIF_CAPITAUX", new Bilan("CAPITAUX PROPRES", "title", null));
- passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_CAPITAL"));
- passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESERVES"));
- passifTab.put("PASSIF_CP_RAN", new Bilan("RAN", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RAN"));
- passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESULTAT"));
- passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_SUBVENTION"));
- passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées", "", null));
- passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_PROVISION"));
- passifTab.put("PASSIF_PR_PROVISIONS", new Bilan("PROVISIONS", "title", null));
- passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions", "", null));
- passifTab.get("PASSIF_PR_PROVISIONS").add(passifTab.get("PASSIF_PROVISIONS"));
- passifTab.put("PASSIF_DETTES", new Bilan("DETTES", "title", null));
- passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
- passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AVANCES"));
- passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
- passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FISCALES"));
- passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
- passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
- passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA", "", null));
- passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_PCA"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_CAPITAUX"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_CP_PROVISION"));
- passifTab.get("PASSIF").add(passifTab.get("PASSIF_DETTES"));
- }
-
- /**
- * Permet de calculer le bilan
- */
- public void updateBilan() {
- log.debug("Update bilan :");
-
- MainViewImpl context = LimaContext.get().getMainUI();
- progressBar = new ProgressBarImpl(context, context);
- Runnable runnable = new Runnable() {
- public void run() {
- progressBar.setVisible(true);
- }
- };
- SwingUtilities.invokeLater(runnable);
-
- new Thread() {
- @Override
- public void run() {
-
- progressBar.setTitle("Chargement du bilan");
- progressBar.getProgressBar().setString("0% : Préparation des données");
- progressBar.getProgressBar().setValue(0);
-
- // Chargement de la balance
- List<BalanceDTO> ListbalanceDTO = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
-
-
- progressBar.getProgressBar().setString("10% : Balance chargée");
- progressBar.getProgressBar().setValue(10);
- /**
- * Vérifie chaque numéro de compte (balance) pour déterminer sa position
- * dans le bilan.
- * Chaque catégorie est un objet bilan, et possède à son tour des bilans
- * correspondants aux comptes.
- * Cette boucle ne prend pas en compte les amortissement et provisions.
- * Ces comptes sont mis dans une liste à part, pour être traités une seconde fois.
- */
-
- progressBar.getProgressBar().setString("15% : Création catégorie");
- progressBar.getProgressBar().setValue(15);
- createCategory();
- // Liste amort/prov à traiter apres
- provisionMap = new Hashtable<String, List<BalanceDTO>>();
-
- progressBar.getProgressBar().setString("20% : Chargement des comptes");
- progressBar.getProgressBar().setValue(20);
- // Récupère le nombre de balances
- float nbBalances = ListbalanceDTO.size();
- float incremente = 40 / nbBalances;
- float value = 20;
- // Pour chaque balance
- for (BalanceDTO balanceDTO : ListbalanceDTO) {
- /**
- * ACTIF
- */
- /** IMMOBILISATION */
- if (Category.accountNumberCategory("20", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("21", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("22", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("23", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("25", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("26", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("27", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /** ACTIF CIRCULANT */
- if (Category.accountNumberCategory("31", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("32", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("33", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("34", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("35", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("36", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("37", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_STOCK").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("99", balanceDTO.getAccount().getIdNumber())) {
- // TODO
- //actifTab.get("ACTIF_CIRCULANT_AVANCES").add(balanceDTO,Util.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("41", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("50", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_VMP").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("51", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("52", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("53", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("54", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- if (Category.accountNumberCategory("486", balanceDTO.getAccount().getIdNumber())) {
- actifTab.get("ACTIF_CIRCULANT_CCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /** AMORT. & PROV. */
- if (Category.accountNumberCategory("280", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_INCORPOREL", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO);
- }
- if (Category.accountNumberCategory("281", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_CORPOREL", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO);
- }
- if (Category.accountNumberCategory("282", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_IMMOBILISE_FINANCIER", listBalance);
- }
- provisionMap.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO);
- }
- if (Category.accountNumberCategory("491", balanceDTO.getAccount().getIdNumber())) {
- if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") == null) {
- LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
- provisionMap.put("ACTIF_CIRCULANT_CREANCES", listBalance);
- }
- provisionMap.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO);
- }
- /**
- * PASSIF
- */
- /** CAPITAUX PROPRES */
- if (Category.accountNumberCategory("101", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("104", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("105", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("107", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("108", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("109", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_CAPITAL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("106", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RESERVES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("11", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RAN").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("12", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_RESULTAT").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("13", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_SUBVENTION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("14", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_CP_PROVISION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- /** PROVISIONS */
- if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_PROVISIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- /** DETTES */
- if (Category.accountNumberCategory("16", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_EMPRUNTS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_AVANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("40", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_FOURNISSEURS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("43", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("44", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_FISCALES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("999", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_IMMOBILISATIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("9999", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_AUTRES_DETTES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- if (Category.accountNumberCategory("487", balanceDTO.getAccount().getIdNumber())) {
- passifTab.get("PASSIF_DETTES_PCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Incrémente la barre de chargement
- value = value + incremente;
- progressBar.getProgressBar().setValue((int) value);
- progressBar.getProgressBar().setString((int) value + "% : Compte : " + balanceDTO.getName());
- }
-
- progressBar.getProgressBar().setString("60% : Mise en place des amortissements et provisions");
- progressBar.getProgressBar().setValue(60);
- /**
- * Mise en place des provisions et amortissements
- */
- if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_CORPOREL");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_CORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_FINANCIER");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_IMMOBILISE_FINANCIER").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
- if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") != null) {
- List<BalanceDTO> listBalance = provisionMap.get("ACTIF_CIRCULANT_CREANCES");
- for (BalanceDTO balanceDTO : listBalance) {
- actifTab.get("ACTIF_CIRCULANT_CREANCES").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
-
- progressBar.getProgressBar().setString("70% : Calcul du résultat");
- progressBar.getProgressBar().setValue(70);
- /**
- * Appel de la méthode du calcul du compte de résultat pour avoir le
- * résultat
- */
- ResultViewImpl resultViewImpl = new ResultViewImpl();
- resultViewImpl.updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- passifTab.get("PASSIF_CP_RESULTAT").add(new Bilan("Résultat", "", resultViewImpl.getResult(), "0"), resultViewImpl.getResult());
-
- progressBar.getProgressBar().setString("90% : Création des tableaux");
- progressBar.getProgressBar().setValue(90);
- /**
- * Ajout des données dans le model
- */
- /** ACTIF */
- List<Bilan> listActif = new LinkedList<Bilan>();
- listActif.add(actifTab.get("ACTIF_IMMOBILISE"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
- listActif.add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
- listActif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", actifTab.get("ACTIF_IMMOBILISE").getTotal(), actifTab.get("ACTIF_IMMOBILISE").getDepreciation()));
- listActif.add(actifTab.get("ACTIF_CIRCULANT"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_VMP"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
- listActif.add(actifTab.get("ACTIF_CIRCULANT_CCA"));
- listActif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", actifTab.get("ACTIF_CIRCULANT").getTotal(), actifTab.get("ACTIF_CIRCULANT").getDepreciation()));
- listActif.add(actifTab.get("ACTIF"));
-
- // Création du modèle à partir de la liste précédement créée
- modelBilanActif.setData(listActif);
- modelBilanActif.fireTableDataChanged();
-
- /** PASSIF */
- List<Bilan> listPassif = new LinkedList<Bilan>();
- listPassif.add(passifTab.get("PASSIF_CAPITAUX"));
- listPassif.add(passifTab.get("PASSIF_CP_CAPITAL"));
- listPassif.add(passifTab.get("PASSIF_CP_RESULTAT"));
- listPassif.add(passifTab.get("PASSIF_CP_RESERVES"));
- listPassif.add(passifTab.get("PASSIF_CP_RAN"));
- listPassif.add(passifTab.get("PASSIF_CP_SUBVENTION"));
- listPassif.add(passifTab.get("PASSIF_CP_PROVISION"));
- listPassif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", passifTab.get("PASSIF_CAPITAUX").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF_PR_PROVISIONS"));
- listPassif.add(passifTab.get("PASSIF_PROVISIONS"));
- listPassif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", passifTab.get("PASSIF_PR_PROVISIONS").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF_DETTES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_AVANCES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_FISCALES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
- listPassif.add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
- listPassif.add(passifTab.get("PASSIF_DETTES_PCA"));
- listPassif.add(new Bilan("SOUS-TOTAL (3)", "soustotal", passifTab.get("PASSIF_DETTES").getTotal(), "0"));
- listPassif.add(passifTab.get("PASSIF"));
-
- progressBar.getProgressBar().setString("90% : Opération terminée");
- progressBar.getProgressBar().setValue(90);
- // Création du modèle à partir de la liste précédement créée
- modelBilanPassif.setData(listPassif);
- progressBar.getProgressBar().setValue(95);
- modelBilanPassif.fireTableDataChanged();
- progressBar.getProgressBar().setValue(100);
- progressBar.dispose();
- }
- }.start();
-
- }
-
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- //v.addAll(period.getChildren());
- }
-
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
-}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosableTabHeader.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+<Table insets='0,0,0,0' opaque='false'>
+
+ <String id="title" javaBean='null' />
+ <Boolean id="canClose" javaBean='true'/>
+
+ <row fill='both'>
+ <cell anchor='west' weightx="1" insets='0,0,0,0'>
+ <JLabel id='label' opaque='false' font-size='12'
+ verticalAlignment='center' verticalTextPosition='0'
+ text='{getTitle()}'/>
+ </cell>
+ <cell anchor='east' insets='2,15,0,0' weighty='0'>
+ <JButton id='closeTab' preferredSize='{new Dimension(16,16)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='{isCanClose()}'
+ horizontalTextPosition='0'
+ actionIcon='closeTab'
+ />
+ </cell>
+ </row>
+</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,4 +0,0 @@
-<JFrame title="lima.export" width="620" height="300"
-iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
-
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,41 +0,0 @@
-<JFrame width="500" height="240" id="ClosureTimeSpanView"
-defaultCloseOperation="dispose_on_close">
-
- <style source="css/lima.css" />
- <script>
- protected void windowClosing() {};
- </script>
- <Table insets='4,0,4,0'>
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginPeriod"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endPeriod"/>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JTextArea id="JTextAreaWarning" styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok" />
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-
-
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,28 +0,0 @@
-<Table insets='0,0,0,0'>
- <script>
- protected void initBlockForm() {};
- protected void initUnblockForm() {};
- </script>
- <row fill="horizontal" weightx="0.75" weighty="0" anchor="center" insets='5,5,5,5'>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
- <row >
- <cell fill="both" weightx="1" weighty="1" rows='3' columns='4' >
- <JScrollPane id="closureScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.block" onActionPerformed="initBlockForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.unblock" onActionPerformed="initUnblockForm()" width="150"/>
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,406 +0,0 @@
-/**
- * *##% Lima-Callao ClosureViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-
-import javax.swing.JComboBox;
-import javax.swing.ListSelectionModel;
-import javax.swing.RowFilter;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.StatusDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.TriPeriodAsc;
-import org.chorem.lima.dto.util.TriPeriodDesc;
-import org.chorem.lima.table.model.ClosureTableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-
-/**
- * Permet l'affichage du tableau avec les périodes mensuelles.
- *
- * @author Rémi Chapelet
- */
-public class ClosureViewImpl extends ClosureView {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -8759564865633991757L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
-
- private final JXTable table;
- private JComboBox comboBoxPeriod = new JComboBox();
- private final ClosureTimeSpanForm form;
- private final AddPeriod addPeriodForm;
- private static boolean blockPeriod;
- private JComboBox comboBoxBeginPeriod = new JComboBox();
- private JComboBox comboBoxEndPeriod = new JComboBox();
- private JComboBox comboBeginYearPeriod = new JComboBox();
- private JComboBox comboBeginMonthPeriod = new JComboBox();
- private JComboBox comboEndYearPeriod = new JComboBox();
- private JComboBox comboEndMonthPeriod = new JComboBox();
-
-
- /**
- * Constructor
- */
- public ClosureViewImpl() {
-
- // Initialisation du choix pour les périodes
- initComboBoxPeriod();
-
- /* Set Period model */
- // Création du model pour le tableau
- table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
- table.setRowHeight(24);
- // Permet d'alterner les couleurs des lignes pour le tableau
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- // Definition de la selection possible sur les lignes
- table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
- table.setColumnControlVisible(true);
-
- /*
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Récupère la période master
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
- //FilterPipeline filters = new FilterPipeline(filterArray);
-
- RowFilter<Object, Object> filter = null;
- if (periodMaster != null) {
- // 0 = check only in first column
- // filter :
- // period name containing selected periode
- // Final = ??? TODO
- Calendar calendar = Calendar.getInstance();
- calendar.setTime(periodMaster.getBegin());
- filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
- if (log.isDebugEnabled()) {
- log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
- }
- }
- table.setRowFilter(filter);
- }
- });
-
- // Ajout du tableau dans l'UI
- getClosureScrollPane().setViewportView(table);
-
- /*
- * Initialisation du formulaire pour bloquer ou débloquer une période.
- */
- form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
- form.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- updatePeriod();
- }
- });
-
- /**
- * Initialisation du formulaire pour ajouter un exercice
- */
- addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
-
- Calendar cal = Calendar.getInstance();
-
- //Init YEAR Periode Combobox
- // take care about previous year #120
- int todayYear = cal.get(Calendar.YEAR);
- for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
- comboBeginYearPeriod.addItem(currentYear);
- comboEndYearPeriod.addItem(currentYear);
- }
- comboBeginYearPeriod.setSelectedItem(todayYear);
- comboEndYearPeriod.setSelectedItem(todayYear);
-
-
- //Add BeginYear ComboBox to addPeriodForm
- addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
- addPeriodForm.getBeginYearPeriodPanel().validate();
-
- //Add EndYear ComboBox to addPeriodForm
- addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
- addPeriodForm.getEndYearPeriodPanel().validate();
-
- //Init MONTH Periode Combobox
- cal.set(Calendar.MONTH, Calendar.JANUARY);
- for (int j = 0; j <= 11; j++) {
- comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
- cal.add(Calendar.MONTH, 1);
- }
-
- //Add BeginMonth ComboBox to addPeriodForm
- addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
- addPeriodForm.getBeginMonthPeriodPanel().validate();
-
- //Add EndMonth ComboBox to addPeriodForm
- addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
- addPeriodForm.getEndMonthPeriodPanel().validate();
-
- addPeriodForm.getOkButton().addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- addPeriod();
- addPeriodForm.dispose();
- }
- });
-
- }
-
-
- /**
- * Cette méthode permet de charger les périodes (annuelles) pour choisir
- * les périodes mensuelles à afficher dans le tableau.
- */
- public void initComboBoxPeriod() {
- /**
- * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxPeriod.setModel(periodModel);
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
-
- /**
- * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
- * plusieurs périodes.
- */
- @Override
- public void initBlockForm() {
- blockPeriod = true;
- form.setTitle(_("lima.ui.block.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise le formulaire pour débloquer des périodes mensuelles.
- */
- @Override
- public void initUnblockForm() {
- blockPeriod = false;
- form.setTitle(_("lima.ui.unblock.timespan"));
- initComboBoxForm();
- form.setVisible(true);
- }
-
-
- /**
- * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
- * les deux combobox nécessaires pour début et fin de période.
- */
- public void initComboBoxForm() {
- /**
- * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
- */
- // Récupère les périodes
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- // Création Combobox debut période
- comboBoxBeginPeriod.setModel(periodModel);
- comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Création Combobox fin période
- comboBoxEndPeriod.setModel(periodModel);
- comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- // Ajout des combobox
- form.beginPeriod.add(comboBoxBeginPeriod);
- form.endPeriod.add(comboBoxEndPeriod);
-
- /**
- * Positionne, si les lignes sont sélectionnées, les comboBox sur
- * les bonnes périodes (période min et période max).
- */
- // Si une ou plusieurs lignes sont sélectionnées
- if (table.getSelectedRow() != -1) {
- // Récupère les périodes sélectionnées
- List<PeriodDTO> listPeriod = getSelectedPeriod();
- // Parcours du vecteur
- comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
- comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
- }
- }
-
-
- /**
- * Permet d'ajouter un nouvel exercice.
- */
- protected void addPeriod() {
- if (log.isDebugEnabled()) {
- log.debug("addPeriod : ");
- //Get form data
- }
- PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
-
- // get begin date
- Calendar beginCalendar = Calendar.getInstance();
- if (periodCurrent != null) {
- beginCalendar.setTime(periodCurrent.getBegin());
- }
- beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
- beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
- // month is equals to list index
- beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
- Date beginDate = beginCalendar.getTime();
-
- // get end date
- Calendar endCalendar = Calendar.getInstance();
- endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
- endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
- int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
- endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
- Date endDate = endCalendar.getTime();
-
- if (log.isDebugEnabled()) {
- log.debug("Add new periode from " + beginDate + " to " + endDate);
- }
-
- String periodName = null;
- if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
- }
- else {
- periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
- }
-
- // TODO what is status.get(3) ???
- PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
-
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- closureModel.addPeriod(period, status);
- }
-
- /**
- * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
- * une ou plusieurs périodes, ou bien débloquer.
- * On récupère l'intervalle des périodes donné par le formulaire. On prend
- * les périodes aux extrémités.
- * Si on bloque les périodes, on va trier par ordre croissant sinon par
- * ordre décroissant. En effet, pour débloquer une période, il est important
- * que les périodes qui suivent soient bloquées ; par conséquent on doit
- * commencer par les dernières.
- */
- protected void updatePeriod() {
- // Liste des status
- List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
- // Liste des transactions
- List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
- // Chargement du model
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- /**
- * Récupère l'intervalle des périodes sélectionnées
- */
- PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
- PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
- // Exercice
- PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
- // Si block période, on trie la liste en croissant ou bien décroissant
- List<PeriodDTO> listPeriod = periodMaster.getChildren();
- if (blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- } else {
- Collections.sort(listPeriod, new TriPeriodDesc());
- }
- // Pour toutes les périodes mensuelles
- for (PeriodDTO period : listPeriod) {
- if (((period.getBegin().after(periodBegin.getBegin()))
- && (period.getBegin().before(periodEnd.getBegin())))
- || (period.equals(periodBegin))
- || (period.equals(periodEnd))) {
- if (log.isDebugEnabled()) {
- log.debug("updatePeriod : " + period.getIdName() + " : "
- + blockPeriod);
- }
- /**
- * Détection des messages d'erreur
- */
- String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
- ErrorMessage.showMessage(message);
- }
- }
- // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
- // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
- // décroissant).
- if (!blockPeriod) {
- Collections.sort(listPeriod, new TriPeriodAsc());
- }
- form.setVisible(false);
- form.dispose();
- }
-
- /**
- * Cette méthode permet de retourner une liste des périodes sélectionnées.
- *
- * @return liste des périodes sélectionnées
- */
- protected List<PeriodDTO> getSelectedPeriod() {
- // récupère les lignes sélectionnées
- int viewIndex[] = table.getSelectedRows();
- // chargement du model (tableau des périodes)
- ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
- LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
- // Pour chaque ligne sélectionnée
- for (int i : viewIndex) {
- int modelIndex = table.convertRowIndexToModel(i);
- listPeriod.add(closureModel.getRow(modelIndex));
- }
- return listPeriod;
- }
-
-
- public void initAddPeriod() {
- addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
- addPeriodForm.setVisible(true);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,24 +0,0 @@
-<Table insets='5,5,5,5'>
- <script>
- protected void removeCriteriaWidget(){}
- </script>
- <row>
- <cell>
- <JAXXComboBox id="criteriaComboBox" width="200">
- <item value='date' label='{_("lima.date")}' selected="true"/>
- <item value='voucher' label='{_("lima.voucher")}'/>
- <item value='account' label='{_("lima.account")}'/>
- <item value='description' label='{_("lima.description")}'/>
- <item value='debit' label='{_("lima.debit")}'/>
- <item value='credit' label='{_("lima.credit")}'/>
- <item value='amount' label='{_("lima.amount")}'/>
- </JAXXComboBox>
- </cell>
- <cell weightx="0">
- <JPanel id="criteriaPanel"/>
- </cell>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,213 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.item.Item;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
-import org.jdesktop.swingx.JXDatePicker;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
-import java.util.Date;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class CriteriaWidgetImpl extends CriteriaWidget {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class);
- private JTextField inputTextField;
- private JXDatePicker datePicker;
- private JComboBox comboBox;
- private JComboBox accountCombo;
-
- /**
- * Constructor
- */
- public CriteriaWidgetImpl() {
- // date input creation
- createDateInput();
-
- // item changed listener
- criteriaComboBox.addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- String itemSelected = e.getItem().toString();
- if (itemSelected.equals("date")) {
- createDateInput();
- }
- if (itemSelected.equals("voucher") ||
- itemSelected.equals("description") ||
- itemSelected.equals("account")) {
- createTextInput();
- }
- if (itemSelected.equals("debit") ||
- itemSelected.equals("credit") ||
- itemSelected.equals("amount")) {
- createNumberInput();
- }
- if (itemSelected.equals("account")) {
- createAccountInput();
- }
- }
- }
- });
- }
-
- /**
- *
- */
- private void createNumberInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.greater.than")));
- getComboBox().addItem(new Item(2, _("lima.filter.less.than")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("numberinput : ");
- }
- }
-
- /**
- *
- */
- private void createTextInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getInputTextField());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("textinput : ");
- }
- }
-
- /**
- *
- */
- private void createAccountInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.contains")));
- getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getAccountCombo());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("accountinput : ");
- }
- }
-
- /**
- *
- */
- private void createDateInput() {
- getComboBox().removeAllItems();
- getComboBox().addItem(new Item(1, _("lima.filter.before")));
- getComboBox().addItem(new Item(2, _("lima.filter.after")));
- getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
- criteriaPanel.removeAll();
- criteriaPanel.add(getComboBox());
- criteriaPanel.add(getDatePicker());
- criteriaPanel.validate();
- if (log.isDebugEnabled()) {
- log.debug("dateinput : ");
- }
- }
-
- @Override
- protected void removeCriteriaWidget() {
- LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this);
- }
-
- /**
- * @return
- */
- public JComboBox getComboBox() {
- if (comboBox == null) {
- comboBox = new JComboBox();
- }
- return comboBox;
- }
-
- /**
- * @return
- */
- public JXDatePicker getDatePicker() {
- if (datePicker == null) {
- datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale());
- }
- return datePicker;
- }
-
- /**
- * @return
- */
- public JTextField getInputTextField() {
- if (inputTextField == null) {
- inputTextField = new JTextField();
- inputTextField.setPreferredSize(new Dimension(150, 20));
- }
- return inputTextField;
- }
-
- public JComboBox getAccountCombo() {
- if (accountCombo == null) {
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- Vector<AccountDTO> v = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v);
- accountCombo = new JWideComboBox(model);
- accountCombo.setRenderer(AccountComboBoxRenderer.getInstance());
- accountCombo.setPreferredSize(new Dimension(200, 25));
- // AutoCompletion
- AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance());
- }
- return accountCombo;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ErrorMessage.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,125 +0,0 @@
-/**
- * *##% Lima-Callao ErrorMessage
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Permet l'affichage des messages des erreurs possibles
- *
- * @author Rémi Chapelet
- */
-public class ErrorMessage {
-
-
- public static void showMessage(String msg)
- {
- if ( msg.equals(ServiceHelper.ACCOUNT_DOUBLE) )
- {
- Util.showMessageDialog( _("lima.error.account.double"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.account.not.exist"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_NOT_MASTER) )
- {
- Util.showMessageDialog( _("lima.error.account.not.master"));
- }
- if ( msg.equals(ServiceHelper.ACCOUNT_WITH_ENTRIES) )
- {
- Util.showMessageDialog( _("lima.error.account.with.entries"));
- }
- if ( msg.equals(ServiceHelper.ENTRY_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.entry.not.remove")+"\n\n"
- + _("lima.error.entry.not.exist"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_DOUBLE) )
- {
- Util.showMessageDialog( _("lima.error.journal.double"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.journal.not.exist"));
- }
- if ( msg.equals(ServiceHelper.JOURNAL_WITH_TRANSACTIONS) )
- {
- Util.showMessageDialog( _("lima.error.journal.with.transactions"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_ALL_TIMESPAN) )
- {
- Util.showMessageDialog( _("lima.error.period.all.timespan"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_CREATE_TIMESPANS) )
- {
- Util.showMessageDialog( _("lima.error.period.create.timespan"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_NEXT_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.next.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.period.not.exist"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_PREC_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.prec.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_TIMESPAN_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.timespan.block"));
- }
- if ( msg.equals(ServiceHelper.PERIOD_TIMESPAN_NOT_BLOCK) )
- {
- Util.showMessageDialog( _("lima.error.period.timespan.not.blocked"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_BALANCED) )
- {
- Util.showMessageDialog( _("lima.error.transaction.exist.not.balanced"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_EXIST) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.remove")+"\n\n"
- + _("lima.error.transaction.not.exist"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_JOURNAL) )
- {
- Util.showMessageDialog(_("lima.error.transaction.not.create")+"\n\n"
- + _("lima.error.transaction.not.journal"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_NOT_TIMESPAN) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.create")+"\n\n"
- + _("lima.error.transaction.not.period"));
- }
- if ( msg.equals(ServiceHelper.TRANSACTION_TIMESPAN_BLOCKED) )
- {
- Util.showMessageDialog( _("lima.error.transaction.not.remove")+"\n\n"
- + _("lima.error.transaction.period.not.blocked"));
- }
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,102 +0,0 @@
-/**
- * *##% Lima-main ExportViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.export.CSVExport;
-import org.chorem.lima.export.XMLExport;
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.*;
-
-
-/**
- * Permet de gérer les fichiers à charger dans le programme.
- *
- * @author Rémi Chapelet
- */
-public class ExportViewImpl extends FileChooseView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ExportViewImpl.class);
-
- private static XMLExport xmlExport = new XMLExport();
- private static CSVExport cvsExport;
-
- public ExportViewImpl(String type) {
- // chooser est le JFileChooser
- // Ouverture de la boite de dialogue
- chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
-
- if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
- // Récupère le nom du fichier
- String fichier = chooser.getSelectedFile().getName();
- // Récupère l'adresse du fichier
- String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("Save file : " + fichier + " (" + cheminFichier + ")");
- }
- String result = "";
- /**
- * Action à appeler suivant le choix
- */
- if (type.equals("account")) {
- // Exporter les comptes au format Xml
- result = xmlExport.exportAccount(cheminFichier);
- } else {
- if (type.equals("all_csv")) {
- // Exporter toutes les données au format csv
- cvsExport = new CSVExport(cheminFichier);
- result = cvsExport.exportDatas();
- } else {
- // Exporter toutes les données au format xml
- result = xmlExport.exportFile(cheminFichier);
- }
- }
-
- /**
- * Message de sortie : succès ou erreur
- */
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
- } else {
- Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
- }
-
-
- if (log.isDebugEnabled()) {
- log.debug("File saved : " + fichier + " (" + cheminFichier + ")");
- }
- // Si il y a eu une erreur
-
- }
-
-
- }
-
-
-}
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/FileChooseView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,4 +1,3 @@
<JFrame title="lima.export">
- <style source="css/lima.css"/>
<JFileChooser id="chooser" width="620" height="400"/>
</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccueilView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/HomeView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,7 @@
+<Table insets="0,0,0,0" fill="both">
+ <row>
+ <cell>
+ <JLabel text="lima.home"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,109 +0,0 @@
-/**
- * *##% Lima-main ImportViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.imports.CSVImport;
-import org.chorem.lima.imports.CSVImportEBP;
-import org.chorem.lima.imports.XMLImport;
-import org.chorem.lima.service.FileService;
-import org.chorem.lima.service.ServiceFactory;
-import org.chorem.lima.util.Util;
-import org.chorem.lima.service.util.ServiceHelper;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.*;
-
-/**
- * Permet de gérer les fichiers à charger dans le programme.
- *
- * @author Rémi Chapelet
- */
-public class ImportViewImpl extends FileChooseView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(ImportViewImpl.class);
-
- public ImportViewImpl(String type) {
- // chooser est le JFileChooser
- // Ouverture de la boite de dialogue
- chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
- if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
- String fichier = chooser.getSelectedFile().getName();
- String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
-
- if (log.isDebugEnabled()) {
- log.debug("Open file : " + fichier + " (" + cheminFichier + ")");
- }
- String result = "";
- /**
- * Action à appeler suivant le choix
- */
-
- XMLImport xmlImport = new XMLImport();
- if (type.equals("account")) {
- // Importer les comptes au format Xml
- result = xmlImport.importAccount(cheminFichier);
- } else {
- if (type.equals("journal")) {
- // Importer les journaux au format Xml
- result = xmlImport.importJournal(cheminFichier);
- } else {
- if (type.equals("all_csv")) {
- // Importer les données au format csv
- CSVImport cvsimport = new CSVImport(cheminFichier);
- result = cvsimport.importDatas();
- } else {
- if (type.equals("all_csv_ebp")) {
- // Importer les données au format csv
- CSVImportEBP cvsimport = new CSVImportEBP(cheminFichier);
- result = cvsimport.importDatas();
- } else {
- // Importer les données au format Xml
- FileService fileService = ServiceFactory.getServiceFactory().getFileService();
- result = fileService.importFile(cheminFichier);
- LimaContext.getContext().getDataManager().reset();
- }
- }
- }
- }
-
- /**
- * Message de sortie : succès ou erreur
- */
- if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
- } else {
- Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
- }
-
- if (log.isDebugEnabled()) {
- log.debug("File opened : " + fichier + " (" + cheminFichier + ")");
- }
- }
- }
-
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,38 +0,0 @@
-<JFrame locationRelativeTo="{null}" defaultCloseOperation="dispose_on_close">
-
- <style source="css/lima.css" />
- <Table insets='5,5,5,5'>
- <row>
- <cell>
- <JLabel text="lima.name"/>
- </cell>
- <cell>
- <JTextField id="nameTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.description"/>
- </cell>
- <cell>
- <JTextField id="descriptionTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.prefix"/>
- </cell>
- <cell>
- <JTextField id="prefixTextField"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,26 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <script>
- protected void initAddForm() {};
- protected void initUpdateForm() {};
- protected void removeJournal() {};
- </script>
- <row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
- <JScrollPane id="journalScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add" onActionPerformed="initAddForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell >
- <JButton id="updateButton" text="lima.update" onActionPerformed="initUpdateForm()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove" onActionPerformed="removeJournal()" width="150"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/JournalViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,192 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.model.JournalTableModel;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.HighlighterFactory;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-/**
- * @author ore
- */
-public class JournalViewImpl extends JournalView {
-
- /**
- * log *
- */
- private static final Log log = LogFactory.getLog(JournalViewImpl.class);
- private final JournalForm form;
- private final JXTable table;
- private boolean isAddForm;
-
- public JournalViewImpl() {
- /** Set Journal model */
- table = new JXTable(LimaContext.getContext().getDataManager().getJournalModel());
- table.setRowHeight(24);
- table.setHighlighters(HighlighterFactory.createAlternateStriping());
- table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- table.setColumnControlVisible(true);
- getJournalScrollPane().setViewportView(table);
- form = LimaContext.getContext().getMainUI().getJournalForm();
- form.getOkButton().addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(
- ActionEvent e) {
- if (isAddForm) {
- addJournal();
- } else {
- updateJournal();
- }
- }
- });
-
- form.getRootPane().setDefaultButton(form.getOkButton());
- }
-
- /**
- *
- */
- @Override
- protected void initAddForm() {
- isAddForm = true;
- form.setTitle(_("lima.ui.add.journal"));
- form.getNameTextField().setText(DTOHelper.EMPTY_STRING);
- form.getNameTextField().setEditable(true);
- form.getDescriptionTextField().setText(DTOHelper.EMPTY_STRING);
- form.getPrefixTextField().setText(DTOHelper.EMPTY_STRING);
- form.setVisible(true);
- }
-
- /**
- *
- */
- @Override
- protected void initUpdateForm() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- isAddForm = false;
- // Show journal data selected in the form
- JournalDTO journal = getSelectedJournal();
- form.setTitle(_("lima.ui.update.journal"));
- form.getNameTextField().setText(journal.getIdName());
- form.getNameTextField().setEditable(false);
- form.getDescriptionTextField().setText(journal.getDescription());
- form.getPrefixTextField().setText(journal.getPrefix());
- form.setVisible(true);
- }
- }
-
- //TO FIX : champs vides
- /**
- *
- */
- protected void addJournal() {
- if (log.isDebugEnabled()) {
- log.debug("addJournal : ");
- //Get form data
- }
- String name = form.getNameTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String prefix = form.getPrefixTextField().getText();
- form.dispose();
- JournalDTO journal = new JournalDTO("0", name, description, prefix);
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.addJournal(journal);
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- *
- */
- protected void updateJournal() {
- if (log.isDebugEnabled()) {
- log.debug("updateJournal : ");
- }
- // Getting form data
- String name = form.getNameTextField().getText();
- String description = form.getDescriptionTextField().getText();
- String prefix = form.getPrefixTextField().getText();
- // Setting new collected data
- JournalDTO journal = getSelectedJournal();
- // Clone
- JournalDTO clone = DTOHelper.cloneJournal(journal);
- clone.setIdName(name);
- clone.setDescription(description);
- clone.setPrefix(prefix);
- form.dispose();
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.updateJournal(journal, clone);
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- *
- */
- @Override
- protected void removeJournal() {
- // Any row selected
- if (table.getSelectedRow() != -1) {
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- int n = JOptionPane.showOptionDialog(this,
- _("lima.question.remove.journal"),
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[1]); //default button title
- if (n == JOptionPane.YES_OPTION) {
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- String result = journalModel.removeJournal(getSelectedJournal());
- /**
- * Messages erreurs
- */
- ErrorMessage.showMessage(result);
- }
- }
- }
-
- /**
- * @return
- */
- protected JournalDTO getSelectedJournal() {
- int viewIndex = table.getSelectedRow();
- int modelIndex = table.convertRowIndexToModel(viewIndex);
- JournalTableModel journalModel = (JournalTableModel) table.getModel();
- return journalModel.getRow(modelIndex);
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,111 +0,0 @@
-<Table insets='0,0,0,0' fill="both">
- <script>
- protected void addLettering() {};
- protected void removeLettering() {};
- protected void precedentAccount() {};
- protected void nextAccount() {};
- </script>
- <row weightx="1" weighty="0">
- <cell>
- <!-- account -->
- <Table insets='0,0,0,0'>
- <row weightx="0" weighty="0">
- <cell anchor='center' weightx="0" weighty="0">
- <!-- precedent -->
- <JButton id="precedentButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='precedentAccount()'
- />
- </cell>
- <cell anchor='center' weightx="0" weighty="0">
- <!-- next -->
- <JButton id="nextButton"
- preferredSize='{new Dimension(24,24)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- onActionPerformed='nextAccount()'
- />
- </cell>
- </row>
- <!-- account -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.account"/>
- </cell>
- <cell weightx="0" weighty="0">
- <JPanel id="accountPanel"/>
- </cell>
- </row>
- <!-- since -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.since"/>
- </cell>
- <cell>
- <JPanel id="sincePanel"/>
- </cell>
- </row>
- <!-- to -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell anchor="east">
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="toPanel"/>
- </cell>
- </row>
- </Table>
- </cell>
- <cell>
- <!-- entries -->
- <Table insets='0,0,0,0' fill="both">
- <row columns="3">
- <cell>
- <JLabel text="lima.entries"/>
- </cell>
- </row>
- <row>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.lettered' value='{_("lima.lettered")}'
- selected='true'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.not.lettered'
- value='{_("lima.not.lettered")}'/>
- </cell>
- <cell>
- <JRadioButton buttonGroup='entryButtons' text='lima.all' value='{_("lima.all")}'/>
- </cell>
- </row>
- </Table>
- </cell>
- </row>
- <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <!-- table -->
- <JScrollPane id="tablePanel"/>
- </cell>
- </row>
- <row>
- <cell>
- <!-- add lettering -->
- <JButton id="addButton" text="lima.add.lettering" onActionPerformed="addLettering()"/>
- </cell>
- <cell>
- <!-- remove lettering -->
- <JButton id="removeButton" text="lima.remove.lettering" onActionPerformed="removeLettering()"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,118 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.JWideComboBox;
-import org.chorem.lima.combobox.model.AccountComboBoxModel;
-import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.AccountDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.util.AccountToStringConverter;
-import org.nuiton.util.Resource;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-
-import javax.swing.*;
-import java.awt.*;
-import java.util.List;
-import java.util.Vector;
-
-/**
- * @author ore
- */
-public class LetteringViewImpl extends LetteringView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(LetteringViewImpl.class);
- private final JWideComboBox accountComboBox;
-
- public LetteringViewImpl() {
- /** Calling services */
- List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
- LimaContext.getContext().getDataManager().getAccountModel().getData());
- /** Creating accounting model */
- Vector<AccountDTO> v1 = new Vector<AccountDTO>(accounts);
- AccountComboBoxModel model = new AccountComboBoxModel(v1);
- accountComboBox = new JWideComboBox();
- accountComboBox.setPreferredSize(new Dimension(200, 25));
- accountComboBox.setModel(model);
- LimaContext.getContext().getDataManager().getAccountModel().addPropertyChangeListener(model);
- accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance());
- accountPanel.add(accountComboBox);
-
- /** AutoCompletion */
- AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConverter.getInstance());
-
- Icon forwardIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Forward24.gif");
- Icon backIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Back24.gif");
- nextButton.setIcon(forwardIcon);
- precedentButton.setIcon(backIcon);
-
- /** Creating period model */
- List<PeriodDTO> periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
- LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus()
- );
- Vector<PeriodDTO> v2 = new Vector<PeriodDTO>();
- for (PeriodDTO period : periodes) {
- v2.addElement(period);
- v2.addAll(period.getChildren());
- }
- JWideComboBox sinceComboBox = new JWideComboBox(v2);
- sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- sinceComboBox.setPreferredSize(new Dimension(200, 25));
- sincePanel.add(sinceComboBox);
-
- JWideComboBox toComboBox = new JWideComboBox(v2);
- toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
- toComboBox.setPreferredSize(new Dimension(200, 25));
- toPanel.add(toComboBox);
-
- JXTable table = new JXTable();
- tablePanel.setViewportView(table);
- }
-
- /**
- *
- */
- @Override
- protected void nextAccount() {
- if (!(accountComboBox.getSelectedIndex() == accountComboBox.getModel().getSize() - 1)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() + 1);
- }
-
- }
-
- /**
- *
- */
- @Override
- protected void precedentAccount() {
- if (!(accountComboBox.getSelectedIndex() == 0)) {
- accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() - 1);
- }
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,9 +1,25 @@
-<JFrame title="lima.title" onWindowClosing="getHandler().close(this)"
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+<JFrame abstract='true' title="lima.title" onWindowClosing="getHandler().close(this)"
defaultCloseOperation="do_nothing_on_close"
undecorated='{getConfig().isFullScreen()}'
resizable="true" width="800" height="600"
extendedState='{this.MAXIMIZED_BOTH}'>
- <style source="css/lima.css"/>
+
<script><![CDATA[
import java.util.Locale;
import org.chorem.lima.LimaConfig;
@@ -20,29 +36,28 @@
return l != null && l.toString().equals(expected);
}
-protected void onChangeView() {}
-protected void showAccountView() {}
-protected void showAccueilView() {}
-protected void showAddPeriod() {}
-protected void showBalanceView() {}
-protected void showBilanView() {}
-protected void showClosurePeriodView() {}
-protected void showClosureTimeSpanView() {}
-protected void showClosureView() {}
-protected void showExportView(String type) {}
-protected void showImportView(String type) {}
-protected void showJournalView() {}
-protected void showLetteringView() {}
-protected void showReportsView() {}
-protected void showResultView() {}
-protected void showSearchView() {}
-protected void showTransactionView() {}
+protected abstract void onChangeView();
+protected abstract void showHomeView();
+protected abstract void showAccountView();
+protected abstract void showAddPeriod();
+protected abstract void showBalanceView();
+protected abstract void showBilanView();
+protected abstract void showClosurePeriodView();
+protected abstract void showClosureTimeSpanView();
+protected abstract void showClosureView();
+protected abstract void showExportView(String type);
+protected abstract void showImportView(String type);
+protected abstract void showJournalView();
+protected abstract void showLetteringView();
+protected abstract void showReportsView();
+protected abstract void showResultView();
+protected abstract void showSearchView();
+protected abstract void showTransactionView();
]]>
</script>
+
<JMenuBar>
-
<JMenu text="lima.menu.file">
-
<JMenu text="lima.import" actionIcon='import-element'>
<JMenuItem text="lima.import.all" onActionPerformed='showImportView("all")'/>
<JMenuItem text="lima.import.all.csv" onActionPerformed='showImportView("all_csv")'/>
@@ -50,16 +65,13 @@
<JMenuItem text="lima.import.account" onActionPerformed='showImportView("account")'/>
<JMenuItem text="lima.import.journal" onActionPerformed='showImportView("journal")'/>
</JMenu>
-
<JMenu text="lima.export" actionIcon='export-element'>
<JMenuItem text="lima.export.all" onActionPerformed='showExportView("all")'/>
<JMenuItem text="lima.export.all.csv" onActionPerformed='showExportView("all_csv")'/>
<JMenuItem text="lima.export.account" onActionPerformed='showExportView("account")'/>
</JMenu>
<JSeparator/>
-
- <JMenuItem text="lima.print"
- actionIcon='print'/>
+ <JMenuItem text="lima.print" actionIcon='print'/>
<JSeparator/>
<JMenuItem id='menuFileFullscreen'
text="lima.action.fullscreen"
@@ -68,6 +80,8 @@
mnemonic="P"
visible="{!isUndecorated()}"
onActionPerformed="getHandler().changeScreen(this, true)"/>
+ <JMenuItem text="lima.preferences"
+ actionIcon="config" onActionPerformed="getHandler().showConfig(this)"/>
<JMenuItem id='menuFileNormalscreen'
text="lima.action.normalscreen"
toolTipText="lima.action.normalscreen.tip"
@@ -81,28 +95,34 @@
text="lima.quit" onActionPerformed='getHandler().close(this)'/>
</JMenu>
- <JMenu text="lima.edit">
- <JMenuItem text="lima.journal" onActionPerformed='showJournalView()'
+ <JMenu text="lima.chartofaccounts">
+ <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='showAccountView()'
+ actionIcon='account'/>
+ <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='showJournalView()'
actionIcon='journal'/>
- <JMenuItem text="lima.account" onActionPerformed='showAccountView()'
- actionIcon='account'/>
- <JMenuItem text="lima.find.transaction" onActionPerformed='showSearchView()'
- actionIcon='search'/>
- <JMenuItem text="lima.preferences"
- actionIcon="config" onActionPerformed="getHandler().showConfig(this)"/>
</JMenu>
- <JMenu text="lima.daily">
- <JMenuItem text="lima.edit.transaction" onActionPerformed='showTransactionView()'
+ <JMenu text="lima.fiscalyear">
+ <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='showAddPeriod()'/>
+ <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='showClosureTimeSpanView()'
+ actionIcon='closure-timespan'/>
+ <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='showClosurePeriodView()'/>
+ <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='showClosureView()'
+ actionIcon='closure'/>
+ </JMenu>
+
+ <JMenu text="lima.entries">
+ <JMenuItem text="lima.entries.addtransaction" onActionPerformed='showTransactionView()'
actionIcon='transaction'/>
- <JMenuItem text="lima.lettering" onActionPerformed='showLetteringView()'
+ <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='showSearchView()'
+ actionIcon='search'/>
+ <JMenuItem text="lima.entries.lettering" onActionPerformed='showLetteringView()'
actionIcon='lettering'/>
</JMenu>
<JMenu text="lima.view">
<JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten" onItemStateChanged='onChangeView()'
- selected="false"
- actionIcon='view'/>
+ selected="false" actionIcon='view'/>
</JMenu>
<JMenu text="lima.reports">
@@ -112,18 +132,7 @@
<JMenuItem text="lima.result" onActionPerformed='showResultView()'/>
</JMenu>
- <JMenu text="lima.menubar.closure">
-
- <JMenuItem text="lima.menubar.closure.addPeriod" onActionPerformed='showAddPeriod()'/>
-
- <JMenuItem text="lima.menubar.closure.timespan" onActionPerformed='showClosureTimeSpanView()'
- actionIcon='closure-timespan'/>
-
- <JMenuItem text="lima.menubar.closure.period" onActionPerformed='showClosurePeriodView()'/>
-
- <JMenuItem text="lima.menubar.closure.listperiod" onActionPerformed='showClosureView()'
- actionIcon='closure'/>
- </JMenu>
+
<JMenu text="lima.menu.help" mnemonic="{'H'}">
<JMenuItem id="help" text='lima.menu.help.help' actionIcon="help"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,28 +1,48 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
package org.chorem.lima.ui;
+import static org.nuiton.i18n.I18n._;
+import static org.nuiton.i18n.I18n.n_;
+
+import java.awt.Desktop;
+import java.net.URL;
+import java.util.Locale;
+
import jaxx.runtime.JAXXContext;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.ErrorDialogUI;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
import jaxx.runtime.swing.editor.config.model.ConfigUIModel;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import static org.nuiton.i18n.I18n.n_;
-import java.awt.*;
-import java.net.URL;
-import java.util.Locale;
-
/**
* User: chemit
* Date: 8 nov. 2009
* Time: 09:59:54
*/
-public class MainViewHandler { //implements JAXXHelp {
+public class MainViewHandler {
/**
* to use log facility, just put in your code: log.info(\"...\");
@@ -39,11 +59,11 @@
public MainView initUI(LimaContext rootContext, boolean fullscreen) {
// show main ui
- final MainView ui = new MainViewImpl(rootContext);
+ MainView ui = new MainViewImpl(rootContext);
LimaContext.MAIN_UI_ENTRY_DEF.setContextValue(rootContext, ui);
- ErrorDialogUI.init(ui);
+ //ErrorDialogUI.init(ui);
// set fullscreen propery on main ui
ui.getGraphicsConfiguration().getDevice().setFullScreenWindow(fullscreen ? ui : null);
@@ -130,37 +150,12 @@
ConfigUIBuilder.showConfigUI(configUI, ui, false);
}
- // @Override
public void showHelp(JAXXContext context, String helpId) {
-// MainView mainUI = getUI(context);
-//
-// ObserveHelpBroker helpBroker = context.getContextValue(ObserveHelpBroker.class);
-//
-// if (helpId == null) {
-// helpId = helpBroker.getDefaultID();
-// }
-// log.debug("show help " + helpId);
-// mainUI.getHelp().setCurrentID(helpId);
-//
-// mainUI.setContextValue(mainUI.getMode(), "oldMode");
-// mainUI.setMode(ObserveUIMode.HELP);
+
}
public void closeHelp(JAXXContext context) {
-// MainView mainUI = getUI(context);
-// ObserveUIMode oldMode = mainUI.getContextValue(ObserveUIMode.class, "oldMode");
-// if (oldMode == null) {
-// // on regarde si une base est chargee
-// ObserveDataContext dataContext = context.getContextValue(ObserveDataContext.class);
-// StorageService<?> mainStorage = dataContext.getStorage();
-//
-// if (mainStorage == null) {
-// oldMode = ObserveUIMode.NO_DB;
-// } else {
-// oldMode = ObserveUIMode.DB;
-// }
-// }
-// mainUI.setMode(oldMode);
+
}
public void gotoSite(JAXXContext rootContext) {
@@ -215,7 +210,7 @@
if (ui != null) {
- ErrorDialogUI.init(null);
+ //ErrorDialogUI.init(null);
LimaContext.MAIN_UI_ENTRY_DEF.removeContextValue(rootContext);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,212 +1,274 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
package org.chorem.lima.ui;
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JTabbedPane;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+
import jaxx.runtime.JAXXContext;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.table.TransactionJXTable;
import org.chorem.lima.table.model.TransactionFlattenTableModel;
-import static org.nuiton.i18n.I18n._;
+import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.ui.entrybook.EntryBookView;
+import org.chorem.lima.ui.period.AddPeriod;
+import org.chorem.lima.ui.period.ClosureTimeSpanForm;
+import org.chorem.lima.ui.period.FiscalPeriodView;
+import org.chorem.lima.ui.report.BalanceViewImpl;
+import org.chorem.lima.ui.report.BilanViewImpl;
+import org.chorem.lima.ui.report.ReportsView;
+import org.chorem.lima.ui.report.ReportsViewImpl;
+import org.chorem.lima.ui.report.ResultViewImpl;
+import org.chorem.lima.ui.transaction.LetteringViewImpl;
+import org.chorem.lima.ui.transaction.SearchTransactionViewImpl;
+import org.chorem.lima.ui.transaction.TransactionViewImpl;
-import javax.swing.*;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-
/**
* @author ore
*/
public class MainViewImpl extends MainView {
- /**
- * log
- */
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 5339665516073792117L;
+
+ /** log. */
private static final Log log = LogFactory.getLog(MainViewImpl.class);
- private AccueilViewImpl accueilView;
- private ClosureViewImpl closureView;
+
+ private HomeViewImpl homeView;
+
+ private FiscalPeriodView closureView;
+
private TransactionViewImpl transactionView;
+
private TransactionViewImpl searchResultView;
- private JournalViewImpl journalView;
- private AccountViewImpl accountView;
+
+ private EntryBookView journalView;
+
+ private AccountView accountView;
+
private SearchTransactionViewImpl searchView;
+
private ReportsViewImpl reportsView;
+
private ResultViewImpl resultView;
+
private LetteringViewImpl letteringView;
- private AccountForm accountForm;
- private JournalForm journalForm;
+
private ClosureTimeSpanForm closureTimeSpanForm;
+
private BilanViewImpl bilanView;
+
private BalanceViewImpl balanceView;
+
private AddPeriod addPeriod;
- public AccueilViewImpl getAccueilView() {
- if (accueilView == null) {
- accueilView = new AccueilViewImpl();
- }
- return accueilView;
+ public MainViewImpl(JAXXContext c) {
+ super(c);
+
+ showHomeView();
+
+ // Register a change listener
+ contentTabbedPane.addChangeListener(new ChangeListener() {
+ // This method is called whenever the selected tab changes
+
+ @Override
+ public void stateChanged(ChangeEvent evt) {
+ JTabbedPane pane = (JTabbedPane) evt.getSource();
+
+ // Get current tab
+ int sel = pane.getSelectedIndex();
+ if (sel != -1) {
+ Component component = pane.getComponentAt(sel);
+ // if TransactionViewImpl
+ if (component instanceof TransactionViewImpl) {
+ TransactionJXTable table = ((TransactionViewImpl) component).getTransactionTable();
+ // if model is TransactionFlattenTableModel
+ if (table.getModel() instanceof TransactionFlattenTableModel) {
+ ((TransactionFlattenTableModel) table.getModel()).initFlattenModel();
+ table.addColorEmptyLine();
+ }
+ }
+ }
+ }
+ });
}
- public AccountForm getAccountForm() {
- if (accountForm == null) {
- accountForm = new AccountForm();
+ public HomeViewImpl getHomeView() {
+ if (homeView == null) {
+ homeView = new HomeViewImpl(this);
}
- return accountForm;
+ return homeView;
}
- public AccountViewImpl getAccountView() {
+ public AccountView getAccountView() {
if (accountView == null) {
- accountView = new AccountViewImpl();
+ accountView = new AccountView(this);
}
return accountView;
}
public AddPeriod getAddPeriod() {
if (addPeriod == null) {
- addPeriod = new AddPeriod();
+ addPeriod = new AddPeriod(this);
}
return addPeriod;
}
public BalanceViewImpl getBalanceView() {
if (balanceView == null) {
- balanceView = new BalanceViewImpl();
+ balanceView = new BalanceViewImpl(this);
}
return balanceView;
}
public BilanViewImpl getBilanView() {
if (bilanView == null) {
- bilanView = new BilanViewImpl();
+ bilanView = new BilanViewImpl(this);
}
return bilanView;
}
public ClosureTimeSpanForm getClosureTimeSpanForm() {
if (closureTimeSpanForm == null) {
- closureTimeSpanForm = new ClosureTimeSpanForm();
+ closureTimeSpanForm = new ClosureTimeSpanForm(this);
}
return closureTimeSpanForm;
}
- public ClosureViewImpl getClosureView() {
+ public FiscalPeriodView getClosureView() {
if (closureView == null) {
- closureView = new ClosureViewImpl();
+ closureView = new FiscalPeriodView(this);
}
return closureView;
}
- public ExportViewImpl getExportView(String type) {
+ /*public ExportViewImpl getExportView(String type) {
ExportViewImpl exportView = new ExportViewImpl(type);
return exportView;
}
public ImportViewImpl getImportView(String type) {
- ImportViewImpl importView = new ImportViewImpl(type);
+ ImportViewImpl importView = new ImportViewImpl(this, type);
return importView;
- }
+ }*/
- public JournalForm getJournalForm() {
- if (journalForm == null) {
- journalForm = new JournalForm();
- }
- return journalForm;
- }
-
- public JournalView getJournalView() {
+ public EntryBookView getEntryBookView() {
if (journalView == null) {
- journalView = new JournalViewImpl();
+ journalView = new EntryBookView(this);
}
return journalView;
}
public LetteringViewImpl getLetteringView() {
if (letteringView == null) {
- letteringView = new LetteringViewImpl();
+ letteringView = new LetteringViewImpl(this);
}
return letteringView;
}
public ReportsView getReportsView() {
if (reportsView == null) {
- reportsView = new ReportsViewImpl();
+ reportsView = new ReportsViewImpl(this);
}
return reportsView;
}
public ResultViewImpl getResultView() {
if (resultView == null) {
- resultView = new ResultViewImpl();
+ resultView = new ResultViewImpl(this);
}
return resultView;
}
public SearchTransactionViewImpl getSearchView() {
if (searchView == null) {
- searchView = new SearchTransactionViewImpl();
+ searchView = new SearchTransactionViewImpl(this);
}
return searchView;
}
public TransactionViewImpl getSearchResultView() {
if (searchResultView == null) {
- searchResultView = new TransactionViewImpl();
+ searchResultView = new TransactionViewImpl(this);
}
return searchResultView;
}
public TransactionViewImpl getTransactionView() {
if (transactionView == null) {
- transactionView = new TransactionViewImpl();
+ transactionView = new TransactionViewImpl(this);
}
return transactionView;
}
/**
+ * Show a new closable tab.
+ *
* @param name name of tab to show
* @param container the tab container
+ * @param canClose {@code false} if tab can't be closed
*/
- private void showTab(String name, Component container) {
+ protected void showTab(String name, Component container, boolean canClose) {
// if contentTabbedPane doesnot yet contains tab
if (contentTabbedPane.indexOfTab(name) == -1) {
- MyTabHeader panel = new MyTabHeader();
- panel.getLabel().setText(name);
+ ClosableTabHeader closableHeader = new ClosableTabHeader();
+ closableHeader.setTitle(name);
+ closableHeader.setCanClose(canClose);
contentTabbedPane.addTab(name, container);
contentTabbedPane.setSelectedComponent(container);
- contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), panel);
- panel.getCloseTab().addMouseListener(new javax.swing.event.MouseInputAdapter() {
-
+ contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader);
+ closableHeader.getCloseTab().addActionListener(new ActionListener() {
@Override
- public void mouseClicked(MouseEvent e) {
+ public void actionPerformed(ActionEvent e) {
JButton button = (JButton) e.getSource();
- MyTabHeader mytab = (MyTabHeader) button.getParent();
- String name = mytab.getLabel().getText();
+ ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent();
+ String name = closableTab.getTitle();
contentTabbedPane.remove(contentTabbedPane.indexOfTab(name));
}
});
}
}
+
+ /**
+ * Show a new closable tab.
+ *
+ * @param name name of tab to show
+ * @param container the tab container
+ */
+ protected void showTab(String name, Component container) {
+ showTab(name, container, true);
+ }
@Override
- protected void showAccueilView() {
- showTab(_("lima.tab.home"), getAccueilView());
+ protected void showHomeView() {
+ showTab(_("lima.tab.home"), getHomeView(), false);
}
@Override
@@ -221,31 +283,40 @@
@Override
protected void showClosureView() {
- showTab(_("lima.tab.closure"), getClosureView());
+ showTab(_("lima.tab.period"), getClosureView());
}
+ /*
+ * @see org.chorem.lima.ui.MainView#showClosurePeriodView()
+ */
@Override
+ protected void showClosurePeriodView() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
protected void showClosureTimeSpanView() {
- getClosureView().initBlockForm();
+ //getClosureView().initBlockForm();
}
@Override
protected void showAddPeriod() {
- getClosureView().initAddPeriod();
+ //getClosureView().initAddPeriod();
}
@Override
protected void showImportView(String type) {
- if (!getImportView(type).isEnabled()) {
+ /*if (!getImportView(type).isEnabled()) {
getImportView(type).setEnabled(true);
- }
+ }*/
}
@Override
protected void showExportView(String type) {
- if (!getExportView(type).isEnabled()) {
+ /*if (!getExportView(type).isEnabled()) {
getExportView(type).setEnabled(true);
- }
+ }*/
}
@Override
@@ -273,7 +344,7 @@
@Override
protected void showJournalView() {
- showTab(_("lima.tab.journal"), getJournalView());
+ showTab(_("lima.tab.journal"), getEntryBookView());
}
@Override
@@ -294,66 +365,13 @@
showTab(_("lima.tab.result"), getResultView());
}
-// @Override
-// protected void windowClosing() {
-// if (log.isDebugEnabled()) {
-// log.debug("Shutdown called");
-// }
-// //Main.getActionFactory().fireAction("quit", this);
-// try {
-// dispose();
-// Main.ShutdownHook.interrupted();
-// //Main.getContext().close();
-// Runtime.getRuntime().halt(0);
-// System.exit(0);
-// } catch (Exception ex) {
-// log.error("error while closing " + ex.getMessage(), ex);
-// Runtime.getRuntime().halt(1);
-// }
-// }
-
- public MainViewImpl(JAXXContext c) {
- super(c);
-
-// ContextProvider.checkContextInit();
-
- showAccueilView();
-
-
- // Register a change listener
- contentTabbedPane.addChangeListener(new ChangeListener() {
- // This method is called whenever the selected tab changes
-
- @Override
- public void stateChanged(ChangeEvent evt) {
- JTabbedPane pane = (JTabbedPane) evt.getSource();
-
- // Get current tab
- int sel = pane.getSelectedIndex();
- if (sel != -1) {
- Component component = pane.getComponentAt(sel);
- // if TransactionViewImpl
- if (component instanceof TransactionViewImpl) {
- TransactionJXTable table = ((TransactionViewImpl) component).getTransactionTable();
- // if model is TransactionFlattenTableModel
- if (table.getModel() instanceof TransactionFlattenTableModel) {
- ((TransactionFlattenTableModel) table.getModel()).initFlattenModel();
- table.addColorEmptyLine();
- }
- }
- }
- }
- });
- }
-
-
@Override
public void dispose() {
// Disposing other windows before main view
- disposeWindow(searchView);
- disposeWindow(journalForm);
- disposeWindow(accountForm);
- disposeWindow(closureTimeSpanForm);
+ //disposeWindow(searchView);
+ //disposeWindow(journalForm);
+ //disposeWindow(accountForm);
+ //disposeWindow(closureTimeSpanForm);
super.dispose();
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MyTabHeader.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,20 +0,0 @@
-<Table insets='0,0,0,0' opaque='false'>
- <row fill='both'>
- <cell anchor='west' weightx="1" insets='0,0,0,0'>
- <JLabel id='label' opaque='false' font-size='12'
- verticalAlignment='center' verticalTextPosition='0'/>
- </cell>
- <cell anchor='east' insets='2,15,0,0' weighty='0'>
- <JButton id='closeTab' preferredSize='{new Dimension(16,16)}'
- verticalAlignment='0'
- verticalTextPosition='0'
- opaque='true'
- borderPainted='false'
- focusPainted='false'
- enabled='true'
- horizontalTextPosition='0'
- actionIcon='closeTab'
- />
- </cell>
- </row>
-</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,47 +0,0 @@
-
-<Table insets='0,0,0,0'>
- <row>
- <cell fill="horizontal">
- <JLabel text="lima.reports"/>
- </cell>
- <cell>
- <JAXXComboBox>
- <item value='{_("lima.balance")}'/>
- <item value='{_("lima.journal")}'/>
- <item value='{_("lima.grand.livre")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JPanel id="reportsPanel"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal">
- <JLabel text="lima.period"/>
- </cell>
- <cell>
- <JAXXComboBox>
- <item value='{null}' label=' '/>
- <item value='Exercice 08'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.non.valids.transactions"/>
- </cell>
- <cell>
- <JCheckBox id="nonValidsTransactionsCheckBox"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton text="lima.export.PDF"/>
- </cell>
- <cell>
- <JButton text="lima.export.CSV"/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,34 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-
-package org.chorem.lima.ui;
-
-/**
- * @author ore
- */
-public class ReportsViewImpl extends ReportsView {
-
- /**
- * Constructor
- */
- public ReportsViewImpl() {
- }
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,41 +0,0 @@
-<Table insets="0,0,0,0" fill="both">
- <script>
- protected void update() {};
- </script>
-
- <!-- Choix pour les périodes -->
- <row weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
-
- <row columns="2" weightx="2" fill="both" insets="8,40,8,40">
- <cell>
- <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="update()" />
- </cell>
- </row>
-
- <!-- Affichage du compte de résultat -->
- <row weightx="1" weighty="6" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tabCharge" />
- </cell>
- <cell>
- <JScrollPane id="tabProduit" />
- </cell>
- </row>
-
- <!-- Affichage du résultat -->
- <row weightx="1" weighty="1" anchor="center" fill="both">
- <cell>
- <JScrollPane id="tabChargeRes" />
- </cell>
- <cell>
- <JScrollPane id="tabProduitRes" />
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,381 +0,0 @@
-/**
- * *##% Lima-Callao ResultViewImpl
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.balance.BalanceHelper;
-import org.chorem.lima.balance.Category;
-import org.chorem.lima.dto.BalanceDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.table.ResultChargesJXTable;
-import org.chorem.lima.table.ResultProduitsJXTable;
-import org.chorem.lima.table.model.ResultChargesTableModel;
-import org.chorem.lima.table.model.ResultProduitsTableModel;
-import org.chorem.lima.util.Util;
-import static org.nuiton.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jdesktop.swingx.JXTable;
-
-import javax.swing.table.DefaultTableModel;
-import javax.swing.*;
-
-import java.awt.event.*;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.Hashtable;
-import java.util.Vector;
-
-/**
- * Cette classe permet d'afficher le compte de résultat de l'entreprise.
- * Elle utilise quatre tableaux :
- * _ pour produit (identifié par tabProduit)
- * _ pour charge (identifié par tabCharge)
- * _ pour les totaux (identifié par tabChargeRes et tabProduitRes)
- * <p/>
- * Elle va dans un premier temps déterminer les deux tableaux charges et produits.
- * Ensuite, elle va calculer le résultat pour charges et produits.
- * Enfin elle détermine le résultat final suivant le bénéfice ou perte, il sera
- * placé dans les produits ou charges.
- *
- * @author Rémi Chapelet
- */
-public class ResultViewImpl extends ResultView {
-
- private static final Log log = LogFactory.getLog(ResultViewImpl.class);
- private JComboBox comboBoxPeriod = new JComboBox();
- private BalanceHelper balance = new BalanceHelper();
- private JXTable tableChargeRes;
- private JXTable tableProduitRes;
- private String resultat;
- private ResultChargesTableModel modelResultCharges;
- private ResultProduitsTableModel modelResultProduits;
- private DefaultTableModel modelChargeRes;
- private DefaultTableModel modelProduitRes;
-
- public ResultViewImpl() {
-
- // Initialise la combobox pour les périodes
- initComboBoxPeriod();
-
- // Création des modèles
- modelResultCharges = new ResultChargesTableModel(null);
- modelResultProduits = new ResultProduitsTableModel(null);
-
- /**
- * Initialise les tableaux pour afficher les résultats de produits
- * et charges
- */
- String[] columnNames = {"1", "2"};
- // Résultat charges
- modelChargeRes = new DefaultTableModel();
- modelChargeRes.setColumnIdentifiers(columnNames);
- tableChargeRes = new JXTable(modelChargeRes);
- // On cache le header des colonnes
- tableChargeRes.setColumnControlVisible(false);
- tableChargeRes.getTableHeader().setVisible(false);
- // Résultat produits
- modelProduitRes = new DefaultTableModel();
- modelProduitRes.setColumnIdentifiers(columnNames);
- tableProduitRes = new JXTable(modelProduitRes);
- // On cache le header des colonnes
- tableProduitRes.setColumnControlVisible(false);
- tableProduitRes.getTableHeader().setVisible(false);
-
-
- // Charge les produits et charges
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
-
- /**
- * CHARGES
- */
- // Création du tableau avec le modèle
- JXTable tableCharge = new ResultChargesJXTable(modelResultCharges);
- // Ajout du tableau
- tabCharge.setViewportView(tableCharge);
-
- /**
- * PRODUITS
- */
- // Création du tableau avec le modèle
- JXTable tableProduit = new ResultProduitsJXTable(modelResultProduits);
- // Ajout du tableau
- tabProduit.setViewportView(tableProduit);
-
- /**
- * Ajout d'un listener lorsque l'utilisateur change de période.
- */
- comboBoxPeriod.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- // Actualise le compte de résultat
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- }
- });
-
- }
-
- @Override
- public void update() {
- updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
- }
-
-
- /**
- * Permet d'initialiser le résultat des charges
- *
- * @param totalCharges
- */
- private void initTabChargeRes(String totalCharges) {
- // Définition des données
- Object[] data =
- {_("lima.result.total.charge"), totalCharges};
- // Si il existe déja une ligne
- if (modelChargeRes.getRowCount() > 0) {
- modelChargeRes.removeRow(0);
- }
- // Ajout de la ligne
- modelChargeRes.addRow(data);
- tableChargeRes.setModel(modelChargeRes);
- tabChargeRes.setViewportView(tableChargeRes);
- }
-
- /**
- * Permet d'initialiser le résultat des produits
- *
- * @param totalProduits
- */
- private void initTabProduitRes(String totalProduits) {
- // Définition des données
- Object[] data =
- {_("lima.result.total.produit"), totalProduits};
- // Si il existe déja une ligne
- if (modelProduitRes.getRowCount() > 0) {
- modelProduitRes.removeRow(0);
- }
- // Ajout de la ligne
- modelProduitRes.addRow(data);
- tableProduitRes.setModel(modelProduitRes);
- tabProduitRes.setViewportView(tableProduitRes);
- }
-
-
- /**
- * Permet d'actualiser le modèle produits et charges pour les données. De
- * même, il détermine de nouveau le résultat.
- * Il recherche la balance, puis trie pour prendre seulement les comptes 6
- * et 7. Ensuite il positionne chacun de ses comptes dans la bonne rubrique
- * (produits et charges, financier, exceptionnelles, etc).
- * Enfin, il associe les données aux modèles, et lance le calcul des
- * résultats.
- * @param period
- */
- protected void updateResult(PeriodDTO period) {
- // Chargement de la balance
- List<BalanceDTO> ListbalanceDTO = balance.createBalance(period);
- /**
- * Création tableau associatif pour produits et charges
- */
- // charges
- Hashtable<String, List<BalanceDTO>> chargeTab = new Hashtable<String, List<BalanceDTO>>();
- chargeTab.put("exploitation", new LinkedList<BalanceDTO>());
- chargeTab.put("financier", new LinkedList<BalanceDTO>());
- chargeTab.put("exceptionnel", new LinkedList<BalanceDTO>());
- chargeTab.put("autres", new LinkedList<BalanceDTO>());
- // Produits
- Hashtable<String, List<BalanceDTO>> produitTab = new Hashtable<String, List<BalanceDTO>>();
- produitTab.put("exploitation", new LinkedList<BalanceDTO>());
- produitTab.put("financier", new LinkedList<BalanceDTO>());
- produitTab.put("exceptionnel", new LinkedList<BalanceDTO>());
-
- /**
- * On filtre tous les comptes de balance pour ne prendre que les comptes
- * 6 (charges) et 7 (produits).
- * Ensuite on associe chaque compte à la catégorie dont il appartient dans
- * le compte de résultat.
- * Exemple : 641 rémunération du personnel
- * On recherche sur ce compte dans quelle catégorie il appartient. Ici,
- * catégorie 64, donc à mettre dans Charges-Exploitation
- */
- String totalCharges = "0";
- String totalProduits = "0";
- // Parcours tous les comptes de la balance pour rechercher les comptes 6 et 7
- for (BalanceDTO balanceDTO : ListbalanceDTO) {
- /**
- * CHARGES
- */
- // Exploitation
- if (Category.accountNumberCategory("60", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("61", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("62", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("63", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("64", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("65", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("681", balanceDTO.getAccount().getIdNumber())
- ) {
- chargeTab.get("exploitation").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Financières
- if (Category.accountNumberCategory("66", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("686", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("financier").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Exceptionnelles
- if (Category.accountNumberCategory("67", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("687", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("exceptionnel").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- // Autres
- if (Category.accountNumberCategory("691", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("695", balanceDTO.getAccount().getIdNumber())) {
- chargeTab.get("autres").add(balanceDTO);
- totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
- }
- /**
- * PRODUIT
- */
- // Exploitation
- if (Category.accountNumberCategory("70", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("71", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("72", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("73", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("74", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("75", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("781", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("791", balanceDTO.getAccount().getIdNumber())
- ) {
- produitTab.get("exploitation").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Financières
- if (Category.accountNumberCategory("76", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("786", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("796", balanceDTO.getAccount().getIdNumber())) {
- produitTab.get("financier").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- // Exceptionnelles
- if (Category.accountNumberCategory("77", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("787", balanceDTO.getAccount().getIdNumber()) ||
- Category.accountNumberCategory("797", balanceDTO.getAccount().getIdNumber())) {
- produitTab.get("exceptionnel").add(balanceDTO);
- totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
- }
- }
-
- /**
- * Création des tableaux Charges et Produits
- */
- // CHARGES
- List<BalanceDTO> listCharges = new LinkedList<BalanceDTO>();
- BalanceDTO titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
- listCharges.add(titleExploitation);
- listCharges.addAll(chargeTab.get("exploitation"));
- BalanceDTO titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
- listCharges.add(titleFinancier);
- listCharges.addAll(chargeTab.get("financier"));
- BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
- listCharges.add(titleExceptionnel);
- listCharges.addAll(chargeTab.get("exceptionnel"));
- BalanceDTO titleAutre = new BalanceDTO("Autres", "title", "0", "0", "title", null);
- listCharges.add(titleAutre);
- listCharges.addAll(chargeTab.get("autres"));
- // Création du modèle à partir de la liste précédement créée
- modelResultCharges.setData(listCharges);
- modelResultCharges.fireTableDataChanged();
-
- // PRODUITS
- List<BalanceDTO> listProduits = new LinkedList<BalanceDTO>();
- titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
- listProduits.add(titleExploitation);
- listProduits.addAll(produitTab.get("exploitation"));
- titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
- listProduits.add(titleFinancier);
- listProduits.addAll(produitTab.get("financier"));
- titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
- listProduits.add(titleExceptionnel);
- listProduits.addAll(produitTab.get("exceptionnel"));
- // Création du modèle à partir de la liste précédement créée
- modelResultProduits.setData(listProduits);
- modelResultProduits.fireTableDataChanged();
-
- /**
- * Actualise les résultats
- */
- initTabChargeRes(totalCharges);
- initTabProduitRes(totalProduits);
-
- // Affiche le résultat en produit OU en charge suivant le bénéfice ou perte
- resultat = "0";
- // On efface les résultats (ligne bénéfice ou perte)
- if (modelChargeRes.getRowCount() > 1) {
- modelChargeRes.removeRow(0);
- }
- if (modelProduitRes.getRowCount() > 1) {
- modelProduitRes.removeRow(0);
- }
- // Si les charges sont plus grandes que les produits : pertes
- if (Util.compareTo(totalCharges, totalProduits) == 1) {
- resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
- Object[] data ={_("lima.result.loss"), resultat};
- modelChargeRes.addRow(data);
- modelChargeRes.fireTableDataChanged();
- } else {
- // Sinon profit
- resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
- Object[] data ={_("lima.result.profit"), resultat};
-
- modelProduitRes.addRow(data);
- modelProduitRes.fireTableDataChanged();
- }
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initComboBoxPeriod() {
- // Recherche la liste de toutes les périodes
- List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
- // Model pour les périodes
- Vector<PeriodDTO> v = new Vector<PeriodDTO>();
- // On ajoute un élément null pour permettre d'afficher toutes les périodes
- v.addElement(null);
- // Pour chaque période (annuelle et NON mensuelle !)
- for (PeriodDTO period : periodes) {
- v.addElement(period);
- v.addAll(period.getChildren());
- }
- comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
- comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
- periodPanel.add(comboBoxPeriod);
- periodPanel.validate();
- }
-
- public String getResult() {
- return resultat;
- }
-
-}
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,43 +0,0 @@
-<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
- onWindowClosing="windowClosing()"
- defaultCloseOperation="do_nothing_on_close"
- iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
- <script>
- protected void addCriteriaWidget() {};
- protected void doSearch() {};
- protected void windowClosing() {};
- </script>
- <JScrollPane>
- <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
- <row>
- <cell>
- <JButton id="addButton" text="lima.add" width="100" onActionPerformed="addCriteriaWidget()"/>
- </cell>
- <cell>
- <JLabel text="lima.search.items.where" width="200"/>
- </cell>
- <cell>
- <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
- <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
- <item value='any' label='{_("lima.any.criteria")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="3">
- <VBox id="criteriaWidgetPanel"
- border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" onActionPerformed="doSearch()" text="lima.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.cancel" onActionPerformed="windowClosing()"/>
- </cell>
- </row>
- </Table>
- </JScrollPane>
-</JFrame>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,217 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import static org.nuiton.i18n.I18n._;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.table.TransactionJXTable;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.*;
-
-/**
- * @author ore
- */
-public class SearchTransactionViewImpl extends SearchTransactionView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(SearchTransactionViewImpl.class);
- private final TransactionJXTable table;
-
- public SearchTransactionViewImpl() {
- // At Least one criteria
- CriteriaWidgetImpl widget = new CriteriaWidgetImpl();
- widget.getRemoveButton().setEnabled(false);
- criteriaWidgetPanel.add(widget);
- this.validate();
-
- TransactionViewImpl searchResult = LimaContext.getContext().getMainUI().getSearchResultView();
- searchResult.setFiltreEnabled(false);
- table = searchResult.getTransactionTable();
- getRootPane().setDefaultButton(okButton);
- }
-
- @Override
- protected void addCriteriaWidget() {
- criteriaWidgetPanel.add(new CriteriaWidgetImpl());
- this.validate();
- }
-
- public void removeCriteriaWidget(CriteriaWidget widget) {
- criteriaWidgetPanel.remove(widget);
- this.validate();
- }
-
- protected void showTransactionView() {
- LimaContext.getContext().getMainUI().showSearchResultView();
- }
-
- @Override
- protected void doSearch() {
- if (criteriaWidgetPanel.getComponentCount() > 0) {
- table.getModel().initData();
- table.addColorEmptyLine();
- /** Any or All */
- String allOrAny = (String) criteriaAllAnyComboBox.getSelectedItem();
- boolean all = allOrAny.equals("all");
- for (int i = 0; i < criteriaWidgetPanel.getComponentCount(); i++) {
- CriteriaWidgetImpl myWidget = (CriteriaWidgetImpl) criteriaWidgetPanel.getComponent(i);
- JComboBox comboCriteria = myWidget.getCriteriaComboBox();
- if (comboCriteria.getSelectedIndex() != -1) {
- String itemSelected = (String) comboCriteria.getSelectedItem();
- /**
- * Date item
- */
- if (itemSelected.equals("date")) {
- searchDate(myWidget, FilterEnum.Date, all);
- }
-
- /**
- * Voucher item
- */
- if (itemSelected.equals("voucher")) {
- searchText(myWidget, FilterEnum.Voucher, all);
- }
-
- /**
- * Account item
- */
- if (itemSelected.equals("account")) {
- searchText(myWidget, FilterEnum.Account, all);
- }
-
- /**
- * Description item
- */
- if (itemSelected.equals("description")) {
- searchText(myWidget, FilterEnum.Description, all);
- }
-
- /**
- * Debit item
- */
- if (itemSelected.equals("debit")) {
- searchNumber(myWidget, FilterEnum.Debit, all);
- }
-
- /**
- * Credit item
- */
- if (itemSelected.equals("credit")) {
- searchNumber(myWidget, FilterEnum.Credit, all);
- }
-
- /**
- * Amount item
- */
- if (itemSelected.equals("amount")) {
- searchNumber(myWidget, FilterEnum.Amount, all);
- }
-
- } else {
- throw new NullPointerException();
- }
- } // end for
- } else {
- throw new NullPointerException();
- }
- }
-
- /**
- * @param myWidget
- * @param type
- * @param all
- */
- protected void searchDate(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JXDatePicker datePicker = myWidget.getDatePicker();
- if (datePicker.getDate() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with date : " + datePicker.getDate());
- }
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- private void searchNumber(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JTextField text = myWidget.getInputTextField();
- if (text.getText() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with number : " + text.getText());
- }
- /**
- * Parse double
- */
- try {
- String value = text.getText();
- Double.parseDouble(value.equals(DTOHelper.EMPTY_STRING) ? "0" : value);
-
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } catch (NumberFormatException e) {
- JOptionPane.showMessageDialog(this, _("lima.exception.number.format"));
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- private void searchText(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
- JTextField text = myWidget.getInputTextField();
- if (text.getText() != null) {
- if (log.isDebugEnabled()) {
- log.debug("search with text : " + text.getText());
- }
- JComboBox comboNextCriteria = myWidget.getComboBox();
- if (comboNextCriteria.getSelectedIndex() != -1) {
- table.getModel().filter(type, myWidget, all);
- showTransactionView();
- } else {
- throw new NullPointerException();
- }
- } else {
- throw new NullPointerException();
- }
- }
-
- @Override
- protected void windowClosing() {
- this.setVisible(false);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,48 +0,0 @@
-<Table insets='0,0,0,0'>
- <script>
- protected void addEmptyTransaction() {};
- protected void removeTransaction() {};
- protected void addEmptyEntry() {};
- </script>
- <JPopupMenu id="MenuRightPanel">
- <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu>
- <JPopupMenu id="MenuRightTransaction">
- <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
- <JMenuItem text="lima.print"/>
- </JPopupMenu>
- <row fill="horizontal" weightx="0.75" weighty="0" anchor="center" insets='5,5,5,5'>
- <cell>
- <JLabel id="journalLabel" text="lima.journal"/>
- </cell>
- <cell>
- <JPanel id="journalPanel"/>
- </cell>
- <cell>
- <JLabel id="periodLabel" text="lima.period"/>
- </cell>
- <cell>
- <JPanel id="periodPanel"/>
- </cell>
- </row>
- <row >
- <cell fill="both" weightx="1" weighty="1" rows='3' columns='4' >
- <JScrollPane id="transactionScrollPane"/>
- </cell>
- <cell>
- <JButton id="addButton" text="lima.add.transaction" onActionPerformed="addEmptyTransaction()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="removeButton" text="lima.remove.transaction" onActionPerformed="removeTransaction()" width="150"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton text="lima.add.entry" onActionPerformed="addEmptyEntry()" width="150"/>
- </cell>
- </row>
-
-</Table>
\ No newline at end of file
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java 2010-04-02 17:02:58 UTC (rev 2828)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -1,372 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui;
-
-import javax.swing.*;
-import java.awt.event.*;
-import java.util.Date;
-import java.util.List;
-import java.util.Vector;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.combobox.model.JournalComboBoxModel;
-import org.chorem.lima.combobox.model.PeriodComboBoxModel;
-import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
-import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
-import org.chorem.lima.dto.EntryDTO;
-import org.chorem.lima.dto.JournalDTO;
-import org.chorem.lima.dto.PeriodDTO;
-import org.chorem.lima.dto.TransactionDTO;
-import org.chorem.lima.dto.util.DTOHelper;
-import org.chorem.lima.enumeration.FilterEnum;
-import org.chorem.lima.listener.ClicRight;
-import org.chorem.lima.service.util.ServiceHelper;
-import org.chorem.lima.table.model.*;
-import org.chorem.lima.table.TransactionJXTable;
-import org.chorem.lima.util.Util;
-import static org.nuiton.i18n.I18n._;
-
-
-/**
- * @author ore
- * @author Rémi Chapelet
- */
-public class TransactionViewImpl extends TransactionView {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(TransactionViewImpl.class);
- private JComboBox comboJournal;
- private JComboBox comboPeriod;
- private TransactionJXTable transactionTable;
- private TransactionDataTableModel model;
- private TransactionFilteredTableModel filterModel;
- private TransactionSortedTableModel sortedModel;
- private TransactionSortedTableColumnModel columnModel;
- private TransactionFlattenTableModel flattenModel;
-
- public TransactionDataTableModel getModel() {
- if (model == null) {
- model = LimaContext.getContext().getDataManager().getTransactionModel();
- }
- return model;
- }
-
- public TransactionFilteredTableModel getFilterModel() {
- if (filterModel == null) {
- filterModel = new TransactionFilteredTableModel(getModel());
- }
- return filterModel;
- }
-
- public TransactionSortedTableColumnModel getColumnModel() {
- if (columnModel == null) {
- columnModel = new TransactionSortedTableColumnModel(getSortedModel());
- }
- return columnModel;
- }
-
- public TransactionSortedTableModel getSortedModel() {
- if (sortedModel == null) {
- sortedModel = new TransactionSortedTableModel(getFilterModel());
- }
- return sortedModel;
- }
-
- public TransactionFlattenTableModel getFlattenModel() {
- if (flattenModel == null) {
- flattenModel = new TransactionFlattenTableModel(getSortedModel());
- }
- return flattenModel;
- }
-
- public TransactionJXTable getTransactionTable() {
- if (transactionTable == null) {
- transactionTable = new TransactionJXTable(getFlattenModel(), getColumnModel());
- transactionTable.setName("TransactionTable");
- }
- return transactionTable;
- }
-
- public JComboBox getComboJournal() {
- if (comboJournal == null) {
- comboJournal = new JComboBox();
- comboJournal.setName("Liste journal");
- }
- return comboJournal;
- }
-
- public JComboBox getComboPeriod() {
- if (comboPeriod == null) {
- comboPeriod = new JComboBox();
- comboPeriod.setName("Liste periode");
- }
- return comboPeriod;
- }
-
- /**
- * Constructor
- */
- public TransactionViewImpl() {
-
- initJournalComboBox();
- initPeriodComboBox();
-
- getTransactionTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
- transactionScrollPane.setViewportView(getTransactionTable());
-
- /**
- * Property change listeners
- */
- getModel().addPropertyChangeListener(getFilterModel());
- getFilterModel().addPropertyChangeListener(getSortedModel());
- getSortedModel().addPropertyChangeListener(getFlattenModel());
-
- getComboJournal().addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- getTransactionTable().removeColorEmptyLine();
- getFlattenModel().initData();
-
- if (e.getStateChange() == ItemEvent.SELECTED) {
- JComboBox comboBox = (JComboBox) e.getSource();
- JournalDTO item = (JournalDTO) comboBox.getSelectedItem();
- getFlattenModel().filter(FilterEnum.Journal, item, true);
- LimaContext.getContext().getDataManager().setCurrentJournal(item);
- }
-
- if (!(getComboPeriod().getSelectedIndex() == -1 || getComboPeriod().getSelectedIndex() == 0)) {
- getFlattenModel().filter(FilterEnum.Period, getComboPeriod().getSelectedItem(), true);
- }
- }
- });
- getComboPeriod().addItemListener(new ItemListener() {
-
- @Override
- public void itemStateChanged(ItemEvent e) {
- getTransactionTable().removeColorEmptyLine();
- getFlattenModel().initData();
- if (e.getStateChange() == ItemEvent.SELECTED) {
- JComboBox comboBox = (JComboBox) e.getSource();
- PeriodDTO item = (PeriodDTO) comboBox.getSelectedItem();
- getFlattenModel().filter(FilterEnum.Period, item, true);
- LimaContext.getContext().getDataManager().setCurrentPeriod(item);
- }
-
- if (!(getComboJournal().getSelectedIndex() == -1 || getComboJournal().getSelectedIndex() == 0)) {
- getFlattenModel().filter(FilterEnum.Journal, getComboJournal().getSelectedItem(), true);
- }
- }
- });
- /**
- * Permet de mettre la sélection du combobox par défaut sur le mois actuel lors
- * de l'ouverture de la page des transactions.
- */
- int index = 0;
- // Récupère la date actuelle
- Date d = new Date();
- String dateToday = ServiceHelper.dateToMonth(d) + " " + (d.getYear() + 1900);
- for (int i = 0; i <= getComboPeriod().getItemCount(); i++) {
- Object o = getComboPeriod().getItemAt(i);
- if (o != null) {
- if (dateToday.equals(((PeriodDTO) o).getIdName())) {
- index = i;
- }
- }
- }
- if (index != 0){
- getComboPeriod().setSelectedIndex(index);
-
- }
-
- /**
- * Implémente le clic droit
- */
- MouseListener popupListeneTransr = new ClicRight(MenuRightTransaction);
- getTransactionTable().addMouseListener(popupListeneTransr);
- }
-
-
- /**
- * Initialise la combobox contenant les journaux
- */
- private void initJournalComboBox() {
- /** Getting data from journal model **/
- List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData();
- /** Creating combobox model */
- Vector<JournalDTO> v = new Vector<JournalDTO>(journals.size());
- /** null item */
- v.add(null);
- v.addAll(journals);
- JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v);
- /** Property Change Listener */
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- getComboJournal().setModel(comboBoxModel);
- getComboJournal().setRenderer(JournalComboBoxRenderer.getInstance());
- // AutoCompletion
- // AutoCompleteDecorator.decorate(comboJournal, JournalToStringConverter.getInstance());
- journalPanel.add(getComboJournal());
- journalPanel.validate();
- }
-
- /**
- * Initialise la combobox contenant les périodes
- */
- private void initPeriodComboBox() {
- // Recherche la liste de toutes les périodes
-
- ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
- PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
- getComboPeriod().setModel(periodModel);
- getComboPeriod().setRenderer(PeriodComboBoxRenderer.getInstance());
- // AutoCompletion
- // AutoCompleteDecorator.decorate(comboPeriod, PeriodToStringConverter.getInstance());
- periodPanel.add(getComboPeriod());
- periodPanel.validate();
- }
-
- /**
- * @param enabled new value
- */
- public void setFiltreEnabled(boolean enabled) {
- getComboPeriod().setEnabled(enabled);
- getComboJournal().setEnabled(enabled);
- }
-
- /**
- * ajout de transaction vide avec le bouton
- */
- @Override
- protected void addEmptyTransaction() {
- String result = transactionTable.getModel().addEmptyTransaction();
- /**
- * Si il n'y pas de message success, alors il existe une erreur.
- * Création de la boite de dialogue avec le message d'erreur correspondant
- */
- ErrorMessage.showMessage(result);
- }
-
- /**
- * suppression de transaction avec le bouton
- */
- @Override
- protected void removeTransaction() {
- // Any row selected
- Integer indexSelectedRow = transactionTable.getSelectedRow();
- if (indexSelectedRow != -1) {
- String message = DTOHelper.isTransaction(
- transactionTable.getModel().getElementAt(indexSelectedRow))
- ? _("lima.question.remove.transaction")
- : _("lima.question.remove.entry");
- int n = Util.showConfirmDialog(message);
- if (n == JOptionPane.YES_OPTION) {
- TransactionTableModel model = transactionTable.getModel();
- // Message de retour
- String result = "";
- if (TransactionFlattenTableModel.isFlattenModel(model)) {
- // Flatten
- TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) transactionTable.getModel();
- flattenModel.removeEmptyLine();
- /**
- * Supprime la ligne sélectionnée : transaction ou entry
- */
- if (DTOHelper.isTransaction(model.getElementAt(indexSelectedRow))) {
- // Transaction
- result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
- } else {
- // Entry
- result = flattenModel.removeEntry((EntryDTO) model.getElementAt(indexSelectedRow));
- }
- transactionTable.addColorEmptyLine();
- } else {
- // Not Flatten
- result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
- }
- /**
- * Messages erreurs
- */
- if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
- ErrorMessage.showMessage(message);
- }
- }
- }
- }
-
- /**
- * Implémente le bouton ajout d'une entrée.
- * Permet d'ajouter une ligne comptable sur la transaction sélectionnée.
- */
- @Override
- protected void addEmptyEntry() {
- if (transactionTable.getSelectionModel().isSelectionEmpty()) {
- // Not line selected
- } else {
- // Line selected
- int selectedRow = transactionTable.getSelectedRow();
- int parentIndex = flattenModel.getParentIndex(selectedRow);
- /**
- * Is transaction editable ?
- */
- Object o = flattenModel.getElementAt(parentIndex);
- if (DTOHelper.isTransaction(o)) {
- // Transaction n'est pas éditable
- if (!ServiceHelper.isEditable((TransactionDTO) o)) {
- Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
- return;
- }
- } else {
- //Entry n'est pas éditable
- if (!ServiceHelper.isEditable((EntryDTO) o)) {
- Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
- return;
- }
- }
-
- // Click in not current transaction
- if (flattenModel.getCurrentParentIndex() != parentIndex) {
- int posNext = flattenModel.emptyLineNextPosition(selectedRow);
- /**
- * Once traitement for transaction
- */
- if (flattenModel.isEmptyLineEmpty()) {
- flattenModel.createEmptyLine();
- } else {
- flattenModel.removeEmptyLine();
- selectedRow = transactionTable.getSelectedRow();
- parentIndex = flattenModel.getParentIndex(selectedRow);
- posNext = flattenModel.emptyLineNextPosition(selectedRow);
- flattenModel.createEmptyLine();
- }
- flattenModel.addEmptyLine(posNext);
-
- // To end
- flattenModel.setCurrentParentIndex(parentIndex);
- }
- /**
- * New Line Color
- */
- transactionTable.addColorEmptyLine();
- }
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,74 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+
+ <org.chorem.lima.entity.Account id="account" javaBean='null'/>
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setAccount(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.number"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="numberTextField" editable='{isAddState()}' text="{getAccount().getAccountNumber()}"/>
+ <javax.swing.text.Document javaBean="getNumberTextField().getDocument()"
+ onInsertUpdate='getAccount().setAccountNumber(getNumberTextField().getText())'
+ onRemoveUpdate='getAccount().setAccountNumber(getNumberTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.label"/>
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="descriptionTextField" text="{getAccount().getLabel()}"/>
+ <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()"
+ onInsertUpdate='getAccount().setLabel(getDescriptionTextField().getText())'
+ onRemoveUpdate='getAccount().setLabel(getDescriptionTextField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.account.type"/>
+ </cell>
+ <cell fill="horizontal">
+ <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.account.model.AccountTypeListModel()}'
+ selectedItem="{getAccount().getType()}"
+ onActionPerformed="getAccount().setType((String)getTypeComboBox().getSelectedItem())"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="none">
+ <JButton text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell fill="none">
+ <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AccountView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,55 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table>
+
+ <AccountViewHandler id="handler" javaBean="new AccountViewHandler(this)" />
+ <Boolean id="selectedRow" javaBean="false" />
+
+ <script>
+ <![CDATA[
+ //getHandler().init();
+ ]]>
+ </script>
+
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='3'>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
+ highlighters='{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}' />
+ <javax.swing.ListSelectionModel javaBean="getAccountsTreeTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal">
+ <JButton id="addButton" text="lima.common.add" onActionPerformed="getHandler().addAccount()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="updateButton" text="lima.common.update" onActionPerformed="getHandler().updateAccount()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="removeButton" text="lima.common.remove" onActionPerformed="getHandler().removeAccount()"
+ enabled="{isSelectedRow()}"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,169 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.account;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+import javax.swing.tree.TreePath;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.ui.account.model.AccountTreeTableModel;
+import org.chorem.lima.ui.account.AccountForm;
+import org.chorem.lima.ui.account.AccountView;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTreeTable;
+
+/**
+ * Handler associated with account view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountViewHandler {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
+ protected AccountView view;
+
+ protected AccountViewHandler(AccountView view) {
+ this.view = view;
+ }
+
+ /**
+ * Add new account with account form.
+ */
+ public void addAccount() {
+
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ Account newAccount = new AccountImpl();
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(newAccount);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+
+ // null == cancel action
+ newAccount = accountForm.getAccount();
+ if (newAccount != null) {
+ // get current selection path
+ TreePath treePath = null;
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ if ( selectedRow != -1) {
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ } else {
+ treePath = new TreePath(accountsTreeTableModel.getRoot());
+ }
+
+ // add it
+ try {
+ accountsTreeTableModel.addAccount(treePath, newAccount);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add account", ex);
+ }
+ }
+ };
+
+ /**
+ * Open account form with selected account.
+ */
+ public void updateAccount() {
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ // get selected account
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null
+ Account selectedAccount = (Account)treePath.getLastPathComponent();
+
+ AccountForm accountForm = new AccountForm(view);
+ accountForm.setAccount(selectedAccount);
+ // jaxx constructor don't call super() ?
+ accountForm.setLocationRelativeTo(view);
+ accountForm.setVisible(true);
+
+ // null == cancel action
+ selectedAccount = accountForm.getAccount();
+ if (selectedAccount != null) {
+ // get current selection path
+ if ( selectedRow != -1) {
+ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ } else {
+ treePath = new TreePath(accountsTreeTableModel.getRoot());
+ }
+
+ // update it
+ try {
+ accountsTreeTableModel.updateAccount(treePath, selectedAccount);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add account", ex);
+ }
+ }
+ };
+
+ /**
+ * Ask for user to remove for selected account, and remove it if confirmed.
+ */
+ public void removeAccount() {
+
+ // maybe this code can be factorised
+ JXTreeTable accountsTreeTable = view.getAccountsTreeTable();
+ AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel();
+
+ // Any row selected
+ int selectedRow = view.getAccountsTreeTable().getSelectedRow();
+ if ( selectedRow != -1) {
+ int n = JOptionPane.showConfirmDialog(view,
+ _("lima.question.remove.account"),
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+ if (n == JOptionPane.YES_OPTION) {
+ // update view of treetable
+ TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow);
+ Account account = (Account) treePath.getLastPathComponent();
+ try {
+ accountsTreeTableModel.removeAccount(treePath, account);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete account", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't delete account", ex);
+ }
+ }
+ }
+ };
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,240 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.account.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.tree.TreePath;
+
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+
+/**
+ * Tree table model for account edition.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountTreeTableModel extends AbstractTreeTableModel {
+
+ /** Account service. */
+ protected final AccountService accountService;
+
+ /**
+ * Model constructor. Init account service used here.
+ */
+ public AccountTreeTableModel() {
+ // root
+ super(new AccountImpl());
+ // Gets factory service
+ accountService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ /**
+ * @deprecated can't be used
+ */
+ public Account getData() {
+ return (Account) root;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = null;
+ switch (column) {
+ case 0:
+ res = _("lima.account.number");
+ break;
+ case 1:
+ res = _("lima.account.label");
+ break;
+ }
+ return res;
+ }
+
+ @Override
+ public int getChildCount(Object node) {
+ int result = 0;
+ if (node instanceof Account) {
+ if (node == getRoot()) {
+ try {
+ result = accountService.getChildrenAccounts(null).size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) node;
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ Object result = null;
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ result = allAccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) parent;
+
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ int result = 0;
+ Account parentAccount = (Account) parent;
+ Account childAccount = (Account) child;
+
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts = accountService.getChildrenAccounts(null);
+ result = allAccounts.indexOf(child);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts = accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.indexOf(childAccount);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(Object node, int column) {
+ Object result = "n/a";
+ if (node instanceof Account) {
+ Account account = (Account) node;
+ switch (column) {
+ case 0:
+ result = account.getAccountNumber();
+ break;
+ case 1:
+ result = account.getLabel();
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(Object node, int column) {
+ return false;
+ }
+
+ @Override
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ /**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+
+ accountService.createAccount(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
+ * Update account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void updateAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ accountService.updateAccount(account);
+ int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ // TODO maybe not working if order change
+ modelSupport.fireChildChanged(path.getParentPath(), index, account);
+ }
+
+ /**
+ * Remove account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ int index = getIndexOfChild(path.getParentPath().getLastPathComponent(), account);
+ accountService.removeAccount(account);
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,79 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.account.model;
+
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ * Combo box model with accounts types.
+ * (actif, passif, produit, charge).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountTypeListModel extends AbstractListModel implements ComboBoxModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -6817328905036446359L;
+
+ protected Object selectedObject;
+
+ /** Data. TODO put string in another place, don't use hard coded string. */
+ protected Object[] data = new Object[]{ "actif", "passif", "produit", "charge" };
+
+ public AccountTypeListModel() {
+ super();
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedObject = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedObject;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return data.length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return data[index];
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,75 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ ##% -->
+<JDialog modal="true">
+
+ <org.chorem.lima.entity.EntryBook id="entryBook" javaBean="null" />
+ <Boolean id="addState" javaBean='true'/>
+
+ <script>
+ <![CDATA[
+ protected void performCancel() {
+ setEntryBook(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <Table>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.label"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookLabelField" editable='{isAddState()}' text="{getEntryBook().getLabel()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookLabelField().getDocument()"
+ onInsertUpdate='getEntryBook().setLabel(getEntryBookLabelField().getText())'
+ onRemoveUpdate='getEntryBook().setLabel(getEntryBookLabelField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.description"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookDescriptionField" text="{getEntryBook().getDescription()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookDescriptionField().getDocument()"
+ onInsertUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())'
+ onRemoveUpdate='getEntryBook().setDescription(getEntryBookDescriptionField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.entrybook.prefix"/>
+ </cell>
+ <cell>
+ <JTextField id="entryBookPrefixField" text="{getEntryBook().getPrefix()}"/>
+ <javax.swing.text.Document javaBean="getEntryBookPrefixField().getDocument()"
+ onInsertUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())'
+ onRemoveUpdate='getEntryBook().setPrefix(getEntryBookPrefixField().getText())' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="dispose()"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,58 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table>
+
+ <EntryBookViewHandler id="handler" javaBean="new EntryBookViewHandler(this)" />
+ <!-- Selected row bindings -->
+ <Boolean id="selectedRow" javaBean="false" />
+
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='4'>
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24"
+ model="{new org.chorem.lima.ui.entrybook.model.EntryBookTableModel()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ columnControlVisible="true"/>
+ <javax.swing.ListSelectionModel javaBean="getEntryBooksTable().getSelectionModel()"
+ onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal">
+ <JButton id="addButton" text="lima.common.add"
+ onActionPerformed="getHandler().addEntryBook()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="updateButton" text="lima.common.update" enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().updateEntryBook()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="removeButton" text="lima.common.remove" enabled="{isSelectedRow()}"
+ onActionPerformed="getHandler().deleteEntryBook()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,131 @@
+/* *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.entrybook;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JOptionPane;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
+import org.chorem.lima.util.ErrorHelper;
+import org.jdesktop.swingx.JXTable;
+
+/**
+ * Handler for entry book view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookViewHandler {
+
+ private static final Log log = LogFactory.getLog(EntryBookViewHandler.class);
+
+ protected EntryBookView view;
+
+ public EntryBookViewHandler(EntryBookView view) {
+ this.view = view;
+ }
+
+ public void addEntryBook() {
+
+ JXTable entryBookTable = view.getEntryBooksTable();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ EntryBook newEntryBook = new EntryBookImpl();
+ EntryBookForm entryBookForm = new EntryBookForm(view);
+ entryBookForm.setEntryBook(newEntryBook);
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+
+ // null == cancel action
+ newEntryBook = entryBookForm.getEntryBook();
+ if (newEntryBook != null) {
+
+ // add it
+ try {
+ entryBookTableModel.addEntryBook(newEntryBook);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add entry book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't add entry book", ex);
+ }
+ }
+ }
+
+ public void updateEntryBook() {
+
+ JXTable entryBookTable = view.getEntryBooksTable();
+ int selectedRow = entryBookTable.getSelectedRow();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ // add it
+ try {
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBookForm entryBookForm = new EntryBookForm(view);
+ entryBookForm.setEntryBook(selectedEntryBook);
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+
+ // null == cancel action
+ selectedEntryBook = entryBookForm.getEntryBook();
+ if (selectedEntryBook != null) {
+ entryBookTableModel.updateEntryBook(selectedEntryBook);
+ }
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add update book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't update entry book", ex);
+ }
+ }
+
+ public void deleteEntryBook() {
+ JXTable entryBookTable = view.getEntryBooksTable();
+ int selectedRow = entryBookTable.getSelectedRow();
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel)entryBookTable.getModel();
+
+ // add it
+ try {
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+
+ int response = JOptionPane.showConfirmDialog(view, _("Do you really want to delete entry book %s ?", selectedEntryBook.getLabel()),
+ _("Confirmation"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ entryBookTableModel.removeEntryBook(selectedEntryBook);
+ }
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete update book", ex);
+ }
+ ErrorHelper.showErrorDialog("Can't delete entry book", ex);
+ }
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/table/model/JournalTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,214 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.entrybook.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(EntryBookTableModel.class);
+
+ /** Services. */
+ protected EntryBookService entryBookService;
+
+ /**
+ * Constructor.
+ */
+ public EntryBookTableModel() {
+ entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ }
+
+ /*
+ * @return
+ *
+ public List<JournalDTO> getData() {
+ return data;
+ }*/
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ try {
+ result = entryBookService.getAllEntryBooks().size();
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.entrybook.label");
+ break;
+ case 1:
+ res = _("lima.entrybook.description");
+ break;
+ case 2:
+ res = _("lima.entrybook.prefix");
+ break;
+ }
+ return res;
+ }
+
+ public EntryBook getEntryBookAtRow(int row) throws LimaException {
+ EntryBook entryBook = null;
+ entryBook = entryBookService.getAllEntryBooks().get(row);
+
+ return entryBook;
+ }
+
+ /*
+ * @param row
+ * @return
+ *
+ @Override
+ public Object getRow(int row) {
+ return data.get(row);
+ }*/
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = null;
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ result = entryBook.getLabel();
+ break;
+ case 1:
+ result = entryBook.getDescription();
+ break;
+ case 2:
+ result = entryBook.getPrefix();
+ break;
+ }
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ entryBook.setLabel((String)value);
+ break;
+ case 1:
+ entryBook.setDescription((String)value);
+ break;
+ case 2:
+ entryBook.setPrefix((String)value);
+ break;
+ }
+
+ // update on remote service
+ entryBookService.updateEntryBook(entryBook);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // TODO why false ?
+ return false;
+ }
+
+ /**
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void addEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.createEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsInserted(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void updateEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.updateEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsUpdated(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ entryBookService.removeEntryBook(entryBook);
+ fireTableRowsDeleted(row, row);
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ExportViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ExportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,102 @@
+/**
+ * *##% Lima-main ExportViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.export;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ejb.csv.CSVExport;
+import org.chorem.lima.business.ejb.xml.XMLExport;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.*;
+
+
+/**
+ * Permet de gérer les fichiers à charger dans le programme.
+ *
+ * @author Rémi Chapelet
+ */
+public class ExportViewImpl extends FileChooseView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ExportViewImpl.class);
+
+ private static XMLExport xmlExport = new XMLExport();
+ private static CSVExport cvsExport;
+
+ public ExportViewImpl(String type) {
+ // chooser est le JFileChooser
+ // Ouverture de la boite de dialogue
+ chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+
+ if (chooser.showSaveDialog(this) == JFileChooser.APPROVE_OPTION) {
+ // Récupère le nom du fichier
+ String fichier = chooser.getSelectedFile().getName();
+ // Récupère l'adresse du fichier
+ String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Save file : " + fichier + " (" + cheminFichier + ")");
+ }
+ String result = "";
+ /**
+ * Action à appeler suivant le choix
+ */
+ if (type.equals("account")) {
+ // Exporter les comptes au format Xml
+ result = xmlExport.exportAccount(cheminFichier);
+ } else {
+ if (type.equals("all_csv")) {
+ // Exporter toutes les données au format csv
+ cvsExport = new CSVExport(cheminFichier);
+ result = cvsExport.exportDatas();
+ } else {
+ // Exporter toutes les données au format xml
+ result = xmlExport.exportFile(cheminFichier);
+ }
+ }
+
+ /**
+ * Message de sortie : succès ou erreur
+ */
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+
+ if (log.isDebugEnabled()) {
+ log.debug("File saved : " + fichier + " (" + cheminFichier + ")");
+ }
+ // Si il y a eu une erreur
+
+ }
+
+
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ImportViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ImportViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,109 @@
+/**
+ * *##% Lima-main ImportViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.export;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.ejb.csv.CSVImport;
+import org.chorem.lima.business.ejb.csv.CSVImportEBP;
+import org.chorem.lima.business.ejb.xml.XMLImport;
+import org.chorem.lima.service.FileService;
+import org.chorem.lima.service.ServiceFactory;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.*;
+
+/**
+ * Permet de gérer les fichiers à charger dans le programme.
+ *
+ * @author Rémi Chapelet
+ */
+public class ImportViewImpl extends FileChooseView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(ImportViewImpl.class);
+
+ public ImportViewImpl(String type) {
+ // chooser est le JFileChooser
+ // Ouverture de la boite de dialogue
+ chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+ if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+ String fichier = chooser.getSelectedFile().getName();
+ String cheminFichier = chooser.getSelectedFile().getAbsolutePath();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Open file : " + fichier + " (" + cheminFichier + ")");
+ }
+ String result = "";
+ /**
+ * Action à appeler suivant le choix
+ */
+
+ XMLImport xmlImport = new XMLImport();
+ if (type.equals("account")) {
+ // Importer les comptes au format Xml
+ result = xmlImport.importAccount(cheminFichier);
+ } else {
+ if (type.equals("journal")) {
+ // Importer les journaux au format Xml
+ result = xmlImport.importJournal(cheminFichier);
+ } else {
+ if (type.equals("all_csv")) {
+ // Importer les données au format csv
+ CSVImport cvsimport = new CSVImport(cheminFichier);
+ result = cvsimport.importDatas();
+ } else {
+ if (type.equals("all_csv_ebp")) {
+ // Importer les données au format csv
+ CSVImportEBP cvsimport = new CSVImportEBP(cheminFichier);
+ result = cvsimport.importDatas();
+ } else {
+ // Importer les données au format Xml
+ FileService fileService = ServiceFactory.getServiceFactory().getFileService();
+ result = fileService.importFile(cheminFichier);
+ LimaContext.getContext().getDataManager().reset();
+ }
+ }
+ }
+ }
+
+ /**
+ * Message de sortie : succès ou erreur
+ */
+ if (result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ Util.showMessageDialog(_("lima.import.success"), _("lima.success"), JOptionPane.INFORMATION_MESSAGE);
+ } else {
+ Util.showMessageDialog(_("lima.import.error"), _("lima.error"), JOptionPane.ERROR_MESSAGE);
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("File opened : " + fichier + " (" + cheminFichier + ")");
+ }
+ }
+ }
+
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/AddPeriod.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,96 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+<JDialog modal="true">
+
+ <script>
+ <![CDATA[
+ import org.nuiton.util.MonthEnum;
+ import org.chorem.lima.entity.FiscalPeriodImpl;
+ import org.chorem.lima.ui.period.model.FiscalPeriodMonthComboBoxModel;
+ import org.chorem.lima.ui.period.model.FiscalPeriodSplinnerModel;
+ import java.util.Calendar;
+
+ protected void performOk() {
+ if (period == null) {
+ // FIXME never ever use IMPL !!!
+ setPeriod(new FiscalPeriodImpl());
+ }
+
+ // get begin date
+ Calendar calendarBegin = Calendar.getInstance();
+ calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal());
+ calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue());
+
+ // get end date
+ Calendar calendarEnd = Calendar.getInstance();
+ calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal());
+ calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue());
+
+ getPeriod().setBeginDate(calendarBegin.getTime());
+ getPeriod().setEndDate(calendarEnd.getTime());
+
+ dispose();
+ }
+
+ protected void performCancel() {
+ setPeriod(null);
+ dispose();
+ }
+ ]]>
+ </script>
+
+ <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" />
+
+ <Table fill="both">
+ <row>
+ <cell>
+ <JLabel text="lima.period.begindate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.period.enddate"/>
+ </cell>
+ <cell>
+ <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/>
+ </cell>
+ <cell>
+ <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <Table fill="none" anchor="center" weighty="1">
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosurePeriodView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,19 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+<JFrame title="lima.export" width="620" height="300" iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+
+</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureTimeSpanForm.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,56 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<JDialog modal="true">
+ <style source="styles.css" />
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <Table>
+ <row>
+ <cell>
+ <JLabel text="lima.closure.period.begin"/>
+ </cell>
+ <cell>
+ <JPanel id="beginPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.to"/>
+ </cell>
+ <cell>
+ <JPanel id="endPeriod"/>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JTextArea styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" text="lima.common.ok" />
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="dispose()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,408 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.period;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+
+import javax.swing.JComboBox;
+import javax.swing.ListSelectionModel;
+import javax.swing.RowFilter;
+
+import jaxx.runtime.JAXXContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.model.PeriodComboBoxModel;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.StatusDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.TriPeriodAsc;
+import org.chorem.lima.dto.util.TriPeriodDesc;
+import org.chorem.lima.table.model.ClosureTableModel;
+import org.chorem.lima.ui.ErrorMessage;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+
+/**
+ * Permet l'affichage du tableau avec les périodes mensuelles.
+ *
+ * @author Rémi Chapelet
+ */
+public class ClosureViewImpl extends ClosureView {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -8759564865633991757L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(ClosureViewImpl.class);
+
+ private final JXTable table;
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private final ClosureTimeSpanForm form;
+ private final AddPeriod addPeriodForm;
+ private static boolean blockPeriod;
+ private JComboBox comboBoxBeginPeriod = new JComboBox();
+ private JComboBox comboBoxEndPeriod = new JComboBox();
+ private JComboBox comboBeginYearPeriod = new JComboBox();
+ private JComboBox comboBeginMonthPeriod = new JComboBox();
+ private JComboBox comboEndYearPeriod = new JComboBox();
+ private JComboBox comboEndMonthPeriod = new JComboBox();
+
+ /**
+ * @param parentContext
+ */
+ public ClosureViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialisation du choix pour les périodes
+ initComboBoxPeriod();
+
+ /* Set Period model */
+ // Création du model pour le tableau
+ table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel());
+ table.setRowHeight(24);
+ // Permet d'alterner les couleurs des lignes pour le tableau
+ table.setHighlighters(HighlighterFactory.createAlternateStriping());
+ // Definition de la selection possible sur les lignes
+ table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ table.setColumnControlVisible(true);
+
+ /*
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Récupère la période master
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)};
+ //FilterPipeline filters = new FilterPipeline(filterArray);
+
+ RowFilter<Object, Object> filter = null;
+ if (periodMaster != null) {
+ // 0 = check only in first column
+ // filter :
+ // period name containing selected periode
+ // Final = ??? TODO
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(periodMaster.getBegin());
+ filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0);
+ if (log.isDebugEnabled()) {
+ log.debug("Apply filter on " + calendar.get(Calendar.YEAR));
+ }
+ }
+ table.setRowFilter(filter);
+ }
+ });
+
+ // Ajout du tableau dans l'UI
+ getClosureScrollPane().setViewportView(table);
+
+ /*
+ * Initialisation du formulaire pour bloquer ou débloquer une période.
+ */
+ form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm();
+ form.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updatePeriod();
+ }
+ });
+
+ /**
+ * Initialisation du formulaire pour ajouter un exercice
+ */
+ addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod();
+
+ Calendar cal = Calendar.getInstance();
+
+ //Init YEAR Periode Combobox
+ // take care about previous year #120
+ int todayYear = cal.get(Calendar.YEAR);
+ for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) {
+ comboBeginYearPeriod.addItem(currentYear);
+ comboEndYearPeriod.addItem(currentYear);
+ }
+ comboBeginYearPeriod.setSelectedItem(todayYear);
+ comboEndYearPeriod.setSelectedItem(todayYear);
+
+
+ //Add BeginYear ComboBox to addPeriodForm
+ addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod);
+ addPeriodForm.getBeginYearPeriodPanel().validate();
+
+ //Add EndYear ComboBox to addPeriodForm
+ addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod);
+ addPeriodForm.getEndYearPeriodPanel().validate();
+
+ //Init MONTH Periode Combobox
+ cal.set(Calendar.MONTH, Calendar.JANUARY);
+ for (int j = 0; j <= 11; j++) {
+ comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault()));
+ cal.add(Calendar.MONTH, 1);
+ }
+
+ //Add BeginMonth ComboBox to addPeriodForm
+ addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod);
+ addPeriodForm.getBeginMonthPeriodPanel().validate();
+
+ //Add EndMonth ComboBox to addPeriodForm
+ addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod);
+ addPeriodForm.getEndMonthPeriodPanel().validate();
+
+ addPeriodForm.getOkButton().addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addPeriod();
+ addPeriodForm.dispose();
+ }
+ });
+
+ }
+
+
+ /**
+ * Cette méthode permet de charger les périodes (annuelles) pour choisir
+ * les périodes mensuelles à afficher dans le tableau.
+ */
+ public void initComboBoxPeriod() {
+ /**
+ * Charge pour le JComboBox le choix des périodes (exercices) à afficher.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxPeriod.setModel(periodModel);
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+
+ /**
+ * Cette méthode permet d'initialiser le formulaire pour bloquer une ou
+ * plusieurs périodes.
+ */
+ @Override
+ public void initBlockForm() {
+ blockPeriod = true;
+ form.setTitle(_("lima.ui.block.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise le formulaire pour débloquer des périodes mensuelles.
+ */
+ @Override
+ public void initUnblockForm() {
+ blockPeriod = false;
+ form.setTitle(_("lima.ui.unblock.timespan"));
+ initComboBoxForm();
+ form.setVisible(true);
+ }
+
+
+ /**
+ * Initialise les combobox pour le formulaire de période. Il ajoute ainsi
+ * les deux combobox nécessaires pour début et fin de période.
+ */
+ public void initComboBoxForm() {
+ /**
+ * Charge pour les JComboBox le choix des périodes mensuelles à bloquer.
+ */
+ // Récupère les périodes
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ // Création Combobox debut période
+ comboBoxBeginPeriod.setModel(periodModel);
+ comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Création Combobox fin période
+ comboBoxEndPeriod.setModel(periodModel);
+ comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ // Ajout des combobox
+ form.beginPeriod.add(comboBoxBeginPeriod);
+ form.endPeriod.add(comboBoxEndPeriod);
+
+ /**
+ * Positionne, si les lignes sont sélectionnées, les comboBox sur
+ * les bonnes périodes (période min et période max).
+ */
+ // Si une ou plusieurs lignes sont sélectionnées
+ if (table.getSelectedRow() != -1) {
+ // Récupère les périodes sélectionnées
+ List<PeriodDTO> listPeriod = getSelectedPeriod();
+ // Parcours du vecteur
+ comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0));
+ comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1)));
+ }
+ }
+
+
+ /**
+ * Permet d'ajouter un nouvel exercice.
+ */
+ protected void addPeriod() {
+ if (log.isDebugEnabled()) {
+ log.debug("addPeriod : ");
+ //Get form data
+ }
+ PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod();
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+
+ // get begin date
+ Calendar beginCalendar = Calendar.getInstance();
+ if (periodCurrent != null) {
+ beginCalendar.setTime(periodCurrent.getBegin());
+ }
+ beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem());
+ beginCalendar.set(Calendar.DAY_OF_MONTH, 1);
+ // month is equals to list index
+ beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex());
+ Date beginDate = beginCalendar.getTime();
+
+ // get end date
+ Calendar endCalendar = Calendar.getInstance();
+ endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem());
+ endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex());
+ int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+ endCalendar.set(Calendar.DAY_OF_MONTH, maximum);
+ Date endDate = endCalendar.getTime();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Add new periode from " + beginDate + " to " + endDate);
+ }
+
+ String periodName = null;
+ if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR));
+ }
+ else {
+ periodName = Integer.toString(beginCalendar.get(Calendar.YEAR));
+ }
+
+ // TODO what is status.get(3) ???
+ PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3));
+
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ closureModel.addPeriod(period, status);
+ }
+
+ /**
+ * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer
+ * une ou plusieurs périodes, ou bien débloquer.
+ * On récupère l'intervalle des périodes donné par le formulaire. On prend
+ * les périodes aux extrémités.
+ * Si on bloque les périodes, on va trier par ordre croissant sinon par
+ * ordre décroissant. En effet, pour débloquer une période, il est important
+ * que les périodes qui suivent soient bloquées ; par conséquent on doit
+ * commencer par les dernières.
+ */
+ protected void updatePeriod() {
+ // Liste des status
+ List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus();
+ // Liste des transactions
+ List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData();
+ // Chargement du model
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ /**
+ * Récupère l'intervalle des périodes sélectionnées
+ */
+ PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem();
+ PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem();
+ // Exercice
+ PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem();
+ // Si block période, on trie la liste en croissant ou bien décroissant
+ List<PeriodDTO> listPeriod = periodMaster.getChildren();
+ if (blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ } else {
+ Collections.sort(listPeriod, new TriPeriodDesc());
+ }
+ // Pour toutes les périodes mensuelles
+ for (PeriodDTO period : listPeriod) {
+ if (((period.getBegin().after(periodBegin.getBegin()))
+ && (period.getBegin().before(periodEnd.getBegin())))
+ || (period.equals(periodBegin))
+ || (period.equals(periodEnd))) {
+ if (log.isDebugEnabled()) {
+ log.debug("updatePeriod : " + period.getIdName() + " : "
+ + blockPeriod);
+ }
+ /**
+ * Détection des messages d'erreur
+ */
+ String message = closureModel.updatePeriod(period, blockPeriod, status, transactions);
+ ErrorMessage.showMessage(message);
+ }
+ }
+ // On trie par ordre croissant si c'était en décroissant, sinon l'affichage
+ // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre
+ // décroissant).
+ if (!blockPeriod) {
+ Collections.sort(listPeriod, new TriPeriodAsc());
+ }
+ form.setVisible(false);
+ form.dispose();
+ }
+
+ /**
+ * Cette méthode permet de retourner une liste des périodes sélectionnées.
+ *
+ * @return liste des périodes sélectionnées
+ */
+ protected List<PeriodDTO> getSelectedPeriod() {
+ // récupère les lignes sélectionnées
+ int viewIndex[] = table.getSelectedRows();
+ // chargement du model (tableau des périodes)
+ ClosureTableModel closureModel = (ClosureTableModel) table.getModel();
+ LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>();
+ // Pour chaque ligne sélectionnée
+ for (int i : viewIndex) {
+ int modelIndex = table.convertRowIndexToModel(i);
+ listPeriod.add(closureModel.getRow(modelIndex));
+ }
+ return listPeriod;
+ }
+
+
+ public void initAddPeriod() {
+ addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod"));
+ addPeriodForm.setVisible(true);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ClosureView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,65 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table>
+
+ <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" />
+ <Boolean id="selectedPeriod" javaBean="false" />
+
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <row fill="horizontal" weightx="1" anchor="center" columns="2">
+ <cell>
+ <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'>
+ <JLabel text="lima.period.periodFilterLabel"/>
+ <JComboBox id="periodFilterComboBox" />
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1">
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="fiscalPeriodTable"
+ model="{new org.chorem.lima.ui.period.model.FiscalPeriodTableModel()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}"
+ rowHeight="24"
+ selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
+ columnControlVisible="true" />
+ <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()"
+ onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
+ </JScrollPane>
+ </cell>
+ <cell fill="horizontal" weighty="1" anchor="north">
+ <Table>
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.period.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="blockButton" text="lima.period.block" enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().blockFiscalPeriod()" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+</Table>
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,103 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.period;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.period.model.FiscalPeriodTableModel;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodViewHandler {
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class);
+
+ protected FiscalPeriodView view;
+
+ protected FiscalPeriodViewHandler(FiscalPeriodView view) {
+ this.view = view;
+ }
+
+ public void addFiscalPeriod() {
+
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel();
+
+ AddPeriod addPeriodDialog = new AddPeriod(view);
+ // jaxx don't call super() ?
+ addPeriodDialog.setLocationRelativeTo(view);
+ addPeriodDialog.setVisible(true);
+
+ FiscalPeriod period = addPeriodDialog.getPeriod();
+ // null = cancel
+ if (period != null) {
+
+ Date beginDate = period.getBeginDate();
+ Date endDate = period.getEndDate();
+ // set both to 0:00.000
+ beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+ endDate = DateUtils.ceiling(beginDate, Calendar.HOUR);
+
+ // on cree pour l'instant des periodes de 1mois
+ Date loopDate = beginDate;
+ while (loopDate.compareTo(endDate) < 0) {
+ Date loopUpperDate = DateUtils.addMonths(loopDate, 1);
+
+ Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1);
+ FinancialPeriod financialPeriod = new FinancialPeriodImpl();
+ financialPeriod.setBeginDate(loopDate);
+ financialPeriod.setEndDate(periodEndDate);
+ period.addFinancialPeriod(financialPeriod);
+
+ loopDate = loopUpperDate;
+ }
+
+ try {
+ model.addFiscalPeriod(period);
+ } catch (LimaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't add fiscal period", ex);
+ }
+ ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
+ }
+ }
+ }
+
+ public void blockFiscalPeriod() {
+ throw new NotImplementedException("To be continued...");
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,90 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.period.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.nuiton.util.MonthEnum;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodMonthComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ public FiscalPeriodMonthComboBoxModel(Object selectedMonth) {
+ this.selectedMonth = selectedMonth;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return MonthEnum.values().length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return MonthEnum.values()[index].getLibelle();
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,56 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.period.model;
+
+import java.util.Calendar;
+
+import javax.swing.SpinnerNumberModel;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodSplinnerModel extends SpinnerNumberModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -3647031968061521832L;
+
+ /**
+ * Init modele with current year as initial value.
+ */
+ public FiscalPeriodSplinnerModel() {
+ super();
+
+ Calendar calendar = Calendar.getInstance();
+ int year = calendar.get(Calendar.YEAR);
+ setValue(year);
+
+ // minimum = next year ?
+ setMinimum(year - 1);
+
+ // maximum = ???
+ setMaximum(year + 10);
+ }
+
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,168 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.period.model;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 77027335135838258L;
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class);
+
+ protected FiscalPeriodService fiscalPeriodService;
+
+ public FiscalPeriodTableModel() {
+ fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+
+ int result = 0;
+ try {
+ result = fiscalPeriodService.getAllFiscalPeriods().size();
+ }
+ catch (LimaException ex) {
+ // FIXME
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int columnIndex) {
+
+ String result = "n/a";
+
+ switch(columnIndex) {
+ case 0 :
+ result = _("Exercice");
+ break;
+ case 1:
+ result = _("Bloquée");
+ break;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnClass(int)
+ */
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ // both String
+ return String.class;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#isCellEditable(int, int)
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ Object result = "n/a";
+
+ // a refaire, c'est pas optimisé
+ List<FiscalPeriod> periods;
+ try {
+ periods = fiscalPeriodService.getAllFiscalPeriods();
+ FiscalPeriod fiscalPeriod = periods.get(rowIndex);
+
+ switch (columnIndex) {
+ case 0:
+ result = fiscalPeriod.getBeginDate() + " - " + fiscalPeriod.getEndDate();
+ break;
+ case 1:
+ result = fiscalPeriod.getLocked();
+ break;
+ }
+
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
+ */
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+
+ }
+
+ /**
+ * @param period
+ */
+ public void addFiscalPeriod(FiscalPeriod period) throws LimaException {
+
+ int currentRowCount = getRowCount();
+
+ // Calling fiscal period service
+ fiscalPeriodService.createFiscalPeriod(period);
+ fireTableRowsInserted(currentRowCount, currentRowCount);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,8 @@
+.warning {
+ foreground: red;
+ // JTextArea sur plusieurs lignes
+ lineWrap: true;
+ // Implique que les mots ne sont pas coupés
+ wrapStyleWord: true;
+ editable: false;
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,32 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void updateBalance() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ <cell>
+ <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="updateBalance()" />
+ </cell>
+ </row>
+
+ <!-- Affichage de la balance -->
+ <row columns="3" weightx="1" weighty="10" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tableBalance" />
+ </cell>
+ </row>
+
+ <!-- Affichage du résultat -->
+ <row columns="3" weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tableBalanceRes" />
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,195 @@
+/**
+ * *##% Lima-Callao
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.table.model.BalanceTableModel;
+import org.chorem.lima.table.renderer.BalanceTableCellRenderer;
+import static org.nuiton.i18n.I18n._;
+
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.table.DefaultTableModel;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet l'affichage de la balance comptable.
+ *
+ * @author Rémi Chapelet
+ */
+public class BalanceViewImpl extends BalanceView {
+
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private JXTable table;
+ private JXTable tableRes;
+ private BalanceHelper balance = new BalanceHelper();
+ private BalanceTableModel modelBalance;
+ private DefaultTableModel model;
+
+ /**
+ * @param parentContext
+ */
+ public BalanceViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ //Initialise les périodes pour la combobox
+ initComboBoxPeriod();
+
+ /**
+ * Création du model pour le tableau
+ */
+ // Création de la balance
+ List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ // Création de la table
+ modelBalance = new BalanceTableModel(listBalance);
+ table = new JXTable(modelBalance);
+ /** Design de la table */
+ table.setRowHeight(24);
+ // Permet d'alterner les couleurs des lignes pour le tableau
+ table.setHighlighters(HighlighterFactory.createAlternateStriping());
+ table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
+ table.setColumnControlVisible(true);
+ // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
+ for (int i = 0; i < table.getModel().getColumnCount(); i++) {
+ table.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
+ }
+
+ // Affichage de la table
+ tableBalance.setViewportView(table);
+
+ /**
+ * Calcul pour le total des soldes
+ */
+ model = new DefaultTableModel();
+ String[] columnNames = {"1", "2", "3", "4", "5", "6"};
+ model.setColumnIdentifiers(columnNames);
+ tableRes = new JXTable(model);
+ // On cache le header des colonnes
+ tableRes.setColumnControlVisible(false);
+ tableRes.getTableHeader().setVisible(false);
+ // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc)
+ for (int i = 0; i < tableRes.getModel().getColumnCount(); i++) {
+ tableRes.getColumnModel().getColumn(i).setCellRenderer(new BalanceTableCellRenderer());
+ }
+ // Initialise les valeurs pour le résultat total
+ initTableBalanceRes(listBalance);
+
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Recherche la balance
+ updateBalance();
+ }
+ });
+ }
+
+ /**
+ * Permet de initialiser la table de résultat à chaque appel de cette
+ * méthode.
+ *
+ * @param listBalance
+ */
+ private void initTableBalanceRes(List<BalanceDTO> listBalance) {
+ // Déclaration des variables
+ String TotalMoveDebit = "0";
+ String TotalMoveCredit = "0";
+ String TotalBalanceDebit = "0";
+ String TotalBalanceCredit = "0";
+ // Pour chaque ligne de la balance
+ for (BalanceDTO balanceDTO : listBalance) {
+ /** Calcul des mouvements */
+ TotalMoveDebit = DTOHelper.AddNumbersString(TotalMoveDebit, balanceDTO.getDebit());
+ TotalMoveCredit = DTOHelper.AddNumbersString(TotalMoveCredit, balanceDTO.getCredit());
+ /** Calcul des soldes */
+ if (balanceDTO.getType().equalsIgnoreCase("Actif") ||
+ balanceDTO.getType().equalsIgnoreCase("Charge")) {
+ String solde = DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit());
+ TotalBalanceDebit = DTOHelper.AddNumbersString(solde, TotalBalanceDebit);
+ } else {
+ String solde = DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit());
+ TotalBalanceCredit = DTOHelper.AddNumbersString(solde, TotalBalanceCredit);
+ }
+ }
+ // Définition des données
+ Object[] data =
+ {"", _("lima.balance.total"), TotalMoveDebit, TotalMoveCredit, TotalBalanceDebit, TotalBalanceCredit};
+ // Si il existe déja une ligne
+ if (model.getRowCount() > 0) {
+ model.removeRow(0);
+ }
+ // Ajout de la ligne
+ model.addRow(data);
+ tableRes.setModel(model);
+ tableBalanceRes.setViewportView(tableRes);
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ v.addAll(period.getChildren());
+ }
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+ /**
+ * Permet de recharger la balance. Elle appelle la méthode createBalance, qui
+ * va parcourir de nouveau les entrées comptables pour la période, et calculer
+ * la balance.
+ */
+ @Override
+ protected void updateBalance() {
+ // Récupère la liste de la balance
+ List<BalanceDTO> listBalance = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ modelBalance.setData(listBalance);
+ modelBalance.fireTableDataChanged();
+ initTableBalanceRes(listBalance);
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,29 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void addLettering() {};
+ protected void removeLettering() {};
+ protected void precedentAccount() {};
+ protected void nextAccount() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row>
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ </row>
+
+ <!-- Affichage du bilan (actif et passif) -->
+ <row weightx="1.0" weighty="1.0" anchor="center" fill="both">
+ <cell weightx="0.5">
+ <JScrollPane id="tabActif" />
+ </cell>
+ <cell weightx="0.5">
+ <JScrollPane id="tabPassif" />
+ </cell>
+ </row>
+
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/BilanViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,485 @@
+/**
+ * *##% Lima-Callao BilanViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.bilan.Bilan;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.balance.Category;
+import org.chorem.lima.table.BilanActifJXTable;
+import org.chorem.lima.table.BilanPassifJXTable;
+import org.chorem.lima.table.model.BilanActifTableModel;
+import org.chorem.lima.table.model.BilanPassifTableModel;
+import org.chorem.lima.ui.MainViewImpl;
+import org.chorem.lima.ui.ProgressBarImpl;
+
+import java.awt.event.*;
+import javax.swing.*;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet de calculer le bilan. Elle utilise la balance et
+ * le compte de résultat.
+ *
+ * @author Rémi Chapelet
+ */
+public class BilanViewImpl extends BilanView {
+
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private BilanActifJXTable tableActif;
+ private BilanPassifJXTable tablePassif;
+ private BilanActifTableModel modelBilanActif;
+ private BilanPassifTableModel modelBilanPassif;
+ Hashtable<String, Bilan> actifTab = new Hashtable<String, Bilan>();
+ Hashtable<String, Bilan> passifTab = new Hashtable<String, Bilan>();
+ Hashtable<String, List<BalanceDTO>> provisionMap;
+ private BalanceHelper balance = new BalanceHelper();
+ private ProgressBarImpl progressBar;
+
+ /**
+ * @param parentContext
+ */
+ public BilanViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialise la combobox pour les périodes
+ initComboBoxPeriod();
+
+ // Création des modèles
+ modelBilanActif = new BilanActifTableModel(new LinkedList<Bilan>());
+ modelBilanPassif = new BilanPassifTableModel(new LinkedList<Bilan>());
+
+
+ // Chargement du bilan
+ //updateBilan();
+
+ /** ACTIF */
+ tableActif = new BilanActifJXTable(modelBilanActif);
+ // Ajout du tableau
+ tabActif.setViewportView(tableActif);
+
+ /** PASSIF */
+ tablePassif = new BilanPassifJXTable(modelBilanPassif);
+ // Ajout du tableau
+ tabPassif.setViewportView(tablePassif);
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ updateBilan();
+ }
+ });
+
+ }
+
+ /**
+ * Cette partie consiste à créer les catégories du bilan
+ */
+ public void createCategory() {
+ /** ACTIF */
+
+ actifTab.put("ACTIF", new Bilan("TOTAL (1) + (2)", "total", null));
+ actifTab.put("ACTIF_IMMOBILISE", new Bilan("ACTIF IMMOBILISE", "title", null));
+ actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
+ actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
+ actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier", "", null));
+ actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
+ actifTab.put("ACTIF_CIRCULANT", new Bilan("ACTIF CIRCULANT", "title", null));
+ actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
+ actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
+ actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
+ actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_VMP"));
+ actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
+ actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA", "", null));
+ actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CCA"));
+ actifTab.get("ACTIF").add(actifTab.get("ACTIF_IMMOBILISE"));
+ actifTab.get("ACTIF").add(actifTab.get("ACTIF_CIRCULANT"));
+ /** PASSIF */
+ passifTab.put("PASSIF", new Bilan("TOTAL (1) + (2) + (3)", "total", null));
+ passifTab.put("PASSIF_CAPITAUX", new Bilan("CAPITAUX PROPRES", "title", null));
+ passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_CAPITAL"));
+ passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESERVES"));
+ passifTab.put("PASSIF_CP_RAN", new Bilan("RAN", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RAN"));
+ passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESULTAT"));
+ passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_SUBVENTION"));
+ passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées", "", null));
+ passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_PROVISION"));
+ passifTab.put("PASSIF_PR_PROVISIONS", new Bilan("PROVISIONS", "title", null));
+ passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions", "", null));
+ passifTab.get("PASSIF_PR_PROVISIONS").add(passifTab.get("PASSIF_PROVISIONS"));
+ passifTab.put("PASSIF_DETTES", new Bilan("DETTES", "title", null));
+ passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
+ passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AVANCES"));
+ passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
+ passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FISCALES"));
+ passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
+ passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
+ passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA", "", null));
+ passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_PCA"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_CAPITAUX"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_CP_PROVISION"));
+ passifTab.get("PASSIF").add(passifTab.get("PASSIF_DETTES"));
+ }
+
+ /**
+ * Permet de calculer le bilan
+ */
+ public void updateBilan() {
+ log.debug("Update bilan :");
+
+ MainViewImpl context = LimaContext.get().getMainUI();
+ progressBar = new ProgressBarImpl(context, context);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ progressBar.setVisible(true);
+ }
+ };
+ SwingUtilities.invokeLater(runnable);
+
+ new Thread() {
+ @Override
+ public void run() {
+
+ progressBar.setTitle("Chargement du bilan");
+ progressBar.getProgressBar().setString("0% : Préparation des données");
+ progressBar.getProgressBar().setValue(0);
+
+ // Chargement de la balance
+ List<BalanceDTO> ListbalanceDTO = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem());
+
+
+ progressBar.getProgressBar().setString("10% : Balance chargée");
+ progressBar.getProgressBar().setValue(10);
+ /**
+ * Vérifie chaque numéro de compte (balance) pour déterminer sa position
+ * dans le bilan.
+ * Chaque catégorie est un objet bilan, et possède à son tour des bilans
+ * correspondants aux comptes.
+ * Cette boucle ne prend pas en compte les amortissement et provisions.
+ * Ces comptes sont mis dans une liste à part, pour être traités une seconde fois.
+ */
+
+ progressBar.getProgressBar().setString("15% : Création catégorie");
+ progressBar.getProgressBar().setValue(15);
+ createCategory();
+ // Liste amort/prov à traiter apres
+ provisionMap = new Hashtable<String, List<BalanceDTO>>();
+
+ progressBar.getProgressBar().setString("20% : Chargement des comptes");
+ progressBar.getProgressBar().setValue(20);
+ // Récupère le nombre de balances
+ float nbBalances = ListbalanceDTO.size();
+ float incremente = 40 / nbBalances;
+ float value = 20;
+ // Pour chaque balance
+ for (BalanceDTO balanceDTO : ListbalanceDTO) {
+ /**
+ * ACTIF
+ */
+ /** IMMOBILISATION */
+ if (Category.accountNumberCategory("20", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("21", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("22", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("23", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("25", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("26", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("27", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /** ACTIF CIRCULANT */
+ if (Category.accountNumberCategory("31", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("32", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("33", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("34", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("35", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("36", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("37", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_STOCK").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("99", balanceDTO.getAccount().getIdNumber())) {
+ // TODO
+ //actifTab.get("ACTIF_CIRCULANT_AVANCES").add(balanceDTO,Util.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("41", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("50", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_VMP").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("51", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("52", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("53", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("54", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ if (Category.accountNumberCategory("486", balanceDTO.getAccount().getIdNumber())) {
+ actifTab.get("ACTIF_CIRCULANT_CCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /** AMORT. & PROV. */
+ if (Category.accountNumberCategory("280", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_INCORPOREL", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("281", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_CORPOREL", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_CORPOREL").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("282", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_IMMOBILISE_FINANCIER", listBalance);
+ }
+ provisionMap.get("ACTIF_IMMOBILISE_FINANCIER").add(balanceDTO);
+ }
+ if (Category.accountNumberCategory("491", balanceDTO.getAccount().getIdNumber())) {
+ if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") == null) {
+ LinkedList<BalanceDTO> listBalance = new LinkedList<BalanceDTO>();
+ provisionMap.put("ACTIF_CIRCULANT_CREANCES", listBalance);
+ }
+ provisionMap.get("ACTIF_CIRCULANT_CREANCES").add(balanceDTO);
+ }
+ /**
+ * PASSIF
+ */
+ /** CAPITAUX PROPRES */
+ if (Category.accountNumberCategory("101", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("104", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("105", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("107", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("108", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("109", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_CAPITAL").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("106", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RESERVES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("11", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RAN").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("12", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_RESULTAT").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("13", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_SUBVENTION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("14", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_CP_PROVISION").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ /** PROVISIONS */
+ if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_PROVISIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ /** DETTES */
+ if (Category.accountNumberCategory("16", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_EMPRUNTS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("15", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_AVANCES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("40", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_FOURNISSEURS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("43", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("44", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_FISCALES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("999", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_IMMOBILISATIONS").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("9999", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_AUTRES_DETTES").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ if (Category.accountNumberCategory("487", balanceDTO.getAccount().getIdNumber())) {
+ passifTab.get("PASSIF_DETTES_PCA").add(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Incrémente la barre de chargement
+ value = value + incremente;
+ progressBar.getProgressBar().setValue((int) value);
+ progressBar.getProgressBar().setString((int) value + "% : Compte : " + balanceDTO.getName());
+ }
+
+ progressBar.getProgressBar().setString("60% : Mise en place des amortissements et provisions");
+ progressBar.getProgressBar().setValue(60);
+ /**
+ * Mise en place des provisions et amortissements
+ */
+ if (provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_INCORPOREL");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_IMMOBILISE_CORPOREL") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_CORPOREL");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_CORPOREL").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_IMMOBILISE_FINANCIER") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_IMMOBILISE_FINANCIER");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_IMMOBILISE_FINANCIER").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+ if (provisionMap.get("ACTIF_CIRCULANT_CREANCES") != null) {
+ List<BalanceDTO> listBalance = provisionMap.get("ACTIF_CIRCULANT_CREANCES");
+ for (BalanceDTO balanceDTO : listBalance) {
+ actifTab.get("ACTIF_CIRCULANT_CREANCES").addDepreciation(balanceDTO, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+
+ progressBar.getProgressBar().setString("70% : Calcul du résultat");
+ progressBar.getProgressBar().setValue(70);
+ /**
+ * Appel de la méthode du calcul du compte de résultat pour avoir le
+ * résultat
+ */
+ ResultViewImpl resultViewImpl = new ResultViewImpl();
+ resultViewImpl.updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ passifTab.get("PASSIF_CP_RESULTAT").add(new Bilan("Résultat", "", resultViewImpl.getResult(), "0"), resultViewImpl.getResult());
+
+ progressBar.getProgressBar().setString("90% : Création des tableaux");
+ progressBar.getProgressBar().setValue(90);
+ /**
+ * Ajout des données dans le model
+ */
+ /** ACTIF */
+ List<Bilan> listActif = new LinkedList<Bilan>();
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL"));
+ listActif.add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER"));
+ listActif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", actifTab.get("ACTIF_IMMOBILISE").getTotal(), actifTab.get("ACTIF_IMMOBILISE").getDepreciation()));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_STOCK"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_AVANCES"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_CREANCES"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_VMP"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE"));
+ listActif.add(actifTab.get("ACTIF_CIRCULANT_CCA"));
+ listActif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", actifTab.get("ACTIF_CIRCULANT").getTotal(), actifTab.get("ACTIF_CIRCULANT").getDepreciation()));
+ listActif.add(actifTab.get("ACTIF"));
+
+ // Création du modèle à partir de la liste précédement créée
+ modelBilanActif.setData(listActif);
+ modelBilanActif.fireTableDataChanged();
+
+ /** PASSIF */
+ List<Bilan> listPassif = new LinkedList<Bilan>();
+ listPassif.add(passifTab.get("PASSIF_CAPITAUX"));
+ listPassif.add(passifTab.get("PASSIF_CP_CAPITAL"));
+ listPassif.add(passifTab.get("PASSIF_CP_RESULTAT"));
+ listPassif.add(passifTab.get("PASSIF_CP_RESERVES"));
+ listPassif.add(passifTab.get("PASSIF_CP_RAN"));
+ listPassif.add(passifTab.get("PASSIF_CP_SUBVENTION"));
+ listPassif.add(passifTab.get("PASSIF_CP_PROVISION"));
+ listPassif.add(new Bilan("SOUS-TOTAL (1)", "soustotal", passifTab.get("PASSIF_CAPITAUX").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF_PR_PROVISIONS"));
+ listPassif.add(passifTab.get("PASSIF_PROVISIONS"));
+ listPassif.add(new Bilan("SOUS-TOTAL (2)", "soustotal", passifTab.get("PASSIF_PR_PROVISIONS").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF_DETTES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_EMPRUNTS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_AVANCES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_FOURNISSEURS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_FISCALES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES"));
+ listPassif.add(passifTab.get("PASSIF_DETTES_PCA"));
+ listPassif.add(new Bilan("SOUS-TOTAL (3)", "soustotal", passifTab.get("PASSIF_DETTES").getTotal(), "0"));
+ listPassif.add(passifTab.get("PASSIF"));
+
+ progressBar.getProgressBar().setString("90% : Opération terminée");
+ progressBar.getProgressBar().setValue(90);
+ // Création du modèle à partir de la liste précédement créée
+ modelBilanPassif.setData(listPassif);
+ progressBar.getProgressBar().setValue(95);
+ modelBilanPassif.fireTableDataChanged();
+ progressBar.getProgressBar().setValue(100);
+ progressBar.dispose();
+ }
+ }.start();
+
+ }
+
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ //v.addAll(period.getChildren());
+ }
+
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,47 @@
+
+<Table insets='0,0,0,0'>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.reports"/>
+ </cell>
+ <cell>
+ <JAXXComboBox>
+ <item value='{_("lima.balance")}'/>
+ <item value='{_("lima.journal")}'/>
+ <item value='{_("lima.grand.livre")}'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns="2">
+ <JPanel id="reportsPanel"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="lima.period"/>
+ </cell>
+ <cell>
+ <JAXXComboBox>
+ <item value='{null}' label=' '/>
+ <item value='Exercice 08'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text="lima.non.valids.transactions"/>
+ </cell>
+ <cell>
+ <JCheckBox id="nonValidsTransactionsCheckBox"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton text="lima.export.PDF"/>
+ </cell>
+ <cell>
+ <JButton text="lima.export.CSV"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ReportsViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,39 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+
+package org.chorem.lima.ui.report;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class ReportsViewImpl extends ReportsView {
+
+ /**
+ * @param parentContext
+ */
+ public ReportsViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+ }
+
+
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<Table insets="0,0,0,0" fill="both">
+ <script>
+ protected void update() {};
+ </script>
+
+ <!-- Choix pour les périodes -->
+ <row weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JLabel id="periodLabel" text="lima.period"/>
+ </cell>
+ <cell>
+ <JPanel id="periodPanel"/>
+ </cell>
+ </row>
+
+ <row columns="2" weightx="2" fill="both" insets="8,40,8,40">
+ <cell>
+ <JButton width="80" id="updateButton" text="lima.update" onActionPerformed="update()" />
+ </cell>
+ </row>
+
+ <!-- Affichage du compte de résultat -->
+ <row weightx="1" weighty="6" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tabCharge" />
+ </cell>
+ <cell>
+ <JScrollPane id="tabProduit" />
+ </cell>
+ </row>
+
+ <!-- Affichage du résultat -->
+ <row weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <JScrollPane id="tabChargeRes" />
+ </cell>
+ <cell>
+ <JScrollPane id="tabProduitRes" />
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/ResultViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,387 @@
+/**
+ * *##% Lima-Callao ResultViewImpl
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.report;
+
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.balance.BalanceHelper;
+import org.chorem.lima.balance.Category;
+import org.chorem.lima.dto.BalanceDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.table.ResultChargesJXTable;
+import org.chorem.lima.table.ResultProduitsJXTable;
+import org.chorem.lima.table.model.ResultChargesTableModel;
+import org.chorem.lima.table.model.ResultProduitsTableModel;
+import org.chorem.lima.util.Util;
+import static org.nuiton.i18n.I18n._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.table.DefaultTableModel;
+import javax.swing.*;
+
+import java.awt.event.*;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * Cette classe permet d'afficher le compte de résultat de l'entreprise.
+ * Elle utilise quatre tableaux :
+ * _ pour produit (identifié par tabProduit)
+ * _ pour charge (identifié par tabCharge)
+ * _ pour les totaux (identifié par tabChargeRes et tabProduitRes)
+ * <p/>
+ * Elle va dans un premier temps déterminer les deux tableaux charges et produits.
+ * Ensuite, elle va calculer le résultat pour charges et produits.
+ * Enfin elle détermine le résultat final suivant le bénéfice ou perte, il sera
+ * placé dans les produits ou charges.
+ *
+ * @author Rémi Chapelet
+ */
+public class ResultViewImpl extends ResultView {
+
+ private static final Log log = LogFactory.getLog(ResultViewImpl.class);
+ private JComboBox comboBoxPeriod = new JComboBox();
+ private BalanceHelper balance = new BalanceHelper();
+ private JXTable tableChargeRes;
+ private JXTable tableProduitRes;
+ private String resultat;
+ private ResultChargesTableModel modelResultCharges;
+ private ResultProduitsTableModel modelResultProduits;
+ private DefaultTableModel modelChargeRes;
+ private DefaultTableModel modelProduitRes;
+
+ /**
+ * @param parentContext
+ */
+ public ResultViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // Initialise la combobox pour les périodes
+ initComboBoxPeriod();
+
+ // Création des modèles
+ modelResultCharges = new ResultChargesTableModel(null);
+ modelResultProduits = new ResultProduitsTableModel(null);
+
+ /**
+ * Initialise les tableaux pour afficher les résultats de produits
+ * et charges
+ */
+ String[] columnNames = {"1", "2"};
+ // Résultat charges
+ modelChargeRes = new DefaultTableModel();
+ modelChargeRes.setColumnIdentifiers(columnNames);
+ tableChargeRes = new JXTable(modelChargeRes);
+ // On cache le header des colonnes
+ tableChargeRes.setColumnControlVisible(false);
+ tableChargeRes.getTableHeader().setVisible(false);
+ // Résultat produits
+ modelProduitRes = new DefaultTableModel();
+ modelProduitRes.setColumnIdentifiers(columnNames);
+ tableProduitRes = new JXTable(modelProduitRes);
+ // On cache le header des colonnes
+ tableProduitRes.setColumnControlVisible(false);
+ tableProduitRes.getTableHeader().setVisible(false);
+
+
+ // Charge les produits et charges
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+
+ /**
+ * CHARGES
+ */
+ // Création du tableau avec le modèle
+ JXTable tableCharge = new ResultChargesJXTable(modelResultCharges);
+ // Ajout du tableau
+ tabCharge.setViewportView(tableCharge);
+
+ /**
+ * PRODUITS
+ */
+ // Création du tableau avec le modèle
+ JXTable tableProduit = new ResultProduitsJXTable(modelResultProduits);
+ // Ajout du tableau
+ tabProduit.setViewportView(tableProduit);
+
+ /**
+ * Ajout d'un listener lorsque l'utilisateur change de période.
+ */
+ comboBoxPeriod.addItemListener(new ItemListener() {
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ // Actualise le compte de résultat
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ }
+ });
+
+ }
+
+ @Override
+ public void update() {
+ updateResult((PeriodDTO) comboBoxPeriod.getSelectedItem());
+ }
+
+
+ /**
+ * Permet d'initialiser le résultat des charges
+ *
+ * @param totalCharges
+ */
+ private void initTabChargeRes(String totalCharges) {
+ // Définition des données
+ Object[] data =
+ {_("lima.result.total.charge"), totalCharges};
+ // Si il existe déja une ligne
+ if (modelChargeRes.getRowCount() > 0) {
+ modelChargeRes.removeRow(0);
+ }
+ // Ajout de la ligne
+ modelChargeRes.addRow(data);
+ tableChargeRes.setModel(modelChargeRes);
+ tabChargeRes.setViewportView(tableChargeRes);
+ }
+
+ /**
+ * Permet d'initialiser le résultat des produits
+ *
+ * @param totalProduits
+ */
+ private void initTabProduitRes(String totalProduits) {
+ // Définition des données
+ Object[] data =
+ {_("lima.result.total.produit"), totalProduits};
+ // Si il existe déja une ligne
+ if (modelProduitRes.getRowCount() > 0) {
+ modelProduitRes.removeRow(0);
+ }
+ // Ajout de la ligne
+ modelProduitRes.addRow(data);
+ tableProduitRes.setModel(modelProduitRes);
+ tabProduitRes.setViewportView(tableProduitRes);
+ }
+
+
+ /**
+ * Permet d'actualiser le modèle produits et charges pour les données. De
+ * même, il détermine de nouveau le résultat.
+ * Il recherche la balance, puis trie pour prendre seulement les comptes 6
+ * et 7. Ensuite il positionne chacun de ses comptes dans la bonne rubrique
+ * (produits et charges, financier, exceptionnelles, etc).
+ * Enfin, il associe les données aux modèles, et lance le calcul des
+ * résultats.
+ * @param period
+ */
+ protected void updateResult(PeriodDTO period) {
+ // Chargement de la balance
+ List<BalanceDTO> ListbalanceDTO = balance.createBalance(period);
+ /**
+ * Création tableau associatif pour produits et charges
+ */
+ // charges
+ Hashtable<String, List<BalanceDTO>> chargeTab = new Hashtable<String, List<BalanceDTO>>();
+ chargeTab.put("exploitation", new LinkedList<BalanceDTO>());
+ chargeTab.put("financier", new LinkedList<BalanceDTO>());
+ chargeTab.put("exceptionnel", new LinkedList<BalanceDTO>());
+ chargeTab.put("autres", new LinkedList<BalanceDTO>());
+ // Produits
+ Hashtable<String, List<BalanceDTO>> produitTab = new Hashtable<String, List<BalanceDTO>>();
+ produitTab.put("exploitation", new LinkedList<BalanceDTO>());
+ produitTab.put("financier", new LinkedList<BalanceDTO>());
+ produitTab.put("exceptionnel", new LinkedList<BalanceDTO>());
+
+ /**
+ * On filtre tous les comptes de balance pour ne prendre que les comptes
+ * 6 (charges) et 7 (produits).
+ * Ensuite on associe chaque compte à la catégorie dont il appartient dans
+ * le compte de résultat.
+ * Exemple : 641 rémunération du personnel
+ * On recherche sur ce compte dans quelle catégorie il appartient. Ici,
+ * catégorie 64, donc à mettre dans Charges-Exploitation
+ */
+ String totalCharges = "0";
+ String totalProduits = "0";
+ // Parcours tous les comptes de la balance pour rechercher les comptes 6 et 7
+ for (BalanceDTO balanceDTO : ListbalanceDTO) {
+ /**
+ * CHARGES
+ */
+ // Exploitation
+ if (Category.accountNumberCategory("60", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("61", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("62", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("63", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("64", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("65", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("681", balanceDTO.getAccount().getIdNumber())
+ ) {
+ chargeTab.get("exploitation").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Financières
+ if (Category.accountNumberCategory("66", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("686", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("financier").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Exceptionnelles
+ if (Category.accountNumberCategory("67", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("687", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("exceptionnel").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ // Autres
+ if (Category.accountNumberCategory("691", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("695", balanceDTO.getAccount().getIdNumber())) {
+ chargeTab.get("autres").add(balanceDTO);
+ totalCharges = DTOHelper.AddNumbersString(totalCharges, DTOHelper.SubNumbersString(balanceDTO.getDebit(), balanceDTO.getCredit()));
+ }
+ /**
+ * PRODUIT
+ */
+ // Exploitation
+ if (Category.accountNumberCategory("70", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("71", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("72", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("73", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("74", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("75", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("781", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("791", balanceDTO.getAccount().getIdNumber())
+ ) {
+ produitTab.get("exploitation").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Financières
+ if (Category.accountNumberCategory("76", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("786", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("796", balanceDTO.getAccount().getIdNumber())) {
+ produitTab.get("financier").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ // Exceptionnelles
+ if (Category.accountNumberCategory("77", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("787", balanceDTO.getAccount().getIdNumber()) ||
+ Category.accountNumberCategory("797", balanceDTO.getAccount().getIdNumber())) {
+ produitTab.get("exceptionnel").add(balanceDTO);
+ totalProduits = DTOHelper.AddNumbersString(totalProduits, DTOHelper.SubNumbersString(balanceDTO.getCredit(), balanceDTO.getDebit()));
+ }
+ }
+
+ /**
+ * Création des tableaux Charges et Produits
+ */
+ // CHARGES
+ List<BalanceDTO> listCharges = new LinkedList<BalanceDTO>();
+ BalanceDTO titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
+ listCharges.add(titleExploitation);
+ listCharges.addAll(chargeTab.get("exploitation"));
+ BalanceDTO titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
+ listCharges.add(titleFinancier);
+ listCharges.addAll(chargeTab.get("financier"));
+ BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
+ listCharges.add(titleExceptionnel);
+ listCharges.addAll(chargeTab.get("exceptionnel"));
+ BalanceDTO titleAutre = new BalanceDTO("Autres", "title", "0", "0", "title", null);
+ listCharges.add(titleAutre);
+ listCharges.addAll(chargeTab.get("autres"));
+ // Création du modèle à partir de la liste précédement créée
+ modelResultCharges.setData(listCharges);
+ modelResultCharges.fireTableDataChanged();
+
+ // PRODUITS
+ List<BalanceDTO> listProduits = new LinkedList<BalanceDTO>();
+ titleExploitation = new BalanceDTO("Exploitation", "title", "0", "0", "title", null);
+ listProduits.add(titleExploitation);
+ listProduits.addAll(produitTab.get("exploitation"));
+ titleFinancier = new BalanceDTO("Financiers", "title", "0", "0", "title", null);
+ listProduits.add(titleFinancier);
+ listProduits.addAll(produitTab.get("financier"));
+ titleExceptionnel = new BalanceDTO("Exceptionnelles", "title", "0", "0", "title", null);
+ listProduits.add(titleExceptionnel);
+ listProduits.addAll(produitTab.get("exceptionnel"));
+ // Création du modèle à partir de la liste précédement créée
+ modelResultProduits.setData(listProduits);
+ modelResultProduits.fireTableDataChanged();
+
+ /**
+ * Actualise les résultats
+ */
+ initTabChargeRes(totalCharges);
+ initTabProduitRes(totalProduits);
+
+ // Affiche le résultat en produit OU en charge suivant le bénéfice ou perte
+ resultat = "0";
+ // On efface les résultats (ligne bénéfice ou perte)
+ if (modelChargeRes.getRowCount() > 1) {
+ modelChargeRes.removeRow(0);
+ }
+ if (modelProduitRes.getRowCount() > 1) {
+ modelProduitRes.removeRow(0);
+ }
+ // Si les charges sont plus grandes que les produits : pertes
+ if (Util.compareTo(totalCharges, totalProduits) == 1) {
+ resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
+ Object[] data ={_("lima.result.loss"), resultat};
+ modelChargeRes.addRow(data);
+ modelChargeRes.fireTableDataChanged();
+ } else {
+ // Sinon profit
+ resultat = DTOHelper.SubNumbersString(totalProduits, totalCharges);
+ Object[] data ={_("lima.result.profit"), resultat};
+
+ modelProduitRes.addRow(data);
+ modelProduitRes.fireTableDataChanged();
+ }
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initComboBoxPeriod() {
+ // Recherche la liste de toutes les périodes
+ List<PeriodDTO> periodes = LimaContext.getContext().getDataManager().getPeriodes();
+ // Model pour les périodes
+ Vector<PeriodDTO> v = new Vector<PeriodDTO>();
+ // On ajoute un élément null pour permettre d'afficher toutes les périodes
+ v.addElement(null);
+ // Pour chaque période (annuelle et NON mensuelle !)
+ for (PeriodDTO period : periodes) {
+ v.addElement(period);
+ v.addAll(period.getChildren());
+ }
+ comboBoxPeriod.setModel(new DefaultComboBoxModel(v));
+ comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance());
+ periodPanel.add(comboBoxPeriod);
+ periodPanel.validate();
+ }
+
+ public String getResult() {
+ return resultat;
+ }
+
+}
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidget.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidget.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,41 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table insets='5,5,5,5'>
+ <script>
+ protected void removeCriteriaWidget(){}
+ </script>
+ <row>
+ <cell>
+ <JAXXComboBox id="criteriaComboBox" width="200">
+ <item value='date' label='{_("lima.date")}' selected="true"/>
+ <item value='voucher' label='{_("lima.voucher")}'/>
+ <item value='account' label='{_("lima.account")}'/>
+ <item value='description' label='{_("lima.description")}'/>
+ <item value='debit' label='{_("lima.debit")}'/>
+ <item value='credit' label='{_("lima.credit")}'/>
+ <item value='amount' label='{_("lima.amount")}'/>
+ </JAXXComboBox>
+ </cell>
+ <cell weightx="0">
+ <JPanel id="criteriaPanel"/>
+ </cell>
+ <cell>
+ <JButton id="removeButton" text="lima.remove" onActionPerformed="removeCriteriaWidget()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/CriteriaWidgetImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,217 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import static org.nuiton.i18n.I18n._;
+import org.chorem.lima.combobox.JWideComboBox;
+import org.chorem.lima.combobox.model.AccountComboBoxModel;
+import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.item.Item;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.util.AccountToStringConverter;
+import org.jdesktop.swingx.JXDatePicker;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class CriteriaWidgetImpl extends CriteriaWidget {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class);
+ private JTextField inputTextField;
+ private JXDatePicker datePicker;
+ private JComboBox comboBox;
+ private JComboBox accountCombo;
+
+ /**
+ * @param parentContext
+ */
+ public CriteriaWidgetImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // date input creation
+ createDateInput();
+
+ // item changed listener
+ criteriaComboBox.addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ String itemSelected = e.getItem().toString();
+ if (itemSelected.equals("date")) {
+ createDateInput();
+ }
+ if (itemSelected.equals("voucher") ||
+ itemSelected.equals("description") ||
+ itemSelected.equals("account")) {
+ createTextInput();
+ }
+ if (itemSelected.equals("debit") ||
+ itemSelected.equals("credit") ||
+ itemSelected.equals("amount")) {
+ createNumberInput();
+ }
+ if (itemSelected.equals("account")) {
+ createAccountInput();
+ }
+ }
+ }
+ });
+ }
+
+ /**
+ *
+ */
+ private void createNumberInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.greater.than")));
+ getComboBox().addItem(new Item(2, _("lima.filter.less.than")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getInputTextField());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("numberinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createTextInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.contains")));
+ getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getInputTextField());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("textinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createAccountInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.contains")));
+ getComboBox().addItem(new Item(2, _("lima.filter.not.contains")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ getComboBox().addItem(new Item(4, _("lima.filter.starts.with")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getAccountCombo());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("accountinput : ");
+ }
+ }
+
+ /**
+ *
+ */
+ private void createDateInput() {
+ getComboBox().removeAllItems();
+ getComboBox().addItem(new Item(1, _("lima.filter.before")));
+ getComboBox().addItem(new Item(2, _("lima.filter.after")));
+ getComboBox().addItem(new Item(3, _("lima.filter.equals.to")));
+ criteriaPanel.removeAll();
+ criteriaPanel.add(getComboBox());
+ criteriaPanel.add(getDatePicker());
+ criteriaPanel.validate();
+ if (log.isDebugEnabled()) {
+ log.debug("dateinput : ");
+ }
+ }
+
+ @Override
+ protected void removeCriteriaWidget() {
+ LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this);
+ }
+
+ /**
+ * @return
+ */
+ public JComboBox getComboBox() {
+ if (comboBox == null) {
+ comboBox = new JComboBox();
+ }
+ return comboBox;
+ }
+
+ /**
+ * @return
+ */
+ public JXDatePicker getDatePicker() {
+ if (datePicker == null) {
+ datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale());
+ }
+ return datePicker;
+ }
+
+ /**
+ * @return
+ */
+ public JTextField getInputTextField() {
+ if (inputTextField == null) {
+ inputTextField = new JTextField();
+ inputTextField.setPreferredSize(new Dimension(150, 20));
+ }
+ return inputTextField;
+ }
+
+ public JComboBox getAccountCombo() {
+ if (accountCombo == null) {
+ List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
+ LimaContext.getContext().getDataManager().getAccountModel().getData());
+ Vector<AccountDTO> v = new Vector<AccountDTO>(accounts);
+ AccountComboBoxModel model = new AccountComboBoxModel(v);
+ accountCombo = new JWideComboBox(model);
+ accountCombo.setRenderer(AccountComboBoxRenderer.getInstance());
+ accountCombo.setPreferredSize(new Dimension(200, 25));
+ // AutoCompletion
+ AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance());
+ }
+ return accountCombo;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,128 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table insets='0,0,0,0' fill="both">
+ <script>
+ protected void addLettering() {};
+ protected void removeLettering() {};
+ protected void precedentAccount() {};
+ protected void nextAccount() {};
+ </script>
+ <row weightx="1" weighty="0">
+ <cell>
+ <!-- account -->
+ <Table insets='0,0,0,0'>
+ <row weightx="0" weighty="0">
+ <cell anchor='center' weightx="0" weighty="0">
+ <!-- precedent -->
+ <JButton id="precedentButton"
+ preferredSize='{new Dimension(24,24)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='true'
+ horizontalTextPosition='0'
+ onActionPerformed='precedentAccount()'
+ />
+ </cell>
+ <cell anchor='center' weightx="0" weighty="0">
+ <!-- next -->
+ <JButton id="nextButton"
+ preferredSize='{new Dimension(24,24)}'
+ verticalAlignment='0'
+ verticalTextPosition='0'
+ opaque='true'
+ borderPainted='false'
+ focusPainted='false'
+ enabled='true'
+ horizontalTextPosition='0'
+ onActionPerformed='nextAccount()'
+ />
+ </cell>
+ </row>
+ <!-- account -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.account"/>
+ </cell>
+ <cell weightx="0" weighty="0">
+ <JPanel id="accountPanel"/>
+ </cell>
+ </row>
+ <!-- since -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.since"/>
+ </cell>
+ <cell>
+ <JPanel id="sincePanel"/>
+ </cell>
+ </row>
+ <!-- to -->
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell anchor="east">
+ <JLabel text="lima.to"/>
+ </cell>
+ <cell>
+ <JPanel id="toPanel"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ <cell>
+ <!-- entries -->
+ <Table insets='0,0,0,0' fill="both">
+ <row columns="3">
+ <cell>
+ <JLabel text="lima.entries"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.lettered' value='{_("lima.lettered")}'
+ selected='true'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.not.lettered'
+ value='{_("lima.not.lettered")}'/>
+ </cell>
+ <cell>
+ <JRadioButton buttonGroup='entryButtons' text='lima.all' value='{_("lima.all")}'/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row columns="2" weightx="1" weighty="1" anchor="center" fill="both">
+ <cell>
+ <!-- table -->
+ <JScrollPane id="tablePanel"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <!-- add lettering -->
+ <JButton id="addButton" text="lima.add.lettering" onActionPerformed="addLettering()"/>
+ </cell>
+ <cell>
+ <!-- remove lettering -->
+ <JButton id="removeButton" text="lima.remove.lettering" onActionPerformed="removeLettering()"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/LetteringViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,127 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.JWideComboBox;
+import org.chorem.lima.combobox.model.AccountComboBoxModel;
+import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.util.AccountToStringConverter;
+import org.nuiton.util.Resource;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class LetteringViewImpl extends LetteringView {
+
+
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(LetteringViewImpl.class);
+ private final JWideComboBox accountComboBox;
+
+ /**
+ * @param parentContext
+ */
+ public LetteringViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ /** Calling services */
+ List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount(
+ LimaContext.getContext().getDataManager().getAccountModel().getData());
+ /** Creating accounting model */
+ Vector<AccountDTO> v1 = new Vector<AccountDTO>(accounts);
+ AccountComboBoxModel model = new AccountComboBoxModel(v1);
+ accountComboBox = new JWideComboBox();
+ accountComboBox.setPreferredSize(new Dimension(200, 25));
+ accountComboBox.setModel(model);
+ LimaContext.getContext().getDataManager().getAccountModel().addPropertyChangeListener(model);
+ accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance());
+ accountPanel.add(accountComboBox);
+
+ /** AutoCompletion */
+ AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConverter.getInstance());
+
+ Icon forwardIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Forward24.gif");
+ Icon backIcon = Resource.getIcon("toolbarButtonGraphics/navigation/Back24.gif");
+ nextButton.setIcon(forwardIcon);
+ precedentButton.setIcon(backIcon);
+
+ /** Creating period model */
+ List<PeriodDTO> periodes = LimaContext.getContext().getNeogiaFactory().getPeriodService().getAllPeriod(
+ LimaContext.getContext().getNeogiaFactory().getStatusService().getAllStatus()
+ );
+ Vector<PeriodDTO> v2 = new Vector<PeriodDTO>();
+ for (PeriodDTO period : periodes) {
+ v2.addElement(period);
+ v2.addAll(period.getChildren());
+ }
+ JWideComboBox sinceComboBox = new JWideComboBox(v2);
+ sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
+ sinceComboBox.setPreferredSize(new Dimension(200, 25));
+ sincePanel.add(sinceComboBox);
+
+ JWideComboBox toComboBox = new JWideComboBox(v2);
+ toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance());
+ toComboBox.setPreferredSize(new Dimension(200, 25));
+ toPanel.add(toComboBox);
+
+ JXTable table = new JXTable();
+ tablePanel.setViewportView(table);
+ }
+
+ /**
+ *
+ */
+ @Override
+ protected void nextAccount() {
+ if (!(accountComboBox.getSelectedIndex() == accountComboBox.getModel().getSize() - 1)) {
+ accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() + 1);
+ }
+
+ }
+
+ /**
+ *
+ */
+ @Override
+ protected void precedentAccount() {
+ if (!(accountComboBox.getSelectedIndex() == 0)) {
+ accountComboBox.setSelectedIndex(accountComboBox.getSelectedIndex() - 1);
+ }
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,60 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
+ onWindowClosing="windowClosing()"
+ defaultCloseOperation="do_nothing_on_close"
+ iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
+ <script>
+ protected void addCriteriaWidget() {};
+ protected void doSearch() {};
+ protected void windowClosing() {};
+ </script>
+ <JScrollPane>
+ <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
+ <row>
+ <cell>
+ <JButton id="addButton" text="lima.add" width="100" onActionPerformed="addCriteriaWidget()"/>
+ </cell>
+ <cell>
+ <JLabel text="lima.search.items.where" width="200"/>
+ </cell>
+ <cell>
+ <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
+ <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
+ <item value='any' label='{_("lima.any.criteria")}'/>
+ </JAXXComboBox>
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <VBox id="criteriaWidgetPanel"
+ border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
+ />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="okButton" onActionPerformed="doSearch()" text="lima.ok"/>
+ </cell>
+ <cell>
+ <JButton id="cancelButton" text="lima.cancel" onActionPerformed="windowClosing()"/>
+ </cell>
+ </row>
+ </Table>
+ </JScrollPane>
+</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/SearchTransactionViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,224 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import static org.nuiton.i18n.I18n._;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.table.TransactionJXTable;
+import org.jdesktop.swingx.JXDatePicker;
+
+import javax.swing.*;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ * @author ore
+ */
+public class SearchTransactionViewImpl extends SearchTransactionView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(SearchTransactionViewImpl.class);
+ private final TransactionJXTable table;
+
+ /**
+ * @param parentContext
+ */
+ public SearchTransactionViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ // At Least one criteria
+ CriteriaWidgetImpl widget = new CriteriaWidgetImpl();
+ widget.getRemoveButton().setEnabled(false);
+ criteriaWidgetPanel.add(widget);
+ this.validate();
+
+ TransactionViewImpl searchResult = LimaContext.getContext().getMainUI().getSearchResultView();
+ searchResult.setFiltreEnabled(false);
+ table = searchResult.getTransactionTable();
+ getRootPane().setDefaultButton(okButton);
+ }
+
+ @Override
+ protected void addCriteriaWidget() {
+ criteriaWidgetPanel.add(new CriteriaWidgetImpl());
+ this.validate();
+ }
+
+ public void removeCriteriaWidget(CriteriaWidget widget) {
+ criteriaWidgetPanel.remove(widget);
+ this.validate();
+ }
+
+ protected void showTransactionView() {
+ LimaContext.getContext().getMainUI().showSearchResultView();
+ }
+
+ @Override
+ protected void doSearch() {
+ if (criteriaWidgetPanel.getComponentCount() > 0) {
+ table.getModel().initData();
+ table.addColorEmptyLine();
+ /** Any or All */
+ String allOrAny = (String) criteriaAllAnyComboBox.getSelectedItem();
+ boolean all = allOrAny.equals("all");
+ for (int i = 0; i < criteriaWidgetPanel.getComponentCount(); i++) {
+ CriteriaWidgetImpl myWidget = (CriteriaWidgetImpl) criteriaWidgetPanel.getComponent(i);
+ JComboBox comboCriteria = myWidget.getCriteriaComboBox();
+ if (comboCriteria.getSelectedIndex() != -1) {
+ String itemSelected = (String) comboCriteria.getSelectedItem();
+ /**
+ * Date item
+ */
+ if (itemSelected.equals("date")) {
+ searchDate(myWidget, FilterEnum.Date, all);
+ }
+
+ /**
+ * Voucher item
+ */
+ if (itemSelected.equals("voucher")) {
+ searchText(myWidget, FilterEnum.Voucher, all);
+ }
+
+ /**
+ * Account item
+ */
+ if (itemSelected.equals("account")) {
+ searchText(myWidget, FilterEnum.Account, all);
+ }
+
+ /**
+ * Description item
+ */
+ if (itemSelected.equals("description")) {
+ searchText(myWidget, FilterEnum.Description, all);
+ }
+
+ /**
+ * Debit item
+ */
+ if (itemSelected.equals("debit")) {
+ searchNumber(myWidget, FilterEnum.Debit, all);
+ }
+
+ /**
+ * Credit item
+ */
+ if (itemSelected.equals("credit")) {
+ searchNumber(myWidget, FilterEnum.Credit, all);
+ }
+
+ /**
+ * Amount item
+ */
+ if (itemSelected.equals("amount")) {
+ searchNumber(myWidget, FilterEnum.Amount, all);
+ }
+
+ } else {
+ throw new NullPointerException();
+ }
+ } // end for
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ /**
+ * @param myWidget
+ * @param type
+ * @param all
+ */
+ protected void searchDate(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JXDatePicker datePicker = myWidget.getDatePicker();
+ if (datePicker.getDate() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with date : " + datePicker.getDate());
+ }
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ private void searchNumber(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JTextField text = myWidget.getInputTextField();
+ if (text.getText() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with number : " + text.getText());
+ }
+ /**
+ * Parse double
+ */
+ try {
+ String value = text.getText();
+ Double.parseDouble(value.equals(DTOHelper.EMPTY_STRING) ? "0" : value);
+
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } catch (NumberFormatException e) {
+ JOptionPane.showMessageDialog(this, _("lima.exception.number.format"));
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ private void searchText(CriteriaWidgetImpl myWidget, FilterEnum type, boolean all) {
+ JTextField text = myWidget.getInputTextField();
+ if (text.getText() != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("search with text : " + text.getText());
+ }
+ JComboBox comboNextCriteria = myWidget.getComboBox();
+ if (comboNextCriteria.getSelectedIndex() != -1) {
+ table.getModel().filter(type, myWidget, all);
+ showTransactionView();
+ } else {
+ throw new NullPointerException();
+ }
+ } else {
+ throw new NullPointerException();
+ }
+ }
+
+ @Override
+ protected void windowClosing() {
+ this.setVisible(false);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionView.jaxx)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,71 @@
+<!-- ##% Lima Swing
+ Copyright (C) 2008 - 2010 CodeLutin
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<Table>
+ <script>
+ <![CDATA[
+
+ ]]>
+ </script>
+ <!-- <JPopupMenu id="MenuRightPanel">
+ <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu>
+ <JPopupMenu id="MenuRightTransaction">
+ <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/>
+ <JMenuItem text="lima.print"/>
+ </JPopupMenu> -->
+ <row fill="horizontal" weightx="0.75" weighty="0" anchor="center">
+ <cell>
+ <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/>
+ </cell>
+ <cell>
+ <JComboBox id="entryBookComboBox"
+ model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" />
+ </cell>
+ <cell>
+ <JLabel id="periodLabel" text="lima.transaction.period"/>
+ </cell>
+ <cell>
+ <JComboBox id="financialPeriodPanel"
+ model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" rows='3' columns='4'>
+ <JScrollPane>
+ <org.chorem.lima.ui.transaction.table.TransactionTable
+ id="transactionsTable" sortable="false" rowHeight="22"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ highlighters="{HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" />
+ </JScrollPane>
+ </cell>
+ <cell>
+ <JButton id="addButton" text="lima.add.transaction" onActionPerformed="addEmptyTransaction()" width="150"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="removeButton" text="lima.remove.transaction" onActionPerformed="removeTransaction()" width="150"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton text="lima.add.entry" onActionPerformed="addEmptyEntry()" width="150"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/ui/TransactionViewImpl.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,375 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction;
+
+import javax.swing.*;
+import java.awt.event.*;
+import java.util.Date;
+import java.util.List;
+import java.util.Vector;
+
+import jaxx.runtime.JAXXContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.combobox.model.JournalComboBoxModel;
+import org.chorem.lima.combobox.model.PeriodComboBoxModel;
+import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer;
+import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.listener.ClicRight;
+import org.chorem.lima.service.util.ServiceHelper;
+import org.chorem.lima.table.model.*;
+import org.chorem.lima.table.TransactionJXTable;
+import org.chorem.lima.ui.ErrorMessage;
+import org.chorem.lima.util.Util;
+import static org.nuiton.i18n.I18n._;
+
+
+/**
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class TransactionViewImpl extends TransactionView {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(TransactionViewImpl.class);
+ private JComboBox comboJournal;
+ private JComboBox comboPeriod;
+ private TransactionJXTable transactionTable;
+ private TransactionDataTableModel model;
+ private TransactionFilteredTableModel filterModel;
+ private TransactionSortedTableModel sortedModel;
+ private TransactionSortedTableColumnModel columnModel;
+ private TransactionFlattenTableModel flattenModel;
+
+ /**
+ * @param parentContext
+ */
+ public TransactionViewImpl(JAXXContext parentContext) {
+ super(parentContext);
+
+ initJournalComboBox();
+ initPeriodComboBox();
+
+ getTransactionTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+ transactionScrollPane.setViewportView(getTransactionTable());
+
+ /**
+ * Property change listeners
+ */
+ getModel().addPropertyChangeListener(getFilterModel());
+ getFilterModel().addPropertyChangeListener(getSortedModel());
+ getSortedModel().addPropertyChangeListener(getFlattenModel());
+
+ getComboJournal().addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ getTransactionTable().removeColorEmptyLine();
+ getFlattenModel().initData();
+
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ JComboBox comboBox = (JComboBox) e.getSource();
+ JournalDTO item = (JournalDTO) comboBox.getSelectedItem();
+ getFlattenModel().filter(FilterEnum.Journal, item, true);
+ LimaContext.getContext().getDataManager().setCurrentJournal(item);
+ }
+
+ if (!(getComboPeriod().getSelectedIndex() == -1 || getComboPeriod().getSelectedIndex() == 0)) {
+ getFlattenModel().filter(FilterEnum.Period, getComboPeriod().getSelectedItem(), true);
+ }
+ }
+ });
+ getComboPeriod().addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ getTransactionTable().removeColorEmptyLine();
+ getFlattenModel().initData();
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ JComboBox comboBox = (JComboBox) e.getSource();
+ PeriodDTO item = (PeriodDTO) comboBox.getSelectedItem();
+ getFlattenModel().filter(FilterEnum.Period, item, true);
+ LimaContext.getContext().getDataManager().setCurrentPeriod(item);
+ }
+
+ if (!(getComboJournal().getSelectedIndex() == -1 || getComboJournal().getSelectedIndex() == 0)) {
+ getFlattenModel().filter(FilterEnum.Journal, getComboJournal().getSelectedItem(), true);
+ }
+ }
+ });
+ /**
+ * Permet de mettre la sélection du combobox par défaut sur le mois actuel lors
+ * de l'ouverture de la page des transactions.
+ */
+ int index = 0;
+ // Récupère la date actuelle
+ Date d = new Date();
+ String dateToday = ServiceHelper.dateToMonth(d) + " " + (d.getYear() + 1900);
+ for (int i = 0; i <= getComboPeriod().getItemCount(); i++) {
+ Object o = getComboPeriod().getItemAt(i);
+ if (o != null) {
+ if (dateToday.equals(((PeriodDTO) o).getIdName())) {
+ index = i;
+ }
+ }
+ }
+ if (index != 0){
+ getComboPeriod().setSelectedIndex(index);
+
+ }
+
+ /**
+ * Implémente le clic droit
+ */
+ MouseListener popupListeneTransr = new ClicRight(MenuRightTransaction);
+ getTransactionTable().addMouseListener(popupListeneTransr);
+ }
+
+ /**
+ * Initialise la combobox contenant les journaux
+ */
+ private void initJournalComboBox() {
+ /** Getting data from journal model **/
+ List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData();
+ /** Creating combobox model */
+ Vector<JournalDTO> v = new Vector<JournalDTO>(journals.size());
+ /** null item */
+ v.add(null);
+ v.addAll(journals);
+ JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v);
+ /** Property Change Listener */
+ LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
+ getComboJournal().setModel(comboBoxModel);
+ getComboJournal().setRenderer(JournalComboBoxRenderer.getInstance());
+ // AutoCompletion
+ // AutoCompleteDecorator.decorate(comboJournal, JournalToStringConverter.getInstance());
+ journalPanel.add(getComboJournal());
+ journalPanel.validate();
+ }
+
+ /**
+ * Initialise la combobox contenant les périodes
+ */
+ private void initPeriodComboBox() {
+ // Recherche la liste de toutes les périodes
+
+ ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel();
+ PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel);
+ getComboPeriod().setModel(periodModel);
+ getComboPeriod().setRenderer(PeriodComboBoxRenderer.getInstance());
+ // AutoCompletion
+ // AutoCompleteDecorator.decorate(comboPeriod, PeriodToStringConverter.getInstance());
+ periodPanel.add(getComboPeriod());
+ periodPanel.validate();
+ }
+
+ /**
+ * @param enabled new value
+ */
+ public void setFiltreEnabled(boolean enabled) {
+ getComboPeriod().setEnabled(enabled);
+ getComboJournal().setEnabled(enabled);
+ }
+
+ /**
+ * ajout de transaction vide avec le bouton
+ */
+ @Override
+ protected void addEmptyTransaction() {
+ String result = transactionTable.getModel().addEmptyTransaction();
+ /**
+ * Si il n'y pas de message success, alors il existe une erreur.
+ * Création de la boite de dialogue avec le message d'erreur correspondant
+ */
+ ErrorMessage.showMessage(result);
+ }
+
+ /**
+ * suppression de transaction avec le bouton
+ */
+ @Override
+ protected void removeTransaction() {
+ // Any row selected
+ Integer indexSelectedRow = transactionTable.getSelectedRow();
+ if (indexSelectedRow != -1) {
+ String message = DTOHelper.isTransaction(
+ transactionTable.getModel().getElementAt(indexSelectedRow))
+ ? _("lima.question.remove.transaction")
+ : _("lima.question.remove.entry");
+ int n = Util.showConfirmDialog(message);
+ if (n == JOptionPane.YES_OPTION) {
+ TransactionTableModel model = transactionTable.getModel();
+ // Message de retour
+ String result = "";
+ if (TransactionFlattenTableModel.isFlattenModel(model)) {
+ // Flatten
+ TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) transactionTable.getModel();
+ flattenModel.removeEmptyLine();
+ /**
+ * Supprime la ligne sélectionnée : transaction ou entry
+ */
+ if (DTOHelper.isTransaction(model.getElementAt(indexSelectedRow))) {
+ // Transaction
+ result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
+ } else {
+ // Entry
+ result = flattenModel.removeEntry((EntryDTO) model.getElementAt(indexSelectedRow));
+ }
+ transactionTable.addColorEmptyLine();
+ } else {
+ // Not Flatten
+ result = model.removeTransaction((TransactionDTO) model.getElementAt(indexSelectedRow));
+ }
+ /**
+ * Messages erreurs
+ */
+ if (!result.equals(ServiceHelper.RESPOND_SUCCESS)) {
+ ErrorMessage.showMessage(message);
+ }
+ }
+ }
+ }
+
+ /**
+ * Implémente le bouton ajout d'une entrée.
+ * Permet d'ajouter une ligne comptable sur la transaction sélectionnée.
+ */
+ @Override
+ protected void addEmptyEntry() {
+ if (transactionTable.getSelectionModel().isSelectionEmpty()) {
+ // Not line selected
+ } else {
+ // Line selected
+ int selectedRow = transactionTable.getSelectedRow();
+ int parentIndex = flattenModel.getParentIndex(selectedRow);
+ /**
+ * Is transaction editable ?
+ */
+ Object o = flattenModel.getElementAt(parentIndex);
+ if (DTOHelper.isTransaction(o)) {
+ // Transaction n'est pas éditable
+ if (!ServiceHelper.isEditable((TransactionDTO) o)) {
+ Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ } else {
+ //Entry n'est pas éditable
+ if (!ServiceHelper.isEditable((EntryDTO) o)) {
+ Util.showMessageDialog(_("lima.error.transaction.period.not.blocked") + ".", _("lima.error"), JOptionPane.WARNING_MESSAGE);
+ return;
+ }
+ }
+
+ // Click in not current transaction
+ if (flattenModel.getCurrentParentIndex() != parentIndex) {
+ int posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ /**
+ * Once traitement for transaction
+ */
+ if (flattenModel.isEmptyLineEmpty()) {
+ flattenModel.createEmptyLine();
+ } else {
+ flattenModel.removeEmptyLine();
+ selectedRow = transactionTable.getSelectedRow();
+ parentIndex = flattenModel.getParentIndex(selectedRow);
+ posNext = flattenModel.emptyLineNextPosition(selectedRow);
+ flattenModel.createEmptyLine();
+ }
+ flattenModel.addEmptyLine(posNext);
+
+ // To end
+ flattenModel.setCurrentParentIndex(parentIndex);
+ }
+ /**
+ * New Line Color
+ */
+ transactionTable.addColorEmptyLine();
+ }
+ }
+
+ public TransactionDataTableModel getModel() {
+ if (model == null) {
+ model = LimaContext.getContext().getDataManager().getTransactionModel();
+ }
+ return model;
+ }
+
+ public TransactionFilteredTableModel getFilterModel() {
+ if (filterModel == null) {
+ filterModel = new TransactionFilteredTableModel(getModel());
+ }
+ return filterModel;
+ }
+
+ public TransactionSortedTableColumnModel getColumnModel() {
+ if (columnModel == null) {
+ columnModel = new TransactionSortedTableColumnModel(getSortedModel());
+ }
+ return columnModel;
+ }
+
+ public TransactionSortedTableModel getSortedModel() {
+ if (sortedModel == null) {
+ sortedModel = new TransactionSortedTableModel(getFilterModel());
+ }
+ return sortedModel;
+ }
+
+ public TransactionFlattenTableModel getFlattenModel() {
+ if (flattenModel == null) {
+ flattenModel = new TransactionFlattenTableModel(getSortedModel());
+ }
+ return flattenModel;
+ }
+
+ public TransactionJXTable getTransactionTable() {
+ if (transactionTable == null) {
+ transactionTable = new TransactionJXTable(getFlattenModel(), getColumnModel());
+ transactionTable.setName("TransactionTable");
+ }
+ return transactionTable;
+ }
+
+ public JComboBox getComboJournal() {
+ if (comboJournal == null) {
+ comboJournal = new JComboBox();
+ comboJournal.setName("Liste journal");
+ }
+ return comboJournal;
+ }
+
+ public JComboBox getComboPeriod() {
+ if (comboPeriod == null) {
+ comboPeriod = new JComboBox();
+ comboPeriod.setName("Liste periode");
+ }
+ return comboPeriod;
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,112 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Opened financial period combo box model.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ protected EntryBookService entryBookService;
+
+ public EntryBookComboBoxModel(Object selectedMonth) {
+ entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = entryBookService.getAllEntryBooks().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ // TODO add cache
+ try {
+ result = entryBookService.getAllEntryBooks().get(index);
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,113 @@
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.transaction.model;
+
+import javax.swing.ComboBoxModel;
+import javax.swing.event.ListDataListener;
+
+import org.chorem.lima.business.FinancialPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.nuiton.util.MonthEnum;
+
+/**
+ * Opened financial period combo box model.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FinancialPeriodComboBoxModel implements ComboBoxModel {
+
+ protected Object selectedMonth;
+
+ protected FinancialPeriodService financialPeriodService;
+
+ public FinancialPeriodComboBoxModel(Object selectedMonth) {
+ financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ int result = 0;
+ // TODO add cache
+ try {
+ result = financialPeriodService.getNonLockedFinancialPeriods().size();
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ Object result = null;
+ // TODO add cache
+ try {
+ result = financialPeriodService.getNonLockedFinancialPeriods().get(index);
+ }
+ catch (LimaException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void addListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
+ */
+ @Override
+ public void removeListDataListener(ListDataListener l) {
+
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedMonth = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedMonth;
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,295 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import java.awt.Color;
+import java.awt.Component;
+
+import javax.swing.ListSelectionModel;
+import javax.swing.table.TableColumnModel;
+import javax.swing.table.TableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.listener.EmptyLineSelectionListener;
+import org.chorem.lima.listener.TransactionHeaderListener;
+import org.chorem.lima.listener.TransactionKeyListener;
+import org.chorem.lima.table.editor.AccountTableCellEditor;
+import org.chorem.lima.table.editor.DateTableCellEditor;
+import org.chorem.lima.table.editor.JournalTableCellEditor;
+import org.chorem.lima.table.editor.NumberTableCellEditor;
+import org.chorem.lima.table.editor.PeriodTableCellEditor;
+import org.chorem.lima.table.editor.TextTableCellEditor;
+import org.chorem.lima.table.model.TransactionFlattenTableModel;
+import org.chorem.lima.table.model.TransactionSortedTableColumnModel;
+import org.chorem.lima.table.model.TransactionTableModel;
+import org.chorem.lima.table.renderer.AccountTableCellRenderer;
+import org.chorem.lima.table.renderer.AmountTableCellRenderer;
+import org.chorem.lima.table.renderer.DateTableCellRenderer;
+import org.chorem.lima.table.renderer.JournalTableCellRenderer;
+import org.chorem.lima.table.renderer.PeriodTableCellRenderer;
+import org.chorem.lima.table.renderer.StatusTableCellRenderer;
+import org.chorem.lima.table.renderer.TextTableCellRenderer;
+import org.chorem.lima.table.renderer.TransactionHeaderRenderer;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+/**
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class TransactionTable extends JXTable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(TransactionTable.class);
+
+ private ColorHighlighter colorEmptyLine;
+
+ private ColorHighlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ private EmptyLineSelectionListener emptyLineSelectionListener;
+
+ private TransactionKeyListener keyListener;
+
+ /**
+ * @param model
+ * @param columnModel
+ */
+ public TransactionTable(TransactionTableModel model, TransactionSortedTableColumnModel columnModel) {
+ super(model, columnModel);
+ createDefaultColumnsFromModel();
+
+ //setSelectionBackground(new Color(250,250,250));
+ //setSelectionForeground(new Color(0,0,0));
+
+ setHighlighters(HighlighterFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250)));
+ setColumnControlVisible(true);
+ getColumnExt(TransactionEnum.LETTERING.ordinal()).setVisible(false);
+ /**
+ * New Table Header
+ */
+ getTableHeader().setDefaultRenderer(TransactionHeaderRenderer.getInstance());
+ getTableHeader().addMouseListener(new TransactionHeaderListener(this));
+
+ /**
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur clique sur une ligne du tableau, on ajoute
+ * automatiquement une nouvelle ligne (une entrée comptable)
+ */
+ //addMouseListener(getEmptyLineSelectionListener());
+ /**
+ * Fin mod
+ */
+
+ /**
+ * Mod : il est possible d'activer cette option.
+ * Lorsque l'utilisateur appuie sur une touche "insert" ou autres, le
+ * programme insère une ligne comptable.
+ */
+ addKeyListener(getKeyListener());
+
+
+ /**
+ * Editing true
+ */
+ setTransactionEditable(true);
+
+ // cell rendering
+ TableColumnModel tcm = getColumnModel();
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellRenderer(DateTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellRenderer(AccountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellRenderer(JournalTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellRenderer(PeriodTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.STATUS.ordinal()).setCellRenderer(StatusTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.BALANCE.ordinal()).setCellRenderer(AmountTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellRenderer(TextTableCellRenderer.getInstance());
+
+ // cell editoring
+ tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance());
+ tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());
+ packAll();
+ /**
+ * Color transactions
+ */
+ addColorTransaction();
+ addColorBalance();
+ }
+
+ /**
+ * @param editable
+ */
+ public void setTransactionEditable(boolean editable) {
+ if (editable) {
+ addMouseListener(emptyLineSelectionListener);
+ addKeyListener(keyListener);
+ } else {
+ removeMouseListener(emptyLineSelectionListener);
+ removeKeyListener(keyListener);
+ }
+ TransactionTableModel model = (TransactionTableModel) getModel();
+ model.setEditable(editable);
+ }
+
+ /**
+ *
+ */
+ public void addColorEmptyLine() {
+ /*
+ * Renvoie une couleur jaune pour chaque nouvelle ligne créée
+ removeColorEmptyLine();
+ if (TransactionFlattenTableModel.isFlattenModel(getModel())) {
+ final int posNext = ((TransactionFlattenTableModel) getModel()).getEmptyLinePosition();
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return adapter.row == posNext;
+ }
+ };
+ colorEmptyLine = new ColorHighlighter(predicate, new Color(248,255,136), Color.BLACK,new Color(248,255,136), Color.BLACK);
+ addHighlighter(colorEmptyLine);
+ }*/
+ }
+
+ /**
+ *
+ */
+ public void removeColorEmptyLine() {
+ if (colorEmptyLine != null) {
+ removeHighlighter(colorEmptyLine);
+ }
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les transactions dans le tableau
+ * afin de bien distinguer les transactions et entrées comptables.
+ */
+ public void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ return DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) ? true : false;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null);
+ addHighlighter(colorTransaction);
+ }
+
+
+ /**
+ * Permet de surligner une transaction dans le tableau lorsque cette dernière
+ * n'est pas équilibrée.
+ */
+ public void addColorBalance() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+
+ @Override
+ public boolean isHighlighted(Component arg0, ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ // Si c'est une transaction
+ if ( DTOHelper.isTransaction(getModel().getElementAt(adapter.row)) )
+ {
+ if ( !DTOHelper.isBalanced((TransactionDTO) getModel().getElementAt(adapter.row)) )
+ {
+ isHighlighted = true;
+ }
+ }
+ return isHighlighted;
+ }
+ };
+ colorTransaction = new ColorHighlighter(predicate, new Color(255,198,209),null,null,null);
+ addHighlighter(colorTransaction);
+ }
+
+ /**
+ *
+ */
+ public void removeColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ }
+
+ @Override
+ public TransactionTableModel getModel() {
+ return (TransactionTableModel) this.dataModel;
+ }
+
+ @Override
+ public TransactionSortedTableColumnModel getColumnModel() {
+ return (TransactionSortedTableColumnModel) this.columnModel;
+ }
+
+ public EmptyLineSelectionListener getEmptyLineSelectionListener() {
+ if (emptyLineSelectionListener == null) {
+ return new EmptyLineSelectionListener();
+ }
+ return emptyLineSelectionListener;
+ }
+
+ /**
+ * @return
+ */
+ public TransactionKeyListener getKeyListener() {
+ if (keyListener == null) {
+ return new TransactionKeyListener();
+ }
+ return keyListener;
+ }
+
+ /**
+ * @param model
+ * @return
+ */
+ public boolean isFlattenModel(TableModel model) {
+ return TransactionFlattenTableModel.isFlattenModel(model);
+ }
+
+ @Override
+ public void setModel(TableModel arg0) {
+ super.setModel(arg0);
+ removeColorEmptyLine();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTable.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java 2010-04-02 17:04:31 UTC (rev 2829)
@@ -0,0 +1,204 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.transaction.table;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+import javax.xml.rpc.ServiceFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.business.RecordService;
+import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.comparator.JournalComparator;
+import org.chorem.lima.comparator.PeriodComparator;
+import org.chorem.lima.comparator.StatusComparator;
+import org.chorem.lima.enumeration.FilterEnum;
+import org.chorem.lima.enumeration.TransactionEnum;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ServiceHelper;
+
+/**
+ * Basic transaction table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class TransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(TransactionTableModel.class);
+
+ /**
+ * Services
+ */
+ protected final RecordService recordService;
+ protected final TransactionService transactionService;
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public TransactionTableModel() {
+ /* Services */
+ recordService = LimaServiceFactory.getInstance().getRecordService();
+ transactionService = LimaServiceFactory.getInstance().getTransactionService();
+ }
+
+ @Override
+ public int getRowCount() {
+ return model.getRowCount();
+ }
+
+ @Override
+ public int getColumnCount() {
+ return model.getColumnCount();
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ return model.getValueAt(getSortedRow(row), column);
+ }
+
+ @Override
+ public Object getElementAt(int row) {
+ return model.getElementAt(getSortedRow(row));
+ }
+
+ @Override
+ public boolean isEditable() {
+ return model.isEditable();
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+ return model.getColumnClass(column);
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ return model.getColumnName(column);
+ }
+
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ return model.isCellEditable(getSortedRow(row), column);
+ }
+
+ @Override
+ public void setValueAt(Object value, int row, int col) {
+ row = getSortedRow(row);
+ String response;
+ /**
+ * TransactionDTO
+ */
+ TransactionDTO trans = (TransactionDTO) getElementAt(row);
+ TransactionDTO cloneTrans = DTOHelper.cloneTransaction(trans);
+ switch (TransactionEnum.values()[col]) {
+ case PERIOD:
+ cloneTrans.setPeriod((PeriodDTO) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setPeriod(cloneTrans.getPeriod());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case JOURNAL:
+ cloneTrans.setJournal((JournalDTO) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setJournal(cloneTrans.getJournal());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DATE:
+ cloneTrans.setEntryDate((Date) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setEntryDate(cloneTrans.getEntryDate());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DOCUMENT:
+ cloneTrans.setVoucherRef((String) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setVoucherRef(cloneTrans.getVoucherRef());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ case DESCRIPTION:
+ cloneTrans.setDescription((String) value);
+ response = transactionServ.updateTransaction(
+ LimaContext.getContext().getDataManager().getStatus(),
+ trans,
+ cloneTrans);
+ if (ServiceHelper.RESPOND_SUCCESS.equals(response)) {
+ trans.setDescription(cloneTrans.getDescription());
+ trans.setStatus(cloneTrans.getStatus());
+ }
+ break;
+ }
+ }
+
+ /**
+ *
+ */
+ @Override
+ public String addEmptyTransaction() {
+ return model.addEmptyTransaction();
+ }
+
+ /**
+ * @param trans
+ */
+ @Override
+ public String removeTransaction(TransactionDTO trans) {
+ return model.removeTransaction(trans);
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/TransactionTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:02:58 +0200 (Fri, 02 Apr 2010)
New Revision: 2828
Log:
Regeneration des fichiers i18n
Modified:
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-02 17:02:21 UTC (rev 2827)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-02 17:02:58 UTC (rev 2828)
@@ -1,9 +1,15 @@
-lima.error.errorpane.title=Lima error
-lima.error.errorpane.htmlmessage=<html><body><b>An application error happened</b>:<br/>%s</body></html>
+Bloqu\u00E9e=
+Can't\ add\ fiscal\ period=
+Confirmation=
+Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
+Exercice=
+Global\ lima\ exception=
lima.about.message=
-lima.accountplan=Plan de comptes
lima.account=Account
+lima.account.label=
+lima.account.number=
lima.account.type=Account type
+lima.accountplan=Plan de comptes
lima.actif=Asset
lima.action.commandline.disable.main.ui=Do not launch main ui
lima.action.commandline.help=Show help in console
@@ -37,15 +43,25 @@
lima.block=block
lima.cancel=Cancel
lima.charge=Expense
+lima.chartofaccounts=
+lima.chartofaccounts.journal=
+lima.chartofaccounts.management=
lima.closure.period.begin=Period from
lima.closure.timespan.warning=Warning\: when the period is blocked, it is possible to add, edit and delete entries on the accounting period.
+lima.common.add=
+lima.common.cancel=
+lima.common.ok=
+lima.common.remove=
+lima.common.update=
lima.config.category.directories=
lima.config.category.directories.description=
lima.config.category.other=
lima.config.category.other.description=
lima.config.configFileName.description=
lima.config.locale.description=
+lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen=
+lima.config.ui.fullscreen.description=
lima.credit=Credit
lima.daily=Daily
lima.date=Date
@@ -66,6 +82,12 @@
lima.edit=Edit
lima.edit.transaction=Edit transaction
lima.entries=Entries
+lima.entries.addtransaction=
+lima.entries.lettering=
+lima.entries.searchtransaction=
+lima.entrybook.description=
+lima.entrybook.label=
+lima.entrybook.prefix=
lima.error=Error
lima.error.account.double=It exists an account with a same number
lima.error.account.not.exist=This account doesn't exist
@@ -73,6 +95,8 @@
lima.error.account.with.entries=This account has some entries
lima.error.entry.not.exist=
lima.error.entry.not.remove=
+lima.error.errorpane.htmlmessage=<html><body><b>An application error happened</b>\:<br/>%s</body></html>
+lima.error.errorpane.title=Lima error
lima.error.journal.double=A journal exist with this name
lima.error.journal.not.exist=This journal doesn't exist
lima.error.journal.with.transactions=This journal has some transactions
@@ -106,6 +130,11 @@
lima.filter.not.contains=Not contains
lima.filter.starts.with=Starts with
lima.find.transaction=Find transaction
+lima.fiscalyear=
+lima.fiscalyear.addperiod=
+lima.fiscalyear.closefiscalyear=
+lima.fiscalyear.closeperiod=
+lima.fiscalyear.listclosed=
lima.grand.livre=General Ledger
lima.home=Home - TODO
lima.import=Import
@@ -118,6 +147,7 @@
lima.import.success=Your datas had been loaded
lima.init.closed=Lima closed at %1$s
lima.init.context.done=Context was initialized in %1$s
+lima.init.errorclosing=
lima.init.ui.done=UI initialized
lima.journal=Journal
lima.lettered=Lettered
@@ -138,6 +168,8 @@
lima.menubar.closure.timespan=close a period (monthly)
lima.message.config.loaded=Config was loaded
lima.message.error.empty.line=Please choose an account
+lima.message.help.usage=
+lima.misc.supportemail.description=
lima.model.account=Account
lima.model.balance=Balance
lima.model.credit=Credit
@@ -159,8 +191,14 @@
lima.ok=OK
lima.passif=Liability
lima.period=Period
+lima.period.addFiscalPeriod=
+lima.period.begindate=
+lima.period.block=
lima.period.close=Close
+lima.period.enddate=
+lima.period.filter=
lima.period.open=Open
+lima.period.periodFilterLabel=
lima.preferences=Preferences
lima.prefix=Prefix
lima.print=Print
@@ -213,6 +251,7 @@
lima.tab.home=Home
lima.tab.journal=Journal
lima.tab.lettering=Lettering
+lima.tab.period=
lima.tab.reports=Reports
lima.tab.result=Result
lima.tab.search.result=Search result
@@ -220,6 +259,8 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=About Lima...
lima.to=To
+lima.transaction.entrybook=
+lima.transaction.period=
lima.ui.add.account=Add account
lima.ui.add.journal=Add journal
lima.ui.block.timespan=Block period
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-02 17:02:21 UTC (rev 2827)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-02 17:02:58 UTC (rev 2828)
@@ -1,10 +1,14 @@
-lima.error.errorpane.title=Lima erreur
-lima.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>:<br/>%s</body></html>
-lima.about.message=
-lima.account.number=Num�ro du compte
-lima.accountplan=Plan de comptes
-lima.account.label=Libell�
+Bloqu\u00E9e=
+Can't\ add\ fiscal\ period=
+Confirmation=
+Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?=
+Exercice=
+Global\ lima\ exception=
+lima.about.message=\u00C0 propos de Lima
lima.account=Compte
+lima.account.label=Libell\u00E9
+lima.account.menu=Plan de comptes
+lima.account.number=Num\u00E9ro du compte
lima.account.type=Type de compte
lima.actif=Actif
lima.action.commandline.disable.main.ui=Ne pas lancer l'ui
@@ -13,14 +17,14 @@
lima.action.fullscreen.tip=Passer en mode plein \u00E9cran
lima.action.normalscreen=Ecran normal
lima.action.normalscreen.tip=Revenir en \u00E9cran normal
-lima.add=Ajout
+lima.add=
lima.add.entry=Ajouter une entr\u00E9e
-lima.add.lettering=Ajouter une lettre
-lima.add.transaction=Ajouter une transaction
+lima.add.lettering=
+lima.add.transaction=
lima.all=Tous
lima.all.criteria=Tous les crit\u00E8res correspondent
lima.amount=Montant
-lima.any.criteria=Au moins un critcre correspond
+lima.any.criteria=Au moins un crit\u00E8re correspond
lima.balance=Balance
lima.balance.account.libelle=Libell\u00E9
lima.balance.account.number=N\u00B0 de compte
@@ -37,17 +41,27 @@
lima.bilan.passif=Passif
lima.bilan.total=Total
lima.block=Bloquer
-lima.cancel=Annuler
+lima.cancel=
lima.charge=Charge
+lima.chartofaccounts=Plan des comptes
+lima.chartofaccounts.journal=Journal
+lima.chartofaccounts.management=Gestion du plan
lima.closure.period.begin=P\u00E9riode de
lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode.
+lima.common.add=Ajout
+lima.common.cancel=Annuler
+lima.common.ok=OK
+lima.common.remove=Supprimer
+lima.common.update=Modifier
lima.config.category.directories=R\u00E9pertoires
lima.config.category.directories.description=R\u00E9pertoires utilis\u00E9s par Lima
lima.config.category.other=Autre
lima.config.category.other.description=Autre propri\u00E9t\u00E9s de configuration
lima.config.configFileName.description=
lima.config.locale.description=Locale utilis\u00E9e par l'application
+lima.config.ui.flaunchui.description=
lima.config.ui.fullscreen=Drapeau pour utiliser le mode plein \u00E9cran
+lima.config.ui.fullscreen.description=
lima.credit=Credit
lima.daily=Quotidien
lima.date=Date
@@ -67,7 +81,13 @@
lima.description=Description
lima.edit=Editer
lima.edit.transaction=Editer une transaction
-lima.entries=Lignes d'\u00E9criture
+lima.entries=Op\u00E9ration de Saisie
+lima.entries.addtransaction=Ajouter une transaction
+lima.entries.lettering=Ajouter une lettre
+lima.entries.searchtransaction=Recherche les transactions
+lima.entrybook.description=Description
+lima.entrybook.label=Libelle
+lima.entrybook.prefix=Pr\u00E9fixe
lima.error=Erreur
lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte
lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas
@@ -75,6 +95,8 @@
lima.error.account.with.entries=Ce compte poss\u00E8de des entr\u00E9es comptables
lima.error.entry.not.exist=
lima.error.entry.not.remove=
+lima.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html>
+lima.error.errorpane.title=Lima erreur
lima.error.journal.double=Un journal poss\u00E8de d\u00E9j\u00E0 ce nom
lima.error.journal.not.exist=Ce journal n'existe pas
lima.error.journal.with.transactions=Ce journal poss\u00E8de des transactions comptables
@@ -108,6 +130,11 @@
lima.filter.not.contains=Ne contient pas
lima.filter.starts.with=Commence par
lima.find.transaction=Rechercher transaction
+lima.fiscalyear=Exercice comptable
+lima.fiscalyear.addperiod=Ajouter une p\u00E9riode
+lima.fiscalyear.closefiscalyear=Cl\u00F4turer l'exercice
+lima.fiscalyear.closeperiod=Cl\u00F4turer une p\u00E9riode
+lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures
lima.grand.livre=Grand-Livre
lima.home=Page d'accueil - TODO
lima.import=Import
@@ -120,6 +147,7 @@
lima.import.success=Vos donn\u00E9es ont bien \u00E9t\u00E9 charg\u00E9es
lima.init.closed=Lima ferm\u00E9 \u00E0 %1$s
lima.init.context.done=Initialisation du context termin\u00E9 en %1$s
+lima.init.errorclosing=
lima.init.ui.done=Initialisation des interface graphiques termin\u00E9e
lima.journal=Journal
lima.lettered=Lettr\u00E9
@@ -133,13 +161,11 @@
lima.menu.help.i18n.fr=Fran\u00E7ais
lima.menu.help.i18n.uk=Anglais
lima.menu.help.site=Acc\u00E9der au site de Lima
-lima.menubar.closure=Cl\u00F4ture
-lima.menubar.closure.addPeriod=Ajouter une p\u00E9riode
-lima.menubar.closure.listperiod=Voir toutes les cl\u00F4tures
-lima.menubar.closure.period=Cl\u00F4turer l'exercice
-lima.menubar.closure.timespan=Cl\u00F4turer une p\u00E9riode
+lima.menubar.closure.addPeriod=
lima.message.config.loaded=
lima.message.error.empty.line=Veuillez choisir un compte
+lima.message.help.usage=
+lima.misc.supportemail.description=
lima.model.account=Compte
lima.model.balance=Balance
lima.model.credit=Cr\u00E9dit
@@ -158,13 +184,20 @@
lima.non.valids.transactions=Ecritures non valides
lima.not.lettered=Non lettr\u00E9
lima.number=Num\u00E9ro
-lima.ok=OK
+lima.ok=
lima.passif=Passif
lima.period=P\u00E9riode
+lima.period.addFiscalPeriod=Nouvel exercice
+lima.period.begindate=D\u00E9but de l'exercice \:
+lima.period.block=Bloquer l'exercice
lima.period.close=Ferm\u00E9
+lima.period.enddate=Fin de l'exercice \:
+lima.period.filter=Filtre
+lima.period.menu=Exercice
lima.period.open=Ouvert
+lima.period.periodFilterLabel=Exercice
lima.preferences=Pr\u00E9f\u00E9rences
-lima.prefix=Prefixe
+lima.prefix=Pr\u00E9fixe
lima.print=Imprimer
lima.produit=Produit
lima.progressBar.export.etape1=Cr\u00E9ation base du fichier
@@ -187,7 +220,7 @@
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
lima.quit=Quitter
-lima.remove=Supprimer
+lima.remove=
lima.remove.lettering=Supprimer la lettre
lima.remove.transaction=Supprimer une transaction
lima.reports=Rapports
@@ -211,10 +244,10 @@
lima.tab.account=Compte
lima.tab.balance=Balance
lima.tab.bilan=Bilan
-lima.tab.closure=Cl\u00F4ture
lima.tab.home=Accueil
lima.tab.journal=Journal
lima.tab.lettering=Lettrage
+lima.tab.period=Exercice
lima.tab.reports=Rapports
lima.tab.result=Compte de r\u00E9sultat
lima.tab.search.result=Recherche
@@ -222,6 +255,8 @@
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
lima.to=A
+lima.transaction.entrybook=Journal
+lima.transaction.period=
lima.ui.add.account=Ajouter un compte
lima.ui.add.journal=Ajouter un journal
lima.ui.block.timespan=Bloquer une p\u00E9riode mensuelle
@@ -229,7 +264,7 @@
lima.ui.update.account=Mettre \u00E0 jour le compte
lima.ui.update.journal=Mettre \u00E0 jour le journal
lima.unblock=D\u00E9bloquer
-lima.update=Mettre \u00E0 jour
+lima.update=
lima.view=Vue
lima.view.flatten=Vue aplatie
lima.voucher=Document
1
0
r2827 - trunk/lima-swing/src/main/java/org/chorem/lima/service
by echatellier@users.chorem.org 02 Apr '10
by echatellier@users.chorem.org 02 Apr '10
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:02:21 +0200 (Fri, 02 Apr 2010)
New Revision: 2827
Log:
La factory des services supporte maintenant tous les services
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-02 17:01:48 UTC (rev 2826)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-02 17:02:21 UTC (rev 2827)
@@ -1,5 +1,5 @@
-/* *##%
- * Copyright (C) 2010 Code Lutin, Chatellier Eric
+/* *##% Lima Swing
+ * Copyright (C) 2008 - 2010 CodeLutin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
+ * ##%*/
package org.chorem.lima.service;
@@ -31,8 +31,12 @@
import org.apache.openejb.assembler.classic.Assembler;
import org.apache.openejb.loader.SystemInstance;
import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.ejb.JournalServiceImpl;
-import org.chorem.lima.business.ejb.PeriodServiceImpl;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.FinancialPeriodService;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.RecordService;
+import org.chorem.lima.business.TransactionService;
+import org.chorem.lima.business.ejb.EntryBookServiceImpl;
/**
* Is class is a service factory based on embedded openejb container.
@@ -42,6 +46,13 @@
* <li>http://openejb.apache.org/embedding-openejb.html</li>
* </ul>
*
+ * Elle est pour l'instant statique en attendant mieux.
+ *
+ * Toutes les méthodes utilisent, <ServiceName>ImplLocal comme nom local
+ * (convention openejb) c'est donc plus factorisable que le code actuel.
+ * Mais il vaudrait mieux essayer en distant pour verifier si
+ * la factorisation est similaire.
+ *
* @author chatellier
* @version $Revision$
*
@@ -60,10 +71,11 @@
/**
* Init openejb jndi context.
*/
- public LimaServiceFactory() {
- Properties properties = new Properties();
+ protected LimaServiceFactory() {
// embedded server
+ // TODO put this in configuration
+ Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory");
try {
@@ -105,10 +117,10 @@
// PortableRemoteObject.narrow(obj, FooHome.class);
// TODO put lookup name in configuration
- String lookupName = AccountService.class.getName().replace('.', '/');
+ String lookupName = "AccountServiceImplLocal";
AccountService ejbHome = null;
try {
- ejbHome = (AccountService)ctx.lookup("AccountServiceImplLocal");
+ ejbHome = (AccountService)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
@@ -122,7 +134,7 @@
*
* @return account service proxy
*/
- public JournalServiceImpl getJournalService() {
+ public EntryBookServiceImpl getJournalService() {
// first way is
// FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
@@ -133,10 +145,10 @@
// PortableRemoteObject.narrow(obj, FooHome.class);
// TODO put lookup name in configuration
- String lookupName = JournalServiceImpl.class.getName().replace('.', '/');
- JournalServiceImpl ejbHome = null;
+ String lookupName = "JournalServiceImplLocal";
+ EntryBookServiceImpl ejbHome = null;
try {
- ejbHome = (JournalServiceImpl)ctx.lookup("JournalServiceImplLocal");
+ ejbHome = (EntryBookServiceImpl)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
@@ -146,11 +158,11 @@
}
/**
- * Get Journal service.
+ * Get FiscalPeriod service.
*
- * @return account service proxy
+ * @return fiscalPeriod service proxy
*/
- public PeriodServiceImpl getPeriodService() {
+ public FiscalPeriodService getFiscalPeriodService() {
// first way is
// FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
@@ -161,10 +173,10 @@
// PortableRemoteObject.narrow(obj, FooHome.class);
// TODO put lookup name in configuration
- String lookupName = PeriodServiceImpl.class.getName().replace('.', '/');
- PeriodServiceImpl ejbHome = null;
+ String lookupName = "FiscalPeriodServiceImplLocal";
+ FiscalPeriodService ejbHome = null;
try {
- ejbHome = (PeriodServiceImpl)ctx.lookup("PeriodServiceImplLocal");
+ ejbHome = (FiscalPeriodService)ctx.lookup(lookupName);
} catch (NamingException eee) {
if (log.isErrorEnabled()) {
log.error("Can't lookup for service : " + lookupName, eee);
@@ -174,6 +186,118 @@
}
/**
+ * Get FinancialPeriod service.
+ *
+ * @return fiscalPeriod service proxy
+ */
+ public FinancialPeriodService getFinancialPeriodService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = "FinancialPeriodServiceImplLocal";
+ FinancialPeriodService ejbHome = null;
+ try {
+ ejbHome = (FinancialPeriodService)ctx.lookup(lookupName);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get transaction service.
+ *
+ * @return transaction service proxy
+ */
+ public TransactionService getTransactionService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = "TransactionServiceImplLocal";
+ TransactionService ejbHome = null;
+ try {
+ ejbHome = (TransactionService)ctx.lookup(lookupName);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get transaction service.
+ *
+ * @return transaction service proxy
+ */
+ public EntryBookService getEntryBookService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = "EntryBookServiceImplLocal";
+ EntryBookService ejbHome = null;
+ try {
+ ejbHome = (EntryBookService)ctx.lookup(lookupName);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
+ * Get record service.
+ *
+ * @return record service proxy
+ */
+ public RecordService getRecordService() {
+
+ // first way is
+ // FooHome ejbHome = (FooHome)new InitialContext().lookup("java:openejb/ejb/my/bean/Foo");
+
+ // second way is (spec compliant)
+ // Object obj = ctx.lookup("my/bean/Foo");
+ // FooHome ejbHome = (FooHome)
+ // PortableRemoteObject.narrow(obj, FooHome.class);
+
+ // TODO put lookup name in configuration
+ String lookupName = "RecordServiceImplLocal";
+ RecordService ejbHome = null;
+ try {
+ ejbHome = (RecordService)ctx.lookup(lookupName);
+ } catch (NamingException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't lookup for service : " + lookupName, eee);
+ }
+ }
+ return ejbHome;
+ }
+
+ /**
* Destroy openejb jndi context.
*
* Code taken from openEJB faq :
1
0
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:01:48 +0200 (Fri, 02 Apr 2010)
New Revision: 2826
Log:
Import/export code is now in business.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/imports/
1
0
02 Apr '10
Author: echatellier
Date: 2010-04-02 19:01:38 +0200 (Fri, 02 Apr 2010)
New Revision: 2825
Log:
Import/export code is now in business.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/export/
1
0
r2824 - in trunk/lima-business: . src/main/java/org/chorem/lima/business src/main/java/org/chorem/lima/business/ejb src/main/java/org/chorem/lima/business/ejb/csv src/main/java/org/chorem/lima/business/ejb/xml src/main/java/org/chorem/lima/business/utils src/main/resources src/test/java/org/chorem/lima/business src/test/resources
by echatellier@users.chorem.org 02 Apr '10
by echatellier@users.chorem.org 02 Apr '10
02 Apr '10
Author: echatellier
Date: 2010-04-02 18:55:19 +0200 (Fri, 02 Apr 2010)
New Revision: 2824
Log:
Fin de la structure des ejb (interface/impl) mais sans contenu
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVExport.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImport.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImportEBP.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLExport.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLImport.java
trunk/lima-business/src/test/resources/log4j.properties
Removed:
trunk/lima-business/src/main/java/org/chorem/lima/business/dto/
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java
trunk/lima-business/src/main/resources/log4j.properties
Modified:
trunk/lima-business/pom.xml
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
trunk/lima-business/src/main/resources/lima.properties
trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java
Modified: trunk/lima-business/pom.xml
===================================================================
--- trunk/lima-business/pom.xml 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/pom.xml 2010-04-02 16:55:19 UTC (rev 2824)
@@ -33,10 +33,6 @@
<artifactId>nuiton-utils</artifactId>
</dependency>
<dependency>
- <groupId>javax.time</groupId>
- <artifactId>jsr-310-ri</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
</dependency>
@@ -62,6 +58,12 @@
<!-- Temp disable -->
<showDeprecation>false</showDeprecation>
<showWarnings>true</showWarnings>
+
+ <!-- XML/CSV import export don't compile for now -->
+ <excludes>
+ <exclude>**/*Import*.java</exclude>
+ <exclude>**/*Export*.java</exclude>
+ </excludes>
</configuration>
</plugin>
</plugins>
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,5 +1,5 @@
-/* *##%
- * Copyright (C) 2010 Code Lutin, Chatellier Eric
+/* *##% Lima Business
+ * 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
@@ -14,7 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
+ * ##%*
+ */
package org.chorem.lima.business;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,44 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.chorem.lima.entity.EntryBook;
+
+/**
+ * Entry book service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface EntryBookService {
+
+ List<EntryBook> getAllEntryBooks() throws LimaException;
+
+ void createEntryBook(EntryBook entryBook) throws LimaException;
+
+ void updateEntryBook(EntryBook entryBook) throws LimaException;
+
+ void removeEntryBook(EntryBook entryBook) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,46 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.chorem.lima.entity.FinancialPeriod;
+
+/**
+ * Financial period service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface FinancialPeriodService {
+
+ List<FinancialPeriod> getAllFinancialPeriods() throws LimaException;
+
+ List<FinancialPeriod> getNonLockedFinancialPeriods() throws LimaException;
+
+ void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException;
+
+ //void updateFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException;
+
+ //void removeFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,44 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.chorem.lima.entity.FiscalPeriod;
+
+/**
+ * Fiscal period service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface FiscalPeriodService {
+
+ List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
+
+ void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ //void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ //void removeFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/FiscalPeriodService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,84 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+/**
+ * Import export service.
+ *
+ * Currently import and export as XML.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface ImportExportService {
+
+ /**
+ * Get database export as xml.
+ *
+ * For now it's use byte[] to be {@link java.io.Serializable}. InputStream
+ * nor file is allowed.
+ *
+ * TODO find a better solution than byte[]
+ *
+ * @return export as byte array
+ * @throws LimaException
+ */
+ byte[] exportAsXML() throws LimaException;
+
+ /**
+ * Import xml data into database.
+ *
+ * For now it's use byte[] to be {@link java.io.Serializable}. InputStream
+ * nor file is allowed.
+ *
+ * TODO find a better solution than byte[]
+ *
+ * @param data xml data as byte array
+ * @throws LimaException
+ */
+ void importAsXML(byte[] data) throws LimaException;
+
+ /**
+ * Get database export as CSV;
+ *
+ * @return export as byte array
+ * @throws LimaException
+ */
+ byte[] exportAsCSV() throws LimaException;
+
+ /**
+ * Import data as CSV into database.
+ *
+ * @param data data to import (CSV)
+ * @throws LimaException
+ */
+ void importAsCSV(byte[] data) throws LimaException;
+
+ /**
+ * Import data as EBP CSV export.
+ *
+ * @param data
+ * @throws LimaException
+ */
+ void importAsEbpCSV(byte[] data) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportExportService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaBusinessException.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,19 +1,20 @@
-/* *##% Lima
- * Copyright (C) 2010 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaConfig.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,5 +1,5 @@
-/* *##%
- * Copyright (C) 2010 Code Lutin, Chatellier Eric
+/* *##% Lima Business
+ * 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
@@ -14,7 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
+ * ##%*
+ */
package org.chorem.lima.business;
@@ -25,8 +26,10 @@
import org.nuiton.util.ArgumentsParserException;
/**
- * TODO add comment here.
+ * Configuration pour le business.
*
+ * A voir comment le lier avec celui de lima main.
+ *
* @author chatellier
* @version $Revision$
*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaException.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,19 +1,20 @@
-/* *##% Lima
- * Copyright (C) 2010 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business;
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,42 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+/**
+ * Fiscal period service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface RecordService {
+
+ //List<FiscalPeriod> getAllFiscalPeriods() throws LimaException;
+
+ //void createFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ //void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+
+ //void removeFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/RecordService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,50 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+/**
+ * Service de generation des rapports.
+ *
+ * Actuellement:
+ * <ul>
+ * <li>Balance</li>
+ * <li>Bilan</li>
+ * </ul>
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface ReportService {
+
+
+ /**
+ * Generation du bilan.
+ *
+ * @param period
+ * @return
+ * @throws LimaException
+ */
+ String generateBalanceSheet(String period) throws LimaException;
+
+
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,44 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business;
+
+import java.util.List;
+
+import org.chorem.lima.entity.Transaction;
+
+/**
+ * Transaction service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public interface TransactionService {
+
+ //List<Transaction> getAllTransactions() throws LimaException;
+
+ //void createTransaction(Transaction transaction) throws LimaException;
+
+ //void updateTransaction(Transaction transaction) throws LimaException;
+
+ //void removeTransaction(Transaction transaction) throws LimaException;
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/TransactionService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AbstractLimaService.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,5 +1,5 @@
-/* *##%
- * Copyright (C) 2010 Code Lutin, Chatellier Eric
+/* *##% Lima Business
+ * 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
@@ -14,7 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
+ * ##%*
+ */
package org.chorem.lima.business.ejb;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,20 +1,20 @@
-/*
- * *##% Callao AccountServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
@@ -93,6 +93,9 @@
throw new LimaBusinessException("Invalid AccountNumber : " + account.getAccountNumber());
}
+ // TODO verifier que le numero de compte du fils commence par celui du pere
+ // (peut etre trop specific à la compta francaise)
+
TopiaContext transaction = null;
try {
// basic check done, make check in database
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,20 +1,20 @@
-/*
- * *##% Callao EntryBookServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
@@ -24,8 +24,11 @@
import java.util.ArrayList;
import java.util.List;
+import javax.ejb.Stateless;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
@@ -33,7 +36,6 @@
import org.chorem.lima.entity.EntryBookDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.Transaction;
-import org.chorem.lima.entity.TransactionDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -45,12 +47,15 @@
*
* @author Rémi Chapelet
*/
-public class EntryBookServiceImpl {
+@Stateless
+public class EntryBookServiceImpl extends AbstractLimaService implements EntryBookService {
private static final Log log = LogFactory.getLog(EntryBookServiceImpl.class);
private TopiaContext rootContext;
+ protected TransactionServiceImpl transactionService = new TransactionServiceImpl();
+
//private ConvertEntryBook convertEntryBook = new ConvertEntryBook();
public EntryBookServiceImpl() {
@@ -70,7 +75,7 @@
* @param EntryBook EntryBook
* @throws LimaException
*/
- public void createEntryBook(EntryBook EntryBook) throws LimaException {
+ public void createEntryBook(EntryBook entryBook) throws LimaException {
/*String result = ServiceHelper.RESPOND_ERROR;
try {
// Acces BDD
@@ -113,60 +118,27 @@
transaction = rootContext.beginTransaction();
// test si un EntryBook de ce nom existe deja
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
- EntryBook existingEntryBook = EntryBookDAO.findByLabel(EntryBook.getLabel());
+ EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBook existingEntryBook = entryBookDAO.findByLabel(entryBook.getLabel());
if (existingEntryBook != null) {
- throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", EntryBook.getLabel()));
+ throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", entryBook.getLabel()));
}
// creation du EntryBook
- EntryBookDAO.create(EntryBook);
+ entryBookDAO.create(entryBook);
// commit
transaction.commitTransaction();
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
+ doCatch(transaction, ex, log);
}
finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
- }
- }
+ doFinally(transaction, log);
}
}
- /*
- * Création d'un EntryBook à partir de son DTO.
- * @param EntryBookDTO EntryBook au format DTO.
- * @return
- *
- public String createEntryBook(EntryBookDTO EntryBookDTO) {
- String result;
- result = createEntryBook(EntryBookDTO.getLabel(), EntryBookDTO.getPrefix(),
- EntryBookDTO.getDescription());
- return result;
- }*/
-
- public List<EntryBook> getAllEntryBook() throws LimaException {
+ public List<EntryBook> getAllEntryBooks() throws LimaException {
/*List<EntryBookDTO> listEntryBookDTO = new ArrayList<EntryBookDTO>();
try {
@@ -208,31 +180,10 @@
transaction.commitTransaction();
}
catch (TopiaException ex) {
- if (transaction != null) {
- try {
- transaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
+ doCatch(transaction, ex, log);
}
finally {
- if (transaction != null) {
- try {
- transaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
- }
- }
+ doFinally(transaction, log);
}
return EntryBooksList;
@@ -310,45 +261,39 @@
return EntryBookDTO;
}*/
- /*
- * Permet de modifier un EntryBook.
- * @param label
- * @param prefix
- * @return
- *
- public String modifyEntryBook(String topiaId, String label, String prefix,
- String description) {
- String result = ServiceHelper.RESPOND_ERROR;
- EntryBook EntryBookModify = searchEntryBookWithTopiaId(topiaId);
- // Si le EntryBook n'existe pas
- if (EntryBookModify == null) {
- if (log.isWarnEnabled()) {
- log.warn("Le EntryBook " + label + " n'existe pas !");
+ /**
+ * Permet de modifier un journal.
+ *
+ * @param entryBook journal
+ * @throws LimaException
+ */
+ public void updateEntryBook(EntryBook entryBook) throws LimaException {
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // test si un EntryBook de ce nom existe deja
+ EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction);
+ EntryBook existingEntryBook = entryBookDAO.findByLabel(entryBook.getLabel());
+ if (existingEntryBook != null) {
+ throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", entryBook.getLabel()));
}
- result = ServiceHelper.EntryBook_NOT_EXIST;
- } else // Sinon on modifie le EntryBook
- {
- try {
- // Acces BDD
- TopiaContext topiaContext = rootContext.beginTransaction();
- // Chargement du DAO
- EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper
- .getEntryBookDAO(topiaContext);
- // Modifie le EntryBook
- EntryBookModify.setPrefix(prefix);
- EntryBookModify.setDescription(description);
- EntryBookDAO.update(EntryBookModify);
- // Création BDD
- topiaContext.commitTransaction();
- // Fermeture BDD
- topiaContext.closeContext();
- result = ServiceHelper.RESPOND_SUCCESS;
- } catch (TopiaException e) {
- log.error(e);
- }
+
+ // creation du EntryBook
+ entryBookDAO.update(entryBook);
+
+ // commit
+ transaction.commitTransaction();
}
- return result;
- }*/
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+ }
/**
* Permet d'effacer un EntryBook dans la base de données.
@@ -360,7 +305,7 @@
* @return
* @throws LimaException
*/
- public void removeEntryBook(EntryBook EntryBook) throws LimaException {
+ public void removeEntryBook(EntryBook entryBook) throws LimaException {
/*String result = ServiceHelper.RESPOND_ERROR;
EntryBook EntryBookDelete = searchEntryBookWithTopiaId(topiaId);
// Si le EntryBook n'existe pas
@@ -408,7 +353,7 @@
}
}
return result;*/
-
+
TopiaContext topiaTransaction = null;
try {
// basic check done, make check in database
@@ -416,58 +361,23 @@
topiaTransaction = rootContext.beginTransaction();
// Vérifie si une transaction n'appartient pas à ce EntryBook.
- TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
- Transaction transaction = transactionDAO.findByEntryBook(EntryBook);
+ Transaction transaction = transactionService.findByEntryBook(topiaTransaction, entryBook);
if (transaction != null) {
throw new LimaBusinessException("Can't delete EntryBook with transactions");
}
// test si un EntryBook de ce nom existe deja
EntryBookDAO EntryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(topiaTransaction);
- EntryBookDAO.delete(EntryBook);
+ EntryBookDAO.delete(entryBook);
// commit
topiaTransaction.commitTransaction();
}
catch (TopiaException ex) {
- if (topiaTransaction != null) {
- try {
- topiaTransaction.rollbackTransaction();
- } catch (TopiaException e) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- }
- }
- if (log.isErrorEnabled()) {
- log.error("Error during create account", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
+ doCatch(topiaTransaction, ex, log);
}
finally {
- if (topiaTransaction != null) {
- try {
- topiaTransaction.closeContext();
- } catch (TopiaException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error during rollback context", ex);
- }
- throw new LimaException("Can't create EntryBook", ex);
- }
- }
+ doFinally(topiaTransaction, log);
}
}
-
- /*
- * Permet d'effacer un EntryBook dans la base de données.
- * ATTENTION : si un EntryBook est associé avec des transactions, il est alors
- * impossible de supprimer celui-ci.
- * @param EntryBookDTO EntryBook au format DTO à supprimer
- * @return
- *
- public String removeEntryBook(EntryBookDTO EntryBookDTO) {
- String result = removeEntryBook(EntryBookDTO.getId());
- return result;
- }*/
-
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,20 +1,20 @@
-/*
- * *##% Callao EntryServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,49 +1,32 @@
-/*
- * *##% Callao FilesServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.AccountDTO;
-import org.chorem.lima.business.dto.EntryDTO;
-import org.chorem.lima.business.dto.JournalDTO;
-import org.chorem.lima.business.dto.PeriodDTO;
-import org.chorem.lima.business.dto.TimeSpanDTO;
-import org.chorem.lima.business.dto.TransactionDTO;
import org.chorem.lima.business.utils.DateUtil;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.jdom.Attribute;
+import org.chorem.lima.entity.Account;
import org.jdom.Document;
import org.jdom.Element;
-import org.jdom.JDOMException;
-import org.jdom.input.SAXBuilder;
-import org.jdom.output.Format;
-import org.jdom.output.XMLOutputter;
-import org.jdom.xpath.XPath;
-import org.nuiton.topia.TopiaContext;
/**
* Cette classe permet d'importer et exporter des données comptables. Ces données
@@ -318,7 +301,7 @@
* @param listAccountDTO
* @param accounts
*/
- protected void accountXML(List<AccountDTO> listAccountDTO, Element accounts) {
+ protected void accountXML(List<Account> listAccount, Element accounts) {
/*for (AccountDTO accountDTO : listAccountDTO) {
Element account = new Element("account");
accounts.addContent(account);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,30 +1,39 @@
-/*
- * *##% Callao TimeSpanServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
+import java.util.List;
+
+import javax.ejb.Stateless;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialPeriodDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
/**
@@ -33,7 +42,8 @@
*
* @author Rémi Chapelet
*/
-public class FinancialPeriodServiceImpl { //implements TimeSpanService {
+@Stateless
+public class FinancialPeriodServiceImpl extends AbstractLimaService implements FinancialPeriodService {
/** log */
private static final Log log = LogFactory.getLog(FinancialPeriodServiceImpl.class);
@@ -61,8 +71,9 @@
* @param locked est à vrai si la période doit être bloquée.
* @return
*/
- public void createTimeSpan(FinancialPeriod timeSpan /*Date beginTimeSpan, Date endTimeSpan,
- Period period, boolean locked*/) {
+ @Override
+ public void createFinancialPeriod(FinancialPeriod financialPeriod /*Date beginTimeSpan, Date endTimeSpan,
+ Period period, boolean locked*/) throws LimaException {
/*
// timeSpan correspond à une période mensuelle.
// La fonction va donc prendre seulement pour date de référence la
@@ -101,8 +112,94 @@
log.error(e);
return ServiceHelper.RESPOND_ERROR;
}*/
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ createFinancialPeriod(transaction, financialPeriod);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
}
+ /**
+ * Create a financial period with an opened transaction.
+ *
+ * @param transaction opened transaction
+ * @param financialPeriod financial period
+ * @throws TopiaException
+ */
+ protected void createFinancialPeriod(TopiaContext transaction, FinancialPeriod financialPeriod) throws TopiaException {
+
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ financialPeriodDAO.create(financialPeriod);
+
+ }
+
+ @Override
+ public List<FinancialPeriod> getAllFinancialPeriods() throws LimaException {
+
+ List<FinancialPeriod> result = null;
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ result = financialPeriodDAO.findAll();
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return result;
+ }
+
+ @Override
+ public List<FinancialPeriod> getNonLockedFinancialPeriods() throws LimaException {
+
+ List<FinancialPeriod> result = null;
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.getFinancialPeriodDAO(transaction);
+ result = financialPeriodDAO.findAllByLocked(false);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return result;
+ }
+
/*
* Permet de trouver un timespan directement avec une date. La date peut
* être quelconque. Exemple : d = 17 sept 2000, renvoie la période du
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,30 +1,43 @@
-/*
- * *##% Callao PeriodServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.ejb.Stateless;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
+import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.entity.FiscalPeriodDAO;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
+import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
/**
@@ -34,13 +47,14 @@
*
* @author Rémi Chapelet
*/
-public class FiscalPeriodServiceImpl { //implements PeriodService {
+@Stateless
+public class FiscalPeriodServiceImpl extends AbstractLimaService implements FiscalPeriodService {
private static final Log log = LogFactory.getLog(FiscalPeriodServiceImpl.class);
private TopiaContext rootContext;
- private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
+ private FinancialPeriodServiceImpl financialPeriodService = new FinancialPeriodServiceImpl();
public FiscalPeriodServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -54,16 +68,23 @@
}
/**
- * Permet de créer une période principale. Elle a une durée de un an,
- * composées de 12 périodes mensuelles. Elle correspond à l'exercice
- * comptable. Pour créer une nouvelle période, la précédente doit être
- * obligatoirement clôturée.
+ * Permet de créer un exercice.
+ *
+ * Elle a une durée de un an, composées de 12 périodes mensuelles.
+ * Elle peut aussi être plus courte ou plus longue si l'entreprise
+ * se constitu ou entre en liquidation ou que l'entreprise decide
+ * de changer
+ *
+ * Elle correspond à l'exercice comptable.
+ * Pour créer une nouvelle période, la précédente doit être obligatoirement clôturée.
+ *
* @param beginTimeSpan date début de période
* @param endTimeSpan date fin de période
* @param lock Vrai si la période est bloquée
* @return
*/
- public void createPeriod(FinancialPeriod period /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) {
+ @Override
+ public void createFiscalPeriod(FiscalPeriod fiscalPeriod /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) throws LimaException {
/*// Par défaut lock est à false
lock = false;
String result = ServiceHelper.RESPOND_ERROR;
@@ -127,8 +148,72 @@
log.error(e);
}
return result; */
+
+ // un exercice ne peut pas faire plus de 24 mois dans tous les cas
+
+ // un exercice doit faire au moins une période
+ if ( fiscalPeriod.getFinancialPeriod() == null ||
+ fiscalPeriod.getFinancialPeriod().isEmpty()) {
+ throw new LimaBusinessException(_("A fiscal period must have at least one financial period !"));
+ }
+
+ // un exercice doit être collé au precedent
+
+ // un exercice ne peut être crée que si l'anti precedent est fermé
+ // on peut creer un exercice si le precedent n'est pas fermé
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ // TODO maybe put this in antoher place
+ for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) {
+ financialPeriodService.createFinancialPeriod(transaction, financialPeriod);
+ }
+
+ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ fiscalPeriodDAO.create(fiscalPeriod);
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
}
+ public List<FiscalPeriod> getAllFiscalPeriods() throws LimaException {
+
+ List<FiscalPeriod> result = null;
+
+ TopiaContext transaction = null;
+ try {
+ // basic check done, make check in database
+ // TODO move it into JTA
+ transaction = rootContext.beginTransaction();
+
+ FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
+ result = fiscalPeriodDAO.findAll();
+
+ // commit
+ transaction.commitTransaction();
+ }
+ catch (TopiaException ex) {
+ doCatch(transaction, ex, log);
+ }
+ finally {
+ doFinally(transaction, log);
+ }
+
+ return result;
+ }
+
/*
* Permet de créer une période à partir d'une période DTO.
* @param periodDTO période à créer au format DTO.
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,120 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
+package org.chorem.lima.business.ejb;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.ejb.Stateless;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.ImportExportService;
+import org.chorem.lima.business.LimaException;
+
+/**
+ * XML and CSV import export service.
+ *
+ * TODO maybe split this impl into different XML and CSV impl.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+@Stateless
+public class ImportExportServiceImpl implements ImportExportService {
+
+ private static final Log log = LogFactory.getLog(ImportExportServiceImpl.class);
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#exportAsXML()
+ */
+ @Override
+ public byte[] exportAsXML() throws LimaException {
+
+ byte[] data = null;
+ ByteArrayOutputStream byteArrayOutputStream = null;
+ try {
+ byteArrayOutputStream = new ByteArrayOutputStream();
+ exportAsXML(byteArrayOutputStream);
+ }
+ catch (IOException eee) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't export as xml", eee);
+ }
+ throw new LimaException("Can't export as xml", eee);
+ }
+ finally {
+ IOUtils.closeQuietly(byteArrayOutputStream);
+ }
+
+ if (byteArrayOutputStream != null) {
+ data = byteArrayOutputStream.toByteArray();
+ }
+
+ return data;
+ }
+
+ /**
+ * Do real output into a simple {@link OutputStream}.
+ *
+ * @param output
+ * @throws IOException
+ */
+ protected void exportAsXML(OutputStream output) throws IOException {
+
+ }
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#importAsXML(byte[])
+ */
+ @Override
+ public void importAsXML(byte[] data) {
+
+ }
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#exportAsCSV()
+ */
+ @Override
+ public byte[] exportAsCSV() throws LimaException {
+ return null;
+ }
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#importAsCSV(byte[])
+ */
+ @Override
+ public void importAsCSV(byte[] data) throws LimaException {
+
+ }
+
+ /*
+ * @see org.chorem.lima.business.ImportExportService#importAsEBPCSV(byte[])
+ */
+ @Override
+ public void importAsEbpCSV(byte[] data) throws LimaException {
+
+ }
+}
Property changes on: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportExportServiceImpl.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/RecordServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,20 +1,20 @@
-/*
- * *##% Callao LogServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
@@ -22,12 +22,15 @@
import java.util.ArrayList;
import java.util.List;
+import javax.ejb.Stateless;
+
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.RecordService;
+import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.Record;
import org.chorem.lima.entity.RecordDAO;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
@@ -40,7 +43,8 @@
*
* @author Rémi Chapelet
*/
-public class RecordServiceImpl { //implements LogService {
+@Stateless
+public class RecordServiceImpl implements RecordService {
/** log */
private static final org.apache.commons.logging.Log log = LogFactory
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,61 +1,57 @@
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
+ */
+
package org.chorem.lima.business.ejb;
-import org.nuiton.topia.TopiaContext;
+import javax.ejb.Stateless;
-public class ReportServiceImpl { //implements ReportService {
+import org.chorem.lima.business.ReportService;
- //@Override
+@Stateless
+public class ReportServiceImpl implements ReportService {
+
public String generateAccount(String number, String amount, String label) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
+ public String generateBalanceTrial(String period) {
+ return null;
+ }
+
public String generateBalanceSheet(String period) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
public String generateCashFlowStatement(String period) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
public String generateGeneralLedger(String period) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
public String generateIncomeStatement(String period) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
public String generateJournal(String type, String period) {
- // TODO Auto-generated method stub
return null;
}
- //@Override
- public String[] getMethods() {
- // TODO Auto-generated method stub
- return null;
- }
-
- //@Override
- public void destroy() {
- // TODO Auto-generated method stub
-
- }
-
- //@Override
- public void init(TopiaContext arg0) {
- // TODO Auto-generated method stub
-
- }
-
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/TransactionServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,47 +1,39 @@
-/*
- * *##% Callao TransactionServiceImpl
- * Copyright (C) 2009 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
+import javax.ejb.Stateless;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
-import org.chorem.lima.business.dto.EntryDTO;
-import org.chorem.lima.business.dto.LogDTO;
-import org.chorem.lima.business.dto.TransactionDTO;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.business.TransactionService;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
-import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.Transaction;
import org.chorem.lima.entity.TransactionDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
+import org.nuiton.topia.framework.TopiaQuery;
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
@@ -52,18 +44,18 @@
*
* @author Rémi Chapelet
*/
-public class TransactionServiceImpl {
+@Stateless
+public class TransactionServiceImpl implements TransactionService {
- private static final Log log = LogFactory
- .getLog(TransactionServiceImpl.class);
+ private static final Log log = LogFactory.getLog(TransactionServiceImpl.class);
private TopiaContext rootContext;
- private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
+ //private RecordServiceImpl logServiceImpl = new RecordServiceImpl();
- private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
+ //private EntryServiceImpl entryServiceImpl = new EntryServiceImpl();
- private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
+ //private FinancialPeriodServiceImpl timeSpanServiceImpl = new FinancialPeriodServiceImpl();
public TransactionServiceImpl() {
LimaConfig config = LimaConfig.getInstance();
@@ -742,5 +734,26 @@
boolean isTransactionBalanced = debit == credit;
return isTransactionBalanced;
}*/
+
+ /**
+ * Permet de retrouver la premiere transaction associée au journal.
+ *
+ * @param topiaTransaction context à utiliser
+ * @param entryBook journal
+ * @throws TopiaException
+ */
+ protected Transaction findByEntryBook(TopiaContext topiaTransaction, EntryBook entryBook) throws TopiaException {
+ TransactionDAO transactionDAO = LimaCallaoDAOHelper.getTransactionDAO(topiaTransaction);
+
+ TopiaQuery query = transactionDAO.createQuery();
+ // entryBook is not visible, but column "entryBook"
+ // exist in transaction table
+ query.add("entryBook", entryBook);
+
+ Transaction result = transactionDAO.findByQuery(query);
+
+ return result;
+ }
+
}
\ No newline at end of file
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/UserServiceImpl.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,20 +1,20 @@
-/*
- * *##% Callao
- * Copyright (C) 2010 CodeLutin
+/* *##% Lima Business
+ * Copyright (C) 2008 - 2010 CodeLutin
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
+ * GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*
*/
package org.chorem.lima.business.ejb;
@@ -23,12 +23,9 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.chorem.lima.entity.User;
-import org.chorem.lima.entity.UserDAO;
import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaContextFactory;
-import org.nuiton.topia.TopiaException;
import org.nuiton.topia.TopiaNotFoundException;
/**
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVExport.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/export/CSVExport.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVExport.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVExport.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,199 @@
+/**
+ * *##% Lima-Callao CVSImport
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb.csv;
+
+import au.com.bytecode.opencsv.CSVWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FileWriter;
+import java.util.*;
+
+/**
+ * Cette méthode permet d'exporter toutes les données de Lima dans un fichier
+ * au format csv.
+ *
+ * @author Rémi Chapelet
+ */
+public class CSVExport {
+
+ private static final Log log = LogFactory.getLog(CSVExport.class);
+ private CSVWriter csvWriter;
+
+ /**
+ * Création de l'instance CSVWriter avec le fichier en paramètre.
+ * @param path
+ */
+ public CSVExport(String path) {
+ try {
+ File f = new File(path);
+ // Le fichier a pour séparateur ';'
+ csvWriter = new CSVWriter(new FileWriter(f), ';');
+ } catch (IOException e) {
+ log.debug(e);
+ }
+ }
+
+ /**
+ * Permet de retourner l'instance csv du fichier.
+ * @return
+ * @throws java.io.IOException
+ */
+ public CSVWriter getCSVWriter() throws IOException {
+ return csvWriter;
+ }
+
+ /**
+ * Méthode principale qui appelle chaque méthode pour chaque type de données
+ * à enregistrer (journaux, comptes, etc).
+ * @return
+ */
+ public String exportDatas() {
+ String result = ServiceHelper.RESPOND_SUCCESS;
+ /**
+ * Export des données
+ */
+ String[] nextLine = new String[1];
+ // Début période
+ // Sélection la période utilisée actuellement
+ PeriodDTO period = LimaContext.getContext().getDataManager()
+ .getCurrentPeriod();
+ // Si la période courante est une période mensuelle, on récupère la période annuelle
+ if (period.getParent() != null) {
+ period = period.getParent();
+ }
+ nextLine[0] = Util.DateToString(period.getBegin(), "dd/MM/yyyy");
+ csvWriter.writeNext(nextLine);
+ // Fin périod
+ nextLine[0] = Util.DateToString(period.getEnd(), "dd/MM/yyyy");
+ csvWriter.writeNext(nextLine);
+ // Export données
+ exportAccount();
+ exportJournal();
+ exportTransaction();
+ // Ecriture dans le fichier les données dans le tampon
+ try {
+ csvWriter.flush();
+ csvWriter.close();
+ } catch (IOException e) {
+ log.debug(e);
+ result = ServiceHelper.RESPOND_ERROR;
+ }
+ return result;
+ }
+
+ /**
+ * Export des comptes
+ */
+ public void exportAccount() {
+ String[] nextLine = new String[5];
+ // Récupère tous les comptes
+ List<AccountDTO> listAccount = ServiceHelper
+ .getAllFlatAccount(LimaContext.getContext().getDataManager()
+ .getAccountModel().getData());
+ // Pour tous les comptes
+ for (AccountDTO account : listAccount) {
+ nextLine[0] = "C";
+ nextLine[1] = account.getIdNumber();
+ nextLine[2] = account.getDescription();
+ nextLine[3] = account.getType();
+ nextLine[4] = account.getIdSeq();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+
+ /**
+ * Export des journaux
+ */
+ public void exportJournal() {
+ String[] nextLine = new String[5];
+ // Récupère tous les journaux
+ List<JournalDTO> listJournal = LimaContext.getContext()
+ .getDataManager().getJournalModel().getData();
+ // Pour tous les journaux
+ for (JournalDTO journal : listJournal) {
+ nextLine[0] = "J";
+ nextLine[1] = journal.getIdName();
+ nextLine[2] = journal.getPrefix();
+ nextLine[3] = journal.getDescription();
+ nextLine[4] = journal.getIdSeq();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLine);
+ }
+ }
+
+ /**
+ * Export des transactions et entrées comptables
+ */
+ public void exportTransaction() {
+ String[] nextLineTrans = new String[8];
+ String[] nextLineEntry = new String[7];
+ // Récupère toutes les transactions
+ List<TransactionDTO> listTransaction = LimaContext.getContext()
+ .getDataManager().getTransactionModel().getData();
+ // Pour toutes les transactions
+ for (TransactionDTO transaction : listTransaction) {
+ nextLineTrans[0] = "T";
+ nextLineTrans[1] = transaction.getVoucherRef();
+ nextLineTrans[2] = transaction.getDescription().trim();
+ nextLineTrans[3] = transaction.getIdName().trim();
+ nextLineTrans[4] = Util.DateToString(transaction.getEntryDate(),
+ "dd/MM/yyyy");
+ nextLineTrans[5] = transaction.getJournal().getPrefix();
+ nextLineTrans[6] = Util.DateToString(transaction.getPeriod()
+ .getBegin(), "dd/MM/yyyy");
+ nextLineTrans[7] = transaction.getIdSeq();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLineTrans);
+ /**
+ * Ajout des entrées
+ */
+ List<EntryDTO> listEntry = transaction.getEntries();
+ // Pour chaque entrée de la transaction
+ for (EntryDTO entry : listEntry) {
+ nextLineEntry[0] = "E";
+ nextLineEntry[1] = entry.getAccount().getIdNumber();
+ nextLineEntry[2] = entry.getDescription();
+ nextLineEntry[3] = entry.getAmount();
+ nextLineEntry[4] = entry.getLettrage();
+ if (entry.getDebit()) {
+ nextLineEntry[5] = "D";
+ } else {
+ nextLineEntry[5] = "C";
+ }
+ nextLineEntry[6] = entry.getIdSeq();
+ // Ajoute la ligne au fichier
+ csvWriter.writeNext(nextLineEntry);
+ }
+ }
+ }
+
+}
\ No newline at end of file
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImport.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImport.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImport.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImport.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,361 @@
+/**
+ * *##% Lima-Callao CVSImport
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb.csv;
+
+import au.com.bytecode.opencsv.CSVReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.*;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.*;
+
+
+/**
+ * Cette classe permet d'importer un fichier de données au format csv créé
+ * par l'application Lima
+ *
+ * @author Rémi Chapelet
+ */
+public class CSVImport {
+
+ private static final Log log = LogFactory.getLog(CSVImport.class);
+ private CSVReader csvReader;
+ private LinkedList<TransactionDTO> listTransactions= new LinkedList<TransactionDTO>();
+ private TransactionDTO transactionLast = null;
+
+ protected final PeriodService periodService;
+ protected final EntryService entryService;
+ protected final TransactionService transactionService;
+
+ /**
+ * Le constructeur avec en paramètre l'adresse du fichier de données.
+ * @param path
+ */
+ public CSVImport(String path) {
+ try {
+ File f = new File(path);
+ // Le fichier a pour séparateur ';'
+ csvReader = new CSVReader(new FileReader(f), ';');
+ } catch (FileNotFoundException e) {
+ log.debug(e);
+ }
+ // Déclaration des services
+ periodService = ServiceFactory.getServiceFactory().getPeriodService();
+ entryService = ServiceFactory.getServiceFactory().getEntryService();
+ transactionService = ServiceFactory.getServiceFactory().getTransactionService();
+ }
+
+ /**
+ * permet de retourner l'instance csv du fichier.
+ * @return
+ * @throws java.io.FileNotFoundException
+ */
+ public CSVReader getCSVReader() throws FileNotFoundException {
+ return csvReader;
+ }
+
+
+ /**
+ * Fonction principale permettant de lire un fichier au format csv.
+ * Chaque ligne possède un identifiant :
+ * C : compte
+ * J : journal
+ * E : entrée comptable
+ * T : transaction
+ * @return
+ */
+ public String importDatas ()
+ {
+ // Message de retour de la méthode : success ou error
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ /**
+ * Déclaration des variables
+ */
+ // Tableau de chaines correspondant à chaque ligne du fichier qui sera lue.
+ String[] nextLine;
+ // Création account Master
+ // Lima possède un compte principal, numéroté '0'.
+ AccountDTO accountRac = new AccountDTO("0", "0", "Plan comptable", null, new LinkedList<AccountDTO>(), null);
+
+ /**
+ * Lecture des premières lignes du fichier
+ */
+ nextLine = csvReader.readNext(); // Date début période
+ Date beginPeriod = Util.stringToDate(nextLine[0], "dd/MM/yyyy");
+ nextLine = csvReader.readNext(); // Date fin période
+ Date endPeriod = Util.stringToDate(nextLine[0], "dd/MM/yyyy");
+
+ /**
+ * Création de la période : l'exercice comptable avec ses 12 mois.
+ */
+ // Création de l'exercice
+ Date begin = Util.InitDateFirstDayMonth(beginPeriod);
+ Date end = Util.InitDateEndDayMonth(endPeriod);
+ PeriodDTO period = new PeriodDTO("",Integer.toString(begin.getYear()+1900),begin,end,null,null,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "PE_OPEN"));
+ // Création des 12 mois
+ List<PeriodDTO> listPeriodChild = new LinkedList<PeriodDTO>();
+ // Pour chaque mois
+ for (int i=0 ; i<12 ; i++)
+ {
+ Date beginTimeSpan = Util.InitDateFirstDayMonth(new Date(begin.getYear(),begin.getMonth()+i,begin.getDate()));
+ Date endTimeSpan = Util.InitDateEndDayMonth(new Date(begin.getYear(),begin.getMonth()+i,begin.getDate()));
+ // Création période
+ PeriodDTO periodChild = new PeriodDTO("",ServiceHelper.dateToMonth(beginTimeSpan)+" "+(beginTimeSpan.getYear()+1900),beginTimeSpan,endTimeSpan,null,period,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "PE_OPEN"));
+ listPeriodChild.add(periodChild);
+ }
+ // On ajoute les 12 mois à l'exercice
+ period.setChildren(listPeriodChild);
+ // On ajoute la liste des exercices (ici un seul exercice) à Lima
+ LinkedList<PeriodDTO> listPeriod= new LinkedList<PeriodDTO>();
+ listPeriod.add(period);
+ // Ajoute la période dans le service des Périodes
+ periodService.createPeriod(period, LimaContext.getContext().getDataManager().getStatus());
+ // Réinitialise les périodes
+ LimaContext.getContext().getDataManager().resetPeriodes(listPeriod);
+
+ /**
+ * Lecture de chaque ligne
+ * Ajout des comptes, journaux et entrées comptables
+ */
+ boolean endReadAccount = false; // Vrai lorsque tous les comptes sont chargés
+ // Pour chaque ligne
+ while ((nextLine = csvReader.readNext()) != null) {
+ // Lecture de la 1ière cellule
+ String indice = nextLine[0];
+ /**
+ * Compte
+ */
+ if ( indice.equals("C") )
+ {
+ log.debug("Ajout compte "+nextLine[1]);
+ result = importAccount(nextLine,accountRac);
+ }
+ /**
+ * Journal
+ */
+ if ( indice.equals("J") )
+ {
+ // Tous les comtes ont été chargés, on relance pour les charger
+ if (!endReadAccount)
+ {
+ LimaContext.getContext().getDataManager().resetAccountModel(accountRac);
+ endReadAccount = true;
+ }
+ log.debug("Ajout journal "+nextLine[1]);
+ result = importJournal(nextLine);
+ }
+ /**
+ * Transaction
+ */
+ if ( indice.equals("T") )
+ {
+ log.debug("Ajout transaction "+nextLine[1]);
+ result = importTransactions(nextLine);
+ }
+ /**
+ * Entry
+ */
+ if ( indice.equals("E") )
+ {
+ log.debug("Ajout entry "+nextLine[1]);
+ result = importEntries(nextLine);
+ }
+ }
+ }catch ( Exception e) {
+ log.debug(e);
+ }
+
+ // Reset transactions
+ LimaContext.getContext().getDataManager().resetTransactionModel(listTransactions);
+ return result;
+ }
+
+ /**
+ * Permet de découper une ligne du fichier csv pour charger les comptes.
+ * Pour chaque compte, il vérifie si il appartient à un compte père.
+ * Exemple : compte 164 - 'Emprunts auprès des établissements'
+ * On recherche dans tous les comptes, le compte numéro 16, si il existe,
+ * alors 16 sera le compte père, sinon on remonte d'un rang (recherche sur
+ * le compte 1, etc.).
+ * @param line
+ * @return
+ */
+ public String importAccount(String[] line,AccountDTO accountRac)
+ {
+ // Numéro de compte (exemple : 512)
+ String numberAccount = line[1];
+ // Label du compte (exemple : Banque)
+ String label = line[2];
+ // Actif/Passif/Produit/Charge
+ String type = line[3];
+ /**
+ * Détection des comptes pères
+ */
+ AccountDTO accountMaster = null;
+ // si compte principal correspondant à une classe (1-2-3-4-5-6-7-8)
+ if ( numberAccount.length() == 1 ) // c-a-d taille du numéro de compte à 1
+ {
+ accountMaster = accountRac;
+ } else {
+ // Sinon on recherche un compte père
+ int i=1;
+ // Liste des comptes existants
+ List<AccountDTO> listAccount = ServiceHelper.getAllFlatAccount(accountRac);
+ // Tant que le compte père n'a pas été trouvé
+ while (i<numberAccount.length() && accountMaster == null)
+ {
+ accountMaster = ServiceHelper.findAccountById(listAccount,numberAccount.substring(0, numberAccount.length()-i));
+ i++;
+ }
+ }
+ // Création du compte
+ AccountDTO account = new AccountDTO("",numberAccount,label,type,new LinkedList<AccountDTO>(),accountMaster);
+ String result = LimaContext.getContext().getDataManager().getAccountModel().addAccount(account);
+ return result;
+ }
+
+ /**
+ * Import des transactions. Il recherche le journal correspondant dans la
+ * base. C'est pourquoi le journal doit être chargé avant la lecture des
+ * transactions. Il fait de même avec les périodes. Lorsqu'il a chargé
+ * toutes les données de la transaction, il ajoute celle-ci dans lima.
+ * Il associe également la transaction lue dans la variable transactionLast.
+ * ainsi après avoir lu la transaction, il va lire les entrées de la transaction.
+ * Lors de l'ajout d'une entrée, il est nécessaire de connaître la transaction
+ * à laquelle elle est rattachée.
+ * @param line
+ * @return
+ */
+ public String importTransactions (String[] line)
+ {
+ String result="";
+ // document de référence
+ String voucherRef = line[1];
+ // description
+ String description = line[2];
+ // nom de la transaction
+ String name = line[3];
+ // date de transaction
+ Date date = Util.stringToDate(line[4], "dd/MM/yyyy");
+ // journal
+ String journal = line[5];
+ JournalDTO journalDTO = ServiceHelper.findJournalById(
+ LimaContext.getContext().getDataManager().getJournalModel().getData(),
+ journal);
+ if (journalDTO == null) {
+ log.warn("Import : Journal " + journal + " does not exist.");
+ }
+ // periode
+ Date period = Util.stringToDate(line[6], "dd/MM/yyyy");
+ // Recherche la période correspondante
+ PeriodDTO periodDTO = ServiceHelper.findPeriodByDate(
+ ServiceHelper.getAllFlatPeriod(LimaContext.getContext().getDataManager().getPeriodes()), period);
+ /**
+ * Création de la transaction
+ */
+ TransactionDTO transaction = new TransactionDTO(null, name, date,
+ voucherRef, description, journalDTO, new LinkedList<EntryDTO>(), periodDTO,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "TR_WIP"));
+ transactionLast = transaction;
+ // Ajoute la transaction dans le service
+ //result = Main.getContext().getDataManager().getTransactionModel().addTransaction(transaction);
+ result = transactionService.addTransaction(transaction, LimaContext.getContext().getDataManager().getStatus());
+ // Ajoute la transaction dans la liste des transactions
+ listTransactions.add(transaction);
+ return result;
+ }
+
+ /**
+ * Permet de rechercher toutes les entrées comptables dans le fichier.
+ * @param line
+ * @param nameTransacPrev
+ * @return
+ */
+ public String importEntries (String[] line)
+ {
+ String result;
+ /**
+ * Account
+ */
+ String accountId = line[1];
+ AccountDTO accountDTO = ServiceHelper.findAccountById(
+ ServiceHelper.getAllFlatAccount(LimaContext.getContext().getDataManager().getAccountModel().getData()),
+ accountId);
+ if (accountDTO == null) {
+ log.warn("Import : Account " + accountId + " does not exist.");
+ }
+ /**
+ * Description
+ */
+ String description = line[2];
+ /**
+ * Amount
+ */
+ String amount = line[3].trim();
+ /**
+ * Lettrage
+ */
+ String lettrage = line[4];
+ /**
+ * Debit - Credit
+ */
+ boolean debit = line[5].equals("D");
+ // Création de l'entrée comptable
+ EntryDTO entry = new EntryDTO("",description,DTOHelper.format(amount),debit,lettrage,accountDTO,transactionLast,null);
+ // Ajout de l'entrée comptable dans le service
+ result = entryService.addEntry(LimaContext.getContext().getDataManager().getStatus(), entry);
+ // Ajout l'entrée à la transaction
+ transactionLast.addChild(entry);
+ return result;
+ }
+
+ /**
+ * Cette méthode permet d'importer les journaux.
+ * @param line
+ * @return
+ */
+ public String importJournal (String[] line)
+ {
+ String name = line[1];
+ String prefixe = line[2];
+ String description = line[3];
+ // Création du journal
+ JournalDTO journalDTO = new JournalDTO("",name,description,prefixe);
+ // Ajout du journal dans le modèle de Lima
+ String result = LimaContext.getContext().getDataManager().getJournalModel().addJournal(journalDTO);
+ return result;
+ }
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImportEBP.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/imports/CSVImportEBP.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImportEBP.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/csv/CSVImportEBP.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,362 @@
+/**
+ * *##% Lima-Callao CVSImportEBP
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb.csv;
+
+import au.com.bytecode.opencsv.CSVReader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.balance.Category;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.dto.util.DTOHelper;
+import org.chorem.lima.util.Util;
+import org.chorem.lima.service.*;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.util.*;
+
+
+/**
+ * Cette classe permet d'importer un fichier de données au format csv.
+ * Il respecte la norme de l'application EBP. Toutefois, il est possible de modifier
+ * facilement et adapter le code pour un autre type de formatage de données.
+ *
+ * @author Rémi Chapelet
+ */
+public class CSVImportEBP {
+
+ private static final Log log = LogFactory.getLog(CSVImportEBP.class);
+ private CSVReader csvReader;
+ private LinkedList<TransactionDTO> listTransactions= new LinkedList<TransactionDTO>();
+ private TransactionDTO transactionWithSamePrefix = null;
+
+ protected final PeriodService periodService;
+ protected final EntryService entryService;
+ protected final TransactionService transactionService;
+
+ /**
+ * Le constructeur avec en paramètre l'adresse du fichier de données.
+ * @param path
+ */
+ public CSVImportEBP(String path) {
+ //URL url = CSVImportEBP.class.getResource(path);
+ try {
+ File f = new File(path);
+ // Le fichier a pour séparateur ';'
+ csvReader = new CSVReader(new FileReader(f), ';');
+ } catch (FileNotFoundException e) {
+ log.debug(e);
+ }
+ // Déclaration des services
+ periodService = ServiceFactory.getServiceFactory().getPeriodService();
+ entryService = ServiceFactory.getServiceFactory().getEntryService();
+ transactionService = ServiceFactory.getServiceFactory().getTransactionService();
+ }
+
+ /**
+ * permet de retourner l'instance csv du fichier.
+ * @return
+ * @throws java.io.FileNotFoundException
+ */
+ public CSVReader getCSVReader() throws FileNotFoundException {
+ return csvReader;
+ }
+
+
+ /**
+ * Fonction principale permettant de lire un fichier au format csv.
+ * Ce dernier permet de lire les fichiers de l'application EBP.
+ * Chaque ligne possède un identifiant :
+ * C : compte
+ * J : journal
+ * E : entrée comptable
+ * Attention : EBP ne possède pas dans son fichier de sauvegarde de
+ * transactions, mais seulement des entrées. Or Lima utilise les transactions,
+ * reliées aux entrées. Il est donc important de créer une transaction pour
+ * chaque groupe d'entrées comptables.
+ * @return
+ */
+ public String importDatas ()
+ {
+ // Message de retour de la méthode : success ou error
+ String result = ServiceHelper.RESPOND_ERROR;
+ try {
+ /**
+ * Déclaration des variables
+ */
+ // Tableau de chaines correspondant à chaque ligne du fichier qui sera lue.
+ String[] nextLine;
+ // Création account Master
+ // Lima possède un compte principal, numéroté '0'.
+ AccountDTO accountRac = new AccountDTO("0", "0", "Plan comptable", null, new LinkedList<AccountDTO>(), null);
+
+ /**
+ * Lecture des 6 premières lignes du fichier
+ */
+ csvReader.readNext(); // Nom application
+ csvReader.readNext(); // Codage des caractères
+ csvReader.readNext(); // Code 01
+ csvReader.readNext(); // Nom de l'entreprise
+ nextLine = csvReader.readNext(); // Date début période
+ Date beginPeriod = Util.stringToDate(nextLine[0], "ddMMyyyy");
+ nextLine = csvReader.readNext(); // Date fin période
+ Date endPeriod = Util.stringToDate(nextLine[0], "ddMMyyyy");
+
+ /**
+ * Création de la période : l'exercice comptable avec ses 12 mois.
+ */
+ // Création de l'exercice
+ Date begin = Util.InitDateFirstDayMonth(beginPeriod);
+ Date end = Util.InitDateEndDayMonth(endPeriod);
+ PeriodDTO period = new PeriodDTO("",Integer.toString(begin.getYear()+1900),begin,end,null,null,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "PE_OPEN"));
+ // Création des 12 mois
+ List<PeriodDTO> listPeriodChild = new LinkedList<PeriodDTO>();
+ // Pour chaque mois
+ for (int i=0 ; i<12 ; i++)
+ {
+ Date beginTimeSpan = Util.InitDateFirstDayMonth(new Date(begin.getYear(),begin.getMonth()+i,begin.getDate()));
+ Date endTimeSpan = Util.InitDateEndDayMonth(new Date(begin.getYear(),begin.getMonth()+i,begin.getDate()));
+ // Création période
+ PeriodDTO periodChild = new PeriodDTO("",ServiceHelper.dateToMonth(beginTimeSpan)+" "+(beginTimeSpan.getYear()+1900),beginTimeSpan,endTimeSpan,null,period,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "PE_OPEN"));
+ listPeriodChild.add(periodChild);
+ }
+ // On ajoute les 12 mois à l'exercice
+ period.setChildren(listPeriodChild);
+ // On ajoute la liste des exercices (ici un seul exercice) à Lima
+ LinkedList<PeriodDTO> listPeriod= new LinkedList<PeriodDTO>();
+ listPeriod.add(period);
+ // Ajoute la période dans le service des Périodes
+ periodService.createPeriod(period, LimaContext.getContext().getDataManager().getStatus());
+ // Réinitialise les périodes
+ LimaContext.getContext().getDataManager().resetPeriodes(listPeriod);
+
+ /**
+ * Lecture de chaque ligne
+ * Ajout des comptes, journaux et entrées comptables
+ */
+ boolean endReadAccount = false; // Vrai lorsque tous les comptes sont chargés
+ String nameTransacPrev = ""; // Valeur du nom de la transaction précédente
+ // Pour chaque ligne
+ while ((nextLine = csvReader.readNext()) != null) {
+ // Lecture de la 1ière cellule
+ String indice = nextLine[0];
+ /**
+ * Compte
+ */
+ if ( indice.equals("C") )
+ {
+ log.debug("Ajout compte "+nextLine[1]);
+ result = importAccount(nextLine,accountRac);
+ }
+ /**
+ * Journal
+ */
+ if ( indice.equals("J") )
+ {
+ // Tous les comtes ont été chargés, on relance pour les charger
+ if (!endReadAccount)
+ {
+ LimaContext.getContext().getDataManager().resetAccountModel(accountRac);
+ endReadAccount = true;
+ }
+ log.debug("Ajout journal "+nextLine[1]);
+ result = importJournal(nextLine);
+ }
+ /**
+ * Entry
+ */
+ if ( indice.equals("E") )
+ {
+ log.debug("Ajout entry "+nextLine[1]);
+ result = importEntries(nextLine,nameTransacPrev);
+ nameTransacPrev = nextLine[4];
+ }
+ }
+ }catch ( Exception e) {
+ log.debug(e);
+ }
+
+ // Reset transactions
+ LimaContext.getContext().getDataManager().resetTransactionModel(listTransactions);
+ return result;
+ }
+
+ /**
+ * Permet de découper une ligne du fichier csv pour charger les comptes.
+ * Pour chaque compte, il vérifie si il appartient à un compte père.
+ * Exemple : compte 164 - 'Emprunts auprès des établissements'
+ * On recherche dans tous les comptes, le compte numéro 16, si il existe,
+ * alors 16 sera le compte père, sinon on remonte d'un rang (recherche sur
+ * le compte 1, etc.).
+ * @param line
+ * @return
+ */
+ public String importAccount(String[] line,AccountDTO accountRac)
+ {
+ // Numéro de compte (exemple : 512)
+ String numberAccount = line[1];
+ // Label du compte (exemple : Banque)
+ String label = line[2];
+ /**
+ * Détection des comptes pères
+ */
+ AccountDTO accountMaster = null;
+ // si compte principal correspondant à une classe (1-2-3-4-5-6-7-8)
+ if ( numberAccount.length() == 1 ) // c-a-d taille du numéro de compte à 1
+ {
+ accountMaster = accountRac;
+ } else {
+ // Sinon on recherche un compte père
+ int i=1;
+ // Liste des comptes existants
+ List<AccountDTO> listAccount = ServiceHelper.getAllFlatAccount(accountRac);
+ // Tant que le compte père n'a pas été trouvé
+ while (i<numberAccount.length() && accountMaster == null)
+ {
+ accountMaster = ServiceHelper.findAccountById(listAccount,numberAccount.substring(0, numberAccount.length()-i));
+ i++;
+ }
+ }
+ // Recherche de la catégorie
+ String category = Category.findCategory(numberAccount);
+ // Création du compte
+ AccountDTO account = new AccountDTO("",numberAccount,label,category,new LinkedList<AccountDTO>(),accountMaster);
+ String result = LimaContext.getContext().getDataManager().getAccountModel().addAccount(account);
+ return result;
+ }
+
+ /**
+ * Permet de rechercher toutes les transactions/entrées comptables dans le fichier.
+ * Néanmoins, le fichier ne possède pas de transactions, il est donc important
+ * d'identifier ces dernières. Il exsite dans le fichier des 'groupes" d'entrées
+ * comptables. Elles se suivent, et possèdent un numéro de document en
+ * commun (appelé dans l'algo ci-dessous 'numTransac').
+ * On vérifie à chaque fois si l'entrée appartient au groupe lu précédent. Si
+ * oui, alors on l'a rattache à la même transaction 'transactionWithSamePrefix' ;
+ * si non, on créé dans ce cas une nouvelle transaction 'transactionWithSamePrefix'.
+ * Chaque transaction est ajoutée dans une liste, pour les ajouter au modèle
+ * dans Lima.
+ * @param line
+ * @param nameTransacPrev
+ * @return
+ */
+ public String importEntries (String[] line, String nameTransacPrev)
+ {
+ String result;
+ /**
+ * Account
+ */
+ String accountId = line[1];
+ AccountDTO accountDTO = ServiceHelper.findAccountById(
+ ServiceHelper.getAllFlatAccount(LimaContext.getContext().getDataManager().getAccountModel().getData()),
+ accountId);
+ if (accountDTO == null) {
+ log.warn("Import : Account " + accountId + " does not exist.");
+ }
+ /**
+ * Date
+ */
+ Date dateTransac = Util.stringToDate(line[2], "ddMMyyyy");
+ /**
+ * Journal
+ */
+ String journalId = line[3];
+ JournalDTO journalDTO = ServiceHelper.findJournalById(
+ LimaContext.getContext().getDataManager().getJournalModel().getData(),
+ journalId);
+ if (journalDTO == null) {
+ log.warn("Import : Journal " + journalId + " does not exist.");
+ }
+ /**
+ * Transaction
+ */
+ String numTransac = line[4];
+ String descTransac = line[6];
+ /**
+ * Debit - Credit
+ */
+ boolean debit = line[7].equals("D");
+ /**
+ * Amount
+ */
+ String amount = line[8].trim();
+ /**
+ * Lettrage
+ */
+ String lettrage = line[10];
+ /**
+ * Création transaction
+ */
+ if ( !nameTransacPrev.equals(numTransac) )
+ {
+ // Recherche la période correspondante
+ PeriodDTO period = ServiceHelper.findPeriodByDate(
+ ServiceHelper.getAllFlatPeriod(LimaContext.getContext().getDataManager().getPeriodes()), dateTransac);
+ // Création de la transaction
+ TransactionDTO transaction = new TransactionDTO(null, "", dateTransac,
+ numTransac, descTransac, journalDTO, new LinkedList<EntryDTO>(), period,
+ ServiceHelper.findStatusByType(LimaContext.getContext().getDataManager().getStatus(), "TR_WIP"));
+ transactionWithSamePrefix = transaction;
+ // Ajoute la transaction dans le service
+ result = transactionService.addTransaction(transaction, LimaContext.getContext().getDataManager().getStatus());
+ // Ajoute la transaction dans la liste des transactions
+ listTransactions.add(transaction);
+ }
+ // Création de l'entrée comptable
+ EntryDTO entry = new EntryDTO("","",DTOHelper.format(amount),debit,lettrage,accountDTO,transactionWithSamePrefix,null);
+ // Ajout de l'entrée comptable dans le service
+ result = entryService.addEntry(LimaContext.getContext().getDataManager().getStatus(), entry);
+ // Ajout l'entrée à la transaction
+ transactionWithSamePrefix.addChild(entry);
+ return result;
+ }
+
+ /**
+ * Cette méthode permet d'importer les journaux.
+ * Attention : dans le fichier de base de EBP, il ne possède pas de journaux,
+ * or il est important d'apporter des journaux dans le logiciel, sinon
+ * les transactions ne sont pas rattachés.
+ * Il suffit d'ajouter les journaux souhaités après les comptes avec la lettre
+ * J dans le fichier.
+ * Exemple : J;Journal des achats;AC
+ * @param line
+ * @return
+ */
+ public String importJournal (String[] line)
+ {
+ String description = line[1];
+ String prefixe = line[2];
+ // Création du journal
+ JournalDTO journalDTO = new JournalDTO("",description,description,prefixe);
+ // Ajout du journal dans le modèle de Lima
+ String result = LimaContext.getContext().getDataManager().getJournalModel().addJournal(journalDTO);
+ return result;
+ }
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLExport.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/export/XMLExport.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLExport.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLExport.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,501 @@
+/**
+ * *##% Lima-Callao XMLExport
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb.xml;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.FileOutputStream;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.EntryDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.dto.PeriodDTO;
+import org.chorem.lima.dto.TransactionDTO;
+import org.chorem.lima.ui.MainViewImpl;
+import org.chorem.lima.ui.ProgressBarImpl;
+import org.chorem.lima.util.ServiceHelper;
+import org.chorem.lima.util.Util;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
+/**
+ * Permet d'exporter les données dans un document xml.
+ *
+ * @author Rémi Chapelet
+ */
+public class XMLExport {
+
+ /**
+ * log
+ */
+ protected static final Log log = LogFactory.getLog(XMLExport.class);
+
+ private static Element racine = new Element("Callao");
+
+ private static org.jdom.Document document = new Document(racine);
+
+ private ProgressBarImpl progressBar;
+
+ private String file;
+
+ // Déclaration variables pour chargement des données
+
+ private static List<PeriodDTO> listPeriodDTO = LimaContext.getContext().getDataManager().getPeriodes();
+ private static List<JournalDTO> listJournalDTO = LimaContext.getContext().getDataManager().getJournalModel().getData();
+ private static AccountDTO AccountMasterDTO = LimaContext.getContext().getDataManager().getAccountModel().getData();
+ private static List<TransactionDTO> listTransactionDTO = LimaContext.getContext().getDataManager().getTransactionModel().getData();
+
+ /**
+ * Cete méthode permet d'exporter des données de Callao vers un fichier au
+ * format xml.
+ *
+ * @param pathFile
+ * @return
+ */
+ public String exportFile(String pathFile) {
+ if (log.isDebugEnabled()) {
+ log.debug("Save file XML : ");
+ }
+ // Charge le nom du fichier
+ file = pathFile;
+ // Mise en place de la barre de progression
+ MainViewImpl context = LimaContext.get().getMainUI();
+ progressBar = new ProgressBarImpl(context, context);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ progressBar.setVisible(true);
+ }
+ };
+ SwingUtilities.invokeLater(runnable);
+ new Thread() {
+ @Override
+ public void run() {
+ // MainViewImpl context = LimaContext.get().getMainUI();
+ // progressBar = new ProgressBarImpl(context, context);
+ progressBar.setTitle(_("lima.progressBar.export.title"));
+ progressBar.getProgressBar().setString(
+ "0% : " + _("lima.progressBar.export.etape1"));
+ progressBar.getProgressBar().setValue(0);
+
+ /**
+ * Partie Informations
+ */
+ progressBar.getProgressBar().setString(
+ "10% : " + _("lima.progressBar.export.etape2"));
+ progressBar.getProgressBar().setValue(10);
+ Element info = new Element("informations");
+ racine.addContent(info);
+ Attribute date = new Attribute("date", new Date().toString());
+ info.setAttribute(date);
+ Attribute user = new Attribute("user", "Name user");
+ info.setAttribute(user);
+ Attribute company = new Attribute("company", "Name company");
+ info.setAttribute(company);
+ /**
+ * Partie Save
+ */
+ // Création Element save
+ Element save = new Element("save");
+ racine.addContent(save);
+ /**
+ * Period
+ */
+ progressBar.getProgressBar().setString(
+ "25% : " + _("lima.progressBar.export.etape3"));
+ progressBar.getProgressBar().setValue(25);
+ Element periods = new Element("periods");
+ Element timeSpans = new Element("timespans");
+ save.addContent(periods);
+ save.addContent(timeSpans);
+ exportPeriod(periods, timeSpans);
+ /**
+ * Journal
+ */
+ progressBar.getProgressBar().setString(
+ "35% : " + _("lima.progressBar.export.etape4"));
+ progressBar.getProgressBar().setValue(35);
+ Element journals = new Element("journals");
+ save.addContent(journals);
+ exportJournal(journals);
+ /**
+ * Account
+ */
+ progressBar.getProgressBar().setString(
+ "50% : " + _("lima.progressBar.export.etape5"));
+ progressBar.getProgressBar().setValue(50);
+ Element accounts = new Element("accounts");
+ save.addContent(accounts);
+ // Appel une fonction récursive pour parcourir l'arborescence des comptes
+ accountXML(AccountMasterDTO.getChildren(), accounts);
+ /**
+ * Transaction
+ */
+ progressBar.getProgressBar().setString(
+ "60% : " + _("lima.progressBar.export.etape6"));
+ progressBar.getProgressBar().setValue(60);
+ Element transactions = new Element("transactions");
+ save.addContent(transactions);
+ Element entries = new Element("entries");
+ save.addContent(entries);
+ exportTransaction(transactions, entries, progressBar);
+ /**
+ * Enregistre le fichier
+ */
+ progressBar.getProgressBar().setString(
+ "100% : " + _("lima.progressBar.export.etape7"));
+ progressBar.getProgressBar().setValue(100);
+ enregistre(file);
+ progressBar.dispose();
+
+ }
+ }.start();
+
+ return ServiceHelper.RESPOND_SUCCESS;
+ }
+
+ public String exportAccount(String pathFile) {
+ if (log.isDebugEnabled()) {
+ log.debug("Save Account XML : ");
+ }
+ // Charge le nom du fichier
+ file = pathFile;
+
+ MainViewImpl context = LimaContext.get().getMainUI();
+ progressBar = new ProgressBarImpl(context, context);
+ Runnable runnable = new Runnable() {
+ public void run() {
+ progressBar.setVisible(true);
+ }
+ };
+ SwingUtilities.invokeLater(runnable);
+
+ // Mise en place de la barre de progression
+ new Thread() {
+ @Override
+ public void run() {
+ // MainViewImpl context = LimaContext.get().getMainUI();
+ // progressBar = new ProgressBarImpl(context, context);
+ progressBar.setTitle(_("lima.progressBar.export.title"));
+ progressBar.getProgressBar().setString(
+ "0% : " + _("lima.progressBar.export.etape1"));
+ progressBar.getProgressBar().setValue(0);
+ /**
+ * Partie Informations
+ */
+ progressBar.getProgressBar().setString(
+ "10% : " + _("lima.progressBar.export.etape2"));
+ progressBar.getProgressBar().setValue(10);
+ Element info = new Element("informations");
+ racine.addContent(info);
+ Attribute date = new Attribute("date", new Date().toString());
+ info.setAttribute(date);
+ Attribute user = new Attribute("user", "Name user");
+ info.setAttribute(user);
+ Attribute company = new Attribute("company", "Name company");
+ info.setAttribute(company);
+ /**
+ * Partie Save
+ */
+ // Création Element save
+ Element save = new Element("save");
+ racine.addContent(save);
+ /**
+ * Account
+ */
+ progressBar.getProgressBar().setString(
+ "50% : " + _("lima.progressBar.export.etape5"));
+ progressBar.getProgressBar().setValue(50);
+ Element accounts = new Element("accounts");
+ save.addContent(accounts);
+ // Appel une fonction récursive pour parcourir l'arborescence des comptes
+ accountXML(AccountMasterDTO.getChildren(), accounts);
+ /**
+ * Enregistre le fichier
+ */
+ progressBar.getProgressBar().setString(
+ "100% : " + _("lima.progressBar.export.etape7"));
+ progressBar.getProgressBar().setValue(100);
+ enregistre(file);
+ progressBar.dispose();
+ }
+ }.start();
+ return ServiceHelper.RESPOND_SUCCESS;
+ }
+
+ /**
+ * @param periods
+ * @param timeSpans
+ */
+ public void exportPeriod(Element periods, Element timeSpans) {
+ // Pour chaque période
+ for (PeriodDTO periodDTO : listPeriodDTO) {
+ // Création élément périod
+ Element period = new Element("period");
+ periods.addContent(period);
+ // Identifiant période
+ Attribute id = new Attribute("id", periodDTO.getIdSeq());
+ period.setAttribute(id);
+ // BeginPeriod
+ // Découpage date
+ String dateTab[] = Util.arrayDate(periodDTO.getBegin());
+ Attribute beginYear = new Attribute("beginYear", dateTab[0]);
+ period.setAttribute(beginYear);
+ Attribute beginMonth = new Attribute("beginMonth", dateTab[1]);
+ period.setAttribute(beginMonth);
+ Attribute beginDay = new Attribute("beginDay", dateTab[2]);
+ period.setAttribute(beginDay);
+ // EndPeriod
+ dateTab = Util.arrayDate(periodDTO.getEnd());
+ Attribute endYear = new Attribute("endYear", dateTab[0]);
+ period.setAttribute(endYear);
+ Attribute endMonth = new Attribute("endMonth", dateTab[1]);
+ period.setAttribute(endMonth);
+ Attribute endDay = new Attribute("endDay", dateTab[2]);
+ period.setAttribute(endDay);
+ // Locked Period
+ if (periodDTO.getStatus().getIdName()
+ .equals(ServiceHelper.PE_CLOSE)) {
+ Attribute locked = new Attribute("locked", "true");
+ period.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ period.setAttribute(locked);
+ }
+ /**
+ * TimeSpan
+ */
+ // Recherche des timeSpans de la période
+ List<PeriodDTO> listTimeSpanDTO = periodDTO.getChildren();
+ // Pour chaque timeSpan
+ for (PeriodDTO timeSpanDTO : listTimeSpanDTO) {
+ Element timeSpan = new Element("timespan");
+ timeSpans.addContent(timeSpan);
+ // Identifiant timeSpan
+ Attribute idTimeSpan = new Attribute("id", timeSpanDTO
+ .getIdSeq());
+ timeSpan.setAttribute(idTimeSpan);
+ Attribute idPeriod = new Attribute("idPeriod", periodDTO
+ .getIdSeq());
+ timeSpan.setAttribute(idPeriod);
+ // Begin TimeSpan
+ // Découpage date
+ dateTab = Util.arrayDate(timeSpanDTO.getBegin());
+ Attribute beginYearTimeSpan = new Attribute("beginYear",
+ dateTab[0]);
+ timeSpan.setAttribute(beginYearTimeSpan);
+ Attribute beginMonthTimeSpan = new Attribute("beginMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(beginMonthTimeSpan);
+ Attribute beginDayTimeSpan = new Attribute("beginDay",
+ dateTab[2]);
+ timeSpan.setAttribute(beginDayTimeSpan);
+ // End TimeSpan
+ dateTab = Util.arrayDate(timeSpanDTO.getEnd());
+ Attribute endYearTimeSpan = new Attribute("endYear", dateTab[0]);
+ timeSpan.setAttribute(endYearTimeSpan);
+ Attribute endMonthTimeSpan = new Attribute("endMonth",
+ dateTab[1]);
+ timeSpan.setAttribute(endMonthTimeSpan);
+ Attribute endDayTimeSpan = new Attribute("endDay", dateTab[2]);
+ timeSpan.setAttribute(endDayTimeSpan);
+ // Lock timeSpan
+ if (timeSpanDTO.getStatus().getIdName().equals(
+ ServiceHelper.PE_CLOSE)) {
+ Attribute locked = new Attribute("locked", "true");
+ timeSpan.setAttribute(locked);
+ } else {
+ Attribute locked = new Attribute("locked", "false");
+ timeSpan.setAttribute(locked);
+ }
+ }
+ }
+ }
+
+ /**
+ * @param journals
+ */
+ public void exportJournal(Element journals) {
+ for (JournalDTO journalDTO : listJournalDTO) {
+ Element journal = new Element("journal");
+ journals.addContent(journal);
+ // Identification du journal
+ Attribute idJournal = new Attribute("id", journalDTO.getIdSeq());
+ journal.setAttribute(idJournal);
+ // Label
+ Attribute label = new Attribute("label", journalDTO.getIdName());
+ journal.setAttribute(label);
+ // Prefix
+ Attribute prefix = new Attribute("prefix", journalDTO.getPrefix());
+ journal.setAttribute(prefix);
+ // Description
+ Attribute description = new Attribute("description", journalDTO
+ .getDescription());
+ journal.setAttribute(description);
+ }
+ }
+
+ /**
+ * Converti la liste des comptes pour être ajouté au document xml.
+ *
+ * @param listAccountDTO
+ * @param accounts
+ */
+ public void accountXML(List<AccountDTO> listAccountDTO, Element accounts) {
+ for (AccountDTO accountDTO : listAccountDTO) {
+ Element account = new Element("account");
+ accounts.addContent(account);
+ // Identification du account
+ Attribute idAccount = new Attribute("id", accountDTO.getIdSeq());
+ account.setAttribute(idAccount);
+ // Label
+ Attribute label = new Attribute("label", accountDTO
+ .getDescription());
+ account.setAttribute(label);
+ // Type
+ Attribute type = new Attribute("type", accountDTO.getType());
+ account.setAttribute(type);
+ // AccountNumber
+ Attribute accountNumber = new Attribute("accountNumber", accountDTO
+ .getIdNumber());
+ account.setAttribute(accountNumber);
+ // MasterAccountNumber
+ Attribute masterAccountNumber = new Attribute("masterAccount",
+ accountDTO.getParent().getIdNumber());
+ account.setAttribute(masterAccountNumber);
+ // Ajoute les comptes enfants à la liste
+ accountXML(accountDTO.getChildren(), accounts);
+ }
+ }
+
+ public void exportTransaction(Element transactions, Element entries,
+ ProgressBarImpl progressBar) {
+ // Nombre de transaction
+ float nbTransactions = listTransactionDTO.size();
+ float incremente = 20 / nbTransactions;
+ float value = 80;
+ // Pour chaque transaction
+ for (TransactionDTO transactionDTO : listTransactionDTO) {
+ Element transaction = new Element("transaction");
+ transactions.addContent(transaction);
+ // Identification de la transaction
+ Attribute idTransaction = new Attribute("id", transactionDTO
+ .getIdSeq());
+ transaction.setAttribute(idTransaction);
+ // EntryDate
+ String dateTab[] = Util.arrayDate(transactionDTO.getEntryDate());
+ Attribute entryDateYear = new Attribute("entryDateYear", dateTab[0]);
+ transaction.setAttribute(entryDateYear);
+ Attribute entryDateMonth = new Attribute("entryDateMonth",
+ dateTab[1]);
+ transaction.setAttribute(entryDateMonth);
+ Attribute entryDateDay = new Attribute("entryDateDay", dateTab[2]);
+ transaction.setAttribute(entryDateDay);
+ // VoucherRef
+ Attribute voucherRef = new Attribute("voucherRef", transactionDTO
+ .getVoucherRef());
+ transaction.setAttribute(voucherRef);
+ // Description
+ Attribute description = new Attribute("description", transactionDTO
+ .getDescription());
+ transaction.setAttribute(description);
+ // Id journal
+ Attribute IdJournal = new Attribute("idJournal", transactionDTO
+ .getJournal().getIdSeq());
+ transaction.setAttribute(IdJournal);
+ // Id timeSpan
+ Attribute IdTimeSpan = new Attribute("idTimeSpan", transactionDTO
+ .getPeriod().getIdSeq());
+ transaction.setAttribute(IdTimeSpan);
+ /**
+ * Entry
+ */
+ List<EntryDTO> listEntryDTO = transactionDTO.getEntries();
+ for (EntryDTO entryDTO : listEntryDTO) {
+ Element entry = new Element("entry");
+ entries.addContent(entry);
+ // Identification du entry
+ Attribute idEntry = new Attribute("id", entryDTO.getIdSeq());
+ entry.setAttribute(idEntry);
+ // Description
+ Attribute descriptionEntry = new Attribute("description",
+ entryDTO.getDescription());
+ entry.setAttribute(descriptionEntry);
+ // Amount
+ Attribute amount = new Attribute("amount", entryDTO.getAmount());
+ entry.setAttribute(amount);
+ // Lettering
+ Attribute lettering = new Attribute("lettering", entryDTO
+ .getLettrage());
+ entry.setAttribute(lettering);
+ // Detail
+ Attribute detail = new Attribute("detail", entryDTO
+ .getDescription());
+ entry.setAttribute(detail);
+ // Debit / crédit
+ if (entryDTO.getDebit()) {
+ Attribute debit = new Attribute("debit", "true");
+ entry.setAttribute(debit);
+ } else {
+ Attribute debit = new Attribute("debit", "false");
+ entry.setAttribute(debit);
+ }
+ // Transaction
+ Attribute idrefTransaction = new Attribute("idTransaction",
+ transactionDTO.getIdSeq());
+ entry.setAttribute(idrefTransaction);
+ // Account
+ Attribute idAccount = new Attribute("idAccount", entryDTO
+ .getAccount().getIdSeq());
+ entry.setAttribute(idAccount);
+ }
+ // Mise à jour de la barre de chargement
+ value = value + incremente;
+ progressBar.getProgressBar().setValue((int) value);
+ progressBar.getProgressBar().setString(
+ value + "% : " + _("lima.progressBar.export.etape6"));
+
+ }
+ }
+
+ /**
+ * Permet d'enregistrer le fichier xml.
+ *
+ * @param fichier
+ */
+ static void enregistre(String fichier) {
+ try {
+ XMLOutputter sortie = new XMLOutputter(Format.getPrettyFormat());
+ sortie.output(document, new FileOutputStream(fichier));
+ } catch (java.io.IOException e) {
+ log.error(e);
+ }
+ }
+
+}
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLImport.java (from rev 2802, trunk/lima-swing/src/main/java/org/chorem/lima/imports/XMLImport.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLImport.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/xml/XMLImport.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,234 @@
+/**
+ * *##% Lima-Callao XMLImport
+ * Copyright (C) 2009 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.business.ejb.xml;
+
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaContext;
+import org.jdom.*;
+import org.chorem.lima.dto.AccountDTO;
+import org.chorem.lima.dto.JournalDTO;
+import org.chorem.lima.service.util.ServiceHelper;
+
+import org.jdom.input.SAXBuilder;
+import java.io.*;
+import org.jdom.xpath.XPath;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+
+import org.chorem.lima.table.model.JournalTableModel;
+import org.chorem.lima.ui.accounting.model.AccountTreeTableModel;
+
+
+/**
+ * Permet de charger les données à partir d'un document xml.
+ * Il est possibble de charger les journaux, les comptes.
+ *
+ * @author Rémi Chapelet
+ */
+public class XMLImport {
+
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(XMLImport.class);
+
+ static Element racine = new Element("Callao");
+
+ static org.jdom.Document document = new Document(racine);
+
+ protected JournalTableModel journalServ;
+ protected AccountTreeTableModel accountServ;
+
+ /**
+ * Import Journal
+ * @param file
+ * @return
+ */
+ public String importJournal(String file)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug("Load Journal XML ");
+ }
+ // Variables
+ journalServ = LimaContext.getContext().getDataManager().getJournalModel();
+ String result = ServiceHelper.RESPOND_ERROR;
+ boolean existError = false;
+ // Chargement du fichier
+ loadFile(file);
+ try {
+ // Recherche de la racine
+ racine = document.getRootElement();
+ // Chargement
+ XPath requeteXpath = XPath.newInstance("//journal");
+ List results = requeteXpath.selectNodes(racine);
+ Iterator iter = results.iterator();
+ // Pour tous les journaux
+ while (iter.hasNext()){
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ log.debug("Label "+label);
+ String prefix = noeudCourant.getAttribute("prefix").getValue();
+ String description = noeudCourant.getAttribute("description").getValue();
+ // Création du journal
+ JournalDTO journal = new JournalDTO("0", label, description, prefix);
+ // Ajout journal
+ result = journalServ.addJournal(journal);
+ // Control erreur
+ if ( result.equals(ServiceHelper.RESPOND_ERROR) )
+ {
+ existError = true;
+ }
+ }
+ } catch (JDOMException e) {
+ log.error("Erreur JDOM " + e.getMessage() );
+ e.printStackTrace();
+ }
+ // Détection des erreurs
+ if ( !existError )
+ {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ return result;
+ }
+
+ public String importAccount(InputStream stream) {
+ if (log.isDebugEnabled()) {
+ log.debug("Load Account XML ");
+ }
+ // Chargement du fichier
+ loadFile(stream, InputStream.class);
+ return importAccount();
+ }
+
+ /**
+ * Import Account
+ * @param file
+ * @return
+ */
+ public String importAccount(String file)
+ {
+ if (log.isDebugEnabled()) {
+ log.debug("Load Account XML ");
+ }
+ loadFile(file);
+ return importAccount();
+ }
+
+ private String importAccount() {
+ // Variables
+ accountServ = LimaContext.getContext().getDataManager().getAccountModel();
+ String result = ServiceHelper.RESPOND_ERROR;
+ boolean existError = false;
+ try {
+ // Recherche de la racine
+ racine = document.getRootElement();
+ // Chargement
+ XPath requeteXpath = XPath.newInstance("//account");
+ List results = requeteXpath.selectNodes(racine);
+ Iterator iter = results.iterator();
+ // Création du compte principal pour Lima
+ AccountDTO accountMaster = new AccountDTO("0", "0", "Plan comptable", null, new LinkedList<AccountDTO>(), null);
+ // Pour tous les accounts
+ while (iter.hasNext()){
+ Element noeudCourant = (Element) iter.next();
+ // Recherche attributs
+ String label = noeudCourant.getAttribute("label").getValue();
+ String accountNumber = noeudCourant.getAttribute("accountNumber").getValue();
+ String masterAccount = noeudCourant.getAttribute("masterAccount").getValue();
+ String type = noeudCourant.getAttribute("type").getValue();
+ // Création bdd
+ // Si il n'a pas de compte père, alors on rattache le compte au compte '0' master.
+ if ( masterAccount.equals("0") )
+ {
+ // Creation account sur le compte 0
+ AccountDTO account = new AccountDTO("0", accountNumber, label, type, new LinkedList<AccountDTO>(), accountMaster);
+ // Ajout dans le service
+ result = accountServ.addAccount(account);
+ // Ajout dans Lima
+ account.getParent().addChild(account);
+ } else {
+ // Creation account sur le compte père donné dans le fichier
+ AccountDTO account = new AccountDTO("0",accountNumber,label,type,
+ new LinkedList<AccountDTO>(),
+ ServiceHelper.findAccountById(ServiceHelper.getAllFlatAccount(accountMaster),masterAccount));
+ // Ajout dans le service
+ result = accountServ.addAccount(account);
+ // Ajout dans Lima
+ account.getParent().addChild(account);
+ }
+ // Control erreur
+ if ( result.equals(ServiceHelper.RESPOND_ERROR) )
+ {
+ existError = true;
+ }
+ }
+ } catch (JDOMException e) {
+ log.error("Erreur JDOM " + e.getMessage() );
+ e.printStackTrace();
+ }
+ // Détection des erreurs
+ if ( !existError )
+ {
+ result = ServiceHelper.RESPOND_SUCCESS;
+ }
+ // Reset pour le chargement des comptes
+ LimaContext.getContext().getDataManager().resetAccountModel();
+ return result;
+ }
+
+ private void loadFile(String file) {
+ loadFile(file, String.class);
+ }
+ /**
+ *
+ * @param file
+ */
+ private <T> void loadFile(T file, Class<T> fileClass)
+ {
+ /**
+ * Chargement du fichier et construction du Dom
+ */
+ if (log.isDebugEnabled()) {
+ log.debug("Load file : "+file);
+ }
+ try {
+ /* On crée une instance de SAXBuilder */
+ SAXBuilder sxb = new SAXBuilder();
+ if (fileClass.equals(String.class)) {
+ document = sxb.build((String)file);
+ } else if (fileClass.equals(InputStream.class)){
+ document = sxb.build((InputStream)file);
+ }
+ } catch (IOException e) {
+ log.error("Erreur lors de la lecture du fichier "
+ + e.getMessage() );
+ e.printStackTrace();
+ } catch (JDOMException e){
+ log.error("Erreur lors de la construction du fichier JDOM "
+ + e.getMessage() );
+ e.printStackTrace();
+ }
+ }
+
+
+}
\ No newline at end of file
Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/ServiceHelper.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,87 +0,0 @@
-/**
- * *##% Callao ServiceHelper
- * Copyright (C) 2009 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.business.utils;
-
-/**
- * Définition des messages acceptés par Callao
- * @author Rémi Chapelet
- *
- * @deprecated since 0.4.0, with no replacement (Exception)
- */
-public interface ServiceHelper {
-
- /**
- * Réponses utilisées par la couche métier Callao
- */
- public static final String RESPOND_SUCCESS = "success";
- public static final String RESPOND_ERROR = "error";
-
- /**
- * Account Error
- */
- public static final String ACCOUNT_DOUBLE = "account_double";
- public static final String ACCOUNT_NOT_MASTER = "account_not_master";
- public static final String ACCOUNT_NOT_EXIST = "account_not_exist";
- public static final String ACCOUNT_WITH_ENTRIES = "account_with_entries";
-
- /**
- * Entries Error
- */
- public static final String ENTRY_NOT_EXIST = "entry_not_exist";
-
- /**
- * Journal
- */
- public static final String JOURNAL_DOUBLE = "journal_double";
- public static final String JOURNAL_NOT_EXIST = "journal_not_exist";
- public static final String JOURNAL_WITH_TRANSACTIONS = "journal_with_transactions";
-
- /**
- * Period
- */
- public static final String PERIOD_CREATE_TIMESPANS = "period_create_timespan";
- public static final String PERIOD_TIMESPAN_NOT_BLOCK = "period_timespan_not_block";
- public static final String PERIOD_TIMESPAN_BLOCK = "period_timespan_block";
- public static final String PERIOD_ALL_TIMESPAN = "period_all_timespan";
- public static final String PERIOD_NOT_EXIST = "period_not_exist";
-
- /**
- * TimeSpan
- */
- public static final String TIMESPAN_PREC_NOT_BLOCK = "timespan_prec_not_block";
- public static final String TIMESPAN_NEXT_NOT_BLOCK = "timespan_next_not_block";
-
- /**
- * Transaction
- */
- public static final String TRANSACTION_NOT_JOURNAL = "transaction_not_journal";
- public static final String TRANSACTION_NOT_TIMESPAN = "transaction_not_timespan";
- public static final String TRANSACTION_TIMESPAN_BLOCKED = "transaction_timespan_blocked";
- public static final String TRANSACTION_NOT_EXIST = "transaction_not_exist";
- public static final String TRANSACTION_NOT_BALANCED = "transaction_not_balanced";
-
- /**
- * Définition des types de logs possibles
- */
- public static final String LOG_ADD = "add";
- public static final String LOG_MODIFY = "modify";
- public static final String LOG_REMOVE = "remove";
-
-}
\ No newline at end of file
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-04-02 16:55:19 UTC (rev 2824)
@@ -6,12 +6,4 @@
hibernate.connection.username=sa
hibernate.connection.password=
hibernate.connection.driver_class=org.h2.Driver
-hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
-
-# Permet de preciser les classes a utiliser
-#topia.persistence.classes=org.chorem.callao.entity.AccountImpl, \
-#org.chorem.callao.entity.ClientImpl, \
-#org.chorem.callao.entity.EntryImpl, org.chorem.callao.entity.PeriodImpl, \
-#org.chorem.callao.entity.JournalImpl, org.chorem.callao.entity.ProjectImpl, \
-#org.chorem.callao.entity.TimeSpanImpl, org.chorem.callao.entity.TransactionImpl, \
-#org.chorem.callao.entity.UsersImpl, org.chorem.callao.entity.LogImpl
+hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
\ No newline at end of file
Deleted: trunk/lima-business/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-business/src/main/resources/log4j.properties 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/main/resources/log4j.properties 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,11 +0,0 @@
-# Global logging configuration
-log4j.rootLogger=WARN, stdout
-
-# Console output...
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
-
-# package level
-log4j.logger.org.chorem.lima=DEBUG
-log4j.logger.org.nuiton.util=DEBUG
\ No newline at end of file
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/AccountServiceImplTest.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -4,9 +4,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.AccountDTO;
import org.chorem.lima.business.ejb.AccountServiceImpl;
-import org.chorem.lima.business.utils.ServiceHelper;
import org.chorem.lima.entity.Account;
import org.junit.AfterClass;
import org.junit.Assert;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FinancialPeriodServiceImplTest.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,15 +1,9 @@
package org.chorem.lima.business;
-import static org.junit.Assert.assertTrue;
-import java.util.Date;
-
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.chorem.lima.entity.FinancialPeriod;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FiscalPeriodServiceImplTest.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -1,19 +1,9 @@
package org.chorem.lima.business;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Date;
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.PeriodDTO;
-import org.chorem.lima.business.dto.TimeSpanDTO;
import org.chorem.lima.business.ejb.FiscalPeriodServiceImpl;
-import org.chorem.lima.business.utils.ServiceHelper;
-import org.chorem.lima.entity.FiscalPeriod;
import org.junit.AfterClass;
-import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java 2010-04-02 16:53:54 UTC (rev 2823)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/RecordServiceImplTest.java 2010-04-02 16:55:19 UTC (rev 2824)
@@ -5,7 +5,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.dto.LogDTO;
import org.chorem.lima.business.ejb.RecordServiceImpl;
import org.chorem.lima.entity.Record;
import org.junit.AfterClass;
Copied: trunk/lima-business/src/test/resources/log4j.properties (from rev 2807, trunk/lima-business/src/main/resources/log4j.properties)
===================================================================
--- trunk/lima-business/src/test/resources/log4j.properties (rev 0)
+++ trunk/lima-business/src/test/resources/log4j.properties 2010-04-02 16:55:19 UTC (rev 2824)
@@ -0,0 +1,11 @@
+# Global logging configuration
+log4j.rootLogger=WARN, stdout
+
+# Console output...
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
+
+# package level
+log4j.logger.org.chorem.lima=DEBUG
+log4j.logger.org.nuiton.util=DEBUG
\ No newline at end of file
1
0
Author: echatellier
Date: 2010-04-02 18:53:54 +0200 (Fri, 02 Apr 2010)
New Revision: 2823
Log:
Use snapshot of topia/eugene
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-04-02 14:26:48 UTC (rev 2822)
+++ trunk/pom.xml 2010-04-02 16:53:54 UTC (rev 2823)
@@ -124,7 +124,7 @@
<dependency>
<groupId>org.apache.openejb</groupId>
<artifactId>openejb-core</artifactId>
- <!-- 3.2.1 has a startup warning with 1.6.0_u18 -->
+ <!-- 3.1.2 has a startup warning with 1.6.0_u18 -->
<version>3.1.3-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
@@ -159,13 +159,6 @@
</dependency>
<dependency>
- <groupId>javax.time</groupId>
- <artifactId>jsr-310-ri</artifactId>
- <version>20100212</version>
- <scope>compile</scope>
- </dependency>
-
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
@@ -240,10 +233,10 @@
<!-- customized libs version -->
<nuiton-utils.version>1.2.1-SNAPSHOT</nuiton-utils.version>
- <eugene.version>2.0</eugene.version>
- <topia.version>2.3.1-SNAPSHOT</topia.version>
+ <eugene.version>2.0.1-SNAPSHOT</eugene.version>
+ <topia.version>2.3.2-SNAPSHOT</topia.version>
<jaxx.version>2.0</jaxx.version>
- <i18n.version>1.1</i18n.version>
+ <i18n.version>1.2</i18n.version>
<!--axis.version>1.4.1</axis.version-->
<!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar
1
0
Author: echatellier
Date: 2010-04-02 16:26:48 +0200 (Fri, 02 Apr 2010)
New Revision: 2822
Log:
Add documentation about "voucher" attribute.
Modified:
trunk/lima-callao/src/main/xmi/accounting.zargo
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
1
0