Author: echatellier Date: 2012-04-13 15:46:24 +0200 (Fri, 13 Apr 2012) New Revision: 3366 Url: http://chorem.org/repositories/revision/lima/3366 Log: Refatoring de la saisie des ?\195?\169critures Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookListRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodListRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodListRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/package-info.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/pom.xml trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.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/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ServiceMonitorable.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -26,6 +26,7 @@ package org.chorem.lima.business; + public interface ServiceMonitorable { void addServiceListener(ServiceListener l); 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -136,14 +136,14 @@ /** Return the list of all financial transaction of a financial period */ @Override - public List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod( + public List<FinancialTransaction> getAllFinancialTransactions( FinancialPeriod period) throws LimaException { - return getAllFinancialTransactionsForEntryBookAndFinancialPeriod(null, period); + return getAllFinancialTransactions(period, null); } /** Return the list of all financial transaction from two dates */ @Override - public List<FinancialTransaction> getAllFinancialTransactionsFromDateToDate( + public List<FinancialTransaction> getAllFinancialTransactions( Date beginDate, Date endDate) throws LimaException { List<FinancialTransaction> financialTransactions = null; TopiaContext topiaTransaction = beginTransaction(rootContext); @@ -178,7 +178,7 @@ /** Return the list of all financial transaction of a financial period and an entrybook */ @Override - public List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException { + public List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod financialPeriod, EntryBook entryBook) throws LimaException { List<FinancialTransaction> financialTransactions = null; TopiaContext topiaTransaction = beginTransaction(rootContext); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as Modified: trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -148,9 +148,12 @@ } protected <M> M newService(Class<M> serviceMonitorableClass) { - M result; Object ejbHome; String serviceName = serviceMonitorableClass.getSimpleName().replace("Monitorable", "Impl"); + // only usefull during non monitorable transition + if (!serviceName.endsWith("Impl")) { + serviceName += "Impl"; + } try { ejbHome = container.getContext().lookup(NAMESPACE + serviceName); } catch (NamingException eee) { @@ -160,7 +163,7 @@ } InvocationHandler handler = new ServiceMonitorableHandler(ejbHome); ClassLoader classLoader = serviceMonitorableClass.getClassLoader(); - result = (M) Proxy.newProxyInstance( + M result = (M) Proxy.newProxyInstance( classLoader, new Class[]{ServiceMonitorable.class, serviceMonitorableClass}, handler Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -55,13 +55,11 @@ void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod(FinancialPeriod period) throws LimaException; + List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period) throws LimaException; - List<FinancialTransaction> getAllFinancialTransactionsFromDateToDate(Date beginDate, - Date endDate) throws LimaException; + List<FinancialTransaction> getAllFinancialTransactions(Date beginDate, Date endDate) throws LimaException; - List<FinancialTransaction> getAllFinancialTransactionsForEntryBookAndFinancialPeriod(EntryBook entryBook, - FinancialPeriod period) throws LimaException; + List<FinancialTransaction> getAllFinancialTransactions(FinancialPeriod period, EntryBook entryBook) throws LimaException; List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException; Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java (rev 0) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,47 @@ +/* + * #%L + * Lima callao + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.entity; + +import java.math.BigDecimal; + +/** + * Define default value for entry entity. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EntryImpl extends EntryAbstract { + + private static final long serialVersionUID = 7016948394597245796L; + + public EntryImpl() { + setAmount(BigDecimal.ZERO); + } + +} //EntryImpl Property changes on: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryImpl.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionImpl.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -46,11 +46,11 @@ @Override public BigDecimal getAmountDebit() { BigDecimal result = new BigDecimal(0); - for (Entry entryFT : getEntry()) { + /*for (Entry entryFT : getEntry()) { if (entryFT.isDebit()) { result.add(entryFT.getAmount()); } - } + }*/ return result; } @@ -60,11 +60,11 @@ @Override public BigDecimal getAmountCredit() { BigDecimal result = new BigDecimal(0); - for (Entry entryFT : getEntry()) { + /*for (Entry entryFT : getEntry()) { if (!entryFT.isDebit()) { result.add(entryFT.getAmount()); } - } + }*/ return result; } } Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/pom.xml =================================================================== --- trunk/lima-swing/pom.xml 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/pom.xml 2012-04-13 13:46:24 UTC (rev 3366) @@ -18,6 +18,12 @@ <dependencies> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>lima-business-api</artifactId> + <version>${project.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>lima-business</artifactId> <version>${project.version}</version> <scope>compile</scope> Modified: 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -50,8 +50,7 @@ import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.AccountService; -import org.chorem.lima.business.monitorable.AccountServiceMonitorable; -import org.chorem.lima.business.monitorable.ImportServiceMonitorable; +import org.chorem.lima.business.api.ImportService; import org.chorem.lima.entity.Account; import org.chorem.lima.enums.AccountsChartEnum; import org.chorem.lima.enums.ImportExportEnum; @@ -111,8 +110,8 @@ public AccountViewHandler(AccountView view) { this.view = view; // Gets factory service - LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); - accountService = LimaServiceFactory.getService(AccountServiceMonitorable.class); + LimaServiceFactory.addServiceListener(ImportService.class, this); + accountService = LimaServiceFactory.getService(AccountService.class); } /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -34,7 +34,6 @@ import org.chorem.lima.business.monitorable.ImportServiceMonitorable; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; @@ -47,7 +46,7 @@ private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + LogFactory.getLog(AccountComboBoxModel.class); protected Object selectedAccount; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -34,7 +34,6 @@ import org.chorem.lima.business.monitorable.ImportServiceMonitorable; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; @@ -54,7 +53,7 @@ private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + LogFactory.getLog(EntryBookComboBoxModel.class); protected Object selectedEntryBook; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -36,7 +36,6 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; @@ -56,7 +55,7 @@ private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + LogFactory.getLog(FinancialPeriodComboBoxModel.class); protected Object selectedFinancialPeriod; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -40,8 +40,9 @@ import java.util.ArrayList; import java.util.List; -/** Account combo box model. */ - +/** + * Account combo box model. + */ public class SubAccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { private static final long serialVersionUID = 1L; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,40 @@ +/* + * #%L + * Lima Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import org.chorem.lima.entity.EntryBook; + +/** + * Entry book combo model. + * + * @author chatellier + * @version $Revision$ + */ +public class EntryBookComboBoxModel extends GenericComboBoxModel<EntryBook> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6991293987668268456L; +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookComboBoxModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookListRenderer.java (from rev 3360, trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookListRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/EntryBookListRenderer.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,61 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * 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>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; + +import org.chorem.lima.entity.EntryBook; + +/** + * EntryBook renderer for fiscal period retaining earning list. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EntryBookListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -9089182547408397051L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + EntryBook entryBook = (EntryBook)value; + Object newValue = entryBook; + if (entryBook != null) { + newValue = entryBook.getCode() + " - " + entryBook.getLabel(); + } + return super.getListCellRendererComponent(list, newValue, index, isSelected, + cellHasFocus); + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,40 @@ +/* + * #%L + * Lima Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import org.chorem.lima.entity.FinancialPeriod; + +/** + * Financial period combo model. + * + * @author chatellier + * @version $Revision$ + */ +public class FinancialPeriodComboBoxModel extends GenericComboBoxModel<FinancialPeriod> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 6991293987668268456L; +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodComboBoxModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodListRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodListRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodListRenderer.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,64 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * 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>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import java.awt.Component; +import java.text.DateFormat; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; + +import org.chorem.lima.entity.FinancialPeriod; + +/** + * Financial period list renderer. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FinancialPeriodListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -9089182547408397051L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + FinancialPeriod financialPeriod = (FinancialPeriod)value; + Object newValue = financialPeriod; + if (financialPeriod != null) { + DateFormat df = DateFormat.getDateInstance(); + newValue = df.format(financialPeriod.getBeginDate()) + " - " + df.format(financialPeriod.getEndDate()); + } + return super.getListCellRendererComponent(list, newValue, index, isSelected, + cellHasFocus); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialPeriodListRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,44 @@ +/* + * #%L + * Lima Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import org.chorem.lima.entity.FiscalPeriod; + +/** + * Model des exercices comptable. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FiscalPeriodComboBoxModel extends GenericComboBoxModel<FiscalPeriod> { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3017195549616278980L; + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodComboBoxModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodListRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodListRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodListRenderer.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,64 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * 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>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import java.awt.Component; +import java.text.DateFormat; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; + +import org.chorem.lima.entity.FiscalPeriod; + +/** + * Fiscal period list renderer. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FiscalPeriodListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -9089182547408397051L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + FiscalPeriod fiscalPeriod = (FiscalPeriod)value; + Object newValue = fiscalPeriod; + if (fiscalPeriod != null) { + DateFormat df = DateFormat.getDateInstance(); + newValue = df.format(fiscalPeriod.getBeginDate()) + " - " + df.format(fiscalPeriod.getEndDate()); + } + return super.getListCellRendererComponent(list, newValue, index, isSelected, + cellHasFocus); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FiscalPeriodListRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,67 @@ +/* + * #%L + * Lima Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.common; + +import java.util.List; + +import javax.swing.DefaultComboBoxModel; + +/** + * Model generique pour les objects lima. + * + * @param <E> type d'object géré + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class GenericComboBoxModel<E> extends DefaultComboBoxModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 4778917695588663498L; + + protected List<E> objects; + + @Override + public int getSize() { + int result = 0; + if (objects != null) { + result = objects.size(); + } + return result; + } + + @Override + public Object getElementAt(int index) { + return objects.get(index); + } + + public void setObjects(List<E> objects) { + this.objects = objects; + fireContentsChanged(this, 0, objects.size()); + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/GenericComboBoxModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2011 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,8 +24,6 @@ */ package org.chorem.lima.ui.entrybook; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jdesktop.swingx.JXTable; import java.awt.event.KeyEvent; @@ -39,10 +37,6 @@ /** serialVersionUID. */ private static final long serialVersionUID = 6228396251512013262L; - /** log. */ - private static final Log log = LogFactory - .getLog(EntryBookTable.class); - protected EntryBookViewHandler handler; public EntryBookTable(EntryBookViewHandler handler) { Modified: 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -37,8 +37,7 @@ import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.EntryBookService; -import org.chorem.lima.business.monitorable.EntryBookServiceMonitorable; -import org.chorem.lima.business.monitorable.ImportServiceMonitorable; +import org.chorem.lima.business.api.ImportService; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; import org.chorem.lima.enums.EntryBooksChartEnum; @@ -66,10 +65,8 @@ public EntryBookViewHandler(EntryBookView view) { this.view = view; - entryBookService = - LimaServiceFactory.getService( - EntryBookServiceMonitorable.class); - LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + entryBookService = LimaServiceFactory.getService(EntryBookService.class); + LimaServiceFactory.addServiceListener(ImportService.class, this); } public void init() { Modified: 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-04-13 13:46:24 UTC (rev 3366) @@ -35,7 +35,7 @@ <EntryBooksReportsViewHandler id="handler" javaBean="new EntryBooksReportsViewHandler(this)"/> <Boolean id="selectedRow" javaBean="false"/> - <EntryBookComboBoxModel id="modelEntryBook"/> + <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/> <EntryBooksReportsTableModel id="modelTable"/> <script> <![CDATA[ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin,Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -62,14 +62,8 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; -// /** log. */ -// private static final Log log = LogFactory -// .getLog(FinancialTransactionTable.class); - protected FinancialTransactionViewHandler handler; -// private ColorHighlighter colorBalance; - private int x_tab; private int y_tab; @@ -148,238 +142,6 @@ return handler; } -// /** -// * Cette méthode permet de colorer toutes les transactions dans le tableau -// * afin de bien distinguer les transactions et entrées comptables. -// * On récupère la première cellule, on vérifie que c'est une date -// */ -// protected void addColorTransaction() { -// if (colorTransaction != null) { -// removeHighlighter(colorTransaction); -// } -// HighlightPredicate predicate = new HighlightPredicate() { -// @Override -// public boolean isHighlighted(Component renderer, -// ComponentAdapter adapter) { -// return adapter.getValueAt(adapter.row, 0) instanceof Date; -// } -// }; -// colorTransaction = -// new ColorHighlighter(predicate, new Color(222, 222, 222), null); -// addHighlighter(colorTransaction); -// } - -// /** -// * Permet de surligner une transaction dans le tableau lorsque -// * cette dernière n'est pas équilibrée. -// * On récupère la dernière cellule de la ligne -// * et on vérifie si la valeur est différente de 0 -// */ -// protected void addColorNonBalancedTransaction() { -// if (colorBalance != null) { -// removeHighlighter(colorBalance); -// } -// HighlightPredicate predicate = new HighlightPredicate() { -// @Override -// public boolean isHighlighted(Component renderer, -// ComponentAdapter adapter) { -// boolean isHighlighted = false; -// Object value = adapter.getValueAt(adapter.row, 8); -// if (value instanceof BigDecimal) { -// BigDecimal currentBalance = (BigDecimal) value; -// // can compare two BigDecimals with different scales -// // e.g: 3.1 == 3.10 -// if (currentBalance.compareTo(BigDecimal.ZERO) != 0) { -// isHighlighted = true; -// } -// } -// return isHighlighted; -// } -// }; -// colorTransaction = -// new ColorHighlighter(predicate, new Color(255, 198, 209), null); -// addHighlighter(colorTransaction); -// } - -// /** -// * for each action combination key are think -// * for extend keyboard and laptop keyboard -// */ -// @Override -// public void keyPressed(KeyEvent e) { -// -// //TODO combinaison de touches dans la config -// -// // delete selected row with the key : delete or ctrl + clear -// // ou de l'entree -// if (e.getKeyCode() == KeyEvent.VK_DELETE -// || e.getKeyCode() == KeyEvent.VK_CLEAR -// && e.getModifiers() == KeyEvent.CTRL_MASK) { -// handler.deleteSelectedRow(); -// } -// -// // add entry with the key combination : insert or ctrl + enter -// if (e.getKeyCode() == KeyEvent.VK_INSERT -// || e.getKeyCode() == KeyEvent.VK_ENTER -// && e.getModifiers() == KeyEvent.CTRL_MASK) { -// handler.addEntry(); -// } -// -// // copy : ctrl + c -// -// // add financial transaction with the key combination : ctrl + c -// if (e.getKeyCode() == KeyEvent.VK_C -// && e.getModifiers() == KeyEvent.CTRL_MASK) { -// handler.copyRow(); -// } -// -// // paste : ctrl + v -// -// // add financial transaction with the key combination : ctrl + v -// if (e.getKeyCode() == KeyEvent.VK_V -// && e.getModifiers() == KeyEvent.CTRL_MASK) { -// handler.pasteRow(); -// } -// -// // add financial transaction with the key combination : ctrl + tab -// if (e.getKeyCode() == KeyEvent.VK_TAB -// && e.getModifiers() == KeyEvent.CTRL_MASK) { -// handler.addFinancialTransaction(); -// } -// -// // clear row selection with the key: escape -// if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { -// if (!isEditing()) { -// clearSelection(); -// } -// } -// -// /** -// * Touche tab -// * Incrémente le curseur de case tant que la case n'est pas editable -// * Ajoute une entrée comptable si tab est sur -// * la dernière cellule et si la transaction est non équilibré -// * sinon rajoute une transaction -// */ -// -// if (e.getKeyChar() == KeyEvent.VK_TAB) { -// int max_x = getColumnCount(); -// int max_y = getRowCount(); -// x_tab = getSelectedColumn(); -// y_tab = getSelectedRow(); -// Boolean end = true; -// -// if (x_tab < max_x - 1) { -// x_tab++; -// } -// //end of row -// else { -// x_tab = 0; -// y_tab++; -// } -// -// //skip all cell while not editable or if end of table add entry or transaction or end of table -// while (!isCellEditable(y_tab, x_tab) && end) { -// //if end of row -// if (x_tab == max_x - 1) { -// Object object = handler.tableModel.getElementAt(y_tab); -// -// //if transaction, add entry -// if (object instanceof FinancialTransaction) { -// FinancialTransaction financialTransaction = (FinancialTransaction) object; -// if (financialTransaction.getEntry().size() == 0) { -// handler.addEntry(); -// setColumnSelectionInterval(1, 1); -// } -// } -// //if entry -// else { -// //FIXME set value is doing after key pressed -// // so update not terminated before get balanced -// //Swing Worker stop the UI 500ms -// // found best solution ? -// final JXTable table = this; -// final int y_t = y_tab; -// final int m_t = max_y; -// new SwingWorker<Void, Void>() { -// @Override -// protected Void doInBackground() throws InterruptedException { -// Thread.sleep(500); -// return null; -// } -// -// @Override -// protected void done() { -// Object object = handler.tableModel.getElementAt(y_tab - 1); -// FinancialTransaction financialTransaction = null; -// if (object instanceof Entry) { -// financialTransaction = ((Entry) object).getFinancialTransaction(); -// } else if (object instanceof FinancialTransaction) { -// financialTransaction = (FinancialTransaction) object; -// } -// BigDecimal amountC = financialTransaction.getAmountCredit(); -// BigDecimal amountD = financialTransaction.getAmountDebit(); -// if (amountC == amountD) { -// if (y_t == m_t - 1) { -// handler.addFinancialTransaction(); -// table.setColumnSelectionInterval(0, 0); -// } -// } else { -// handler.addEntry(); -// table.setColumnSelectionInterval(1, 1); -// y_tab++; -// // positionne la sélection sur la nouvelle ligne créée -// table.setRowSelectionInterval(y_tab, y_tab); -// x_tab = 0; -// } -// } -// }.execute(); -// } -// end = false; -// } else { -// if (x_tab < max_x) { -// setRowSelectionInterval(y_tab, y_tab); -// setColumnSelectionInterval(x_tab, x_tab); -// x_tab++; -// } -// } -// } -// } -// } -// -// -// @Override -// public void keyTyped(KeyEvent e) { -// } -// -// -// @Override -// public void keyReleased(KeyEvent e) { -// } -// -// @Override -// public void mouseClicked(MouseEvent e) { -// } -// -// @Override -// public void mousePressed(MouseEvent e) { -// if (rowAtPoint(e.getPoint()) == -1) { -// clearSelection(); -// } -// } -// -// @Override -// public void mouseReleased(MouseEvent e) { -// } -// -// @Override -// public void mouseEntered(MouseEvent e) { -// } -// -// @Override -// public void mouseExited(MouseEvent e) { -// } - private class MyKeyAdapter extends KeyAdapter { @Override @@ -459,7 +221,7 @@ while (!isCellEditable(y_tab, x_tab) && end) { //if end of row if (x_tab == max_x - 1) { - Object object = handler.getTableModel().getElementAt(y_tab); + Object object = handler.view.getFinancialTransactionTableModel().getElementAt(y_tab); //if transaction, add entry if (object instanceof FinancialTransaction) { @@ -486,7 +248,7 @@ @Override protected void done() { - Object object = handler.getTableModel().getElementAt(y_tab - 1); + Object object = handler.view.getFinancialTransactionTableModel().getElementAt(y_tab - 1); FinancialTransaction financialTransaction = null; if (object instanceof Entry) { financialTransaction = ((Entry) object).getFinancialTransaction(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -25,116 +25,46 @@ package org.chorem.lima.ui.financialtransaction; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaBusinessException; +import static org.nuiton.i18n.I18n._; + +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +import javax.swing.table.AbstractTableModel; + import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.api.FinancialTransactionService; -import org.chorem.lima.business.monitorable.FinancialTransactionServiceMonitorable; -import org.chorem.lima.business.monitorable.ImportServiceMonitorable; -import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.EntryImpl; -import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.ErrorHelper; -import javax.swing.table.AbstractTableModel; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - /** * Basic transaction table model. - * <p/> - * Le modele est filtré sur {@link #selectedFinancialPeriod} et - * {@link #selectedFinancialPeriod} (montée en charge !). * * @author ore * @author chatellier * @version $Revision$ */ -public class FinancialTransactionTableModel extends AbstractTableModel implements ServiceListener { +public class FinancialTransactionTableModel extends AbstractTableModel { - private static final long serialVersionUID = 1L; + /** serialVersionUID. */ + private static final long serialVersionUID = -7495388454688562991L; - /** log. */ - private static final Log log = LogFactory - .getLog(FinancialTransactionTableModel.class); + /** Service (just to update setValueAt(). */ + protected FinancialTransactionService financialTransactionService; - /** Transaction service. */ - protected final FinancialTransactionService financialTransactionService; + protected List<Object> transactionAndEntries; - /** selected financial period */ - protected FinancialPeriod selectedFinancialPeriod; - - /** data cache */ - protected List<?> cacheDataList; - - protected EntryBook selectedEntryBook; - public FinancialTransactionTableModel() { - /* Services */ - financialTransactionService = LimaServiceFactory.getService( - FinancialTransactionServiceMonitorable.class); - LimaServiceFactory.addServiceListener(financialTransactionService, this); - LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); } - /** - * Le model est une combinaison de Transaction/Entries. - * - * @return - */ - protected List<?> getDataList() { - List<Object> results = new ArrayList<Object>(); - if (selectedFinancialPeriod != null) { - try { - List<FinancialTransaction> transactions; - - if (selectedEntryBook == null) { - - // get all transactions for all entry books - transactions = financialTransactionService.getAllFinancialTransactionsForFinancialPeriod( - selectedFinancialPeriod); - } else { - - // get all transactions for selected entry book - transactions = financialTransactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod( - selectedEntryBook, - selectedFinancialPeriod - ); - } - - for (FinancialTransaction transaction : transactions) { - results.add(transaction); - List<Entry> entries = (List<Entry>) transaction.getEntry(); - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't update model", eee); - } - ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } - } - return results; - } - - public void refresh() { - cacheDataList = getDataList(); + public void setTransactionAndEntries(List<Object> transactionAndEntries) { + this.transactionAndEntries = transactionAndEntries; fireTableDataChanged(); } @@ -186,31 +116,31 @@ switch (column) { case 0: - result = _("lima.table.date"); + result = _("lima.ui.financialtransaction.date"); break; case 1: - result = _("lima.table.entrybook"); + result = _("lima.ui.financialtransaction.entrybook"); break; case 2: - result = _("lima.table.voucher"); + result = _("lima.ui.financialtransaction.voucher"); break; case 3: - result = _("lima.table.account"); + result = _("lima.ui.financialtransaction.account"); break; case 4: - result = _("lima.table.description"); + result = _("lima.ui.financialtransaction.description"); break; case 5: - result = _("lima.table.letter"); + result = _("lima.ui.financialtransaction.letter"); break; case 6: - result = _("lima.table.debit"); + result = _("lima.ui.financialtransaction.debit"); break; case 7: - result = _("lima.table.credit"); + result = _("lima.ui.financialtransaction.credit"); break; case 8: - result = _("lima.table.balance"); + result = _("lima.ui.financialtransaction.balance"); break; } return result; @@ -218,12 +148,10 @@ @Override public int getRowCount() { - int result; + int result = 0; - if (cacheDataList == null) { - result = 0; - } else { - result = cacheDataList.size(); + if (transactionAndEntries != null) { + result = transactionAndEntries.size(); } return result; @@ -231,103 +159,85 @@ @Override public Object getValueAt(int row, int column) { - Object result = null; + Object result = transactionAndEntries.get(row); - // just prevent too much result - if (cacheDataList != null) { - result = cacheDataList.get(row); + if (result instanceof FinancialTransaction) { + FinancialTransaction currentRow = (FinancialTransaction) result; + BigDecimal amountDebit = currentRow.getAmountDebit(); + BigDecimal amountCredit = currentRow.getAmountCredit(); - if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction) result; - BigDecimal amountDebit = currentRow.getAmountDebit(); - BigDecimal amountCredit = currentRow.getAmountCredit(); - - switch (column) { - case 0: - result = currentRow.getTransactionDate(); - break; - case 1: - if (currentRow.getEntryBook() != null) { - result = currentRow.getEntryBook().getCode(); - } else { - result = null; - } - break; - case 2: - result = null; //voucher - break; - case 3: - result = null; // account - break; - case 4: - result = null; // description - break; - case 5: - result = null; // letter - break; - case 6: - result = amountDebit; - break; - case 7: - result = amountCredit; - break; - case 8: - result = amountDebit.subtract(amountCredit); - break; - } - } else if (result instanceof Entry) { - Entry currentEntry = (Entry) result; - switch (column) { - case 0: - result = null; // date - break; - case 1: // entry book + switch (column) { + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null) { + result = currentRow.getEntryBook().getCode(); + } else { result = null; - break; - case 2: - result = currentEntry.getVoucher(); - break; - case 3: // account - if (currentEntry.getAccount() != null) { - result = currentEntry.getAccount().getAccountNumber(); - } else { - result = null; - } - break; - case 4: - result = currentEntry.getDescription(); - break; - case 5: - result = currentEntry.getLettering(); - break; - case 6: - result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; - break; - case 7: - result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); - break; - case 8: + } + break; + case 2: + result = null; //voucher + break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5: + result = null; // letter + break; + case 6: + result = amountDebit; + break; + case 7: + result = amountCredit; + break; + case 8: + result = amountDebit.subtract(amountCredit); + break; + } + } else if (result instanceof Entry) { + Entry currentEntry = (Entry) result; + switch (column) { + case 0: + result = null; // date + break; + case 1: // entry book + result = null; + break; + case 2: + result = currentEntry.getVoucher(); + break; + case 3: // account + if (currentEntry.getAccount() != null) { + result = currentEntry.getAccount().getAccountNumber(); + } else { result = null; - break; - } + } + break; + case 4: + result = currentEntry.getDescription(); + break; + case 5: + result = currentEntry.getLettering(); + break; + case 6: + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; + break; + case 7: + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); + break; + case 8: + result = null; + break; } } return result; } - public void setSelectedFinancialPeriod(FinancialPeriod financialPeriod) { - if (log.isDebugEnabled()) { - log.debug("New selected financial period " + financialPeriod); - } - selectedFinancialPeriod = financialPeriod; - refresh(); - } - - public void setSelectedEntryBook(EntryBook selectedEntryBook) { - this.selectedEntryBook = selectedEntryBook; - refresh(); - } - /** * To set cells editable or not * different condition for entry or financial transaction @@ -335,22 +245,15 @@ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { boolean editableCell = false; - Object currentRow = cacheDataList.get(rowIndex); + Object currentRow = transactionAndEntries.get(rowIndex); + // cells editable for the financialtransaction row, no cells exclude the date + if (currentRow instanceof FinancialTransaction && (columnIndex == 0 /*|| columnIndex == 1*/)) { + editableCell = true; + } // cells editable for the entry row, all cells exclude the date if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1 || columnIndex == 8)) { editableCell = true; } - // cells editable for the financialtransaction row, no cells exclude the date - if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) { - -// if (selectedEntryBook == null || columnIndex == 0) { -// -// // can only edit the transaction entry book only if there is -// // no entry book selected (otherwise we will loose the transaction -// editableCell = true; -// } - editableCell = true; - } return editableCell; } @@ -358,13 +261,13 @@ * Obtain the first entry book of the current transaction. * * @param selectedRow - * @return + * @return first entry index */ public int getFirstEntry(int selectedRow) { int result = -1; int currentRow = selectedRow; while (currentRow > -1) { - Object o = cacheDataList.get(currentRow); + Object o = transactionAndEntries.get(currentRow); if (o instanceof Entry) { // current row is still a entry book @@ -391,166 +294,33 @@ return result; } - /** - * @return int: indexOf new FianancialTransaction - * @throws LimaException - */ - public int addFinancialTransaction() throws LimaException { - /* Calling transaction service */ - FinancialTransaction financialTransaction = new FinancialTransactionImpl(); - - //if a period is selected - if (selectedFinancialPeriod == null) { - throw new LimaBusinessException("No financial period selected"); - } - - financialTransaction.setFinancialPeriod(selectedFinancialPeriod); - - if (selectedEntryBook != null) { - financialTransaction.setEntryBook(selectedEntryBook); - } - - // get today - Calendar actualCalendar = Calendar.getInstance(); - - // get the financial period date - Date transactionDate = selectedFinancialPeriod.getBeginDate(); - - Calendar calEnd = Calendar.getInstance(); - calEnd.setTime(selectedFinancialPeriod.getEndDate()); - int dayMax = calEnd.get(Calendar.DAY_OF_MONTH); - Calendar calBegin = Calendar.getInstance(); - calBegin.setTime(selectedFinancialPeriod.getBeginDate()); - int dayMin = calBegin.get(Calendar.DAY_OF_MONTH); - int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); - - if (toDay > dayMax || toDay < dayMin) { - // change the day - transactionDate = DateUtils.setDays(transactionDate, dayMax); - } else { - // change the day - transactionDate = DateUtils.setDays(transactionDate, toDay); - } - - - // set date to the financial transaction - financialTransaction.setTransactionDate(transactionDate); - // create it - FinancialTransaction fTransaction = - financialTransactionService.createFinancialTransaction(financialTransaction); - - //on recharge la liste - cacheDataList = getDataList(); - int row = cacheDataList.indexOf(fTransaction); - fireTableRowsInserted(row, row); - return row; - } - - /** - * @param voucher - * @param description - * @param row - * @return int: indexOf new Entry - * @throws LimaException - */ - public int addEmptyEntry(String voucher, - String description, - int row) throws LimaException { - FinancialTransaction currentTransaction = null; - Object currentRow = cacheDataList.get(row); - Entry entry = new EntryImpl(); - entry.setAmount(BigDecimal.ZERO); - if (voucher != null) { - entry.setVoucher(voucher); - } - if (description != null) { - entry.setDescription(description); - } - //check if current row is a transaction or an entry - if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction) currentRow; - } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); - } - //create it - entry.setFinancialTransaction(currentTransaction); - Entry newEntry = financialTransactionService.createEntry(entry); - - //on recharge la liste - cacheDataList = getDataList(); - int newrow = cacheDataList.indexOf(newEntry); - fireTableRowsInserted(newrow, newrow); - return newrow; - } - - /** - * @param entry - * @param row - * @return int: indexOf new Entry - * @throws LimaException - */ - public int addEntry(Entry entry, int row) throws LimaException { - FinancialTransaction currentTransaction = null; - int financialTransactionRow = 0; - Object currentRow = cacheDataList.get(row); - //check if current row is a transaction or an entry - if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction) currentRow; - //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(currentRow); - } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); - //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(((Entry) currentRow). - getFinancialTransaction()); - } - //create it - entry.setFinancialTransaction(currentTransaction); - Entry newEntry = financialTransactionService.createEntry(entry); - fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); - - //on recharge la liste - cacheDataList = getDataList(); - int newrow = cacheDataList.indexOf(newEntry); - fireTableRowsInserted(newrow, newrow); - return newrow; - } - /** to modifiy financialtransaction or entry */ @Override public void setValueAt(Object value, int row, int column) { - int financialTransactionRow = 0; - if (cacheDataList != null) { - Object currentRow = cacheDataList.get(row); + + try { + Object currentRow = transactionAndEntries.get(row); + if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = - (FinancialTransaction) currentRow; + FinancialTransaction currentFinancialTransaction = (FinancialTransaction) currentRow; switch (column) { case 0: //update currentFinancialTransaction.setTransactionDate((Date) value); break; + /* FIXME echatellier 20120413 : ca devrait carrement pas être editable case 1: if (selectedEntryBook != null) { - // not authorized to change the value return; } currentFinancialTransaction.setEntryBook((EntryBook) value); - break; + break;*/ } + // update transaction - updateFinancialTransaction(currentFinancialTransaction); - - //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(currentRow); + financialTransactionService.updateFinancialTransaction(currentFinancialTransaction); + } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry) currentRow; FinancialTransaction financialTransaction = @@ -559,19 +329,19 @@ switch (column) { case 2: String voucher = ((String) value).trim(); - + int firstEntryRow = getFirstEntry(row); if (row == firstEntryRow) { - + // let's update the voucher of all entries of // the transaction - + for (Entry entry : financialTransaction.getEntry()) { entry.setVoucher(voucher); } updateTransaction = true; } else { - + // not on first row, just update this entry voucher currentEntry.setVoucher(voucher); } @@ -585,7 +355,7 @@ if (row == firstEntryRow) { // let's update the description of all entries of // the transaction - + for (Entry entry : financialTransaction.getEntry()) { entry.setDescription(description1); } @@ -599,16 +369,16 @@ String description = ((String) value).trim(); firstEntryRow = getFirstEntry(row); if (row == firstEntryRow) { - + // let's update the description of all entries of // the transaction - + for (Entry entry : financialTransaction.getEntry()) { entry.setDescription(description); } updateTransaction = true; } else { - + // not on first row, just update this entry description currentEntry.setDescription(description); } @@ -625,86 +395,67 @@ currentEntry.setDebit(false); break; } + + // some modification must update all other + // first row modification update following rows if (updateTransaction) { - + // FIXME echatellier 20120413 make a single service call for (Entry entry : financialTransaction.getEntry()) { - updateEntry(entry); + financialTransactionService.updateEntry(entry); } } else { - - updateEntry(currentEntry); + financialTransactionService.updateEntry(currentEntry); } - - //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(financialTransaction); } - //on recharge la liste - cacheDataList = getDataList(); - fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); - } - } + + // FIXME echatellier 20120413 une modification des dates fait que l'ordre + // devient faux + fireTableRowsUpdated(row, row); - protected void updateFinancialTransaction(FinancialTransaction transaction) { - try { - financialTransactionService.updateFinancialTransaction(transaction); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update financial transaction", eee); - } - ErrorHelper.showErrorDialog("Can't update financial transaction", eee); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't propagate data modification to service", ex); } } - protected void updateEntry(Entry entry) { - try { - financialTransactionService.updateEntry(entry); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update entry", eee); - } - ErrorHelper.showErrorDialog("Can't update entry", eee); - } - } - public Object getElementAt(int row) { - Object result = null; - if (cacheDataList != null) { - result = cacheDataList.get(row); - } + Object result = transactionAndEntries.get(row); return result; } + + public int indexOf(Object o) { + return transactionAndEntries.indexOf(o); + } /** - * Delete selected row in table (could be transaction or entry). - * <p/> - * Called by model. - * - * @param row - * @throws LimaException + * Delete row. + * + * @param row row to delete */ - public void removeObject(int row) throws LimaException { - Object currentRow = cacheDataList.get(row); - if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction) currentRow; - financialTransactionService.removeFinancialTransaction(currentTransaction); - } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - financialTransactionService.removeEntry(currentEntry); - } - //on recharge la liste - cacheDataList = getDataList(); - fireTableDataChanged(); + public void deleteRow(int row) { + transactionAndEntries.remove(row); + fireTableRowsDeleted(row, row); } - @Override - public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || - methodeName.contains("importEntries") || - methodeName.contains("importAll")) { - refresh(); - } + /** + * Insert new row. + * + * @param object object to insert + * @param newRow position + */ + public void addRow(Object object, int newRow) { + transactionAndEntries.add(newRow, object); + fireTableRowsInserted(newRow, newRow); + } + /** + * Insert new row. + * + * @param object + */ + public void addRow(Object object) { + transactionAndEntries.add(object); + fireTableRowsInserted(transactionAndEntries.size() - 1, transactionAndEntries.size() - 1); + + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2012-04-13 13:46:24 UTC (rev 3366) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2008 - 2010 CodeLutin + Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -22,7 +22,6 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> - <Table> <import> @@ -30,62 +29,54 @@ org.chorem.lima.entity.FiscalPeriod org.chorem.lima.entity.FinancialPeriod org.chorem.lima.entity.EntryBook - org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel - org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel - org.chorem.lima.ui.LimaRendererUtil + org.chorem.lima.ui.common.EntryBookListRenderer </import> <FinancialTransactionViewHandler id="handler" constructorParams="this"/> <Boolean id="selectedRow" javaBean="false"/> - <FinancialTransactionTableModel id="financialTransactionTableModel"/> - <FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> - <FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> <script> <![CDATA[ void $afterCompleteSetup() { - handler.initEntryBookModel(entryBookComboBox); - handler.refresh(); + handler.init(); } ]]> </script> <row weightx="1" weighty="0" anchor="center"> <cell anchor="east"> - <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear" - labelFor='{fiscalPeriodComboBox}'/> + <JLabel text="lima.ui.financialtransaction.fiscalyear" labelFor='{fiscalPeriodComboBox}'/> </cell> <cell anchor="west"> - - <JComboBox id="fiscalPeriodComboBox" - model="{fiscalPeriodComboBoxModel}" - renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" - onItemStateChanged="if ( event.getStateChange() == 1 ) financialPeriodComboBoxModel.setSelectedFiscalPeriod( (FiscalPeriod) event.getItem() );"/> + <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> + <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}" + renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}" + onItemStateChanged="handler.fiscalPeriodSelected(event)"/> </cell> <cell anchor="east"> - <JLabel id="financialPeriodLabel" text="lima.common.period" - labelFor='{financialPeriodComboBox}'/> + <JLabel text="lima.ui.financialtransaction.financialperiod" labelFor='{financialPeriodComboBox}'/> </cell> <cell anchor="west"> <JPanel> + <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> <JComboBox id="financialPeriodComboBox" model="{financialPeriodComboBoxModel}" - renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class)}" - onItemStateChanged="if ( event.getStateChange() == 1 ) financialTransactionTableModel.setSelectedFinancialPeriod( (FinancialPeriod) event.getItem() );"/> - <JButton id="back" text="lima.common.buttonback" + renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}" + onItemStateChanged="handler.financialPeriodSelected(event)"/> + <JButton id="back" text="lima.ui.financialtransaction.buttonback" onActionPerformed="handler.back(financialPeriodComboBox)"/> - <JButton id="next" text="lima.common.buttonnext" + <JButton id="next" text="lima.ui.financialtransaction.buttonnext" onActionPerformed="handler.next(financialPeriodComboBox)"/> </JPanel> </cell> <cell anchor="east"> - <JLabel id="entryBookComboBoxLabel" text="lima.common.entrybook" - labelFor='{entryBookComboBox}'/> + <JLabel text="lima.ui.financialtransaction.entrybook" labelFor='{entryBookComboBox}'/> </cell> <cell anchor="west"> - <JComboBox id="entryBookComboBox" - renderer="{LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" - onItemStateChanged="if ( event.getStateChange() == 1 ) financialTransactionTableModel.setSelectedEntryBook( (EntryBook) event.getItem() );"/> + <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/> + <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}" + renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}" + onItemStateChanged="handler.entryBookSelected(event)"/> </cell> </row> <row> @@ -110,7 +101,7 @@ <row> <cell fill="both" weightx="1" weighty="1" rows="3" columns="8"> <JScrollPane> - + <FinancialTransactionTableModel id="financialTransactionTableModel"/> <FinancialTransactionTable id="financialTransactionTable" sortable="false" rowHeight="22" constructorParams='handler' Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -25,27 +25,40 @@ package org.chorem.lima.ui.financialtransaction; -import jaxx.runtime.SwingUtil; +import static org.nuiton.i18n.I18n._; + +import java.awt.event.ItemEvent; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; + +import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.monitorable.EntryBookServiceMonitorable; +import org.chorem.lima.business.LimaRuntimeException; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.api.EntryBookService; +import org.chorem.lima.business.api.FinancialPeriodService; +import org.chorem.lima.business.api.FinancialTransactionService; +import org.chorem.lima.business.api.FiscalPeriodService; +import org.chorem.lima.business.api.ImportService; +import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryImpl; +import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FinancialTransactionImpl; +import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.util.DialogHelper; -import org.chorem.lima.util.ErrorHelper; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - /** * Handler associated with financial transaction view. * @@ -55,158 +68,336 @@ * Last update : $Date$ * By : $Author$ */ -public class FinancialTransactionViewHandler { +public class FinancialTransactionViewHandler implements ServiceListener { /** log. */ - private static final Log log = - LogFactory.getLog(FinancialTransactionViewHandler.class); + private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class); + /** Managed view. */ protected FinancialTransactionView view; + /** Cache object used to copy & paste. */ protected Object clipBoard; - protected FinancialTransactionViewHandler(FinancialTransactionView view) { + protected EntryBookService entryBookService; + protected FinancialPeriodService financialPeriodService; + protected FiscalPeriodService fiscalPeriodService; + protected FinancialTransactionService financialTransactionService; + + public FinancialTransactionViewHandler(FinancialTransactionView view) { this.view = view; + + entryBookService = LimaServiceFactory.getService(EntryBookService.class); + financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class); + fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); + LimaServiceFactory.addServiceListener(FinancialPeriodService.class, this); + LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this); + LimaServiceFactory.addServiceListener(ImportService.class, this); } - public FinancialTransactionTable getTable() { - return view.getFinancialTransactionTable(); + /** + * Init all combo box in view. + */ + public void init() { + try { + // fiscal periods + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); + } + if (!fiscalPeriods.isEmpty()) { + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(0)); + } + + // entry books + List<EntryBook> allEntryBooks = entryBookService.getAllEntryBooks(); + view.getEntryBookComboBoxModel().setObjects(allEntryBooks); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); + } + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't init financial transaction view", ex); + } } - public FinancialTransactionTableModel getTableModel() { - return view.getFinancialTransactionTableModel(); + /** + * New fiscal period selection. + * + * @param event event + */ + public void fiscalPeriodSelected(ItemEvent event) { + if ( event.getStateChange() == ItemEvent.SELECTED ) { + FiscalPeriod selectedFiscalPeriod = (FiscalPeriod) event.getItem(); + + try { + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), + selectedFiscalPeriod.getEndDate()); + + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d financial periods", financialPeriods.size())); + } + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); + + // update transactions + updateFinancialTransactions(); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't update financial period list", ex); + } + } } - public FiscalPeriodComboBoxModel getFiscalPeriodComboBoxModel() { - return view.getFiscalPeriodComboBoxModel(); + /** + * New financial period selection. + * + * @param event event + */ + public void financialPeriodSelected(ItemEvent event) { + if ( event.getStateChange() == ItemEvent.SELECTED ) { + updateFinancialTransactions(); + } } - public FinancialPeriodComboBoxModel getFinancialPeriodComboBoxModel() { - return view.getFinancialPeriodComboBoxModel(); + /** + * New entry book selected. + * + * @param event event + */ + public void entryBookSelected(ItemEvent event) { + if ( event.getStateChange() == ItemEvent.SELECTED ) { + updateFinancialTransactions(); + } } - public void initEntryBookModel(JComboBox comboBox) { - EntryBookServiceMonitorable service = - LimaServiceFactory.getService(EntryBookServiceMonitorable.class); + /** + * Fill transaction for selection fiscal period, financial perdiod + * and entry book. + */ + public void updateFinancialTransactions() { + FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem(); + EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem(); + + // la selection de la financialPeriod est obligatoire + // sinon, tout un exercice, c'est trop lourd + // l'entry book par contre, est facultatif + if (financialPeriod == null) { + return; + } + try { - List<EntryBook> allEntryBooks = service.getAllEntryBooks(); - allEntryBooks.add(0, null); - SwingUtil.fillComboBox(comboBox, allEntryBooks, null); - } catch (LimaException e) { - ErrorHelper.showErrorDialog(view, e.getMessage(), e.getCause()); + List<Object> transAndEntries = new ArrayList<Object>(); + List<FinancialTransaction> transactions; + if (entryBook == null) { + transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod); + } else { + transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook); + } + + // move it to unique collection for table rendering + for (FinancialTransaction transaction : transactions) { + transAndEntries.add(transaction); + List<Entry> entries = (List<Entry>) transaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + transAndEntries.addAll(entries); + } + + view.getFinancialTransactionTableModel().setTransactionAndEntries(transAndEntries); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't get transactions list", ex); } } - //copy entry + /** + * Copy selected transaction or entry. + * + * @param indexSelectedRow + */ public void copyRow(int indexSelectedRow) { - if (indexSelectedRow != -1) { - clipBoard = getTableModel().getElementAt(indexSelectedRow); - } + clipBoard = view.getFinancialTransactionTableModel().getElementAt(indexSelectedRow); } - //paste entry + /** + * Paste entry. + * + * @param indexSelectedRow selected row to paste entry + */ public void pasteRow(int indexSelectedRow) { - FinancialTransactionTable table = getTable(); - FinancialTransactionTableModel tableModel = getTableModel(); + FinancialTransactionTable table = view.getFinancialTransactionTable(); - if (indexSelectedRow != -1) { - if (clipBoard instanceof Entry) { - try { - int index = tableModel.addEntry((Entry) clipBoard, - indexSelectedRow); + if (clipBoard instanceof Entry) { + try { + int index = addEntry((Entry) clipBoard, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't past entry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + //select the new line + ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { + throw new LimaRuntimeException("Can't past entry", eee); } } } - //add a new transaction + /** + * @param entry + * @param row + * @return int: indexOf new Entry + * @throws LimaException + */ + protected int addEntry(Entry entry, int row) throws LimaException { + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + FinancialTransaction currentTransaction = null; + int financialTransactionRow = 0; + Object currentRow = tableModel.getElementAt(row); + //check if current row is a transaction or an entry + if (currentRow instanceof FinancialTransaction) { + currentTransaction = (FinancialTransaction) currentRow; + //update the financial transaction in entire + financialTransactionRow = tableModel.indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); + //update the financial transaction in entire + financialTransactionRow = tableModel.indexOf(((Entry) currentRow). + getFinancialTransaction()); + } + //create it + entry.setFinancialTransaction(currentTransaction); + Entry newEntry = financialTransactionService.createEntry(entry); + currentTransaction.addEntry(entry); + //FIXME echatellier 20120413 what is fired here ? + //fireTableRowsUpdated(financialTransactionRow, financialTransactionRow + currentTransaction.getEntry().size() - 1); + + // on met a jour l'ui + int newRow = financialTransactionRow + currentTransaction.getEntry().size() + 1; + tableModel.addRow(newEntry, newRow); + return newRow; + } + + /** + * Add new transaction. + */ public void addFinancialTransaction() { - FinancialTransactionTable table = getTable(); - FinancialTransactionTableModel tableModel = getTableModel(); + FinancialTransactionTable table = view.getFinancialTransactionTable(); ListSelectionModel selectionModel = table.getSelectionModel(); try { - int index = tableModel.addFinancialTransaction(); + addFinancialTransaction2(); //select the new line int numberRow = table.getRowCount(); selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); //focus on first column - table.changeSelection(index, 0, false, false); -// table.requestFocusInWindow(); - table.scrollCellToVisible(index, 0); + table.changeSelection(numberRow, 0, false, false); + table.scrollCellToVisible(numberRow, 0); } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add financialtransaction", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + throw new LimaRuntimeException("Can't add financialtransaction", eee); } } + + /** + * Add new transaction after calling service. + * + * @throws LimaException + */ + public void addFinancialTransaction2() throws LimaException { - //implement new transaction button - //add a new entry to the selected transaction - public void addEntry() { + FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem(); + EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); - FinancialTransactionTable table = getTable(); - FinancialTransactionTableModel tableModel = getTableModel(); - ListSelectionModel selectionModel = table.getSelectionModel(); + FinancialTransaction financialTransaction = new FinancialTransactionImpl(); + financialTransaction.setFinancialPeriod(financialPeriod); + // can be defined later by user + if (entryBook != null) { + financialTransaction.setEntryBook(entryBook); + } - int indexSelectedRow = table.getSelectedRow(); - if (indexSelectedRow != -1) { + // compute new transaction date from selected financial + // transaction begin date + Calendar actualCalendar = Calendar.getInstance(); + Date transactionDate = financialPeriod.getBeginDate(); + Calendar calEnd = Calendar.getInstance(); + calEnd.setTime(financialPeriod.getEndDate()); + int dayMax = calEnd.get(Calendar.DAY_OF_MONTH); + Calendar calBegin = Calendar.getInstance(); + calBegin.setTime(financialPeriod.getBeginDate()); + int dayMin = calBegin.get(Calendar.DAY_OF_MONTH); + int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); - int firstentryBookrow = - tableModel.getFirstEntry(indexSelectedRow); + // FIXME echatellier 20120413 explain this code, why actualCalendar + // is not enought ? + if (toDay > dayMax || toDay < dayMin) { + transactionDate = DateUtils.setDays(transactionDate, dayMax); + } else { + transactionDate = DateUtils.setDays(transactionDate, toDay); + } - String voucher; - String description; - if (firstentryBookrow == -1) { + // set date to the financial transaction + financialTransaction.setTransactionDate(transactionDate); + // create it + FinancialTransaction fTransaction = financialTransactionService.createFinancialTransaction(financialTransaction); - // no entry book for this transaction - voucher = null; - description = null; + //on recharge la liste + tableModel.addRow(fTransaction); + } - } else { + /** + * Add new entry to selected transaction. + */ + public void addEntry() { + FinancialTransactionTable table = view.getFinancialTransactionTable(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + + // FIXME echatellier 20120413 what is excatlty selected row here ? + // real selected row or selected transaction row ? + int indexSelectedRow = table.getSelectedRow(); + if (indexSelectedRow != -1) { + int firstentryBookrow = tableModel.getFirstEntry(indexSelectedRow); + + String defaultVoucher = null; + String dafaultDescription = null; + if (firstentryBookrow != -1) { // there is no first entry, grab the voucher and - voucher = (String) - tableModel.getValueAt(indexSelectedRow, 2); - description = (String) - tableModel.getValueAt(indexSelectedRow, 4); + defaultVoucher = (String) tableModel.getValueAt(firstentryBookrow, 2); + dafaultDescription = (String) tableModel.getValueAt(firstentryBookrow, 4); } + try { - // creates the new entry + Entry entry = new EntryImpl(); + entry.setVoucher(defaultVoucher); + entry.setDescription(dafaultDescription); + // check if current row is a transaction or an entry + FinancialTransaction currentTransaction = null; + Object currentRow = tableModel.getElementAt(indexSelectedRow); + if (currentRow instanceof FinancialTransaction) { + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); + } + // create it in service + entry.setFinancialTransaction(currentTransaction); + Entry newEntry = financialTransactionService.createEntry(entry); + currentTransaction.addEntry(newEntry); - int index = tableModel.addEmptyEntry( - voucher, - description, - indexSelectedRow - ); + // add it in ui + tableModel.addRow(newEntry, indexSelectedRow + currentTransaction.getEntry().size()); //select the new line + ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval( indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); -// table.requestFocusInWindow(); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add emptyentry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + table.changeSelection(indexSelectedRow + 1, 1, false, false); + + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't add emptyentry", ex); } } else { if (log.isWarnEnabled()) { @@ -218,42 +409,47 @@ /** * Delete selected row in table (could be transaction or entry). * <p/> - * Called by model. + * Called by table. */ public void deleteSelectedRow() { - FinancialTransactionTable table = getTable(); - FinancialTransactionTableModel tableModel = getTableModel(); + FinancialTransactionTable table = view.getFinancialTransactionTable(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - String message; + + int response; if (selectedValue instanceof FinancialTransaction) { - message = _("lima.charts.financialtransaction.question.removetransaction"); + response = JOptionPane.showConfirmDialog( + view, _("lima.ui.financialtransaction.messageremovetransaction"), + _("lima.ui.financialtransaction.titleremovetransaction"), JOptionPane.YES_NO_OPTION); } else { - message = _("lima.charts.financialtransaction.question.removeentry"); + response = JOptionPane.showConfirmDialog( + view, _("lima.ui.financialtransaction.messageremoveentry"), + _("lima.ui.financialtransaction.titleremoveentry"), JOptionPane.YES_NO_OPTION); } - int response = JOptionPane.showConfirmDialog( - view, message, - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); - if (response == JOptionPane.YES_OPTION) { + try { + if (selectedValue instanceof FinancialTransaction) { + FinancialTransaction currentTransaction = + (FinancialTransaction) selectedValue; + financialTransactionService.removeFinancialTransaction(currentTransaction); + + } else if (selectedValue instanceof Entry) { + Entry currentEntry = (Entry) selectedValue; + financialTransactionService.removeEntry(currentEntry); + } + tableModel.deleteRow(indexSelectedRow); - try { - tableModel.removeObject(indexSelectedRow); //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow - 1, indexSelectedRow - 1); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't remove transaction or entry", ex); } } } else { @@ -263,36 +459,47 @@ } } + /** + * Select previous value in combo box. + * + * @param comboBox combo box + */ public void back(JComboBox comboBox) { int row = comboBox.getSelectedIndex(); - if (log.isDebugEnabled()) { - log.debug(row); - } if (row > 0) { comboBox.setSelectedIndex(row - 1); - //FIXME tchemit-2011-09-20 Should never referesh ui by hand - comboBox.repaint(); } } + /** + * Select next value in combo box. + * + * @param comboBox combo box + */ public void next(JComboBox comboBox) { int size = comboBox.getModel().getSize(); int row = comboBox.getSelectedIndex(); - if (log.isDebugEnabled()) { - log.debug(row); - } if (row < size - 1) { comboBox.setSelectedIndex(row + 1); - //FIXME tchemit-2011-09-20 Should never referesh ui by hand - comboBox.repaint(); } } - public void refresh() { - getTableModel().refresh(); - getFiscalPeriodComboBoxModel().refresh(); - getFinancialPeriodComboBoxModel().refresh(); + /* + * @see org.chorem.lima.business.ServiceListener#notifyMethod(java.lang.String, java.lang.String) + */ + @Override + public void notifyMethod(String serviceName, String methodName) { + + if (log.isDebugEnabled()) { + log.debug("Method notified " + serviceName + "#" + methodName); + } + + if (serviceName.contains("FinancialTransaction") || + methodName.contains("importEntries") || + methodName.contains("importAll")) { + updateFinancialTransactions(); + } } } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/package-info.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/package-info.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/package-info.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -0,0 +1,31 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * 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>. + * #L% + */ +/** + * Saisie des écritures. + * + * Selection de l'exercice, de la periode et du journal et affichage + * de la liste correspondante. + */ +package org.chorem.lima.ui.financialtransaction; Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2012-04-13 13:46:24 UTC (rev 3366) @@ -33,7 +33,7 @@ <FinancialTransactionUnbalancedViewHandler id="handler" javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/> <Boolean id="selectedRow" javaBean="false"/> - <FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> + <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> <script> <![CDATA[ void $afterCompleteSetup() { Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -1,61 +0,0 @@ -/* - * #%L - * - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 Codelutin, Chatellier Eric - * %% - * 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>. - * #L% - */ - -package org.chorem.lima.ui.fiscalperiod; - -import java.awt.Component; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JList; - -import org.chorem.lima.entity.EntryBook; - -/** - * EntryBook renderer for fiscal period retaining earning list. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class EntryBookListRenderer extends DefaultListCellRenderer { - - /** serialVersionUID. */ - private static final long serialVersionUID = -9089182547408397051L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, - int index, boolean isSelected, boolean cellHasFocus) { - - EntryBook entryBook = (EntryBook)value; - Object newValue = entryBook; - if (entryBook != null) { - newValue = entryBook.getCode() + " - " + entryBook.getLabel(); - } - return super.getListCellRendererComponent(list, newValue, index, isSelected, - cellHasFocus); - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -59,16 +59,11 @@ private static final long serialVersionUID = -8462838870024505659L; - protected FiscalPeriodViewHandler handler; - protected FiscalPeriodTableModel model; - private Highlighter colorTransaction; - public FiscalPeriodTable(FiscalPeriodTableModel model) { super(model); this.model = model; - this.handler = handler; addKeyListener(this); addMouseListener(this); @@ -90,7 +85,7 @@ return fiscalPeriod.getLocked(); } }; - colorTransaction = + Highlighter colorTransaction = new ColorHighlighter(predicate, null, new Color(222, 0, 0)); addHighlighter(colorTransaction); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -43,8 +43,6 @@ import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; -import org.chorem.lima.business.monitorable.FinancialTransactionServiceMonitorable; -import org.chorem.lima.business.monitorable.FiscalPeriodServiceMonitorable; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; @@ -60,15 +58,15 @@ * * @author chatellier * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ + * + * Last update : $Date$ + * By : $Author$ */ public class FiscalPeriodViewHandler implements ServiceListener { private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); - private FiscalPeriodView view; + protected FiscalPeriodView view; /** Service. */ protected FiscalPeriodService fiscalPeriodService; @@ -83,10 +81,10 @@ public FiscalPeriodViewHandler(FiscalPeriodView view) { this.view = view; - fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodServiceMonitorable.class); - financialTransactionService = LimaServiceFactory.getService(FinancialTransactionServiceMonitorable.class); + fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); - LimaServiceFactory.addServiceListener(FiscalPeriodServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FiscalPeriodService.class, this); } public void init() { @@ -236,7 +234,7 @@ try { boolean found = false; List<FinancialTransaction> financialTransactionsList = - financialTransactionService.getAllFinancialTransactionsFromDateToDate( + financialTransactionService.getAllFinancialTransactions( selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); //check if they are at least one transaction to be report if (!financialTransactionsList.isEmpty()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-04-13 13:46:24 UTC (rev 3366) @@ -29,7 +29,7 @@ <import> javax.swing.text.Document org.chorem.lima.entity.EntryBook - org.chorem.lima.ui.combobox.EntryBookComboBoxModel + org.chorem.lima.ui.common.EntryBookListRenderer </import> <EntryBook id="entryBook" javaBean="null"/> @@ -92,7 +92,7 @@ <JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/> </cell> <cell> - <EntryBookComboBoxModel id="modelEntryBookComboBox"/> + <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBookComboBox"/> <JComboBox id="entryBookComboBox" model="{getModelEntryBookComboBox()}" renderer="{new EntryBookListRenderer()}" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-04-13 13:46:24 UTC (rev 3366) @@ -123,7 +123,7 @@ if (selectedBeginDate != null && selectedEndDate != null) { try { List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllFinancialTransactionsFromDateToDate( + financialTransactionService.getAllFinancialTransactions( selectedBeginDate, selectedEndDate); for (FinancialTransaction financialtransaction : financialtransactions) { results.add(financialtransaction); 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-04-13 13:46:24 UTC (rev 3366) @@ -293,6 +293,23 @@ lima.ui.entrybook.label= lima.ui.entrybook.remove= lima.ui.entrybook.update= +lima.ui.financialtransaction.account= +lima.ui.financialtransaction.balance= +lima.ui.financialtransaction.buttonback= +lima.ui.financialtransaction.buttonnext= +lima.ui.financialtransaction.credit= +lima.ui.financialtransaction.date= +lima.ui.financialtransaction.debit= +lima.ui.financialtransaction.description= +lima.ui.financialtransaction.entrybook= +lima.ui.financialtransaction.financialperiod= +lima.ui.financialtransaction.fiscalyear= +lima.ui.financialtransaction.letter= +lima.ui.financialtransaction.messageremoveentry= +lima.ui.financialtransaction.messageremovetransaction= +lima.ui.financialtransaction.titleremoveentry= +lima.ui.financialtransaction.titleremovetransaction= +lima.ui.financialtransaction.voucher= lima.ui.fiscalperiod.addfiscalperiod.morethan12= lima.ui.fiscalperiod.addfiscalperiodtitle= lima.ui.fiscalperiod.addperiodtitle= 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 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-04-13 13:46:24 UTC (rev 3366) @@ -272,6 +272,23 @@ lima.ui.entrybook.label=Libellé lima.ui.entrybook.remove=Supprimer lima.ui.entrybook.update=Modifier +lima.ui.financialtransaction.account=Compte +lima.ui.financialtransaction.balance=Balance +lima.ui.financialtransaction.buttonback=← +lima.ui.financialtransaction.buttonnext=→ +lima.ui.financialtransaction.credit=Crédit +lima.ui.financialtransaction.date=Date +lima.ui.financialtransaction.debit=Débit +lima.ui.financialtransaction.description=Description +lima.ui.financialtransaction.entrybook=Journal +lima.ui.financialtransaction.financialperiod=Périodes comptables +lima.ui.financialtransaction.fiscalyear=Exercices +lima.ui.financialtransaction.letter=Lettre +lima.ui.financialtransaction.messageremoveentry=Voulez-vous supprimer cette ligne de transaction? +lima.ui.financialtransaction.messageremovetransaction=Voulez-vous supprimer cette transaction? +lima.ui.financialtransaction.titleremoveentry=Suppression +lima.ui.financialtransaction.titleremovetransaction=Suppression +lima.ui.financialtransaction.voucher=Pièce comptable lima.ui.fiscalperiod.addfiscalperiod.morethan12=La période sélectionnée n'est pas de 12 mois, voulez-vous continuer ? lima.ui.fiscalperiod.addfiscalperiodtitle=Nouvel exercice lima.ui.fiscalperiod.addperiodtitle= Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-04-12 16:37:45 UTC (rev 3365) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-04-13 13:46:24 UTC (rev 3366) @@ -38,4 +38,5 @@ # package level log4j.logger.org.chorem.lima=INFO +log4j.logger.org.chorem.lima.business.ejb=DEBUG log4j.logger.org.chorem.lima.ui.account=DEBUG \ No newline at end of file