Author: jpepin Date: 2010-05-10 16:42:46 +0200 (Mon, 10 May 2010) New Revision: 2890 Url: http://chorem.org/repositories/revision/lima/2890 Log: Ajout fonction visualisation des journaux. D?\195?\169placement de classes communes Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/ Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialTransactionService.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -88,10 +88,9 @@ void updateEntry(Entry entry) throws LimaException; void removeEntry(Entry entry) throws LimaException; - - List<Entry> getAllEntriesForAccount(Account account) throws LimaException; - + List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException; - + List<Entry> getAllEntriesForEntryBook(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException; + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -367,12 +367,6 @@ } @Override - public List<Entry> getAllEntriesForAccount(Account account) throws LimaException { - - return getAllEntriesForAccount(account, null, null); - } - - @Override public List<Entry> getAllEntriesForAccount(Account account, Date beginDate, Date endDate) throws LimaException { List<Entry> entries = null; TopiaContext topiaTransaction = null; @@ -411,4 +405,44 @@ return entries; } + + @Override + public List<Entry> getAllEntriesForEntryBook(EntryBook entryBook, Date beginDate, Date endDate) throws LimaException { + List<Entry> entries = null; + TopiaContext topiaTransaction = null; + try { + topiaTransaction = rootContext.beginTransaction(); + EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction); + TopiaQuery query = entryDAO.createQuery(); + + if (entryBook != null) { + query + .add(Entry.ENTRY_BOOK, entryBook); + } + if (beginDate != null && endDate != null){ + String transactionDateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); + query.add(transactionDateProperty+" BETWEEN :beginDate AND :endDate") + .addParam("beginDate", beginDate) + .addParam("endDate", endDate); + } + entries=entryDAO.findAllByQuery(query); + + //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION + for (Entry entry : entries) { + entry.getAccount(); + entry.getFinancialTransaction().getTransactionDate(); + } + + // commit + topiaTransaction.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaTransaction, ex, log); + } + finally { + doFinally(topiaTransaction, log); + } + + return entries; + } } \ No newline at end of file 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-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-05-10 14:42:46 UTC (rev 2890) @@ -140,6 +140,7 @@ --> <JMenu text="lima.reports"> <JMenuItem text="lima.accounts" onActionPerformed='getHandler().showAccountReports(this)'/> + <JMenuItem text="lima.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/> <JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/> <JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/> <JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/> 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-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -38,6 +38,7 @@ import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.accountsreports.AccountsReportsView; import org.chorem.lima.ui.entrybook.EntryBookView; +import org.chorem.lima.ui.entrybooksreports.EntryBooksReportsView; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; import org.chorem.lima.ui.transaction.FinancialTransactionView; import org.chorem.lima.ui.transaction.LetteringView; @@ -306,6 +307,17 @@ } /** + * Show entry book table report to view an account on a period + * @param rootContext + */ + public void showEntryBookReports(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + EntryBooksReportsView entryBooksReportsView= new EntryBooksReportsView(mainView); + mainView.showTab(_("lima.entrybooks"), entryBooksReportsView); + } + + + /** * Show financial transactions view to create entries * @param rootContext */ Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java (from rev 2889, trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsHelper.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ReportsHelper.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,86 @@ +/* *##% 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; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel; + +/** + * TODO add comment here. + * + * @author chatellier + * @version $Revision: 2864 $ + * + * Last update : $Date: 2010-04-16 12:26:55 +0200 (ven. 16 avril 2010) $ + * By : $Author: jpepin $ + */ +public class ReportsHelper { + + /** log. */ + private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); + + /** + * Get total credit for entries. + * + * @param list entries to calculate + * @return total credit + */ + public static double getTotalCredit(List<Entry> entries) { + double credit = 0; + for (Entry entry : entries) { + // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) + if (!entry.getDebit()) { + credit += entry.getAmount(); + } + } + return credit; + } + + /** + * Get total debit for entries. + * + * @param list entries to calculate + * @return total debit + */ + public static double getTotalDebit(List<Entry> entries) { + double debit = 0; + for (Entry entry : entries) { + // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) + if (entry.getDebit()) { + debit += entry.getAmount(); + } + } + return debit; + } + + /** + * Return amount of debit - credit + * + * @param list entries to calculate + * @return Solde + */ + public static double getSolde(List<Entry> entries) { + double balanced = getTotalDebit(entries) - getTotalCredit(entries); + return balanced; + } +} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsHelper.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsHelper.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -1,85 +0,0 @@ -/* *##% Lima Main - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU 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.accountsreports; - -import java.util.List; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.Entry; - -/** - * TODO add comment here. - * - * @author chatellier - * @version $Revision: 2864 $ - * - * Last update : $Date: 2010-04-16 12:26:55 +0200 (ven. 16 avril 2010) $ - * By : $Author: jpepin $ - */ -public class AccountsReportsHelper { - - /** log. */ - private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); - - /** - * Get total credit for entries. - * - * @param list entries to calculate - * @return total credit - */ - public static double getTotalCredit(List<Entry> entries) { - double credit = 0; - for (Entry entry : entries) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (!entry.getDebit()) { - credit += entry.getAmount(); - } - } - return credit; - } - - /** - * Get total debit for entries. - * - * @param list entries to calculate - * @return total debit - */ - public static double getTotalDebit(List<Entry> entries) { - double debit = 0; - for (Entry entry : entries) { - // TODO EC-20100407 voir si le modele correspond (amount, credit,debit) - if (entry.getDebit()) { - debit += entry.getAmount(); - } - } - return debit; - } - - /** - * Return amount of debit - credit - * - * @param list entries to calculate - * @return Solde - */ - public static double getSolde(List<Entry> entries) { - double balanced = getTotalDebit(entries) - getTotalCredit(entries); - return balanced; - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-05-10 14:42:46 UTC (rev 2890) @@ -18,7 +18,7 @@ <Table> <AccountsReportsViewHandler id="handler" javaBean="new AccountsReportsViewHandler(this)" /> <Boolean id="selectedRow" javaBean="false" /> - <org.chorem.lima.ui.transaction.model.AccountComboBoxModel id="modelAccounts"/> + <org.chorem.lima.ui.combobox.AccountComboBoxModel id="modelAccounts"/> <org.chorem.lima.ui.accountsreports.AccountsReportsTableModel id="modelAccountsReportsTable"/> <script> <![CDATA[ @@ -67,7 +67,7 @@ <cell> <JComboBox id="accountSelectorComboBox" model="{getModelAccounts()}" - renderer="{new org.chorem.lima.ui.transaction.model.AccountRenderer()}" + renderer="{new org.chorem.lima.ui.combobox.AccountRenderer()}" onItemStateChanged="getModelAccountsReportsTable().setAccount((Account) event.getItem()); getHandler().updateFooterLabel()" editable="false" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -22,19 +22,12 @@ import java.util.List; - -import javax.swing.JOptionPane; -import javax.swing.text.View; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.ui.transaction.table.FinancialTransactionTable; -import org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel; -import org.chorem.lima.util.ErrorHelper; +import org.chorem.lima.ui.ReportsHelper; + /** * Handler associated with accounts reports view. * @@ -53,14 +46,15 @@ protected AccountsReportsView view; /** Helper **/ - protected AccountsReportsHelper helper; + protected ReportsHelper helper; protected AccountsReportsViewHandler(AccountsReportsView view) { this.view = view; } public void updateFooterLabel(){ - AccountsReportsTableModel tablemodel = (AccountsReportsTableModel) view.getAccountsReportsTable().getModel(); + AccountsReportsTableModel tablemodel = + (AccountsReportsTableModel) view.getAccountsReportsTable().getModel(); List<Entry> cacheDataList = tablemodel.getDataList(); Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,95 @@ +/* *##% 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.combobox; + +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; + +import org.chorem.lima.business.AccountService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.service.LimaServiceFactory; + +/** + * Account combo box model. + */ + +public class AccountComboBoxModel implements ComboBoxModel { + + protected Object selectedAccount; + + protected AccountService accountService; + + public AccountComboBoxModel() { + accountService = LimaServiceFactory.getInstance().getAccountService(); + } + + @Override + public Object getSelectedItem() { + return selectedAccount; + } + + @Override + public void setSelectedItem(Object anItem) { + selectedAccount = anItem; + } + + @Override + public void addListDataListener(ListDataListener arg0) { + // TODO Auto-generated method stub + + } + + @Override + public Object getElementAt(int index) { + Object result = null; + // TODO add cache + try { + result = accountService.getAllAccounts().get(index); + } + catch (LimaException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + return result; + } + + @Override + public int getSize() { + int result = 0; + // TODO add cache + try { + result = accountService.getAllAccounts().size(); + } + catch (LimaException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + return result; + } + + @Override + public void removeListDataListener(ListDataListener arg0) { + // TODO Auto-generated method stub + + } + + + + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,30 @@ +package org.chorem.lima.ui.combobox; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.Account; + +public class AccountRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + Account account = (Account) value; + if (account != null){ + label.setText(account.getAccountNumber()+" - "+account.getLabel()); + } + return label; + + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookComboBoxModel.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -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.combobox; + +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 selectedEntryBook; + + protected EntryBookService entryBookService; + + public EntryBookComboBoxModel() { + 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) { + selectedEntryBook = anItem; + } + + /* + * @see javax.swing.ComboBoxModel#getSelectedItem() + */ + @Override + public Object getSelectedItem() { + return selectedEntryBook; + } +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/EntryBookRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,34 @@ +package org.chorem.lima.ui.combobox; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.EntryBook; + + + +public class EntryBookRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + EntryBook entrybook = (EntryBook) value; + if (entrybook != null){ + label.setText(entrybook.getCode()+" - "+entrybook.getLabel()); + } + return label; + + } + + + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,135 @@ +/* *##% 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.combobox; + +import java.util.Collection; + +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; + +import org.apache.commons.collections.CollectionUtils; +import org.chorem.lima.business.FinancialPeriodService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.service.LimaServiceFactory; + +/** + * Opened financial period combo box model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FinancialPeriodComboBoxModel implements ComboBoxModel { + + protected Object selectedFinancialPeriod; + + protected FinancialPeriodService financialPeriodService; + + protected FiscalPeriod selectedFiscalPeriod; + + public FinancialPeriodComboBoxModel() { + financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService(); + } + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + selectedFiscalPeriod=fiscalPeriod; + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + // TODO add cache + try { + if (selectedFiscalPeriod != null){ + + result = selectedFiscalPeriod.getFinancialPeriod().size(); + } + else { + result = financialPeriodService. + getUnblockedFinancialPeriods().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 { + if (selectedFiscalPeriod != null){ + result = CollectionUtils.get(selectedFiscalPeriod.getFinancialPeriod(), index); + } + else { + result = financialPeriodService.getUnblockedFinancialPeriods(). + 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) { + selectedFinancialPeriod = anItem; + } + + /* + * @see javax.swing.ComboBoxModel#getSelectedItem() + */ + @Override + public Object getSelectedItem() { + return selectedFinancialPeriod; + } +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,63 @@ +/* *##% 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.combobox; + +import static org.nuiton.i18n.I18n._; + +import java.awt.Component; +import java.util.Calendar; +import java.util.Date; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.FinancialPeriod; + + +public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + String[] monthName = {_("lima.date.january"), _("lima.date.february"), + _("lima.date.march"), _("lima.date.april"), _("lima.date.may"), + _("lima.date.june"), _("lima.date.july"), _("lima.date.august"), + _("lima.date.september"), _("lima.date.october"), + _("lima.date.november"), _("lima.date.december")}; + + JLabel label = new JLabel(); + FinancialPeriod financialperiod = (FinancialPeriod) value; + if (financialperiod != null){ + Date d = financialperiod.getBeginDate(); + Calendar beginDate = Calendar.getInstance(); + beginDate.setTime(d); + int year = beginDate.get(Calendar.YEAR); + label.setText(monthName[beginDate.get(Calendar.MONTH)]+" "+String.valueOf(year)); + } + return label; + } + + +} \ No newline at end of file Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,104 @@ +/* *##% 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.combobox; + +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; + +import org.chorem.lima.business.FiscalPeriodService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FiscalPeriodDAO; +import org.chorem.lima.entity.LimaCallaoDAOHelper; +import org.chorem.lima.service.LimaServiceFactory; + +public class FiscalPeriodComboBoxModel implements ComboBoxModel{ + + protected Object selectedFiscalPeriod; + + protected FiscalPeriodService fiscalPeriodService; + + public FiscalPeriodComboBoxModel(){ + fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService(); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + // TODO add cache + try { + result = fiscalPeriodService.getAllUnblockedFiscalPeriods().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; + try { + result = fiscalPeriodService.getAllUnblockedFiscalPeriods().get(index); + } + catch (LimaException ex) { + 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) { + selectedFiscalPeriod = anItem; + } + + /* + * @see javax.swing.ComboBoxModel#getSelectedItem() + */ + @Override + public Object getSelectedItem() { + return selectedFiscalPeriod; + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java (from rev 2883, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -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. + * ##%*/ + +package org.chorem.lima.ui.combobox; + +import java.awt.Component; +import java.util.Calendar; +import java.util.Date; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; + +public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + FiscalPeriod fiscalPeriod = (FiscalPeriod) value; + if (fiscalPeriod != null){ + Date d = fiscalPeriod.getBeginDate(); + Calendar beginDate = Calendar.getInstance(); + beginDate.setTime(d); + int date = beginDate.get(Calendar.YEAR); + label.setText(String.valueOf(date)); + } + return label; + } + + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,216 @@ +/* + * *##% 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.entrybooksreports; + +import static org.nuiton.i18n.I18n._; + +import java.util.ArrayList; +import java.util.Date; +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.EntryBookService; +import org.chorem.lima.business.FinancialTransactionService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.ErrorHelper; + +/** + * Entry book table model. + * + * @author ore + * @author chatellier + * @version $Revision: 2865 $ + * + * Last update : $Date: 2010-04-19 15:19:30 +0200 (lun. 19 avril 2010) $ + * By : $Author: jpepin $ + */ +public class EntryBooksReportsTableModel extends AbstractTableModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 7578692417919755647L; + + /** log. */ + private static final Log log = LogFactory.getLog(EntryBooksReportsTableModel.class); + + /** Services. */ + protected FinancialTransactionService financialTransactionService; + + /** Account. */ + protected EntryBook selectedEntryBook; + + /** Begin Date. */ + protected Date selectedBeginDate; + + /** EndDate. */ + protected Date selectedEndDate; + + /** data cache */ + protected List<Entry> cacheDataList; + + /** + * Constructor. + */ + public EntryBooksReportsTableModel() { + + financialTransactionService = LimaServiceFactory.getInstance().getTransactionService(); + } + + @Override + public int getRowCount() { + int result = 0; + + // just prevent too much result + if (selectedEntryBook != null) { + result = cacheDataList.size(); + } + else { + if (log.isDebugEnabled()) { + log.debug("No account selected skip table model update"); + } + } + + return result; + } + + @Override + public int getColumnCount() { + return 6; + } + + @Override + public String getColumnName(int column) { + String res = "n/a"; + switch (column) { + case 0: + res = _("lima.transaction.column.date"); //Date + break; + case 1: + res = _("lima.transaction.column.account"); //Account + break; + case 2: + res = _("lima.transaction.column.voucher"); // Voucher + break; + case 3: + res = _("lima.transaction.column.description"); //Description + break; + case 4: + res = _("lima.transaction.column.debit"); //Debit + break; + case 5: + res = _("lima.transaction.column.credit"); //Credit + break; + } + return res; + } + + @Override + public Object getValueAt(int row, int column) { + Object result = null; + if(selectedEntryBook != null) { + Entry currentRow = cacheDataList.get(row); + + switch (column) { + case 0: + result = currentRow.getFinancialTransaction().getTransactionDate(); + break; + case 1: + if (currentRow.getAccount() != null){ + result = currentRow.getAccount().getAccountNumber(); + } + else { + result = null; + } + break; + case 2: + result = currentRow.getVoucher(); + break; + case 3: + result = currentRow.getDescription(); + break; + case 4: + result = currentRow.getDebit() ? currentRow.getAmount() : 0; + break; + case 5: + result = currentRow.getDebit() ? 0 : currentRow.getAmount(); + break; + } + } + else { + if (log.isDebugEnabled()) { + log.debug("No Account selected skip table model update"); + } + } + + return result; + } + + + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + // Just read, no write + return false; + } + + public void setBeginDate(Date date){ + log.debug("setBeginDate"); + selectedBeginDate = date; + log.debug(selectedBeginDate); + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + public void setEndDate(Date date){ + log.debug("setEndDate"); + selectedEndDate = date; + log.debug(selectedEndDate); + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + + public void setEntryBook(EntryBook entryBook) { + selectedEntryBook = entryBook; + cacheDataList=getDataList(); + fireTableDataChanged(); + } + + public List<Entry> getDataList(){ + List<Entry> results = new ArrayList<Entry>(); + try { + results = financialTransactionService.getAllEntriesForEntryBook(selectedEntryBook, selectedBeginDate, selectedEndDate); + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get entries list", eee); + } + return results; + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,110 @@ +<!-- ##% 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> + <EntryBooksReportsViewHandler id="handler" javaBean="new EntryBooksReportsViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/> + <org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTableModel id="modelEntryBooksReportsTable"/> + <script> + <![CDATA[ + + import org.chorem.lima.entity.EntryBook; + import org.apache.commons.lang.time.DateUtils; + import java.util.Calendar; + + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + getModelEntryBooksReportsTable().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + getModelEntryBooksReportsTable().setEndDate(endDate); + + getBeginDatePicker().setDate(beginDate); + getEndDatePicker().setDate(endDate); + + ]]> + </script> + <row fill="horizontal" weightx="1" weighty="0" anchor="center"> + <cell> + <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/> + </cell> + <cell> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker" + onActionPerformed="getModelEntryBooksReportsTable().setBeginDate(beginDatePicker.getDate()); + getHandler().updateFooterLabel()" /> + </cell> + <cell> + <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/> + </cell> + <cell> + <org.jdesktop.swingx.JXDatePicker id="endDatePicker" + onActionPerformed="getModelEntryBooksReportsTable().setEndDate(endDatePicker.getDate()); + getHandler().updateFooterLabel()"/> + </cell> + <cell> + <JLabel id="entryBookSelectorLabel" text="lima.entrybook"/> + </cell> + <cell> + <JComboBox id="entryBookComboBox" + model="{getModelEntryBook()}" + renderer="{new org.chorem.lima.ui.combobox.EntryBookRenderer()}" + onItemStateChanged="getModelEntryBooksReportsTable().setEntryBook((EntryBook) event.getItem()); + getHandler().updateFooterLabel()" + editable="false" + /> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" columns="7"> + <JScrollPane> + <org.jdesktop.swingx.JXTable id="entryBooksReportsTable" rowHeight="24" + model="{getModelEntryBooksReportsTable()}" + highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" + columnControlVisible="true"/> + <javax.swing.ListSelectionModel javaBean="getEntryBooksReportsTable().getSelectionModel()" + onValueChanged="setSelectedRow(entryBooksReportsTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> + <row fill="horizontal" anchor="center"> + <cell> + <JLabel text="lima.amountcredit"/> + </cell> + <cell> + <JLabel id="amountCreditLabel" /> + </cell> + <cell> + <JLabel text="lima.amountdebit" /> + </cell> + <cell> + <JLabel id="amountDebitLabel" /> + </cell> + <cell> + <JLabel id="soldeLabel" text="lima.solde"/> + </cell> + <cell> + <JLabel id="amountSoldeLabel"/> + </cell> + </row> +</Table> \ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -0,0 +1,83 @@ +/* *##% 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.entrybooksreports; + +import static org.nuiton.i18n.I18n._; + +import java.util.List; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.ui.ReportsHelper; + + +/** + * Handler associated with accounts reports view. + * + * @author chatellier + * @version $Revision: 2884 $ + * + * Last update : $Date: 2010-05-06 11:57:19 +0200 (jeu. 06 mai 2010) $ + * By : $Author: jpepin $ + */ +public class EntryBooksReportsViewHandler { + + /** log. */ + private static final Log log = + LogFactory.getLog(EntryBooksReportsViewHandler.class); + + protected EntryBooksReportsView view; + + /** Helper **/ + protected ReportsHelper helper; + + protected EntryBooksReportsViewHandler(EntryBooksReportsView view) { + this.view = view; + } + + public void updateFooterLabel(){ + EntryBooksReportsTableModel tablemodel = + (EntryBooksReportsTableModel) view.getEntryBooksReportsTable().getModel(); + + List<Entry> cacheDataList = tablemodel.getDataList(); + + if (tablemodel.getDataList() != null){ + Double amountCredit = helper.getTotalCredit(cacheDataList); + Double amountDebit = helper.getTotalDebit(cacheDataList); + view.amountCreditLabel.setText(String.valueOf(amountCredit)); + view.amountDebitLabel.setText(String.valueOf(amountDebit)); + Double amountSolde = Math.abs(helper.getSolde(cacheDataList)); + view.amountSoldeLabel.setText(String.valueOf(amountSolde)); + if (amountSolde <0){ + //solde debiteur + view.soldeLabel.setText(_("lima.soldecredit")); + } + else if(amountSolde > 0) { + //solde créditeur + view.soldeLabel.setText(_("lima.soldedebit")); + } + else { + //solde = 0 + view.soldeLabel.setText(_("lima.solde")); + } + } + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionView.jaxx 2010-05-10 14:42:46 UTC (rev 2890) @@ -18,7 +18,7 @@ <Table> <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" /> <Boolean id="selectedRow" javaBean="false" /> - <org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> + <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> <script> <![CDATA[ @@ -43,8 +43,8 @@ </cell> <cell> <JComboBox id="fiscalPeriodComboBox" - model="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxRenderer()}" + model="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel()}" + renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}" onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())" editable="false"/> </cell> @@ -55,7 +55,7 @@ <cell> <JComboBox id="financialPeriodComboBox" model="{getModelFinancialPeriod()}" - renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}" + renderer="{new org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer()}" onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())" editable="false" /> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringView.jaxx 2010-05-10 14:42:46 UTC (rev 2890) @@ -52,7 +52,7 @@ </cell> <cell> <org.chorem.lima.widgets.JWideComboBox id="accountComboBox" - model="{new org.chorem.lima.ui.transaction.model.AccountComboBoxModel()}" /> + model="{new org.chorem.lima.ui.combobox.AccountComboBoxModel()}" /> </cell> </row> <!-- from --> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -30,8 +30,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; -import org.chorem.lima.ui.transaction.model.AccountComboBoxModel; -import org.chorem.lima.ui.transaction.model.AccountRenderer; +import org.chorem.lima.ui.combobox.AccountComboBoxModel; +import org.chorem.lima.ui.combobox.AccountRenderer; import org.chorem.lima.widgets.JWideComboBox; public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-05-10 14:42:46 UTC (rev 2890) @@ -30,8 +30,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel; -import org.chorem.lima.ui.transaction.model.EntryBookRenderer; +import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; +import org.chorem.lima.ui.combobox.EntryBookRenderer; import org.chorem.lima.widgets.JWideComboBox; public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { 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-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-05-10 14:42:46 UTC (rev 2890) @@ -104,6 +104,7 @@ lima.entries.addtransaction= lima.entries.lettering= lima.entries.searchtransaction= +lima.entrybook= lima.entrybook.code= lima.entrybook.label= lima.entrybook.type= @@ -112,6 +113,7 @@ lima.entrybook.type3= lima.entrybook.type4= lima.entrybook.type5= +lima.entrybooks=EntryBooks 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 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-05-10 13:13:56 UTC (rev 2889) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-10 14:42:46 UTC (rev 2890) @@ -102,6 +102,7 @@ lima.entries.addtransaction=Saisir des \u00E9critures lima.entries.lettering=Ajouter une lettre lima.entries.searchtransaction=Recherche les transactions +lima.entrybook= lima.entrybook.code=Code lima.entrybook.label=Libelle lima.entrybook.type=Type @@ -110,6 +111,7 @@ lima.entrybook.type3=Tr\u00E9sorerie lima.entrybook.type4=G\u00E9n\u00E9ral lima.entrybook.type5=Situation +lima.entrybooks=Journaux 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