r3007 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-callao/src/main/java/org/chorem/lima lima-callao/src/main/java/org/chorem/lima/entity lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/enums lima-swing/src/main/java/org/chorem/lima/ui/combobox lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbal
Author: jpepin Date: 2010-08-19 23:13:17 +0200 (Thu, 19 Aug 2010) New Revision: 3007 Url: http://chorem.org/repositories/revision/lima/3007 Log: Impl?\195?\169mentation recherche ?\195?\169critures. D?\195?\169placement de la m?\195?\169thode accountsToStrings du service account vers le DAO account. Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -344,13 +344,15 @@ Account accountToDelete = accountDAO.findByTopiaId(account.getTopiaId()); //get all subaccounts - List<Account> accounts = getAllChildrenAccounts(accountToDelete, new ArrayList<Account>()); + List<Account> accounts = + getAllChildrenAccounts(accountToDelete, new ArrayList<Account>()); //if account have sub accounts if (accounts.size() > 0){ for (Account subAccount : accounts) { // Check rules for subaccount if have entries accountingRules.removeAccountRules(subAccount, transaction); - Account subAccountToDelete = accountDAO.findByTopiaId(subAccount.getTopiaId()); + Account subAccountToDelete = + accountDAO.findByTopiaId(subAccount.getTopiaId()); accountDAO.delete(subAccountToDelete); } } @@ -435,11 +437,11 @@ } - /** + /* * Convert string of extends number to list of accounts * Example '22, 45..48, 67' -> [22, 45, 46, 47, 48, 67] * SubAccountsMode return list of existing subaccounts ex 6 return : 61, 62, .., 69, 610, .., 619 etc - */ + * @Override public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, Boolean subAccountsMode, TopiaContext topiaContext) throws LimaException{ List<Account> accounts = new ArrayList<Account>(); @@ -536,7 +538,7 @@ } return accounts; - } + }*/ protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -40,7 +40,6 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ejbinterface.AccountServiceLocal; import org.chorem.lima.business.ejbinterface.FinancialStatementService; import org.chorem.lima.business.ejbinterface.FinancialStatementServiceLocal; import org.chorem.lima.business.ejbinterface.ReportServiceLocal; @@ -67,9 +66,6 @@ protected AccountingRules accountingRules; @EJB - AccountServiceLocal accountServiceLocal; - - @EJB ReportServiceLocal reportServiceLocal; public FinancialStatementServiceImpl() { @@ -463,12 +459,12 @@ try { if (accountsNumberList != null){ //Remove Spaces + AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); accountsNumberList = StringUtils.deleteWhitespace(accountsNumberList); StringTokenizer stQuote = new StringTokenizer(accountsNumberList, "-"); while (stQuote.hasMoreTokens()) { String s = stQuote.nextToken(); - List<Account> accountsList = accountServiceLocal. - stringToListAccountsWithTransaction(s, false, topiaContext); + List<Account> accountsList = accountDAO.stringToListAccounts(s, false); BigDecimal resAmount = new BigDecimal(0); for (Account account : accountsList) { @@ -521,7 +517,9 @@ } }catch (LimaException ex) { doCatch(topiaContext, ex, log); - } + } catch (TopiaException e) { + doCatch(topiaContext, e, log); + } return amount; } @@ -546,20 +544,20 @@ for (FinancialStatement financialStatement : financialStatementsList) { accountsList.removeAll( - accountServiceLocal.stringToListAccountsWithTransaction( - financialStatement.getAccounts(), true, transaction)); + accountDAO.stringToListAccounts( + financialStatement.getAccounts(), true)); accountsList.removeAll( - accountServiceLocal.stringToListAccountsWithTransaction( - financialStatement.getCreditAccounts(), true, transaction)); + accountDAO.stringToListAccounts( + financialStatement.getCreditAccounts(), true)); accountsList.removeAll( - accountServiceLocal.stringToListAccountsWithTransaction( - financialStatement.getDebitAccounts(), true, transaction)); + accountDAO.stringToListAccounts( + financialStatement.getDebitAccounts(), true)); accountsList.removeAll( - accountServiceLocal.stringToListAccountsWithTransaction( - financialStatement.getProvisionDeprecationAccounts(), true, transaction)); + accountDAO.stringToListAccounts( + financialStatement.getProvisionDeprecationAccounts(), true)); } for (Account account : accountsList) { 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-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -20,21 +20,23 @@ package org.chorem.lima.business.ejb; import static org.nuiton.i18n.I18n._; - import java.math.BigDecimal; +import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; - import javax.ejb.Stateless; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.FinancialStatementWayEnum; import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.business.ejbinterface.FinancialTransactionServiceLocal; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.AccountDAO; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryDAO; @@ -605,7 +607,97 @@ - protected TopiaContext beginTransaction() throws TopiaException { + + @Override + public List<Entry> searchEntry(Date beginDate, Date endDate, String voucher, + String description, String letter, String accountsList, + Account account, EntryBook entryBook, + FinancialStatementWayEnum fStWayEnum, String operator, + String amount, String amount2) throws LimaException { + List<Entry> entries = null; + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + TopiaQuery query = entryDAO.createQuery(); + String dateProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); + String entryBookProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK); + String entryBookLabelProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK, EntryBook.LABEL); + String accountProperty = TopiaQuery.getProperty(Entry.ACCOUNT, Account.ACCOUNT_NUMBER); + + //Load for lazy + query.addLoad(dateProperty) + .addLoad(entryBookLabelProperty) + .addLoad(accountProperty); + + if (beginDate != null && endDate != null){ + query.addBetween(dateProperty, beginDate, endDate); + } + else if (beginDate != null){ + query.addEquals(dateProperty, beginDate); + } + if (voucher != null){ + query.addWhere(Entry.VOUCHER, Op.LIKE, "%"+voucher+"%"); + } + if (description != null){ + query.addWhere(Entry.DESCRIPTION, Op.LIKE, "%"+description+"%"); + } + if (letter != null){ + query.addWhere(Entry.LETTERING, Op.LIKE, "%"+letter+"%"); + } + if (account != null){ + query.addEquals(Entry.ACCOUNT, account); + } + else if (accountsList != null){ + AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(topiaContext); + List<Account> accounts = accountDAO.stringToListAccounts(accountsList, false); + String accountNumbers = "0,"; + int max = accounts.size(); + for (int i = 1; i <= max; i++) { + accountNumbers += accounts.get(i-1).getAccountNumber(); + if (i != max){ + accountNumbers += ","; + } + } + if (accounts.size() > 0){ + query.addWhere(accountProperty + " in (" + accountNumbers + ")"); + } + + } + if (entryBook != null){ + query.addEquals(entryBookProperty, entryBook); + } + else if (amount != null){ + if (amount2 != null){ + BigDecimal value1 = new BigDecimal(amount); + BigDecimal value2 = new BigDecimal(amount2); + query.addBetween(Entry.AMOUNT, value1, value2); + } + else if (operator != null) { + query.addWhere(Entry.AMOUNT+" "+operator+" "+amount); + } + switch (fStWayEnum) { + case CREDIT: + query.addEquals(Entry.DEBIT, false); + break; + case DEBIT: + query.addEquals(Entry.DEBIT, true); + break; + } + } + log.debug(query); + entries = entryDAO.findAllByQuery(query); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + return entries; + } + + protected TopiaContext beginTransaction() throws TopiaException { // basic check done, make check in database // TODO move it into JTA TopiaContext topiaTransaction; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import javax.ejb.EJB; import javax.ejb.Stateless; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -34,7 +33,6 @@ import org.chorem.lima.beans.ReportsDatasImpl; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ejbinterface.AccountServiceLocal; import org.chorem.lima.business.ejbinterface.ReportService; import org.chorem.lima.business.ejbinterface.ReportServiceLocal; import org.chorem.lima.entity.Account; @@ -57,9 +55,6 @@ private TopiaContext rootContext; - @EJB - AccountServiceLocal accountServiceLocal; - public ReportServiceImpl() { LimaConfig config = LimaConfig.getInstance(); try { @@ -480,8 +475,8 @@ } //build list account from selectedAccounts else{ - accounts = accountServiceLocal.stringToListAccountsWithTransaction( - selectedAccounts, false, topiaTransaction); + accounts = accountDAO.stringToListAccounts( + selectedAccounts, false); } for (Account account : accounts) { ReportsDatas reportsDatas = Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/AccountServiceLocal.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -40,7 +40,6 @@ @Local public interface AccountServiceLocal extends AccountService{ - public List<Account> stringToListAccountsWithTransaction(String selectedAccounts, Boolean subAccountsMode, TopiaContext topiaContext) throws LimaException; void createAccountWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException, LimaBusinessException; void createSubLedgerWithTransaction(Account masterAccount, Account account, TopiaContext topiaContext) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -19,12 +19,16 @@ package org.chorem.lima.business.ejbinterface; +import java.util.Date; import java.util.List; import java.util.Set; import javax.ejb.Remote; + +import org.chorem.lima.FinancialStatementWayEnum; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; @@ -80,5 +84,6 @@ void updateEntry(Entry entry) throws LimaException; void removeEntry(Entry entry) throws LimaException; - + + List<Entry> searchEntry(Date beginDate, Date endDate, String voucher, String description, String letter, String accountsList, Account account, EntryBook entryBook, FinancialStatementWayEnum fStWayEnum, String operator, String amount, String amount2) throws LimaException; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-callao/src/main/java/org/chorem/lima/FinancialStatementWayEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -1,7 +1,43 @@ package org.chorem.lima; +import static org.nuiton.i18n.I18n._; + public enum FinancialStatementWayEnum { - BOTH, DEBIT, CREDIT; + BOTH(_("lima.enum.comboboxamount.both")), + DEBIT(_("lima.enum.comboboxamount.debit")), + CREDIT(_("lima.enum.comboboxamount.credit")); + private final String description; + + private FinancialStatementWayEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = FinancialStatementWayEnum.values().length; + String[] descriptions = new String[nbElts]; + FinancialStatementWayEnum[] enums = FinancialStatementWayEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static FinancialStatementWayEnum valueOfDescription(String description){ + FinancialStatementWayEnum value = null; + + for (FinancialStatementWayEnum enums : FinancialStatementWayEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } + } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -18,9 +18,14 @@ package org.chorem.lima.entity; +import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.StringTokenizer; +import org.apache.commons.lang.StringUtils; import org.nuiton.topia.TopiaException; import org.nuiton.topia.framework.TopiaQuery; +import org.nuiton.topia.framework.TopiaQuery.Op; public class AccountDAOImpl <E extends Account> extends AccountDAOAbstract<E> { @@ -34,11 +39,113 @@ String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); query.addWhere("not exists elements ("+subAccountsProperty+")") .addOrder(Account.ACCOUNT_NUMBER); - return (List<Account>) findAllByQuery(query); } + + /** + * Convert string of extends number to list of accounts + * Example '22, 45..48, 67' -> [22, 45, 46, 47, 48, 67] + * SubAccountsMode return list of existing subaccounts ex 6 return : 61, 62, .., 69, 610, .., 619 etc + */ @Override + public List<Account> stringToListAccounts(String selectedAccounts, + Boolean subAccountsMode) throws TopiaException { + List<Account> accounts = new ArrayList<Account>(); + if (selectedAccounts != null){ + //Remove Spaces + selectedAccounts = StringUtils.deleteWhitespace(selectedAccounts); + //use hashset for delete duplicate numbers + HashSet<String> accountNumbers = new HashSet<String>(); + HashSet<String> accountNumbersToRemove = new HashSet<String>(); + Boolean first = true; + StringTokenizer stStar = new StringTokenizer(selectedAccounts, "-"); + while (stStar.hasMoreTokens()) { + String subString = stStar.nextToken(); + + //Split comma + StringTokenizer stComma = new StringTokenizer(subString, ","); + while (stComma.hasMoreTokens()) { + String s = stComma.nextToken(); + if (s.contains("..") && !s.endsWith("..")){ + //Split .. + String stringDoubleDot[] = s.split("\\.\\."); + int lowAccount = Integer.parseInt(stringDoubleDot[0]); + int highAccount = Integer.parseInt(stringDoubleDot[1]); + + //prevent to much result, can't let intervall superior to 1000 + if (highAccount - lowAccount <= 10000){ + for (int i=lowAccount; i <= highAccount; i++) { + //if first add accounts, else remove + if (first){ + accountNumbers.add(String.valueOf(i)); + } + else { + accountNumbersToRemove.add(String.valueOf(i)); + } + } + } + } + else{ + //if first + if (first){ + accountNumbers.add(s); + } + else { + accountNumbersToRemove.add(s); + } + } + } + first=false; + } + //add all accounts + for (String accountNumber : accountNumbers) { + Account account = null; + if (subAccountsMode){ + account = findSubAccountByNumber(accountNumber); + } + else { + account = findByAccountNumber(accountNumber); + + } + //add account if exist + if (account != null){ + accounts.add(account); + } + //search all account start with accountnumber + else { + TopiaQuery query = createQuery(); + String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); + //String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS); + query.addWhere("not exists elements ("+subAccountsProperty+")") + //.addWhere("not exists elements ("+subLedgersProperty+")") + .addWhere(Account.ACCOUNT_NUMBER, Op.LIKE, accountNumber+"%"); + List<Account> accountsResult = (List<Account>) findAllByQuery(query); + if (accountsResult != null){ + accounts.addAll(accountsResult); + } + } + } + //remove all accounts + for (String accountNumber : accountNumbersToRemove) { + Account account = null; + if (subAccountsMode){ + account = findSubAccountByNumber(accountNumber); + } + else { + account = findByAccountNumber(accountNumber); + } + if (account != null) { + accounts.remove(account); + } + } + } + return accounts; + } + + + + @Override public Account findSubAccountByNumber(String number) throws TopiaException { TopiaQuery query = createQuery(); String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS); Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -23,6 +23,7 @@ public enum ComboBoxAccountsEnum { + ALL(_("lima.enum.comboboxaccount.allaccount")), ACCOUNT(_("lima.enum.comboboxaccount.account")), ACCOUNT_LIST(_("lima.enum.comboboxaccount.accountlist")); Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -1,61 +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.enums; - -import static org.nuiton.i18n.I18n._; - - -public enum ComboBoxAmountEnum { - - BOTH(_("lima.enum.comboboxamount.both")), - DEBIT(_("lima.enum.comboboxamount.debit")), - CREDIT(_("lima.enum.comboboxamount.credit")); - - private final String description; - - private ComboBoxAmountEnum(String description) { - this.description = description; - } - - public String getDescription() { - return this.description; - } - - public static String[] descriptions(){ - int nbElts = ComboBoxAmountEnum.values().length; - String[] descriptions = new String[nbElts]; - ComboBoxAmountEnum[] enums = ComboBoxAmountEnum.values(); - for (int i = 0; i < nbElts; i++) { - descriptions[i] = enums[i].getDescription(); - } - return descriptions; - } - - public static ComboBoxAmountEnum valueOfDescription(String description){ - ComboBoxAmountEnum value = null; - - for (ComboBoxAmountEnum enums : ComboBoxAmountEnum.values()) { - if (description.equals(enums.description)){ - value = enums; - break; - } - } - return value; - } -} Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -0,0 +1,60 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.enums; + +import static org.nuiton.i18n.I18n._; + + +public enum ComboBoxEntryBooksEnum { + + ALL(_("lima.enum.comboboxentrybook.all")), + SELECT_ONE(_("lima.enum.comboboxentrybook.select_one")); + + private final String description; + + private ComboBoxEntryBooksEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxEntryBooksEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxEntryBooksEnum[] enums = ComboBoxEntryBooksEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxEntryBooksEnum valueOfDescription(String description){ + ComboBoxEntryBooksEnum value = null; + + for (ComboBoxEntryBooksEnum enums : ComboBoxEntryBooksEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -23,20 +23,30 @@ public enum ComboBoxOperatorsEnum { - EQUAL(_("lima.enum.comboboxoperator.equal")), - SUPERIOR(_("lima.enum.comboboxoperator.superior")), - INFERIOR(_("lima.enum.comboboxoperator.inferior"));; + EQUAL(_("lima.enum.comboboxoperator.equal"), "="), + SUPERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.superiororequal"), ">="), + INFERIOR_OR_EQUAL(_("lima.enum.comboboxoperator.inferiororequal"), "<="), + SUPERIOR(_("lima.enum.comboboxoperator.superior"), ">"), + INFERIOR(_("lima.enum.comboboxoperator.inferior"), "<"), + INTERVAL(_("lima.enum.comboboxoperator.interval"), ""), + NOT_EQUAL(_("lima.enum.comboboxoperator.notequal"),"!="); private final String description; + private final String symbol; - private ComboBoxOperatorsEnum(String description) { + private ComboBoxOperatorsEnum(String description, String symbol) { this.description = description; + this.symbol = symbol; } public String getDescription() { - return this.description; + return this.description; } + public String getSymbol(){ + return this.symbol; + } + public static String[] descriptions(){ int nbElts = ComboBoxOperatorsEnum.values().length; String[] descriptions = new String[nbElts]; @@ -46,6 +56,7 @@ } return descriptions; } + public static ComboBoxOperatorsEnum valueOfDescription(String description){ ComboBoxOperatorsEnum value = null; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -23,8 +23,8 @@ public enum ComboBoxPeriodEnum { + PERIOD(_("lima.enum.comboboxperiod.period")), DATE(_("lima.enum.comboboxperiod.date")), - PERIOD(_("lima.enum.comboboxperiod.period")), FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -100,6 +100,7 @@ return result; } + public void refresh(){ cacheDatas = getDataList(); fireContentsChanged(this, 0, cacheDatas.size()); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -58,7 +58,8 @@ public void actionPerformed(ActionEvent e) { Object object = this.getSelectedItem(); if (object instanceof Account){ - //handler.setAccount((Account) this.getSelectedItem()); + handler.setAccount((Account) this.getSelectedItem()); + handler.refresh(); } } @@ -72,7 +73,13 @@ public void keyReleased(KeyEvent e) { Object object = this.getSelectedItem(); if (object instanceof Account){ - //handler.setAccount((Account) this.getSelectedItem()); + Account account = (Account) this.getSelectedItem(); + //to prevent useless call to service + if (!account.equals(handler.getAccount())){ + handler.setAccount(account); + handler.refresh(); + } + } // delegate popup list menu Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -18,8 +18,11 @@ package org.chorem.lima.ui.financialtransactionsearch; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; import javax.swing.JPanel; import javax.swing.JTextField; +import org.chorem.lima.entity.Account; import org.chorem.lima.enums.ComboBoxAccountsEnum; public class AccountSearchPanel extends JPanel { @@ -28,7 +31,6 @@ public AccountSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; - refresh(ComboBoxAccountsEnum.ACCOUNT); } static final long serialVersionUID = 1L; @@ -36,14 +38,46 @@ public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum){ switch (comboBoxAccountsEnum) { + case ALL: + handler.setAccount(null); + handler.refresh(); + this.removeAll(); + break; + case ACCOUNT: - AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); + final AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); + handler.setAccount((Account) accountComboBox.getSelectedItem()); + handler.refresh(); this.removeAll(); this.add(accountComboBox); break; case ACCOUNT_LIST: - JTextField accountsList = new JTextField(16); + final JTextField accountsList = new JTextField(16); + KeyListener accountsListKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + String accounts = accountsList.getText(); + //to prevent useless call to service + if (!accounts.equals(handler.getAccountsList())){ + handler.setAccountsList(accounts); + handler.refresh(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + accountsList.addKeyListener(accountsListKeyListener); + handler.setAccountsList(accountsList.getText()); + handler.setAccount(null); + handler.refresh(); this.removeAll(); this.add(accountsList); break; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -0,0 +1,101 @@ +/* *##% 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.financialtransactionsearch; + +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.JPanel; +import javax.swing.JTextField; +import org.chorem.lima.enums.ComboBoxOperatorsEnum; + +public class AmountSearchPanel extends JPanel { + + protected FinancialTransactionSearchViewHandler handler; + + public AmountSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + refresh(ComboBoxOperatorsEnum.EQUAL); + } + + static final long serialVersionUID = 1L; + + public void refresh(ComboBoxOperatorsEnum enums){ + + final JTextField amountTextField = new JTextField(16); + KeyListener amountKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + String amount = amountTextField.getText(); + //to prevent useless call to service + if (!amount.equals(handler.getAmount())){ + handler.setAmount(amount); + handler.refresh(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + amountTextField.addKeyListener(amountKeyListener); + handler.setAmount2(""); + handler.setOperator(enums.getSymbol()); + this.removeAll(); + this.add(amountTextField); + + switch (enums) { + case INTERVAL: + final JTextField amount2TextField = new JTextField(16); + KeyListener amount2KeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + + String amount2 = amount2TextField.getText(); + //to prevent useless call to service + if (!amount2.equals(handler.getAmount2())){ + handler.setAmount2(amount2); + handler.refresh(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + amount2TextField.addKeyListener(amount2KeyListener); + handler.setAmount(""); + this.add(amount2TextField); + break; + } + amountTextField.setText(handler.getAmount()); + handler.refresh(); + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -58,7 +58,8 @@ public void actionPerformed(ActionEvent e) { Object object = this.getSelectedItem(); if (object instanceof EntryBook){ - //handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.refresh(); } } @@ -72,7 +73,8 @@ public void keyReleased(KeyEvent e) { Object object = this.getSelectedItem(); if (object instanceof EntryBook){ - //handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.refresh(); } // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -0,0 +1,54 @@ +/* *##% 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.financialtransactionsearch; + +import javax.swing.JPanel; +import org.chorem.lima.enums.ComboBoxEntryBooksEnum; + +public class EntryBookSearchPanel extends JPanel { + + protected FinancialTransactionSearchViewHandler handler; + + public EntryBookSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + } + + static final long serialVersionUID = 1L; + + public void refresh(ComboBoxEntryBooksEnum enums){ + + switch (enums) { + case SELECT_ONE: + EntryBookSearchComboBox entryBookSearchComboBox = new EntryBookSearchComboBox(handler); + handler.setEntryBook(null); + handler.refresh(); + this.removeAll(); + this.add(entryBookSearchComboBox); + break; + + case ALL: + handler.setEntryBook(null); + handler.refresh(); + this.removeAll(); + break; + } + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -42,7 +42,7 @@ * @author ore * @author Rémi Chapelet */ -public class FinancialTransactionSearchTable extends JXTable implements KeyListener { +public class FinancialTransactionSearchTable extends JXTable { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; @@ -58,8 +58,6 @@ public FinancialTransactionSearchTable(FinancialTransactionSearchViewHandler handler) { this.handler = handler; - - addKeyListener(this); //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); @@ -126,29 +124,4 @@ new ColorHighlighter(predicate, new Color(255, 198, 209), null); addHighlighter(colorTransaction); } - - /** - * for each action combination key are think - * for extend keyboard and laptop keyboard - */ - @Override - public void keyPressed(KeyEvent e) { - - } - - /* - * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) - */ - @Override - public void keyTyped(KeyEvent e) { - - } - - /* - * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) - */ - @Override - public void keyReleased(KeyEvent e) { - - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -66,63 +66,13 @@ private static final Log log = LogFactory .getLog(FinancialTransactionSearchTableModel.class); - /** Transaction service. */ - protected final FinancialTransactionService financialTransactionService; - /** selected financial period */ - protected FiscalPeriod selectedFiscalPeriod; - /** data cache */ - protected List<Object> cacheDataList; - - /** collection + protected List<Entry> cacheDataList; - /** - * Model constructor. - * - * Just init service proxies. - */ - public FinancialTransactionSearchTableModel() { - /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - } - - /** - * Le model est une combinaison de Transaction/Entries. - * - * - * @return - */ - protected List<Object> getDataList() { - List<Object> results = new ArrayList<Object>(); - if(selectedFiscalPeriod != null){ - try { - Set<FinancialTransaction> financialtransactions = - financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); - for (FinancialTransaction financialtransaction : financialtransactions) { - results.add(financialtransaction); - List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } - catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); - } - - ErrorHelper.showErrorDialog("Can't get transaction list", eee); - } - } - - return results; - } - - public void refresh(){ - cacheDataList = getDataList(); + public void refresh(List<Entry> objects){ + cacheDataList = objects; fireTableDataChanged(); } @@ -224,79 +174,45 @@ // just prevent too much result if (cacheDataList != null) { - result = cacheDataList.get(row); - - if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; - BigDecimal amountDebit = currentRow.getAmountDebit(); - BigDecimal amountCredit = currentRow.getAmountCredit(); - + Entry currentRow = cacheDataList.get(row); + switch (column) { case 0: - result = currentRow.getTransactionDate(); + result = currentRow.getFinancialTransaction().getTransactionDate(); break; case 1: - if (currentRow.getEntryBook() != null){ - result = currentRow.getEntryBook().getCode(); + EntryBook entryBook = + currentRow.getFinancialTransaction().getEntryBook(); + if (entryBook != null){ + result = entryBook.getCode(); } else { result = null; } break; case 2: - result = null; //entrybook + result = currentRow.getVoucher(); break; - case 3: - result = null; // account - break; - case 4: - result = null; // description - break; - case 5 : - result = null; // position - break; - case 6: - result = amountDebit; - break; - case 7: - result = amountCredit; - break; - case 8: - result = amountDebit.subtract(amountCredit); - break; - } - } - else if (result instanceof Entry) { - Entry currentEntry = (Entry)result; - switch (column) { - case 0: - result = null; // date - break; - case 1 : // entry book - result = null; - break; - case 2: - result = currentEntry.getVoucher(); - break; case 3: // account - if (currentEntry.getAccount() != null){ - result = currentEntry.getAccount().getAccountNumber(); + Account account = currentRow.getAccount(); + if (account != null){ + result = account.getAccountNumber(); } else { result = null; } break; case 4: - result = currentEntry.getDescription(); + result = currentRow.getDescription(); break; case 5 : - result = currentEntry.getPosition(); + result = currentRow.getPosition(); break; case 6: - result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + result = currentRow.getDebit() ? currentRow.getAmount() : 0; break; case 7: - result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + result = currentRow.getDebit() ? 0 : currentRow.getAmount(); break; case 8: result = null; // balance @@ -304,14 +220,10 @@ } } - } return result; } - public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ - selectedFiscalPeriod = fiscalPeriod; - } /** * To set cells editable or not @@ -333,33 +245,9 @@ } - /** - * @throws LimaException - */ - public void addEmptyEntry(Object value, int row) throws LimaException { - FinancialTransaction currentTransaction = null; - Object currentRow = cacheDataList.get(row); - Entry entry = new EntryImpl(); - entry.setAmount(new BigDecimal(0)); - //check if current row is a transaction or an entry - if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); - } - //create it - entry.setFinancialTransaction(currentTransaction); - financialTransactionService.createEntry(entry); - //on recharge la liste - refresh(); - } - - /** + /* /** * to modifiy financialtransaction or entry - */ + * @Override public void setValueAt(Object value, int row, int column) { int financialTransactionRow=0; @@ -433,35 +321,12 @@ //TODO PEPIN 20100607 Get financial transaction of cachedatelist on replace it fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); } - } + }*/ public Object getElementAt(int row){ Object currentRow = cacheDataList.get(row); return currentRow; } - - - /** - * Delete selected row in table (could be transaction or entry). - * - * Called by model. - * @param Object, int - * @throws LimaException - */ - public void removeObject(Object object, int row) throws LimaException { - Object currentRow = cacheDataList.get(row); - if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; - financialTransactionService.removeFinancialTransaction(currentTransaction); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - financialTransactionService.removeEntry(currentEntry); - } - //on recharge la liste - refresh(); - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2010-08-19 21:13:17 UTC (rev 3007) @@ -22,13 +22,21 @@ <![CDATA[ import org.chorem.lima.enums.ComboBoxPeriodEnum; import org.chorem.lima.enums.ComboBoxAccountsEnum; - import org.chorem.lima.enums.ComboBoxAmountEnum; + import org.chorem.lima.enums.ComboBoxEntryBooksEnum; + import org.chorem.lima.FinancialStatementWayEnum; import org.chorem.lima.enums.ComboBoxOperatorsEnum; AccountSearchPanel accountSearchPanel = new AccountSearchPanel(handler); + AmountSearchPanel amountSearchPanel = new AmountSearchPanel(handler); + EntryBookSearchPanel entryBookSearchPanel = new EntryBookSearchPanel(handler); PeriodSearchPanel periodSearchPanel = new PeriodSearchPanel(handler); void $afterCompleteSetup() { + handler.init(); + handler.setAmountWayEnum(FinancialStatementWayEnum.valueOfDescription( + (String) getAmountComboBox().getSelectedItem())); + handler.setOperator(ComboBoxOperatorsEnum.valueOfDescription( + (String) getOperatorComboBox().getSelectedItem()).getSymbol()); } ]]> @@ -58,16 +66,22 @@ onActionPerformed="accountSearchPanel.refresh(ComboBoxAccountsEnum.valueOfDescription((String) accountComboBox.getSelectedItem())); validate(); repaint()"/></cell> <cell><AccountSearchPanel javaBean="accountSearchPanel"/></cell> - <cell anchor='east'><JLabel text="lima.table.entrybook"/></cell> - <cell anchor='west'><EntryBookSearchComboBox javaBean="new EntryBookSearchComboBox(handler)"/></cell> + <cell><JComboBox id="entryBookComboBox" javaBean="new JComboBox(ComboBoxEntryBooksEnum.descriptions())" + onActionPerformed="entryBookSearchPanel.refresh(ComboBoxEntryBooksEnum.valueOfDescription((String) entryBookComboBox.getSelectedItem())); + validate(); repaint()"/></cell> + <cell><EntryBookSearchPanel javaBean="entryBookSearchPanel"/></cell> </row></Table></cell> </row> <row> <cell><Table><row> <cell><JLabel text="lima.amount"/></cell> - <cell><JComboBox id="amountComboBox" javaBean="new JComboBox(ComboBoxAmountEnum.descriptions())"/></cell> - <cell><JComboBox id="operatorComboBox" javaBean="new JComboBox(ComboBoxOperatorsEnum.descriptions())"/></cell> - <cell><JTextField id='amount'/></cell> + <cell><JComboBox id="amountComboBox" javaBean="new JComboBox(FinancialStatementWayEnum.descriptions())" + onActionPerformed="handler.setAmountWayEnum(FinancialStatementWayEnum.valueOfDescription((String)amountComboBox.getSelectedItem())); + handler.refresh()"/></cell> + <cell><JComboBox id="operatorComboBox" javaBean="new JComboBox(ComboBoxOperatorsEnum.descriptions())" + onActionPerformed="amountSearchPanel.refresh(ComboBoxOperatorsEnum.valueOfDescription((String) operatorComboBox.getSelectedItem())); + validate(); repaint()"/></cell> + <cell><AmountSearchPanel javaBean="amountSearchPanel"/></cell> </row></Table></cell> </row> <row> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -19,10 +19,23 @@ package org.chorem.lima.ui.financialtransactionsearch; import static org.nuiton.i18n.I18n._; - +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.util.Date; +import java.util.List; +import javax.swing.JTextField; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.FinancialStatementWayEnum; +import org.chorem.lima.business.FinancialTransactionServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; +import org.chorem.lima.util.ErrorHelper; /** * Handler associated with financial transaction view. @@ -47,14 +60,225 @@ protected FiscalPeriodComboBoxModel comboBoxModel; + /** Transaction service. */ + protected final FinancialTransactionService financialTransactionService; + + protected Date beginDate; + protected Date endDate; + protected String voucher; + protected String description; + protected String letter; + protected String accountsList; + protected Account account; + protected EntryBook entryBook; + protected FinancialStatementWayEnum amountWayEnum; + protected String operator; + protected String amount; + protected String amount2; + protected FinancialTransactionSearchViewHandler(FinancialTransactionSearchView view) { this.view = view; + + /* Services */ + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + } + + public void init(){ + + final JTextField descriptionTextField = view.getDescription(); + KeyListener descriptionKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + setDescription(descriptionTextField.getText()); + refresh(); + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + descriptionTextField.addKeyListener(descriptionKeyListener); + + final JTextField letterTextField = view.getLetter(); + KeyListener letterKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + //to prevent useless call to service + String letterNew = letterTextField.getText(); + if (!letterNew.equals(letter)){ + setLetter(letterNew); + refresh(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + letterTextField.addKeyListener(letterKeyListener); + + final JTextField voucherTextField = view.getVoucher(); + KeyListener voucherKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + //to prevent useless call to service + String voucherNew = voucherTextField.getText(); + if (!voucherNew.equals(voucher)){ + setVoucher(voucherNew); + refresh(); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + voucherTextField.addKeyListener(voucherKeyListener); + } + + public void setBeginDate(Date beginDate){ + this.beginDate = beginDate; + log.debug(beginDate); + } + + public void setEndDate(Date endDate){ + this.endDate = endDate; + log.debug(endDate); + } + + public void setVoucher(String voucher){ + String result = null; + if (!voucher.equals("")){ + result = voucher; + } + this.voucher=result; + } + + public void setDescription(String description){ + String result = null; + if (!description.equals("")){ + result = description; + } + this.description=result; + } + + public void setLetter(String letter){ + String result = null; + if (!letter.equals("")){ + result = letter; + } + this.letter=result; + } + + public String getAccountsList(){ + return this.accountsList; + } + + public void setAccountsList(String accountsList){ + String result = null; + if (!accountsList.equals("")){ + result = accountsList; + } + this.accountsList=result; + } + public Account getAccount(){ + return this.account; } + public void setAccount(Account account){ + this.account=account; + } + + public void setEntryBook(EntryBook entryBook){ + this.entryBook=entryBook; + } + + + public String getAmount(){ + return this.amount; + } + + public void setAmount(String amount){ + String result = null; + if (!amount.equals("")){ + result = amount; + } + this.amount=result; + } + + public String getAmount2(){ + return this.amount2; + } + + public void setAmount2(String amount2){ + String result = null; + if (!amount2.equals("")){ + result = amount2; + } + this.amount2=result; + } + + public void setAmountWayEnum(FinancialStatementWayEnum amountWayEnum){ + this.amountWayEnum=amountWayEnum; + } + + public void setOperator(String operator){ + String result = null; + if (!operator.equals("")){ + result = operator; + } + this.operator=result; + } + public void refresh(){ tableModel = view.getFinancialTransactionSearchTableModel(); - tableModel.refresh(); + if (tableModel != null){ + log.debug(voucher+" " + +description+" "+letter+" "+accountsList+" " + +account+" "+entryBook+" "+amount); + //prevent to much result + tableModel.refresh(getDataList()); + } } + + protected List<Entry> getDataList() { + List<Entry> results = null; + if (voucher != null || description != null || letter != null || + accountsList != null || account != null || entryBook != null || + (amount != null && operator != null) || (amount != null && amount2 != null)){ + try { + results = financialTransactionService.searchEntry(beginDate, endDate, + voucher, description, letter, accountsList, account, + entryBook, amountWayEnum, operator, amount, amount2); + + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get transaction list", eee); + } + } + return results; + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -18,6 +18,8 @@ package org.chorem.lima.ui.financialtransactionsearch; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.util.Calendar; import java.util.Date; import static org.nuiton.i18n.I18n._; @@ -28,6 +30,8 @@ import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxPeriodEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; @@ -44,7 +48,9 @@ public PeriodSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; - refresh(ComboBoxPeriodEnum.DATE); + + //init date + refresh(ComboBoxPeriodEnum.PERIOD); } static final long serialVersionUID = 1L; @@ -56,7 +62,18 @@ Calendar calendar = Calendar.getInstance(); Date date = calendar.getTime(); date = DateUtils.truncate(date, Calendar.DATE); - JXDatePicker datePicker = new JXDatePicker(date); + final JXDatePicker datePicker = new JXDatePicker(date); + ActionListener dateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(datePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(datePicker.getDate()); + handler.setEndDate(null); + handler.refresh(); + datePicker.addActionListener(dateActionListener); this.removeAll(); this.add(datePicker); break; @@ -74,9 +91,30 @@ Date endDate = calendarEnd.getTime(); //handler().setEndDate(endDate); JLabel beginDateLabel = new JLabel(_("lima.period.begindate")); - JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + JLabel endDateLabel = new JLabel(_("lima.period.enddate")); - JXDatePicker endDatePicker = new JXDatePicker(endDate); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + this.removeAll(); this.add(beginDateLabel); this.add(beginDatePicker); @@ -87,10 +125,20 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - JComboBox fiscalPeriod = new JComboBox(fiscalModel); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(fiscalRenderer); fiscalPeriod.setEditable(false); - //fiscalPeriod.actionPerformed(handler.); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + this.removeAll(); this.add(fiscalPeriod); break; @@ -98,9 +146,19 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - JComboBox financialPeriod = new JComboBox(financialModel); + final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(financialRenderer); financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); this.removeAll(); this.add(financialPeriod); break; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-08-19 21:13:17 UTC (rev 3007) @@ -157,6 +157,9 @@ * Ajoute une entrée comptable si tab est sur * la dernière cellule. */ + + //TODO 2010-08-19 verifier si la transaction est équilibré + // cf. FinancialTransactionTable.java comme modèle if (e.getKeyChar() == KeyEvent.VK_TAB) { // Vérifie si la cellule sélectionnée est la dernière Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-19 21:13:17 UTC (rev 3007) @@ -93,12 +93,20 @@ lima.entrybook.type5= lima.enum.comboboxaccount.account= lima.enum.comboboxaccount.accountlist= +lima.enum.comboboxaccount.allaccount= lima.enum.comboboxamount.both= lima.enum.comboboxamount.credit= lima.enum.comboboxamount.debit= +lima.enum.comboboxentrybook.all= +lima.enum.comboboxentrybook.select_one= lima.enum.comboboxoperator.equal= lima.enum.comboboxoperator.inferior= +lima.enum.comboboxoperator.inferiororequal= +lima.enum.comboboxoperator.interval= +lima.enum.comboboxoperator.intervalle= +lima.enum.comboboxoperator.notequal= lima.enum.comboboxoperator.superior= +lima.enum.comboboxoperator.superiororequal= lima.enum.comboboxperiod.date= lima.enum.comboboxperiod.financialperiod= lima.enum.comboboxperiod.fiscalperiod= 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-08-18 14:47:44 UTC (rev 3006) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-19 21:13:17 UTC (rev 3007) @@ -87,13 +87,20 @@ lima.entrybook.type4=G\u00E9n\u00E9ral lima.entrybook.type5=Situation lima.enum.comboboxaccount.account=Compte -lima.enum.comboboxaccount.accountlist=Liste de compte +lima.enum.comboboxaccount.accountlist=Liste de comptes +lima.enum.comboboxaccount.allaccount=Tous les comptes lima.enum.comboboxamount.both=Les deux lima.enum.comboboxamount.credit=Cr\u00E9dit lima.enum.comboboxamount.debit=D\u00E9bit +lima.enum.comboboxentrybook.all=Tous les journaux +lima.enum.comboboxentrybook.select_one=Journal lima.enum.comboboxoperator.equal=\u00C9gal lima.enum.comboboxoperator.inferior=Inf\u00E9rieur +lima.enum.comboboxoperator.inferiororequal=Inf\u00E9rieur ou \u00E9gal +lima.enum.comboboxoperator.interval=Intervalle +lima.enum.comboboxoperator.notequal=Diff\u00E9rent lima.enum.comboboxoperator.superior=Sup\u00E9rieur +lima.enum.comboboxoperator.superiororequal=Sup\u00E9rieur ou \u00E9gal lima.enum.comboboxperiod.date=Date lima.enum.comboboxperiod.financialperiod=P\u00E9riode Financi\u00E8re lima.enum.comboboxperiod.fiscalperiod=Exercice
participants (1)
-
jpepin@users.chorem.org