r2876 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima lima-swing/src/main/java/org/chorem/lima/combobox lima-swing/src/main/java/org/chorem/lima/listener lima-swing/src/main/java/org/chorem/lima/service lima-swing/src/main/java/org/chorem/lima/table lima-swing/src/main/java/org/chorem/lima/table/editor lima-swing/src/main/java/org/chorem/lima/ui lima-swin
Author: jpepin Date: 2010-04-28 17:59:14 +0200 (Wed, 28 Apr 2010) New Revision: 2876 Log: Ajout, suppression, modification transactions et entr?\195?\169es Added: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/combobox/model/ trunk/lima-swing/src/main/java/org/chorem/lima/combobox/renderer/ trunk/lima-swing/src/main/java/org/chorem/lima/comparator/ trunk/lima-swing/src/main/java/org/chorem/lima/filter/ trunk/lima-swing/src/main/java/org/chorem/lima/item/ trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/export/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-callao/src/main/xmi/accounting.properties trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryBookService.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -32,6 +32,7 @@ * Last update : $Date$ * By : $Author$ */ + public interface EntryBookService { List<EntryBook> getAllEntryBooks() throws LimaException; Added: trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java (rev 0) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/EntryService.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,33 @@ +/* *##% Lima Business + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%* + */ + +package org.chorem.lima.business; + +import org.chorem.lima.entity.Entry; + + +public interface EntryService { + + void createEntry(Entry entry) throws LimaException; + + void updateEntry(Entry entry) throws LimaException; + + void removeEntry(Entry entry) throws LimaException; + +} Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -39,8 +39,6 @@ List<FinancialPeriod> getUnblockedFinancialPeriods() throws LimaException; - List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException; - void createFinancialPeriod(FinancialPeriod financialPeriod) throws LimaException; //void updateFiscalPeriod(FinancialPeriod financialPeriod) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -19,12 +19,18 @@ package org.chorem.lima.business.ejb; +import javax.ejb.Stateless; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.EntryService; import org.chorem.lima.business.LimaConfig; +import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryDAO; +import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; +import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; /** @@ -37,19 +43,13 @@ * * @author Rémi Chapelet */ -public class EntryServiceImpl { // implements EntryService { +@Stateless +public class EntryServiceImpl extends AbstractLimaService implements EntryService { private static final Log log = LogFactory.getLog(EntryServiceImpl.class); private TopiaContext rootContext; - private RecordServiceImpl logServiceImpl = new RecordServiceImpl(); - - // TODO A revoir car transaction a besoin de entry et vice versa - private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl(); - - private AccountServiceImpl accountServiceImpl = new AccountServiceImpl(); - public EntryServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -61,15 +61,59 @@ } } + + @Override + public void removeEntry(Entry entry) throws LimaException { + TopiaContext topiaContext = null; + try { + // basic check done, make check in database + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + //delete + entryDAO.delete(entry); + // commit + topiaContext.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + + @Override + public void updateEntry(Entry entry) throws LimaException { + TopiaContext topiaContext = null; + try { + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + //delete + entryDAO.update(entry); + // commit + topiaContext.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + /** * Création d'une entrée comptable. * La période ne doit PAS être bloquée. * * @return */ + + @Override public void createEntry(Entry entry /*String description, String amount, boolean debit, String lettering, String detail, Transaction transaction, - Account account*/) { + Account account*/) throws LimaException { /*String result = isCorrectEntry(transaction, account); if (result.equals(ServiceHelper.RESPOND_SUCCESS)) { result = ServiceHelper.RESPOND_ERROR; @@ -111,6 +155,25 @@ } } return result;*/ + + TopiaContext topiaContext = null; + try { + // basic check done, make check in database + // TODO move it into JTA + topiaContext = rootContext.beginTransaction(); + + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + entryDAO.create(entry); + + // commit + topiaContext.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } } /* Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -19,12 +19,8 @@ package org.chorem.lima.business.ejb; -import java.util.ArrayList; -import java.util.Collection; import java.util.List; - import javax.ejb.Stateless; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialPeriodService; @@ -32,15 +28,13 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; -import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; import org.nuiton.topia.TopiaException; import org.nuiton.topia.TopiaNotFoundException; -import org.nuiton.topia.framework.TopiaQuery; -import org.nuiton.topia.framework.TopiaQuery.Op; + /** * Gestion des périodes intermédiaires durant l'exercice. * Chaque timeSpan sera fixe, et devra correspondre à un mois complet. @@ -55,8 +49,6 @@ private TopiaContext rootContext; - private static FinancialTransactionServiceImpl transactionServiceImpl = new FinancialTransactionServiceImpl(); - public FinancialPeriodServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -204,17 +196,6 @@ return result; } - - @Override - public List<FinancialPeriod> getUnblockedFinancialPeriodWithFiscalPeriod(FiscalPeriod selectedFiscalPeriod) throws LimaException { - - Collection<FinancialPeriod> temp = selectedFiscalPeriod.getFinancialPeriod(); - - List result = new ArrayList<FinancialPeriod>(temp); - log.debug("result : "+result); - - return result; - } /* * Permet de trouver un timespan directement avec une date. La date peut Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -25,15 +25,11 @@ import javax.ejb.Stateless; -import org.apache.commons.collections.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.FinancialTransactionService; -import org.chorem.lima.entity.Account; -import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.LimaCallaoDAOHelper; @@ -443,6 +439,8 @@ topiaTransaction = rootContext.beginTransaction(); FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); transactionDAO.update(financialtransaction); + // commit + topiaTransaction.commitTransaction(); } catch (TopiaException ex) { doCatch(topiaTransaction, ex, log); @@ -463,6 +461,8 @@ topiaTransaction = rootContext.beginTransaction(); FinancialTransactionDAO transactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); transactionDAO.delete(financialtransaction); + // commit + topiaTransaction.commitTransaction(); } catch (TopiaException ex) { doCatch(topiaTransaction, ex, log); @@ -474,7 +474,6 @@ } - /* * Permet d'ajouter une entrée comptable pour une transaction donnée. * ATTENTION : la transaction doit être NON bloquée. Modified: trunk/lima-callao/src/main/xmi/accounting.properties =================================================================== --- trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-callao/src/main/xmi/accounting.properties 2010-04-28 15:59:14 UTC (rev 2876) @@ -3,6 +3,8 @@ org.chorem.lima.entity.Account.attribute.subAccounts.tagvalue.lazy=false org.chorem.lima.entity.Account.attribute.subLedgers.tagvalue.lazy=false org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false +org.chorem.lima.entity.FinancialTransaction.attribute.entryBook.tagvalue.lazy=false +#org.chorem.lima.entity.Entry.attribute.record.tagvalue.lazy=false org.chorem.lima.entity.Account.attribute.identity.tagvalue.lazy=false org.chorem.lima.entity.FiscalPeriod.attribute.financialPeriod.tagvalue.lazy=false #model.tagvalue.dbSchema=Callao Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -1,98 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.listener; - -import org.chorem.lima.dto.EntryDTO; -import org.chorem.lima.dto.TransactionDTO; -import org.chorem.lima.dto.util.DTOHelper; -import org.chorem.lima.service.util.ServiceHelper; -import org.chorem.lima.table.TransactionJXTable; -import org.chorem.lima.table.model.TransactionFlattenTableModel; - -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; - -/** - * Cette classe permet de définir les actions possibles sur la table des - * transactions. Ainsi lorsque l'utilisateur clique sur une ligne, il est possible - * d'assigner une action précise. - * - * @author ore - * @author Rémi Chapelet - */ -public class EmptyLineSelectionListener extends MouseAdapter { - - @Override - public void mouseClicked(MouseEvent e) { - TransactionJXTable table = (TransactionJXTable) e.getSource(); - if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) - { - TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table.getModel(); - if (table.getSelectionModel().isSelectionEmpty()) - { - // Not line selected - } else { - // Line selected - int selectedRow = table.getSelectedRow(); - int parentIndex = flattenModel.getParentIndex(selectedRow); - /** - * Is transaction editable ? - */ - Object o = flattenModel.getElementAt(parentIndex); - if (DTOHelper.isTransaction(o)) { - // Transaction n'est pas éditable - if (!ServiceHelper.isEditable((TransactionDTO) o)) { - return; - } - } else { - //Entry n'est pas éditable - if (!ServiceHelper.isEditable((EntryDTO) o)) { - return; - } - } - - // Click in not current transaction - if (flattenModel.getCurrentParentIndex() != parentIndex) { - int posNext = flattenModel.emptyLineNextPosition(selectedRow); - /** - * Once traitement for transaction - */ - if (flattenModel.isEmptyLineEmpty()) { - flattenModel.createEmptyLine(); - } else { - flattenModel.removeEmptyLine(); - selectedRow = table.getSelectedRow(); - parentIndex = flattenModel.getParentIndex(selectedRow); - posNext = flattenModel.emptyLineNextPosition(selectedRow); - flattenModel.createEmptyLine(); - } - flattenModel.addEmptyLine(posNext); - - // To end - flattenModel.setCurrentParentIndex(parentIndex); - } - /** - * New Line Color - */ - table.addColorEmptyLine(); - } - } - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -33,6 +33,7 @@ import org.chorem.lima.LimaMain; import org.chorem.lima.business.AccountService; import org.chorem.lima.business.EntryBookService; +import org.chorem.lima.business.EntryService; import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.RecordService; @@ -168,7 +169,7 @@ } return ejbHome; } - + /** * Get FinancialPeriod service. * @@ -212,9 +213,9 @@ } /** - * Get transaction service. + * Get entrybook service. * - * @return transaction service proxy + * @return entrybook service proxy */ public EntryBookService getEntryBookService() { @@ -233,6 +234,29 @@ } /** + * Get entry service. + * + * @return entry service proxy + */ + public EntryService getEntryService() { + + // TODO EC-20100410 put lookup name in configuration + // name should be fully configurable due to custom implementation used + String lookupName = "EntryServiceImplLocal"; + EntryService ejbHome = null; + try { + ejbHome = (EntryService)ctx.lookup(lookupName); + } catch (NamingException eee) { + if (log.isErrorEnabled()) { + log.error("Can't lookup for service : " + lookupName, eee); + } + } + return ejbHome; + } + + + + /** * Get record service. * * @return record service proxy Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/table/TransactionJXTable.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -120,7 +120,7 @@ // cell editoring tcm.getColumn(TransactionEnum.DATE.ordinal()).setCellEditor(DateTableCellEditor.getInstance()); tcm.getColumn(TransactionEnum.ACCOUNT.ordinal()).setCellEditor(AccountTableCellEditor.getInstance()); - tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(JournalTableCellEditor.getInstance()); + tcm.getColumn(TransactionEnum.JOURNAL.ordinal()).setCellEditor(EntryBookTableCellEditor.getInstance()); tcm.getColumn(TransactionEnum.DEBIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance()); tcm.getColumn(TransactionEnum.CREDIT.ordinal()).setCellEditor(NumberTableCellEditor.getInstance()); tcm.getColumn(TransactionEnum.DESCRIPTION.ordinal()).setCellEditor(TextTableCellEditor.getInstance()); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/AccountTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -22,12 +22,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; -import org.chorem.lima.combobox.JWideComboBox; -import org.chorem.lima.combobox.model.AccountComboBoxModel; import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer; -import org.chorem.lima.dto.AccountDTO; -import org.chorem.lima.service.util.ServiceHelper; -import org.chorem.lima.util.AccountToStringConverter; +import org.chorem.lima.entity.FinancialPeriodDAO; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; import javax.swing.*; @@ -57,7 +53,7 @@ private final JComboBox comboBox; private static final long serialVersionUID = 1525438571250871093L; private static AccountTableCellEditor editor; - private static boolean keyPressed = false; + //private static boolean keyPressed = false; /** * Constructor @@ -65,11 +61,13 @@ public AccountTableCellEditor() { // Création du comboBox pour les comptes, elle hérite de comboBox - comboBox = new JWideComboBox(); - + comboBox = new JComboBox(); /** * Charge les comptes dans la comboBox */ + FinancialPeriodDAO financialPeriodDAO = + + // Get data from services List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount( LimaContext.getContext().getDataManager().getAccountModel().getData()); Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -1,72 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.table.editor; - -import org.chorem.lima.LimaContext; -import org.jdesktop.swingx.JXDatePicker; - -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.Date; -import java.util.EventObject; - -/** - * @author ore - */ -public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor { - - private final JXDatePicker datePicker; - private static final long serialVersionUID = -8455896587828255307L; - private static DateTableCellEditor editor; - - /** - * - */ - public DateTableCellEditor() { - datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale()); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Date) { - datePicker.setDate((Date) value); - } - return datePicker; - } - - @Override - public Object getCellEditorValue() { - return datePicker.getDate(); - } - - @Override - public boolean isCellEditable(EventObject evt) { - return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; - } - - public static DateTableCellEditor getInstance() { - if (editor == null) { - editor = new DateTableCellEditor(); - } - return editor; - } -} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/listener/EmptyLineSelectionListener.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/EmptyLineSelectionListener.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,98 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.transaction.table; + +import org.chorem.lima.dto.EntryDTO; +import org.chorem.lima.dto.TransactionDTO; +import org.chorem.lima.dto.util.DTOHelper; +import org.chorem.lima.service.util.ServiceHelper; +import org.chorem.lima.table.TransactionJXTable; +import org.chorem.lima.table.model.TransactionFlattenTableModel; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + +/** + * Cette classe permet de définir les actions possibles sur la table des + * transactions. Ainsi lorsque l'utilisateur clique sur une ligne, il est possible + * d'assigner une action précise. + * + * @author ore + * @author Rémi Chapelet + */ +public class EmptyLineSelectionListener extends MouseAdapter { + + @Override + public void mouseClicked(MouseEvent e) { + TransactionJXTable table = (TransactionJXTable) e.getSource(); + if (TransactionFlattenTableModel.isFlattenModel(table.getModel())) + { + TransactionFlattenTableModel flattenModel = (TransactionFlattenTableModel) table.getModel(); + if (table.getSelectionModel().isSelectionEmpty()) + { + // Not line selected + } else { + // Line selected + int selectedRow = table.getSelectedRow(); + int parentIndex = flattenModel.getParentIndex(selectedRow); + /** + * Is transaction editable ? + */ + Object o = flattenModel.getElementAt(parentIndex); + if (DTOHelper.isTransaction(o)) { + // Transaction n'est pas éditable + if (!ServiceHelper.isEditable((TransactionDTO) o)) { + return; + } + } else { + //Entry n'est pas éditable + if (!ServiceHelper.isEditable((EntryDTO) o)) { + return; + } + } + + // Click in not current transaction + if (flattenModel.getCurrentParentIndex() != parentIndex) { + int posNext = flattenModel.emptyLineNextPosition(selectedRow); + /** + * Once traitement for transaction + */ + if (flattenModel.isEmptyLineEmpty()) { + flattenModel.createEmptyLine(); + } else { + flattenModel.removeEmptyLine(); + selectedRow = table.getSelectedRow(); + parentIndex = flattenModel.getParentIndex(selectedRow); + posNext = flattenModel.emptyLineNextPosition(selectedRow); + flattenModel.createEmptyLine(); + } + flattenModel.addEmptyLine(posNext); + + // To end + flattenModel.setCurrentParentIndex(parentIndex); + } + /** + * New Line Color + */ + table.addColorEmptyLine(); + } + } + } +} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -1,97 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.table.editor; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import org.chorem.lima.combobox.JWideComboBox; -import org.chorem.lima.combobox.model.JournalComboBoxModel; -import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer; -import org.chorem.lima.dto.JournalDTO; -import org.chorem.lima.util.JournalToStringConverter; -import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; - -import javax.swing.*; -import javax.swing.table.TableCellEditor; -import java.awt.*; -import java.awt.event.MouseEvent; -import java.util.EventObject; -import java.util.List; -import java.util.Vector; - -/** - * @author ore - */ -public class JournalTableCellEditor extends AbstractCellEditor implements TableCellEditor { - - /** - * log - */ - protected static final Log log = LogFactory.getLog(JournalTableCellEditor.class); - private final JComboBox comboBox; - private static final long serialVersionUID = 2580476608066111095L; - private static JournalTableCellEditor editor; - - /** - * - */ - public JournalTableCellEditor() { - - comboBox = new JWideComboBox(); - - /** Getting data from journal model **/ - List<JournalDTO> journals = LimaContext.getContext().getDataManager().getJournalModel().getData(); - - /** Creating combobox model */ - Vector<JournalDTO> v = new Vector<JournalDTO>(journals); - JournalComboBoxModel comboBoxModel = new JournalComboBoxModel(v); - /** Property Change Listener */ - LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel); - comboBox.setModel(comboBoxModel); - /** Renderer */ - comboBox.setRenderer(JournalComboBoxRenderer.getInstance()); - - /** AutoCompletion */ - AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance()); - } - - @Override - public Object getCellEditorValue() { - return comboBox.getSelectedItem(); - } - - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - return comboBox; - } - - @Override - public boolean isCellEditable(EventObject evt) { - return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; - } - - public static JournalTableCellEditor getInstance() { - if (editor == null) { - editor = new JournalTableCellEditor(); - } - return editor; - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -27,7 +27,6 @@ import jaxx.runtime.JAXXContext; import jaxx.runtime.swing.AboutPanel; -import jaxx.runtime.swing.ErrorDialogUI; import jaxx.runtime.swing.editor.config.ConfigUI; import jaxx.runtime.swing.editor.config.ConfigUIBuilder; import jaxx.runtime.swing.editor.config.model.ConfigUIModel; Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -1,410 +0,0 @@ -/* *##% Lima Swing - * Copyright (C) 2008 - 2010 CodeLutin - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * ##%*/ - -package org.chorem.lima.ui.fiscalperiod; - -import static org.nuiton.i18n.I18n._; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - -import javax.swing.JComboBox; -import javax.swing.ListSelectionModel; -import javax.swing.RowFilter; - -import jaxx.runtime.JAXXContext; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import org.chorem.lima.combobox.model.PeriodComboBoxModel; -import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.StatusDTO; -import org.chorem.lima.dto.TransactionDTO; -import org.chorem.lima.dto.util.TriPeriodAsc; -import org.chorem.lima.dto.util.TriPeriodDesc; -import org.chorem.lima.table.model.ClosureTableModel; -import org.chorem.lima.ui.ErrorMessage; -import org.chorem.lima.ui.period.AddPeriod; -import org.chorem.lima.ui.period.ClosureTimeSpanForm; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.HighlighterFactory; - - -/** - * Permet l'affichage du tableau avec les périodes mensuelles. - * - * @author Rémi Chapelet - */ -public class ClosureViewImpl extends ClosureView { - - /** serialVersionUID. */ - private static final long serialVersionUID = -8759564865633991757L; - - /** log. */ - private static final Log log = LogFactory.getLog(ClosureViewImpl.class); - - private final JXTable table; - private JComboBox comboBoxPeriod = new JComboBox(); - private final ClosureTimeSpanForm form; - private final AddPeriod addPeriodForm; - private static boolean blockPeriod; - private JComboBox comboBoxBeginPeriod = new JComboBox(); - private JComboBox comboBoxEndPeriod = new JComboBox(); - private JComboBox comboBeginYearPeriod = new JComboBox(); - private JComboBox comboBeginMonthPeriod = new JComboBox(); - private JComboBox comboEndYearPeriod = new JComboBox(); - private JComboBox comboEndMonthPeriod = new JComboBox(); - - /** - * @param parentContext - */ - public ClosureViewImpl(JAXXContext parentContext) { - super(parentContext); - - // Initialisation du choix pour les périodes - initComboBoxPeriod(); - - /* Set Period model */ - // Création du model pour le tableau - table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel()); - table.setRowHeight(24); - // Permet d'alterner les couleurs des lignes pour le tableau - table.setHighlighters(HighlighterFactory.createAlternateStriping()); - // Definition de la selection possible sur les lignes - table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - table.setColumnControlVisible(true); - - /* - * Ajout d'un listener lorsque l'utilisateur change de période. - */ - comboBoxPeriod.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - // Récupère la période master - PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); - //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)}; - //FilterPipeline filters = new FilterPipeline(filterArray); - - RowFilter<Object, Object> filter = null; - if (periodMaster != null) { - // 0 = check only in first column - // filter : - // period name containing selected periode - // Final = ??? TODO - Calendar calendar = Calendar.getInstance(); - calendar.setTime(periodMaster.getBegin()); - filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0); - if (log.isDebugEnabled()) { - log.debug("Apply filter on " + calendar.get(Calendar.YEAR)); - } - } - table.setRowFilter(filter); - } - }); - - // Ajout du tableau dans l'UI - getClosureScrollPane().setViewportView(table); - - /* - * Initialisation du formulaire pour bloquer ou débloquer une période. - */ - form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm(); - form.getOkButton().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - updatePeriod(); - } - }); - - /** - * Initialisation du formulaire pour ajouter un exercice - */ - addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod(); - - Calendar cal = Calendar.getInstance(); - - //Init YEAR Periode Combobox - // take care about previous year #120 - int todayYear = cal.get(Calendar.YEAR); - for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) { - comboBeginYearPeriod.addItem(currentYear); - comboEndYearPeriod.addItem(currentYear); - } - comboBeginYearPeriod.setSelectedItem(todayYear); - comboEndYearPeriod.setSelectedItem(todayYear); - - - //Add BeginYear ComboBox to addPeriodForm - addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod); - addPeriodForm.getBeginYearPeriodPanel().validate(); - - //Add EndYear ComboBox to addPeriodForm - addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod); - addPeriodForm.getEndYearPeriodPanel().validate(); - - //Init MONTH Periode Combobox - cal.set(Calendar.MONTH, Calendar.JANUARY); - for (int j = 0; j <= 11; j++) { - comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); - comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); - cal.add(Calendar.MONTH, 1); - } - - //Add BeginMonth ComboBox to addPeriodForm - addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod); - addPeriodForm.getBeginMonthPeriodPanel().validate(); - - //Add EndMonth ComboBox to addPeriodForm - addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod); - addPeriodForm.getEndMonthPeriodPanel().validate(); - - addPeriodForm.getOkButton().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - addPeriod(); - addPeriodForm.dispose(); - } - }); - - } - - - /** - * Cette méthode permet de charger les périodes (annuelles) pour choisir - * les périodes mensuelles à afficher dans le tableau. - */ - public void initComboBoxPeriod() { - /** - * Charge pour le JComboBox le choix des périodes (exercices) à afficher. - */ - // Récupère les périodes - ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); - PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); - // Création Combobox debut période - comboBoxPeriod.setModel(periodModel); - comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Ajout des combobox - periodPanel.add(comboBoxPeriod); - periodPanel.validate(); - } - - - /** - * Cette méthode permet d'initialiser le formulaire pour bloquer une ou - * plusieurs périodes. - */ - @Override - public void initBlockForm() { - blockPeriod = true; - form.setTitle(_("lima.ui.block.timespan")); - initComboBoxForm(); - form.setVisible(true); - } - - - /** - * Initialise le formulaire pour débloquer des périodes mensuelles. - */ - @Override - public void initUnblockForm() { - blockPeriod = false; - form.setTitle(_("lima.ui.unblock.timespan")); - initComboBoxForm(); - form.setVisible(true); - } - - - /** - * Initialise les combobox pour le formulaire de période. Il ajoute ainsi - * les deux combobox nécessaires pour début et fin de période. - */ - public void initComboBoxForm() { - /** - * Charge pour les JComboBox le choix des périodes mensuelles à bloquer. - */ - // Récupère les périodes - ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); - PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); - // Création Combobox debut période - comboBoxBeginPeriod.setModel(periodModel); - comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Création Combobox fin période - comboBoxEndPeriod.setModel(periodModel); - comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Ajout des combobox - form.beginPeriod.add(comboBoxBeginPeriod); - form.endPeriod.add(comboBoxEndPeriod); - - /** - * Positionne, si les lignes sont sélectionnées, les comboBox sur - * les bonnes périodes (période min et période max). - */ - // Si une ou plusieurs lignes sont sélectionnées - if (table.getSelectedRow() != -1) { - // Récupère les périodes sélectionnées - List<PeriodDTO> listPeriod = getSelectedPeriod(); - // Parcours du vecteur - comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0)); - comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1))); - } - } - - - /** - * Permet d'ajouter un nouvel exercice. - */ - protected void addPeriod() { - if (log.isDebugEnabled()) { - log.debug("addPeriod : "); - //Get form data - } - PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod(); - List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); - - // get begin date - Calendar beginCalendar = Calendar.getInstance(); - if (periodCurrent != null) { - beginCalendar.setTime(periodCurrent.getBegin()); - } - beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem()); - beginCalendar.set(Calendar.DAY_OF_MONTH, 1); - // month is equals to list index - beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex()); - Date beginDate = beginCalendar.getTime(); - - // get end date - Calendar endCalendar = Calendar.getInstance(); - endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem()); - endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex()); - int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); - endCalendar.set(Calendar.DAY_OF_MONTH, maximum); - Date endDate = endCalendar.getTime(); - - if (log.isDebugEnabled()) { - log.debug("Add new periode from " + beginDate + " to " + endDate); - } - - String periodName = null; - if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) { - periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR)); - } - else { - periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)); - } - - // TODO what is status.get(3) ??? - PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3)); - - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - closureModel.addPeriod(period, status); - } - - /** - * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer - * une ou plusieurs périodes, ou bien débloquer. - * On récupère l'intervalle des périodes donné par le formulaire. On prend - * les périodes aux extrémités. - * Si on bloque les périodes, on va trier par ordre croissant sinon par - * ordre décroissant. En effet, pour débloquer une période, il est important - * que les périodes qui suivent soient bloquées ; par conséquent on doit - * commencer par les dernières. - */ - protected void updatePeriod() { - // Liste des status - List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); - // Liste des transactions - List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData(); - // Chargement du model - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - /** - * Récupère l'intervalle des périodes sélectionnées - */ - PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem(); - PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem(); - // Exercice - PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); - // Si block période, on trie la liste en croissant ou bien décroissant - List<PeriodDTO> listPeriod = periodMaster.getChildren(); - if (blockPeriod) { - Collections.sort(listPeriod, new TriPeriodAsc()); - } else { - Collections.sort(listPeriod, new TriPeriodDesc()); - } - // Pour toutes les périodes mensuelles - for (PeriodDTO period : listPeriod) { - if (((period.getBegin().after(periodBegin.getBegin())) - && (period.getBegin().before(periodEnd.getBegin()))) - || (period.equals(periodBegin)) - || (period.equals(periodEnd))) { - if (log.isDebugEnabled()) { - log.debug("updatePeriod : " + period.getIdName() + " : " - + blockPeriod); - } - /** - * Détection des messages d'erreur - */ - String message = closureModel.updatePeriod(period, blockPeriod, status, transactions); - ErrorMessage.showMessage(message); - } - } - // On trie par ordre croissant si c'était en décroissant, sinon l'affichage - // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre - // décroissant). - if (!blockPeriod) { - Collections.sort(listPeriod, new TriPeriodAsc()); - } - form.setVisible(false); - form.dispose(); - } - - /** - * Cette méthode permet de retourner une liste des périodes sélectionnées. - * - * @return liste des périodes sélectionnées - */ - protected List<PeriodDTO> getSelectedPeriod() { - // récupère les lignes sélectionnées - int viewIndex[] = table.getSelectedRows(); - // chargement du model (tableau des périodes) - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>(); - // Pour chaque ligne sélectionnée - for (int i : viewIndex) { - int modelIndex = table.convertRowIndexToModel(i); - listPeriod.add(closureModel.getRow(modelIndex)); - } - return listPeriod; - } - - - public void initAddPeriod() { - addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod")); - addPeriodForm.setVisible(true); - } - -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BalanceViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -23,9 +23,6 @@ import org.chorem.lima.LimaContext; import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; import org.chorem.lima.balance.BalanceHelper; -import org.chorem.lima.dto.BalanceDTO; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.table.model.BalanceTableModel; import org.chorem.lima.table.renderer.BalanceTableCellRenderer; import static org.nuiton.i18n.I18n._; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/BilanViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -21,17 +21,13 @@ import org.chorem.lima.LimaContext; import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; -import org.chorem.lima.dto.BalanceDTO; import org.chorem.lima.bilan.Bilan; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.balance.BalanceHelper; import org.chorem.lima.balance.Category; import org.chorem.lima.table.BilanActifJXTable; import org.chorem.lima.table.BilanPassifJXTable; import org.chorem.lima.table.model.BilanActifTableModel; import org.chorem.lima.table.model.BilanPassifTableModel; -import org.chorem.lima.ui.MainViewImpl; import org.chorem.lima.ui.ProgressBarImpl; import java.awt.event.*; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/report/ResultViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -23,14 +23,10 @@ import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; import org.chorem.lima.balance.BalanceHelper; import org.chorem.lima.balance.Category; -import org.chorem.lima.dto.BalanceDTO; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.table.ResultChargesJXTable; import org.chorem.lima.table.ResultProduitsJXTable; import org.chorem.lima.table.model.ResultChargesTableModel; import org.chorem.lima.table.model.ResultProduitsTableModel; -import org.chorem.lima.util.Util; import static org.nuiton.i18n.I18n._; import org.apache.commons.logging.Log; Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidgetImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -1,217 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.ui.transaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import static org.nuiton.i18n.I18n._; -import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer; -import org.chorem.lima.dto.AccountDTO; -import org.chorem.lima.item.Item; -import org.chorem.lima.service.util.ServiceHelper; -import org.chorem.lima.ui.transaction.autocomplete.AccountToStringConverter; -import org.chorem.lima.ui.transaction.model.AccountComboBoxModel; -import org.chorem.lima.widgets.JWideComboBox; -import org.jdesktop.swingx.JXDatePicker; -import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Date; -import java.util.List; -import java.util.Vector; - -import jaxx.runtime.JAXXContext; - -/** - * @author ore - */ -public class CriteriaWidgetImpl extends CriteriaWidget { - - /** - * log - */ - private static final Log log = LogFactory.getLog(CriteriaWidgetImpl.class); - private JTextField inputTextField; - private JXDatePicker datePicker; - private JComboBox comboBox; - private JComboBox accountCombo; - - /** - * @param parentContext - */ - public CriteriaWidgetImpl(JAXXContext parentContext) { - super(parentContext); - - // date input creation - createDateInput(); - - // item changed listener - criteriaComboBox.addItemListener(new ItemListener() { - - @Override - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - String itemSelected = e.getItem().toString(); - if (itemSelected.equals("date")) { - createDateInput(); - } - if (itemSelected.equals("voucher") || - itemSelected.equals("description") || - itemSelected.equals("account")) { - createTextInput(); - } - if (itemSelected.equals("debit") || - itemSelected.equals("credit") || - itemSelected.equals("amount")) { - createNumberInput(); - } - if (itemSelected.equals("account")) { - createAccountInput(); - } - } - } - }); - } - - /** - * - */ - private void createNumberInput() { - getComboBox().removeAllItems(); - getComboBox().addItem(new Item(1, _("lima.filter.greater.than"))); - getComboBox().addItem(new Item(2, _("lima.filter.less.than"))); - getComboBox().addItem(new Item(3, _("lima.filter.equals.to"))); - criteriaPanel.removeAll(); - criteriaPanel.add(getComboBox()); - criteriaPanel.add(getInputTextField()); - criteriaPanel.validate(); - if (log.isDebugEnabled()) { - log.debug("numberinput : "); - } - } - - /** - * - */ - private void createTextInput() { - getComboBox().removeAllItems(); - getComboBox().addItem(new Item(1, _("lima.filter.contains"))); - getComboBox().addItem(new Item(2, _("lima.filter.not.contains"))); - getComboBox().addItem(new Item(3, _("lima.filter.equals.to"))); - getComboBox().addItem(new Item(4, _("lima.filter.starts.with"))); - criteriaPanel.removeAll(); - criteriaPanel.add(getComboBox()); - criteriaPanel.add(getInputTextField()); - criteriaPanel.validate(); - if (log.isDebugEnabled()) { - log.debug("textinput : "); - } - } - - /** - * - */ - private void createAccountInput() { - getComboBox().removeAllItems(); - getComboBox().addItem(new Item(1, _("lima.filter.contains"))); - getComboBox().addItem(new Item(2, _("lima.filter.not.contains"))); - getComboBox().addItem(new Item(3, _("lima.filter.equals.to"))); - getComboBox().addItem(new Item(4, _("lima.filter.starts.with"))); - criteriaPanel.removeAll(); - criteriaPanel.add(getComboBox()); - criteriaPanel.add(getAccountCombo()); - criteriaPanel.validate(); - if (log.isDebugEnabled()) { - log.debug("accountinput : "); - } - } - - /** - * - */ - private void createDateInput() { - getComboBox().removeAllItems(); - getComboBox().addItem(new Item(1, _("lima.filter.before"))); - getComboBox().addItem(new Item(2, _("lima.filter.after"))); - getComboBox().addItem(new Item(3, _("lima.filter.equals.to"))); - criteriaPanel.removeAll(); - criteriaPanel.add(getComboBox()); - criteriaPanel.add(getDatePicker()); - criteriaPanel.validate(); - if (log.isDebugEnabled()) { - log.debug("dateinput : "); - } - } - - @Override - protected void removeCriteriaWidget() { - LimaContext.getContext().getMainUI().getSearchView().removeCriteriaWidget(this); - } - - /** - * @return - */ - public JComboBox getComboBox() { - if (comboBox == null) { - comboBox = new JComboBox(); - } - return comboBox; - } - - /** - * @return - */ - public JXDatePicker getDatePicker() { - if (datePicker == null) { - datePicker = new JXDatePicker(new Date(), LimaContext.getContext().getConfig().getLocale()); - } - return datePicker; - } - - /** - * @return - */ - public JTextField getInputTextField() { - if (inputTextField == null) { - inputTextField = new JTextField(); - inputTextField.setPreferredSize(new Dimension(150, 20)); - } - return inputTextField; - } - - public JComboBox getAccountCombo() { - if (accountCombo == null) { - List<AccountDTO> accounts = ServiceHelper.getAllFlatAccount( - LimaContext.getContext().getDataManager().getAccountModel().getData()); - Vector<AccountDTO> v = new Vector<AccountDTO>(accounts); - AccountComboBoxModel model = new AccountComboBoxModel(v); - accountCombo = new JWideComboBox(model); - accountCombo.setRenderer(AccountComboBoxRenderer.getInstance()); - accountCombo.setPreferredSize(new Dimension(200, 25)); - // AutoCompletion - AutoCompleteDecorator.decorate(accountCombo, AccountToStringConverter.getInstance()); - } - return accountCombo; - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -79,7 +79,13 @@ int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { Object selectedValue = model.getElementAt(indexSelectedRow); + try { model.addEmptyEntry(selectedValue, indexSelectedRow); + } catch (LimaException ex){ + if (log.isWarnEnabled()) { + log.warn("Can't add empty entry"); + } + } } else { if (log.isWarnEnabled()) { @@ -121,26 +127,11 @@ try { model.removeObject(selectedValue, indexSelectedRow); } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", ex); - } - ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex); - } - - /* - if (selectedValue instanceof Transaction) { - // TODO EC-20100409 implements this - if (log.isWarnEnabled()) { - log.warn("TODO implement Transaction deletion"); - model.removeTransaction(selectedValue); + if (log.isErrorEnabled()) { + log.error("Can't remove transaction or entry", ex); } + ErrorHelper.showErrorDialog("Can't remove transaction or entry", ex); } - else if (selectedValue instanceof Entry) { - // TODO EC-20100409 implements this - if (log.isWarnEnabled()) { - log.warn("TODO implement Entry deletion"); - } - }*/ } } else { Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchFinancialTransactionViewHandler.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,14 @@ +package org.chorem.lima.ui.transaction; + +public class SearchFinancialTransactionViewHandler { + + + protected void addCriteriaWidget() { + + } + + protected void doSearch() { + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransactionViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -23,7 +23,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; import static org.nuiton.i18n.I18n._; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.enumeration.FilterEnum; import org.chorem.lima.table.TransactionJXTable; import org.jdesktop.swingx.JXDatePicker; @@ -47,7 +46,7 @@ * @param parentContext */ public SearchTransactionViewImpl(JAXXContext parentContext) { - super(parentContext); + super(parentContext); // At Least one criteria CriteriaWidgetImpl widget = new CriteriaWidgetImpl(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-28 15:59:14 UTC (rev 2876) @@ -74,7 +74,7 @@ </cell> </row> <row> - <cell fill="both" weightx="1" weighty="1" rows="3" columns="5"> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="6"> <JScrollPane> <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel id="financialTransactionTableModel" /> @@ -87,26 +87,27 @@ onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> - <cell> - <JButton text="lima.add.transaction" - onActionPerformed="getHandler().addFinancialTransaction()"/> - </cell> - </row> - <row> - <cell> - <!-- - <JButton text="lima.remove.transaction" - onActionPerformed="getHandler().removeTransaction()" - enabled="{isSelectedRow()}"/> - --> - <JButton text="lima.remove.transaction" + <cell fill="horizontal" weightx="1" weighty="1" anchor="north"> + <Table> + <row> + <cell> + <JButton text="lima.add.transaction" + onActionPerformed="getHandler().addFinancialTransaction()"/> + </cell> + </row> + <row> + <cell> + <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/> + </cell> + </row> + <row> + <cell> + <JButton text="lima.common.remove" onActionPerformed="getHandler().deleteSelectedRow()" enabled="{isSelectedRow()}"/> + </cell> + </row> + </Table> </cell> </row> - <row> - <cell> - <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionViewImpl.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -34,18 +34,10 @@ import org.chorem.lima.combobox.model.PeriodComboBoxModel; import org.chorem.lima.combobox.renderer.JournalComboBoxRenderer; import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; -import org.chorem.lima.dto.EntryDTO; -import org.chorem.lima.dto.JournalDTO; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.TransactionDTO; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.enumeration.FilterEnum; import org.chorem.lima.listener.ClicRight; -import org.chorem.lima.service.util.ServiceHelper; import org.chorem.lima.table.model.*; import org.chorem.lima.table.TransactionJXTable; -import org.chorem.lima.ui.ErrorMessage; -import org.chorem.lima.util.Util; import static org.nuiton.i18n.I18n._; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountComboBoxModel.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -18,35 +18,78 @@ package org.chorem.lima.ui.transaction.model; -import javax.swing.DefaultComboBoxModel; +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.AccountService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.service.LimaServiceFactory; /** * Account combo box model. - * - * Used in: - * - lettering view - * - * @author ore - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ -public class AccountComboBoxModel extends DefaultComboBoxModel { - /** serialVersionUID. */ - private static final long serialVersionUID = -6914345613508897515L; +public class AccountComboBoxModel implements ComboBoxModel { + + protected AccountService accountService; + + public AccountComboBoxModel() { + accountService = LimaServiceFactory.getInstance().getAccountService(); + } + + @Override + public Object getSelectedItem() { + // TODO Auto-generated method stub + return null; + } - /** log. */ - private static final Log log = LogFactory.getLog(AccountComboBoxModel.class); + @Override + public void setSelectedItem(Object anItem) { + // TODO Auto-generated method stub + + } - /** - * @param items - */ - public AccountComboBoxModel() { - super(); + @Override + public void addListDataListener(ListDataListener arg0) { + // TODO Auto-generated method stub + } + + @Override + public Object getElementAt(int index) { + Object result = null; + // TODO add cache + try { + result = accountService.getAllAccounts().get(index); + } + catch (LimaException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + return result; + } + + @Override + public int getSize() { + int result = 0; + // TODO add cache + try { + result = accountService.getAllAccounts().size(); + } + catch (LimaException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + return result; + } + + @Override + public void removeListDataListener(ListDataListener arg0) { + // TODO Auto-generated method stub + + } + + + + } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/AccountRenderer.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,30 @@ +package org.chorem.lima.ui.transaction.model; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.Account; + +public class AccountRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + Account account = (Account) value; + if (account != null){ + label.setText(account.getAccountNumber()+" - "+account.getLabel()); + } + return label; + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxModel.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -18,9 +18,12 @@ package org.chorem.lima.ui.transaction.model; +import java.util.Collection; + import javax.swing.ComboBoxModel; import javax.swing.event.ListDataListener; +import org.apache.commons.collections.CollectionUtils; import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FiscalPeriod; @@ -60,9 +63,8 @@ // TODO add cache try { if (selectedFiscalPeriod != null){ - result = financialPeriodService. - getUnblockedFinancialPeriodWithFiscalPeriod( - selectedFiscalPeriod).size(); + + result = selectedFiscalPeriod.getFinancialPeriod().size(); } else { result = financialPeriodService. @@ -85,9 +87,7 @@ // TODO add cache try { if (selectedFiscalPeriod != null){ - result = financialPeriodService. - getUnblockedFinancialPeriodWithFiscalPeriod( - selectedFiscalPeriod).get(index); + result = CollectionUtils.get(selectedFiscalPeriod.getFinancialPeriod(), index); } else { result = financialPeriodService.getUnblockedFinancialPeriods(). Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -21,7 +21,6 @@ import static org.nuiton.i18n.I18n._; import java.awt.Component; -import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/AccountTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,82 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.transaction.table; + +import java.awt.Component; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.ui.transaction.model.AccountComboBoxModel; +import org.chorem.lima.ui.transaction.model.AccountRenderer; + +public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + + protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JComboBox comboBox; + private static final long serialVersionUID = 2580476608066111095L; + private static AccountTableCellEditor editor; + + /** + * constructor + */ + public AccountTableCellEditor() { + comboBox = new JComboBox(); + AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); + comboBox.setModel(accountComboBoxModel); + AccountRenderer accountRenderer = new AccountRenderer(); + comboBox.setRenderer(accountRenderer); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof Account){ + comboBox.setSelectedItem((Account) value); + + } + return comboBox; + } + + @Override + public Object getCellEditorValue() { + return comboBox.getSelectedItem(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static AccountTableCellEditor getInstance() { + if (editor == null) { + editor = new AccountTableCellEditor(); + } + return editor; + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/DateTableCellEditor.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/DateTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,72 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.transaction.table; + +import org.chorem.lima.LimaContext; +import org.jdesktop.swingx.JXDatePicker; + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.Date; +import java.util.EventObject; + +/** + * @author ore + */ +public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + private final JXDatePicker datePicker; + private static final long serialVersionUID = -8455896587828255307L; + private static DateTableCellEditor editor; + + /** + * constructor + */ + public DateTableCellEditor() { + datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale()); + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof Date) { + datePicker.setDate((Date) value); + } + return datePicker; + } + + @Override + public Object getCellEditorValue() { + return datePicker.getDate(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static DateTableCellEditor getInstance() { + if (editor == null) { + editor = new DateTableCellEditor(); + } + return editor; + } +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/table/editor/JournalTableCellEditor.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/EntryBookTableCellEditor.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -0,0 +1,88 @@ +/** + * *##% Lima Main + * Copyright (C) 2008 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.ui.transaction.table; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel; +import org.chorem.lima.ui.transaction.model.EntryBookRenderer; +import org.chorem.lima.widgets.JWideComboBox; + +import javax.swing.*; +import javax.swing.table.TableCellEditor; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.EventObject; + +/** + * @author ore + */ +public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { + + protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JComboBox comboBox; + private static final long serialVersionUID = 2580476608066111095L; + private static EntryBookTableCellEditor editor; + + /** + * constructor + */ + public EntryBookTableCellEditor() { + log.debug("test"); + comboBox = new JWideComboBox(); + EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); + comboBox.setModel(entryBookComboBoxModel); + EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); + comboBox.setRenderer(entryBookRenderer); + + /*// Property Change Listener + LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel); + comboBox.setModel(comboBoxModel); + // AutoCompletion + AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/ + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + if (value instanceof EntryBook){ + comboBox.setSelectedItem((EntryBook) value); + + } + return comboBox; + } + + @Override + public Object getCellEditorValue() { + return comboBox.getSelectedItem(); + } + + @Override + public boolean isCellEditable(EventObject evt) { + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; + } + + public static EntryBookTableCellEditor getInstance() { + if (editor == null) { + editor = new EntryBookTableCellEditor(); + } + return editor; + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTable.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -17,13 +17,14 @@ * ##%*/ package org.chorem.lima.ui.transaction.table; + import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.util.Date; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.listener.EmptyLineSelectionListener; -import org.chorem.lima.table.editor.DateTableCellEditor; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.transaction.FinancialTransactionViewHandler; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; @@ -51,8 +52,6 @@ private ColorHighlighter colorBalance; - private EmptyLineSelectionListener emptyLineSelectionListener; - /** */ public FinancialTransactionTable(FinancialTransactionViewHandler handler/*, @@ -105,8 +104,12 @@ tcm.getColumn(TransactionEnum.DOCUMENT.ordinal()).setCellEditor(TextTableCellEditor.getInstance()); tcm.getColumn(TransactionEnum.PERIOD.ordinal()).setCellEditor(PeriodTableCellEditor.getInstance());*/ + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); - + //Get new entry book editor + setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor()); + //Get new account editor + setDefaultEditor(Account.class, new AccountTableCellEditor()); // Color transactions // addColorTransaction(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-28 15:59:14 UTC (rev 2876) @@ -25,15 +25,14 @@ import java.util.Date; import java.util.List; -import javax.swing.JOptionPane; import javax.swing.table.AbstractTableModel; import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.EntryService; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.RecordService; import org.chorem.lima.business.FinancialTransactionService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -41,13 +40,10 @@ import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransactionImpl; -import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.transaction.FinancialTransactionHelper; import org.chorem.lima.util.ErrorHelper; -import org.nuiton.topia.TopiaContextFactory; /** * Basic transaction table model. @@ -79,8 +75,11 @@ /** Transaction service. */ protected final FinancialTransactionService transactionService; + + /** Entry service. */ + protected final EntryService entryService; /** Record service. */ - protected final RecordService recordService; + //protected final RecordService recordService; protected EntryBook selectedEntryBook; @@ -93,9 +92,10 @@ */ public FinancialTransactionTableModel() { /* Services */ - recordService = LimaServiceFactory.getInstance().getRecordService(); + // recordService = LimaServiceFactory.getInstance().getRecordService(); transactionService = LimaServiceFactory.getInstance() .getTransactionService(); + entryService = LimaServiceFactory.getInstance().getEntryService(); } /** @@ -111,7 +111,8 @@ try { List<FinancialTransaction> financialtransactions = - transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod(selectedEntryBook, selectedFinancialPeriod); + transactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod( + selectedEntryBook, selectedFinancialPeriod); for (FinancialTransaction financialtransaction : financialtransactions) { results.add(financialtransaction); @@ -133,7 +134,7 @@ @Override public int getColumnCount() { - return 10; + return 9; } @Override @@ -146,32 +147,29 @@ result = Date.class; break; case 1: - result = Account.class; + result = String.class; break; case 2: result = EntryBook.class; break; case 3: - result = FinancialPeriod.class; + result = Account.class; break; case 4: result = String.class; break; case 5: - result = Double.class; + result = String.class; break; case 6: result = Double.class; break; case 7: - result = String.class; + result = Double.class; break; case 8: - result = String.class; + result = Double.class; break; - case 9: - result = String.class; - break; } return result; @@ -186,32 +184,29 @@ result = _("lima.transaction.column.date"); break; case 1: - result = _("lima.transaction.column.account"); + result = _("lima.transaction.column.voucher"); break; case 2: result = _("lima.transaction.column.entrybook"); break; case 3: - result = _("lima.transaction.column.period"); + result = _("lima.transaction.column.account"); break; case 4: - result = _("lima.transaction.column.status"); + result = _("lima.transaction.column.description"); break; case 5: - result = _("lima.transaction.column.debit"); + result = _("lima.transaction.column.position"); break; case 6: - result = _("lima.transaction.column.credit"); + result = _("lima.transaction.column.debit"); break; case 7: - result = _("lima.transaction.column.balance"); + result = _("lima.transaction.column.credit"); break; case 8: - result = _("lima.transaction.column.description"); + result = _("lima.transaction.column.balance"); break; - case 9: - result = _("lima.transaction.column.document"); - break; } return result; @@ -249,36 +244,36 @@ FinancialTransaction currentRow = (FinancialTransaction)result; switch (column) { case 0: - result = currentRow.getTransactionDate(); + Calendar cal = Calendar.getInstance(); + cal.setTime(currentRow.getTransactionDate()); + result = String.valueOf(cal.get(Calendar.DAY_OF_MONTH)); break; case 1: - result = null; // account ? + result = null; // voucher break; case 2: - result = null; // entry book + //TODO Lazy exception make a methode to get entrybook from the currentFinancialTransaction + result = currentRow.getEntryBook().getLabel(); break; case 3: - result = null; //currentRow.getFinancialPeriod(); + result = null; // account; break; case 4: - result = null; // what is status ? _("lima.transaction.column.status"); + result = null; // description; break; - case 5: - result = FinancialTransactionHelper.getDebit(currentRow); + case 5 : + result = null; //position; break; case 6: - result = FinancialTransactionHelper.getCredit(currentRow); + result = FinancialTransactionHelper.getDebit(currentRow); break; case 7: + result = FinancialTransactionHelper.getCredit(currentRow); + break; + case 8: result = FinancialTransactionHelper.getDebit(currentRow) - FinancialTransactionHelper.getCredit(currentRow); break; - case 8: - result = currentRow.getDescription(); - break; - case 9: - result = currentRow.getVoucherRef(); - break; } } else if (result instanceof Entry) { @@ -287,33 +282,30 @@ case 0: result = null; // date break; - case 1: - result = currentEntry.getAccount(); // account ? + case 1 : + result = currentEntry.getVoucher(); break; case 2: result = null; // entry book break; case 3: - result = null; //currentRow.getFinancialPeriod(); + result = currentEntry.getAccount().getLabel();// account break; case 4: - result = null; // what is status ? _("lima.transaction.column.status"); + result = currentEntry.getDescription(); break; - case 5: - result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + case 5 : + result = currentEntry.getPosition(); break; case 6: - result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; break; case 7: - result = null; + result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); break; case 8: - result = currentEntry.getDescription(); + result = null; // balance break; - case 9: - result = null; - break; } } } @@ -339,7 +331,28 @@ fireTableDataChanged(); } + /** + * To set cells editable or not + * different condition for entry or financial transaction + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + boolean editableCell=false; + List<Object> datas = getDataList(); + Object currentRow = datas.get(rowIndex); + // cells editable for the entry row, all cells exclude the date + if ((currentRow instanceof Entry) && !(columnIndex==0 || columnIndex==2 || columnIndex==8)) { + editableCell=true; + } + // cells editable for the financialtransaction row, no cells exclude the date + if ((currentRow instanceof FinancialTransaction) && (columnIndex==0 || columnIndex==2)){ + editableCell=true; + } + return editableCell; + } + + /** * @throws LimaException */ public void addFinancialTransaction() throws LimaException{ @@ -354,15 +367,14 @@ Calendar actualCalendar = Calendar.getInstance(); // get the financial period date Date transactionDate = selectedFinancialPeriod.getBeginDate(); - //change the day - transactionDate = DateUtils.setDays(transactionDate, actualCalendar.get(Calendar.DAY_OF_MONTH)); - //set date to the financial transaction + // change the day + transactionDate = DateUtils.setDays(transactionDate, + actualCalendar.get(Calendar.DAY_OF_MONTH)); + // set date to the financial transaction financialTransaction.setTransactionDate(transactionDate); - //create it + // create it transactionService.createFinancialTransaction(financialTransaction); int row = getDataList().indexOf(financialTransaction); - //int row = transactionService.getAllTransactions().indexOf(transaction); - log.debug(row); fireTableRowsInserted(row, row); } else { @@ -375,24 +387,30 @@ /** * @throws LimaException */ - public void addEmptyEntry(Object value, int row) { - /* Calling transaction service */ - //TODO transaction = currentdate, current periode, current journal + public void addEmptyEntry(Object value, int row) throws LimaException { + FinancialTransaction currentTransaction = null; List<Object> datas = getDataList(); Object currentRow = datas.get(row); Entry entry = new EntryImpl(); + //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = (FinancialTransaction)currentRow; - currentTransaction.addEntry(entry); + currentTransaction = (FinancialTransaction)currentRow; } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry)currentRow; - //TODO recuperer l'entrée parente, ajouter entrée + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); } + //create it + entry.setFinancialTransaction(currentTransaction); + entryService.createEntry(entry); fireTableRowsUpdated(row, row); } + /** + * to modifiy financialtransaction or entry + */ @Override public void setValueAt(Object value, int row, int column) { @@ -401,7 +419,6 @@ // TODO EC-20100407 remove this ugly code List<Object> datas = getDataList(); Object currentRow = datas.get(row); - if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentFinancialTransaction = (FinancialTransaction)currentRow; @@ -409,85 +426,57 @@ case 0: currentFinancialTransaction.setTransactionDate((Date)value); break; - /*case 1: - result = null; // account ? - break; case 2: - result = null; // entry book + currentFinancialTransaction.setEntryBook((EntryBook)value); break; - case 3: - result = null; //currentRow.getFinancialPeriod(); - break; - case 4: - result = null; // what is status ? _("lima.transaction.column.status"); - break; - case 5: - result = TransactionHelper.getDebit(currentRow); - break; - case 6: - result = TransactionHelper.getCredit(currentRow); - break; - case 7: - result = TransactionHelper.getDebit(currentRow) - TransactionHelper.getCredit(currentRow); - break;*/ - case 8: - currentFinancialTransaction.setDescription((String)value); - break; - case 9: - currentFinancialTransaction.setVoucherRef((String)value); - break; } - // notify service for modification try { transactionService.updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + if (log.isDebugEnabled()){ + log.debug("Can't update financial transaction", e); + } } - //fireTableRowsUpdated(row, row); // to update what ??? - + //update the financial transaction row + fireTableRowsUpdated(row, row); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry)currentRow; switch (column) { - /*case 0: - result = null; // date - break;*/ - case 1: - currentEntry.setAccount((Account)value); // account ? + case 1 : + currentEntry.setVoucher((String)value); break; - /*case 2: - result = null; // entry book - break; case 3: - result = null; //currentRow.getFinancialPeriod(); + currentEntry.setAccount((Account)value); break; case 4: - result = null; // what is status ? _("lima.transaction.column.status"); - break;*/ - case 5: + currentEntry.setDescription((String)value); + break; + case 5 : + currentEntry.setPosition((String)value); + break; + case 6: currentEntry.setAmount((Double)value); currentEntry.setDebit(true); break; - case 6: + case 7: currentEntry.setAmount((Double)value); currentEntry.setDebit(false); break; - /*case 7: - result = null; - break;*/ - case 8: - currentEntry.setDescription((String)value); - break; - /*case 9: - result = null; - break;*/ } - - //transactionService.updateEntry(currentEntry); - // fire modification of all transaction - // see here, table is not adapted :) + try { + entryService.updateEntry(currentEntry); + } catch (LimaException e) { + if (log.isDebugEnabled()){ + log.debug("Can't update entry", e); + } + } + //update the financial transaction in entire + int financialTransactionRow = getDataList().indexOf(((Entry) currentRow).getFinancialTransaction()); + fireTableRowsUpdated(financialTransactionRow, financialTransactionRow); + //update the entry + //fireTableRowsUpdated(row, row); } } else { @@ -513,18 +502,16 @@ * @throws LimaException */ public void removeObject(Object object, int row) throws LimaException { - /* Calling journal service */ - List<Object> datas = getDataList(); Object currentRow = datas.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = (FinancialTransaction)currentRow; transactionService.removeFinancialTransaction(currentTransaction); - fireTableRowsDeleted(row, row); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry)currentRow; - //TODO supprimer l'entrée + entryService.removeEntry(currentEntry); } + fireTableRowsDeleted(row, row); } } Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-26 16:22:31 UTC (rev 2875) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-28 15:59:14 UTC (rev 2876) @@ -299,10 +299,10 @@ lima.transaction.column.date=Jour lima.transaction.column.debit=D\u00E9bit lima.transaction.column.description=Description -lima.transaction.column.document=Document lima.transaction.column.entrybook=Journal lima.transaction.column.period=P\u00E9riode -lima.transaction.column.status=Statut +lima.transaction.column.position=Statut +lima.transaction.column.voucher=Pi\u00E8ce comptable lima.transaction.confirmdelete= lima.transaction.entrybook=Journal lima.transaction.period=P\u00E9riode
participants (1)
-
jpepin@users.chorem.org