r3020 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/ejbinterface lima-business/src/main/resources/i18n lima-callao/src/main/xmi lima-swing/src/main/java/org/chorem/lima/enums lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/accountsreports lima-swing/src/main/java/org/chorem/lima/ui/balance lima-swing/src/main/java/org/chorem/lima/ui/celleditor lima-swing/src/main/java/org/chorem
Author: jpepin Date: 2010-08-26 00:04:25 +0200 (Thu, 26 Aug 2010) New Revision: 3020 Url: http://chorem.org/repositories/revision/lima/3020 Log: Ajout fonction de lettrage. Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.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/ImportServiceImpl.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/FinancialTransactionService.java trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties trunk/lima-callao/src/main/xmi/accounting.zargo trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.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/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/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.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/ExportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ExportServiceImpl.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -513,7 +513,7 @@ nextLine[2] = entry.getDescription(); nextLine[3] = entry.getAmount().toString(); nextLine[4] = Boolean.toString(entry.getDebit()); - nextLine[5] = entry.getLettering(); + nextLine[5] = entry.getLetter().getCode(); nextLine[6] = entry.getDetail(); nextLine[7] = entry.getVoucher(); nextLine[8] = entry.getPosition(); 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -41,6 +41,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodDAO; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.entity.LetterDAO; +import org.chorem.lima.entity.LetterImpl; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionDAO; @@ -86,7 +89,6 @@ public void createFinancialTransactionWithTransaction( FinancialTransaction financialtransaction, TopiaContext topiaContext) throws LimaException { - log.debug(financialtransaction); try { //check if the financial period is blocked accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction( @@ -149,7 +151,6 @@ String financialPeriodProperty = TopiaQuery.getProperty(FinancialTransaction.FINANCIAL_PERIOD); String entryBookLabelProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY_BOOK); - String accountProperty = TopiaQuery.getProperty(FinancialTransaction.ENTRY, Entry.ACCOUNT); // filter with topia query TopiaQuery query = transactionDAO.createQuery("T"); @@ -166,7 +167,9 @@ //load for lazy .addLoad(financialPeriodProperty) .addLoad(entryBookLabelProperty) - .addFetch("T."+accountProperty); + .addLeftJoin("T."+FinancialTransaction.ENTRY, "E", true) + .addFetch("E."+Entry.ACCOUNT) + .addFetch("E."+Entry.LETTER); financialTransactions = transactionDAO.findAllByQuery(query); } catch (TopiaException ex) { @@ -501,7 +504,7 @@ entryOld.setVoucher(entry.getVoucher()); entryOld.setFinancialTransaction(entry.getFinancialTransaction()); entryOld.setPosition(entry.getPosition()); - entryOld.setLettering(entry.getLettering()); + entryOld.setLetter(entry.getLetter()); //calculate financial transaction amounts FinancialTransaction financialTransaction = @@ -589,9 +592,158 @@ } + /** + * Get letter from count of existing letter + * 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, ... + */ + @Override + public Letter getNewLetter() throws LimaException { + Letter letter = new LetterImpl(); + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + int n = letterDAO.count()+1; + String res = numberToString(n, null); + + //if already exist + while (letterDAO.findByCode(res) != null){ + res = numberToString(n++, null); + } + letter.setCode(res); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + return letter; + } + public static String numberToString(int n, StringBuffer result){ + if (result == null){ + result = new StringBuffer(); + } + int mod = (n-1) % 26; + int div = (n-1) / 26; + if (div > 0){ + result.append(numberToString(div, result)); + } + return (result.append((char) (mod+65))).toString(); + } + + @Override + public void createLetter(Letter letter) throws LimaException { + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + createLetterWithTransaction(letter, topiaContext); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + + public void createLetterWithTransaction(Letter letter, TopiaContext topiaContext) throws LimaException { + try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letterDAO.create(letter); + commitTransaction(topiaContext); + } catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + } - @Override + @Override + public void removeLetter(Letter letter) throws LimaException { + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letterDAO.delete(letter); + commitTransaction(topiaContext); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + + + @Override + public List<Letter> getAllLetters() throws LimaException { + List<Letter> letters = null; + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letters = letterDAO.findAll(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + return letters; + } + + + + @Override + public void setEntryLetter(Entry entry, Letter letter) throws LimaException { + + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + Letter letterOld = letterDAO.findByCode(letter.getCode()); + if (letterOld == null){ + createLetterWithTransaction(letter, topiaContext); + letterOld = letter; + } + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); + entryOld.setLetter(letterOld); + commitTransaction(topiaContext); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + + + + @Override + public void removeEntryLetter(Entry entry) throws LimaException { + + TopiaContext topiaContext = null; + try { + topiaContext = beginTransaction(); + + EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); + Entry entryOld = entryDAO.findByTopiaId(entry.getTopiaId()); + entryOld.setLetter(null); + commitTransaction(topiaContext); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + } + + @Override public List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException { List<Object> result = new ArrayList<Object>(); List<FinancialTransaction> financialTransactions = null; @@ -627,9 +779,9 @@ if (description != null){ query.addWhere("E.description", Op.LIKE, "%"+description+"%"); } - String letter = financialTransactionSearch.getLetter(); + Letter letter = financialTransactionSearch.getLetter(); if (letter != null){ - query.addWhere("E.lettering", Op.LIKE, "%"+letter+"%"); + query.addEquals("E.letter", letter); } Account account = financialTransactionSearch.getAccount(); String accountsList = financialTransactionSearch.getAccountList(); @@ -688,7 +840,7 @@ TopiaQuery query2 = entryDAO.createQuery(); query2.addEquals(Entry.FINANCIAL_TRANSACTION, financialTransaction); //Load for lazy - query2.addLoad(Entry.ACCOUNT); + query2.addLoad(Entry.ACCOUNT, Entry.LETTER); List<Entry> entries = entryDAO.findAllByQuery(query2); result.addAll(entries); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -95,6 +95,9 @@ import org.chorem.lima.entity.FiscalPeriodImpl; import org.chorem.lima.entity.Identity; import org.chorem.lima.entity.IdentityImpl; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.entity.LetterDAO; +import org.chorem.lima.entity.LetterImpl; import org.chorem.lima.entity.LimaCallaoDAOHelper; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaContextFactory; @@ -175,17 +178,17 @@ strat.setColumnMapping(csvReader.readNext()); // check if file have a good header - List<String> headAccount = new ArrayList<String>(); - headAccount.add("Journal"); - headAccount.add("Compte"); - headAccount.add("DatEcr"); - headAccount.add("Piece"); - headAccount.add("Libelle"); - headAccount.add("Debit"); - headAccount.add("Credit"); - headAccount.add("Lettre"); + List<String> headEntry = new ArrayList<String>(); + headEntry.add("Journal"); + headEntry.add("Compte"); + headEntry.add("DatEcr"); + headEntry.add("Piece"); + headEntry.add("Libelle"); + headEntry.add("Debit"); + headEntry.add("Credit"); + headEntry.add("Lettre"); if (!Arrays.asList(strat.getColumnMapping()).containsAll( - headAccount)) { + headEntry)) { throw new LimaBusinessException( _("lima-business.import.ebpnoentry")); } @@ -197,6 +200,7 @@ // DAOs AccountDAO accountDAO = LimaCallaoDAOHelper .getAccountDAO(topiaContext); + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); EntryBookDAO entryBookDAO = LimaCallaoDAOHelper .getEntryBookDAO(topiaContext); List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); @@ -244,12 +248,15 @@ entry.setAmount(debit); } entry.setDescription(entryEBP.getLibelle()); - entry.setLettering(entryEBP.getLettre()); entry.setVoucher(entryEBP.getPiece()); + + Letter letter = createLetter( + entryEBP.getLettre(), topiaContext); + entry.setLetter(letter); + String entryBookCode = entryEBP.getJournal(); EntryBook entryBook = entryBookDAO .findByCode(entryBookCode); - // if entrybook not exist create it ! if (entryBook == null) { entryBook = new EntryBookImpl(); @@ -685,7 +692,36 @@ } return result.toString(); } + + + /** + * Import and create Letter : TYPE | Code + */ + public String importLetterCSV(String[] nextLine, + TopiaContext topiaContext) throws LimaException { + StringBuffer result = new StringBuffer(); + try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + + Letter letter = new LetterImpl(); + String code = nextLine[1]; + letter.setCode(code); + + // if exist, skip + if (letterDAO.findByCode(code) != null) { + result.append(_("lima-business.import.letteralreadyexist", code)); + } else { + // create it + financialTransactionService.createLetter(letter); + result.append(_("lima-business.import.letteradded",code)); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return result.toString(); + } + /** * Import and create closedperiodicentrybook import Structure : TYPE | * BeginDate | EndDate | Locked @@ -927,6 +963,26 @@ return result.toString(); } + + /** + * Dynamic letter creation used by CSV and EBP Import + */ + public Letter createLetter(String letterCode, TopiaContext topiaContext) throws LimaException{ + Letter letter = null; + try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); + letter = letterDAO.findByCode(letterCode); + // if letter not exist create it ! + if (letter == null) { + letter = new LetterImpl(); + letter.setCode(letterCode); + } + } catch (TopiaException eeeTE) { + doCatch(topiaContext, eeeTE, log); + } + return letter; + } + public String createAccounts(Map<String, AccountImport> accounts, TopiaContext topiaContext) throws LimaException { StringBuffer result = new StringBuffer(); @@ -1037,6 +1093,7 @@ throws LimaException { StringBuffer result = new StringBuffer(); try { + LetterDAO letterDAO = LimaCallaoDAOHelper.getLetterDAO(topiaContext); EntryBookDAO entryBookDAO = LimaCallaoDAOHelper .getEntryBookDAO(topiaContext); EntryDAO entryDAO = LimaCallaoDAOHelper.getEntryDAO(topiaContext); @@ -1080,7 +1137,11 @@ entry.setDescription(entryImport.getDescription()); entry.setAmount(new BigDecimal(entryImport.getAmount())); entry.setDebit(Boolean.parseBoolean(entryImport.getDebit())); - entry.setLettering(entryImport.getLettering()); + + Letter letter = createLetter( + entryImport.getLettering(), topiaContext); + entry.setLetter(letter); + entry.setDetail(entryImport.getDetail()); entry.setVoucher(entryImport.getVoucher()); entry.setPosition(entryImport.getPosition()); 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -198,12 +198,11 @@ TopiaQuery entriesQuery = createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias); //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION - entriesQuery.addLoad(Entry.FINANCIAL_TRANSACTION); - entriesQuery.addLoad(Entry.ACCOUNT); String loadEntryBookProperty = TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, FinancialTransaction.ENTRY_BOOK); - entriesQuery.addLoad(loadEntryBookProperty); + entriesQuery.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION, Entry.LETTER) + .addLoad(loadEntryBookProperty); reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery)); TopiaQuery amountsQuery = @@ -348,7 +347,7 @@ TopiaQuery entriesQuery = createEntryBookReportsQuery( entryBook, beginDate, endDate, entryDAO, "E"); //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION - entriesQuery.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION); + entriesQuery.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION, Entry.LETTER); String orderDateProperty = TopiaQuery.getProperty("E", Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); String orderIdProperty = 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/FinancialTransactionService.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -28,6 +28,7 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; /** * Transaction service. @@ -51,6 +52,13 @@ * @return all transaction for entry book and period * @throws LimaException */ + + void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; + + void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; + + void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; + List<FinancialTransaction> getAllFinancialTransactionsForFinancialPeriod( FinancialPeriod period) throws LimaException; @@ -60,13 +68,9 @@ List<FinancialTransaction> getAllInexactFinancialTransactions(FiscalPeriod fiscalPeriod) throws LimaException; List<FinancialTransaction> getAllFinancialTransactionsBalanced(FiscalPeriod fiscalPeriod) throws LimaException; + List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException; - void createFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - - void updateFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException; - /** * Methodes for create, update and remove the entry * @param entry @@ -79,5 +83,23 @@ void removeEntry(Entry entry) throws LimaException; - List<Object> searchFinancialTransaction(FinancialTransactionSearch financialTransactionSearch) throws LimaException; + + /** + * Methodes for create, update and remove the letter + * @param entry + * @throws LimaException + */ + + Letter getNewLetter() throws LimaException; + + void createLetter(Letter letter) throws LimaException; + + void removeLetter(Letter letter) throws LimaException; + + List<Letter> getAllLetters() throws LimaException; + + void setEntryLetter(Entry entry, Letter letter) throws LimaException; + + void removeEntryLetter(Entry entry) throws LimaException; + } Modified: trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/resources/i18n/lima-business-en_GB.properties 2010-08-25 22:04:25 UTC (rev 3020) @@ -52,6 +52,8 @@ lima-business.import.fiscalperiodadded=SUCCESS \: The fiscalPeriod %s - %s is created \! \n lima-business.import.fiscalperiodalreadyexist=FAILED \: The fiscalperiod %s - %s already exists \!\n lima-business.import.identityadded=SUCCESS \: The identity %s is created \! \n +lima-business.import.letteradded=SUCCESS \: The letter %s - %s is created \! \n +lima-business.import.letteralreadyexist=FAILED \: The letter %s already exists \!\n lima-business.import.noaccount=ERROR \: This file contains no account lima-business.import.nofiscalperiodopen=FAILED \: No Fiscal period open \! \n lima-business.import.transactionadded=SUCCES \: FinancialTransaction, %s - %s, added\n Modified: trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties =================================================================== --- trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-business/src/main/resources/i18n/lima-business-fr_FR.properties 2010-08-25 22:04:25 UTC (rev 3020) @@ -52,6 +52,8 @@ lima-business.import.fiscalperiodadded=Succ\u00E8s \: Exercice %s - %s ajout\u00E9e \! \n lima-business.import.fiscalperiodalreadyexist=u00C9chec \: L'exerice %s - %s existe d\u00E9j\u00E0 \!\n lima-business.import.identityadded=Succ\u00E8s \: Identit\u00E9 %s ajout\u00E9e \! \n +lima-business.import.letteradded=Succ\u00E8s \: ajout\u00E9e \! \n +lima-business.import.letteralreadyexist=u00C9chec \: La lettre %s existe d\u00E9j\u00E0 \!\n lima-business.import.noaccount=Erreur \: Ce fichier ne contient aucun compte. lima-business.import.nofiscalperiodopen=u00C9chec \: Aucun exercice ouvert \! \n lima-business.import.transactionadded=Succ\u00E8s \: Transaction, %s, %s, ajout\u00E9e\n Modified: trunk/lima-callao/src/main/xmi/accounting.zargo =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -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 ComboBoxLetterEnum { + + ALL(_("lima.enum.comboboxletter.all")), + SELECT_ONE(_("lima.enum.comboboxletter.selectone")); + + private final String description; + + private ComboBoxLetterEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxLetterEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxLetterEnum[] enums = ComboBoxLetterEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxLetterEnum valueOfDescription(String description){ + ComboBoxLetterEnum value = null; + + for (ComboBoxLetterEnum enums : ComboBoxLetterEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -160,10 +160,8 @@ actionIcon='entries-unbalanced'/> <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='getHandler().showTransactionSearchView(this)' actionIcon='entries-search'/> - <!-- Menu prévu pour le lettrage automatique <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)' actionIcon='lettering'/> - --> </JMenu> <JMenu text="lima.reports" mnemonic="{'R'}"> <JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)' Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -46,6 +46,7 @@ import org.chorem.lima.ui.identity.IdentityForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.ui.ledger.LedgerView; +import org.chorem.lima.ui.lettering.LetteringView; import org.chorem.lima.util.ErrorHelper; /** @@ -377,6 +378,12 @@ mainView.showTab(_("lima.entries.searchtransaction"), searchView); } + public void showLetteringView(JAXXContext rootContext){ + MainView mainView = getUI(rootContext); + LetteringView letteringView = new LetteringView(mainView); + mainView.showTab(_("lima.entries.lettering"), letteringView); + } + public void showBalanceView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); BalanceView balanceView = new BalanceView(mainView); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.ui.combobox.AccountComboBoxModel; +import org.chorem.lima.ui.combobox.AccountRenderer; import org.chorem.lima.util.AccountToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -1,49 +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.accountsreports; - -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 { - - private static final long serialVersionUID = 1L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - - JLabel label = new JLabel(); - Account account = (Account) value; - if (account != null){ - String accountLabel = account.getLabel(); - int nbChars = 30; - if (accountLabel.length()>nbChars){ - accountLabel = accountLabel.substring(0, nbChars)+"…"; - } - label.setText(account.getAccountNumber() +" - " + accountLabel); - } - return label; - } - -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -82,9 +82,12 @@ res = _("lima.table.description"); //Description break; case 5: + res = _("lima.table.letter"); //Letter + break; + case 6: res = _("lima.table.debit"); //Debit break; - case 6: + case 7: res = _("lima.table.credit"); //Credit break; } @@ -122,9 +125,17 @@ result = currentRow.getDescription(); break; case 5: + if (currentRow.getLetter() != null){ + result = currentRow.getLetter().getCode(); + } + else { + result = null; + } + break; + case 6: result = currentRow.getDebit() ? currentRow.getAmount() : 0; break; - case 6: + case 7: result = currentRow.getDebit() ? 0 : currentRow.getAmount(); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -42,7 +42,7 @@ <JLabel text="lima.common.filter"/> </cell> <cell anchor="west"> - <JTextField id='balanceFilter' minimumSize='{balanceFilter.getPreferredSize()}'/> + <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter" minimumSize='{balanceFilter.getPreferredSize()}'/> <javax.swing.text.Document javaBean="balanceFilter.getDocument()" onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())' onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())' /> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -34,7 +34,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; -import org.chorem.lima.ui.accountsreports.AccountRenderer; +import org.chorem.lima.ui.combobox.AccountRenderer; import org.chorem.lima.ui.combobox.SubAccountComboBoxModel; import org.chorem.lima.util.AccountToString; import org.chorem.lima.widgets.JWideComboBox; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,146 @@ +/* + * *##% 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.celleditor; + +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.util.EventObject; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.ui.combobox.LetterComboBoxModel; +import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.util.LetterToString; +import org.chorem.lima.widgets.JWideComboBox; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + +public class LetterTableCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener { + + protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JWideComboBox comboBox; + private static final long serialVersionUID = 1L; + private static LetterTableCellEditor editor; + private static LetterComboBoxModel comboBoxModel; + private static boolean keyPressed = false; + + /** + * constructor + */ + public LetterTableCellEditor() { + super(); + comboBox = new JWideComboBox(); + comboBoxModel = new LetterComboBoxModel(); + comboBox.setModel(comboBoxModel); + LetterRenderer renderer = new LetterRenderer(); + comboBox.setRenderer(renderer); + AutoCompleteDecorator.decorate(comboBox, LetterToString.getInstance()); + comboBox.getEditor().getEditorComponent().addKeyListener(this); + } + + @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(); + } + + /** + * Vérifie si la cellule peut être éditable : + * seulement si il y a une frappe au clavier ou un double clic. + * @param evt + * @return + */ + @Override + public boolean isCellEditable(EventObject evt) { + // Si il y a une frappe au clavier + if (evt instanceof KeyEvent) { + final KeyEvent keyEvent = (KeyEvent) evt; + // Empèche la touche echap + if ( keyEvent.getKeyChar() != KeyEvent.VK_ESCAPE){ + // Permet de placer le focus sur l'editor de la comboBox + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + comboBox.getEditor().getEditorComponent().requestFocus(); + JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); + if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) + { + edit.setText(Character.toString(keyEvent.getKeyChar())); + } + } + }); + } + } + keyPressed = false; + return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 ); + } + + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + + // Vérifie si c'est la première frappe au clavier + if ( keyPressed == false ) + { + // Récupère l'editor de la comboBox + JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); + // Met en place le curseur et la selection après la première lettre + edit.select(1, edit.getText().length()); + keyPressed = true; + } + + // delegate popup list menu + if ( e.getKeyChar() == KeyEvent.VK_ENTER ) + { + fireEditingStopped(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + public static LetterTableCellEditor getInstance() { + if (editor == null) { + editor = new LetterTableCellEditor(); + } + return editor; + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java (from rev 2999, trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,49 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.combobox; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.Account; + +public class AccountRenderer extends DefaultListCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + JLabel label = new JLabel(); + Account account = (Account) value; + if (account != null){ + String accountLabel = account.getLabel(); + int nbChars = 30; + if (accountLabel.length()>nbChars){ + accountLabel = accountLabel.substring(0, nbChars)+"…"; + } + label.setText(account.getAccountNumber() +" - " + accountLabel); + } + return label; + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,110 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.combobox; + +import java.util.List; +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialTransactionServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; + +/** + * Account combo box model. + */ + +public class LetterComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(FinancialPeriodTableModel.class); + + protected Object selectedAccount; + + protected List<Letter> datasCache; + + protected FinancialTransactionServiceMonitorable service; + + public LetterComboBoxModel () { + service = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + service.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + datasCache = getDataList(); + } + + @Override + public Object getSelectedItem() { + return selectedAccount; + } + + @Override + public void setSelectedItem(Object anItem) { + selectedAccount = anItem; + fireContentsChanged(this, -1, -1); + } + + + @Override + public Object getElementAt(int index) { + return datasCache.get(index); + } + + @Override + public int getSize() { + return datasCache.size(); + } + + public List<Letter> getDataList(){ + List<Letter> result = null; + try { + result = service.getAllLetters(); + } + catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't get list letters", eee); + } + } + return result; + + } + + public void refresh(){ + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("Letter") || methodeName.contains("importAll")){ + refresh(); + } + } + + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,42 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.combobox; + +import java.awt.Component; +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; +import org.chorem.lima.entity.Letter; + +public class LetterRenderer extends DefaultListCellRenderer { + + private static final long serialVersionUID = 1L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + + JLabel label = new JLabel(); + Letter letter = (Letter) value; + if (letter != null){ + label.setText(letter.getCode()); + } + return label; + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -65,23 +65,26 @@ String res = "n/a"; switch (column) { case 0: - res = _("lima.table.date"); //Date + res = _("lima.table.date"); break; case 1: - res = _("lima.table.account"); //Account + res = _("lima.table.account"); break; case 2: - res = _("lima.table.voucher"); // Voucher + res = _("lima.table.voucher"); break; case 3: - res = _("lima.table.description"); //Description + res = _("lima.table.description"); break; case 4: - res = _("lima.table.debit"); //Debit - break; + res = _("lima.table.letter"); + break; case 5: - res = _("lima.table.credit"); //Credit + res = _("lima.table.debit"); break; + case 6: + res = _("lima.table.credit"); + break; } return res; } @@ -114,9 +117,17 @@ result = currentRow.getDescription(); break; case 4: + if (currentRow.getLetter() != null){ + result = currentRow.getLetter().getCode(); + } + else { + result = null; + } + break; + case 5: result = currentRow.getDebit() ? currentRow.getAmount() : 0; break; - case 5: + case 6: result = currentRow.getDebit() ? 0 : currentRow.getAmount(); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -20,22 +20,14 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import javax.swing.JComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; -import org.chorem.lima.ui.combobox.EntryBookRenderer; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.util.EntryBookToString; -import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + public class FinancialPeriodComboBox extends JComboBox implements ActionListener { private static final long serialVersionUID = 1L; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -43,6 +43,7 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; @@ -159,7 +160,7 @@ result = String.class; break; case 5: - result = String.class; + result = Letter.class; break; case 6: result = BigDecimal.class; @@ -297,8 +298,13 @@ result = currentEntry.getDescription(); break; case 5 : - result = currentEntry.getLettering(); - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; case 6: result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; break; @@ -495,7 +501,7 @@ currentEntry.setDescription((String)value); break; case 5 : - currentEntry.setLettering((String)value); + currentEntry.setLetter((Letter)value); break; case 6: currentEntry.setAmount((BigDecimal)value); 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -26,8 +26,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; -import org.chorem.lima.ui.accountsreports.AccountRenderer; import org.chorem.lima.ui.combobox.AccountComboBoxModel; +import org.chorem.lima.ui.combobox.AccountRenderer; import org.chorem.lima.util.AccountToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -18,6 +18,7 @@ package org.chorem.lima.ui.financialtransactionsearch; +import static org.nuiton.i18n.I18n._; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JPanel; @@ -55,6 +56,7 @@ case ACCOUNT_LIST: final JTextField accountsList = new JTextField(16); accountsList.setMinimumSize(accountsList.getPreferredSize()); + accountsList.setToolTipText(_("lima.tooltip.filter")); KeyListener accountsListKeyListener = new KeyListener() { @Override 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -35,6 +35,7 @@ import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; @@ -158,7 +159,7 @@ result = BigDecimal.class; break; case 8: - result = String.class; + result = Letter.class; break; } @@ -295,8 +296,13 @@ result = null; break; case 8: - result = currentEntry.getLettering(); - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; } } @@ -409,7 +415,7 @@ currentEntry.setDebit(false); break; case 8: - currentEntry.setLettering((String)value); + currentEntry.setLetter((Letter)value); break; } try { 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -24,12 +24,14 @@ import org.chorem.lima.enums.ComboBoxPeriodEnum; import org.chorem.lima.enums.ComboBoxAccountsEnum; import org.chorem.lima.enums.ComboBoxEntryBooksEnum; + import org.chorem.lima.enums.ComboBoxLetterEnum; 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); + LetterSearchPanel letterSearchPanel = new LetterSearchPanel(handler); FinancialTransactionPeriodSearchPanel periodSearchPanel = new FinancialTransactionPeriodSearchPanel(handler); void $afterCompleteSetup() { @@ -64,12 +66,10 @@ onInsertUpdate='handler.setDescription(description.getText())' onRemoveUpdate='handler.setDescription(description.getText())' /> </cell> - <cell><JLabel text="lima.table.letter"/></cell> - <cell><JTextField id='letter' minimumSize='{letter.getPreferredSize()}'/> - <javax.swing.text.Document javaBean="letter.getDocument()" - onInsertUpdate='handler.setLetter(letter.getText())' - onRemoveUpdate='handler.setLetter(letter.getText())' /> - </cell> + <cell><JComboBox id="letterComboBox" javaBean="new JComboBox(ComboBoxLetterEnum.descriptions())" + onActionPerformed="letterSearchPanel.refresh(ComboBoxLetterEnum.valueOfDescription((String) letterComboBox.getSelectedItem())); + validate(); repaint()"/></cell> + <cell><LetterSearchPanel javaBean="letterSearchPanel"/></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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -28,6 +28,7 @@ import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; @@ -97,12 +98,8 @@ financialTransactionSearch.setDescription(result); } - public void setLetter(String letter){ - String result = null; - if (!letter.equals("")){ - result = letter; - } - financialTransactionSearch.setLetter(result); + public void setLetter(Letter letter){ + financialTransactionSearch.setLetter(letter); } public String getAccountsList(){ Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,87 @@ +/* *##% 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.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.JComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.ui.combobox.LetterComboBoxModel; +import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.util.LetterToString; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + +public class LetterSearchComboBox extends JComboBox implements KeyListener, ActionListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(LetterSearchComboBox.class); + + protected FinancialTransactionSearchViewHandler handler; + + public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); + LetterRenderer letterRenderer = new LetterRenderer(); + setModel(letterComboBoxModel); + setRenderer(letterRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Letter){ + handler.setLetter((Letter) this.getSelectedItem()); + } + } + + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Letter){ + handler.setLetter((Letter) this.getSelectedItem()); + } + // delegate popup list menu + if ( e.getKeyChar() == KeyEvent.VK_ENTER ) + { + firePopupMenuCanceled(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,53 @@ +/* *##% 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.ComboBoxLetterEnum; + +public class LetterSearchPanel extends JPanel { + + protected FinancialTransactionSearchViewHandler handler; + + public LetterSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + } + + static final long serialVersionUID = 1L; + + public void refresh(ComboBoxLetterEnum comboBoxEnum){ + + switch (comboBoxEnum) { + case ALL: + handler.setLetter(null); + handler.refresh(); + this.removeAll(); + break; + + case SELECT_ONE: + LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); + this.removeAll(); + this.add(comboBox); + break; + + } + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -37,6 +37,7 @@ import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; @@ -160,7 +161,7 @@ result = BigDecimal.class; break; case 8: - result = String.class; + result = Letter.class; break; } @@ -297,8 +298,13 @@ result = null; break; case 8: - result = currentEntry.getLettering(); - break; + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; } } @@ -411,7 +417,7 @@ currentEntry.setDebit(false); break; case 8: - currentEntry.setLettering((String)value); + currentEntry.setLetter((Letter)value); break; } try { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -41,7 +41,7 @@ <JLabel text="lima.common.filter"/> </cell> <cell anchor="west"> - <JTextField id='balanceFilter' minimumSize='{balanceFilter.getPreferredSize()}'/> + <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter" minimumSize='{balanceFilter.getPreferredSize()}'/> <javax.swing.text.Document javaBean="balanceFilter.getDocument()" onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())' onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())' /> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,57 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 CodeLutin + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<JDialog modal="true"> + <jaxx.runtime.swing.JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> + <Boolean id="validOk" javaBean='true'/> + + <script> + <![CDATA[ + + getRootPane().setDefaultButton(ok); + protected void performCancel() { + setValidOk(false); + dispose(); + } + ]]> + </script> + + <Table> + <row fill="horizontal"> + <cell> + <JRadioButton id="newLetter" text='lima.entries.lettering.radiobutton.new' value='{true}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell><JTextField editable="false" visible="{newLetter.isSelected()}" id='newLetterTextField' /></cell> + </row> + <row> + <cell> + <JRadioButton id="listLetter" text='lima.entries.lettering.radiobutton.list' value='{false}' buttonGroup="{getRadioButtons()}" + selected='true'/> + </cell> + <cell><JComboBox id='LetterListComboBox' visible="{listLetter.isSelected()}" javaBean="new LetterComboBox()"/></cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + <cell fill="none"> + <JButton id="ok" text="lima.common.ok" onActionPerformed="dispose()"/> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,47 @@ +/* *##% 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.lettering; + +import javax.swing.JComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.combobox.LetterComboBoxModel; +import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.util.LetterToString; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + +public class LetterComboBox extends JComboBox { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(LetterComboBox.class); + + + public LetterComboBox() { + + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); + LetterRenderer letterRenderer = new LetterRenderer(); + setModel(letterComboBoxModel); + setRenderer(letterRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringFinancialPeriodComboBox.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,82 @@ +/* *##% 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.lettering; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; +import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; + + +public class LetteringFinancialPeriodComboBox extends JComboBox implements ActionListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(LetteringFinancialPeriodComboBox.class); + + protected LetteringViewHandler handler; + + public LetteringFinancialPeriodComboBox(LetteringViewHandler handler) { + this.handler = handler; + + FinancialPeriodComboBoxModel comboBoxModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer comboBoxRenderer = new FinancialPeriodComboBoxRenderer(); + + setModel(comboBoxModel); + setRenderer(comboBoxRenderer); + addActionListener(this); + + } + + public void back(){ + int row = this.getSelectedIndex(); + log.debug(row); + if (row > 0){ + this.setSelectedItem(this.getItemAt(row-1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + public void next(){ + int size = this.getModel().getSize(); + int row = this.getSelectedIndex(); + log.debug(row); + + if (row < size-1){ + this.setSelectedItem(this.getItemAt(row+1)); + repaint(); + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof FinancialPeriod){ + handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + } + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,174 @@ +/* *##% 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.lettering; + +import static org.nuiton.i18n.I18n._; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.math.BigDecimal; +import java.util.Date; + +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.DateTableCellEditor; +import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; +import org.chorem.lima.ui.celleditor.LetterTableCellEditor; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; + + +/** + * Table des transaction qui ajoute des comportement (keys). + * + * @author jpepin + */ +public class LetteringTable extends JXTable implements KeyListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3133690382049594727L; + + /** log. */ + private static final Log log = LogFactory + .getLog(LetteringTable.class); + + protected LetteringViewHandler handler; + + private Highlighter colorTransaction; + + private ColorHighlighter colorBalance; + + public LetteringTable(LetteringViewHandler handler) { + + this.handler = handler; + + addKeyListener(this); + + //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()); + //Get new letter editor + setDefaultEditor(Letter.class, new LetterTableCellEditor()); + + //highlight financial financial transactions + addColorTransaction(); + // highlight unbalanced financial transactions + addColorNonBalancedTransaction(); + + + } + + /** + * Cette méthode permet de colorer toutes les transactions dans le tableau + * afin de bien distinguer les transactions et entrées comptables. + * On récupère la première cellule, on vérifie que c'est une date + */ + protected void addColorTransaction() { + if (colorTransaction != null) { + removeHighlighter(colorTransaction); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + return adapter.getValueAt(adapter.row, 0) instanceof Date; + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(222,222,222), null); + addHighlighter(colorTransaction); + } + + + + /** + * Permet de surligner une transaction dans le tableau lorsque + * cette dernière n'est pas équilibrée. + * On récupère la dernière cellule de la ligne + * et on vérifie si la valeur est différente de 0 + */ + protected void addColorNonBalancedTransaction() { + if (colorBalance != null) { + removeHighlighter(colorBalance); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + boolean isHighlighted = false; + Object value = adapter.getValueAt(adapter.row, 8); + if (value instanceof BigDecimal) { + BigDecimal currentBalance = (BigDecimal) value; + if (currentBalance.doubleValue() != 0) { + isHighlighted = true; + } + } + return isHighlighted; + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(255, 198, 209), null); + addHighlighter(colorTransaction); + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + + + // add letter with the key combination : ctrl + L + if (e.getKeyCode() == KeyEvent.VK_L + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.addLetter(); + } + + } + + + @Override + public void keyTyped(KeyEvent e) { + + } + + + @Override + public void keyReleased(KeyEvent e) { + + } + + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,415 @@ +/* *##% 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.lettering; + +import static org.nuiton.i18n.I18n._; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import javax.swing.table.AbstractTableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialTransactionServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.utils.EntryComparator; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.ErrorHelper; + + +/** + * Basic transaction table model. + * + * Le modele est filtré sur {@link #selectedEntryBook} et + * {@link #selectedFinancialPeriod} (montée en charge !). + * + * @author ore + * @author chatellier + * @version $Revision: 2897 $ + * + * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $ + * By : $Author: jpepin $ + */ +public class LetteringTableModel extends AbstractTableModel implements ServiceListener{ + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + /** log. */ + private static final Log log = LogFactory + .getLog(LetteringTableModel.class); + + /** Transaction service. */ + protected final FinancialTransactionServiceMonitorable financialTransactionService; + + /** selected financial period */ + protected FinancialPeriod selectedFinancialPeriod; + + /** data cache */ + protected List<Object> cacheDataList; + + /** collection + + + /** + * Model constructor. + * + * Just init service proxies. + */ + public LetteringTableModel() { + /* Services */ + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + } + + /** + * Le model est une combinaison de Transaction/Entries. + * + * + * @return + */ + protected List<Object> getDataList() { + List<Object> results = new ArrayList<Object>(); + if (selectedFinancialPeriod != null){ + try { + List<FinancialTransaction> financialtransactions = + financialTransactionService.getAllFinancialTransactionsForFinancialPeriod( + selectedFinancialPeriod); + 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.error("Can't update model", eee); + } + ErrorHelper.showErrorDialog("Can't get transaction list", eee); + } + } + return results; + } + + public void setLetter(int row, Letter letter){ + try { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof Entry){ + Entry entry = (Entry) currentRow; + financialTransactionService.setEntryLetter(entry, letter); + } + } catch (LimaException eee) { + log.error("Can't set letter", eee); + } + } + + public void removeLetter(int row){ + try { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof Entry){ + Entry entry = (Entry) currentRow; + financialTransactionService.removeEntryLetter(entry); + } + } catch (LimaException eee) { + log.error("Can't remove letter", eee); + } + } + + public void refresh(){ + cacheDataList = getDataList(); + fireTableDataChanged(); + } + + @Override + public int getColumnCount() { + return 9; + } + + @Override + public Class<?> getColumnClass(int column) { + + Class<?> result = null; + + switch (column) { + case 0: + result = Date.class; + break; + case 1: + result = EntryBook.class; + break; + case 2: + result = String.class; + break; + case 3: + result = Account.class; + break; + case 4: + result = String.class; + break; + case 5: + result = Letter.class; + break; + case 6: + result = BigDecimal.class; + break; + case 7: + result = BigDecimal.class; + break; + case 8: + result = BigDecimal.class; + break; + } + + return result; + } + + + + @Override + public String getColumnName(int column) { + String result = "n/a"; + + switch (column) { + case 0: + result = _("lima.table.date"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.voucher"); + break; + case 3: + result = _("lima.table.account"); + break; + case 4: + result = _("lima.table.description"); + break; + case 5: + result = _("lima.table.letter"); + break; + case 6: + result = _("lima.table.debit"); + break; + case 7: + result = _("lima.table.credit"); + break; + case 8: + result = _("lima.table.balance"); + break; + } + + return result; + } + + @Override + public int getRowCount() { + int result = 0; + + if (cacheDataList != null) { + result = cacheDataList.size(); + } + + return result; + } + + @Override + public Object getValueAt(int row, int column) { + Object result = null; + + // 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(); + + switch (column) { + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null){ + result = currentRow.getEntryBook().getCode(); + } + else { + result = null; + } + break; + case 2: + result = null; //voucher + break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5 : + result = null; // letter + break; + case 6: + result = amountDebit; + break; + case 7: + result = amountCredit; + break; + case 8: + result = amountDebit.subtract(amountCredit); + break; + } + } + else if (result instanceof Entry) { + Entry currentEntry = (Entry)result; + switch (column) { + case 0: + result = null; // date + break; + case 1 : // entry book + result = null; + break; + case 2: + result = currentEntry.getVoucher(); + break; + case 3: // account + if (currentEntry.getAccount() != null){ + result = currentEntry.getAccount().getAccountNumber(); + } + else { + result = null; + } + break; + case 4: + result = currentEntry.getDescription(); + break; + case 5 : + if (currentEntry.getLetter() != null){ + result = currentEntry.getLetter().getCode(); + } + else { + result = null; + } + break; + case 6: + result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + break; + case 7: + result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + break; + case 8: + result = null; + break; + } + + } + } + return result; + } + + + public void setFinancialPeriod(FinancialPeriod financialPeriod){ + selectedFinancialPeriod = financialPeriod; + refresh(); + } + + /** + * To set cells editable or not + * different condition for entry or financial transaction + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + boolean editableCell=false; + Object currentRow = cacheDataList.get(rowIndex); + // cells editable for the entry row, all cells exclude the date + if ((currentRow instanceof Entry) && ((columnIndex==5))) { + editableCell=true; + } + return editableCell; } + + + + public Object getElementAt(int row){ + Object result = null; + if (cacheDataList != null){ + result = cacheDataList.get(row); + } + return result; + } + + + /** + * to modifiy letter entry + */ + @Override + public void setValueAt(Object value, int row, int column) { + int financialTransactionRow = 0; + if (cacheDataList != null) { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + switch (column) { + case 5 : + currentEntry.setLetter((Letter)value); + break; + } + try { + financialTransactionService.updateEntry(currentEntry); + + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.error("Can't update entry", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = + getDataList().indexOf(((Entry) currentRow). + getFinancialTransaction()); + } + //on recharge la liste + cacheDataList = getDataList(); + fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + } + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + refresh(); + } + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,90 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 CodeLutin + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<Table> + <LetteringViewHandler id="handler" javaBean="new LetteringViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> + <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> + <script> + <![CDATA[ + import org.chorem.lima.entity.FiscalPeriod; + import org.chorem.lima.entity.FinancialPeriod; + import org.chorem.lima.ui.lettering.LetteringFinancialPeriodComboBox; + + LetteringFinancialPeriodComboBox financialPeriodComboBox = new LetteringFinancialPeriodComboBox(handler); + + + void $afterCompleteSetup() { + getHandler().refresh(); + } + + ]]> + </script> + + <row weightx="1" weighty="0" anchor="center"> + <cell anchor="east"> + <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> + </cell> + <cell anchor="west"> + <JComboBox id="fiscalPeriodComboBox" + model="{getModelFiscalPeriod()}" + renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}" + onActionPerformed="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem()); + getHandler().refresh()" + editable="false"/> + </cell> + <cell anchor="east"> + <JLabel id="financialPeriodLabel" text="lima.common.period" + /> + </cell> + <cell anchor="west"> + <JComboBox javaBean="financialPeriodComboBox"/> + </cell> + <cell> + <JButton id="back" text="lima.common.buttonback" + onActionPerformed="financialPeriodComboBox.back()"/> + </cell> + <cell> + <JButton id="next" text="lima.common.buttonnext" + onActionPerformed="financialPeriodComboBox.next()"/> + </cell> + <cell> + <JButton text="lima.entries.lettering.add" + onActionPerformed="handler.addLetter()" toolTipText="lima.tooltip.lettering" enabled="{isSelectedRow()}"/> + </cell> + <cell> + <JButton text="lima.entries.lettering.remove" + onActionPerformed="handler.removeLetter()" enabled="{isSelectedRow()}"/> + </cell> + + </row> + <row> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> + <JScrollPane> + <org.chorem.lima.ui.lettering.LetteringTableModel + id="tableModel"/> + <org.chorem.lima.ui.lettering.LetteringTable + id="table" sortable="false" rowHeight="22" + constructorParams="getHandler()" model="{getTableModel()}" + selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION }" /> + <javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()" + onValueChanged="setSelectedRow(table.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> +</Table> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,138 @@ +/* *##% 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.lettering; + +import static org.nuiton.i18n.I18n._; +import javax.swing.JComboBox; +import javax.swing.JTextField; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialTransactionServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.Letter; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; +import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; +import org.chorem.lima.util.DialogHelper; + + +/** + * Handler associated with financial transaction view. + * + * @author chatellier + * @version $Revision: 3015 $ + * + * Last update : $Date: 2010-08-23 18:38:53 +0200 (lun., 23 août 2010) $ + * By : $Author: jpepin $ + */ +public class LetteringViewHandler { + + /** log. */ + private static final Log log = + LogFactory.getLog(LetteringViewHandler.class); + + protected LetteringView view; + + protected LetteringTable table; + + protected LetteringTableModel tableModel; + + protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; + + protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; + + /** Transaction service. */ + protected final FinancialTransactionServiceMonitorable financialTransactionService; + + protected Object clipBoard; + + protected LetteringViewHandler(LetteringView view) { + this.view = view; + + /* Services */ + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + } + + + + public void addLetter(){ + Letter letter = null; + Boolean valid = true; + + table = view.getTable(); + tableModel = view.getTableModel(); + + AddLetterForm addLetterForm = new AddLetterForm(); + JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); + + try { + letter = financialTransactionService.getNewLetter(); + newLetterTextField.setText(letter.getCode()); + } catch (LimaException eee) { + log.error("Can't get new letter", eee); + } + + addLetterForm.setLocationRelativeTo(view); + addLetterForm.setVisible(true); + + //false = cancel Action + if (addLetterForm.validOk){ + Object object = addLetterForm.getRadioButtons().getSelectedValue(); + if (!(Boolean) object){ + JComboBox comboBox = addLetterForm.getLetterListComboBox(); + Object selectedObject = comboBox.getSelectedItem(); + if (selectedObject instanceof Letter){ + letter = (Letter) selectedObject; + } + else { + DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); + valid = false; + } + } + if (valid){ + //addLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.setLetter(i, letter); + } + tableModel.refresh(); + } + } + } + + public void removeLetter(){ + + table = view.getTable(); + tableModel = view.getTableModel(); + + //removeLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.removeLetter(i); + } + tableModel.refresh(); + } + + public void refresh(){ + tableModel = view.getTableModel(); + tableModel.refresh(); + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -18,7 +18,6 @@ * ##%*/ import static org.nuiton.i18n.I18n._; - import java.awt.Color; import javax.swing.BorderFactory; import javax.swing.JPanel; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-08-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -1,3 +1,21 @@ +/* *##% 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.util; import org.chorem.lima.entity.Account; Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java 2010-08-25 22:04:25 UTC (rev 3020) @@ -0,0 +1,47 @@ +/* *##% 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.util; + +import org.chorem.lima.entity.Letter; +import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; + +public class LetterToString extends ObjectToStringConverter { + + private static LetterToString converter; + + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null){ + if (item instanceof Letter){ + Letter letter = (Letter) item; + result = letter.getCode(); + } + } + return result; + } + + public static LetterToString getInstance() { + if (converter == null) { + converter = new LetterToString(); + } + return converter; + } + +} 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-25 22:04:25 UTC (rev 3020) @@ -80,14 +80,25 @@ lima.entries=Entries lima.entries.addEntry=Add entry lima.entries.addTransaction=Add transaction +lima.entries.lettering=Lettering +lima.entries.lettering.add=Add letter +lima.entries.lettering.noletterselected=Error \: No selected letter +lima.entries.lettering.radiobutton.list=Existing letters +lima.entries.lettering.radiobutton.new=New letter +lima.entries.lettering.remove=Remove letter lima.entries.searchtransaction=Search transaction lima.entries.searchunbalancedtransaction=Incorrect transactions lima.entries.writetransaction=Write entries lima.enum.comboboxaccount.account=Account lima.enum.comboboxaccount.accountlist=Account list lima.enum.comboboxaccount.allaccount=All accounts +lima.enum.comboboxamount.both=Both +lima.enum.comboboxamount.credit=Credit +lima.enum.comboboxamount.debit=Debit lima.enum.comboboxentrybook.all=All entrybooks lima.enum.comboboxentrybook.select_one=EntryBook +lima.enum.comboboxletter.all=All letters +lima.enum.comboboxletter.selectone=Letter lima.enum.comboboxoperator.equal=Equal lima.enum.comboboxoperator.inferior=Inferior lima.enum.comboboxoperator.inferiororequal=Inferior or equal @@ -220,4 +231,6 @@ lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=About Lima... lima.title.about.description=Open sources accounting software +lima.tooltip.filter=<html>Regular expression \:<br/>- accounts interval i..j <br/>- accounts list i,j,k <br/>- Exclude an account -i</html> +lima.tooltip.lettering=<html>Add a letter on many entries <br/>Select many rows with combination ctrl + click</html> lima.warning.nimbus.landf=Could not find Numbus Look&Feel 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-24 16:54:17 UTC (rev 3019) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-25 22:04:25 UTC (rev 3020) @@ -80,6 +80,12 @@ lima.entries=Traitement lima.entries.addEntry=Ajouter entr\u00E9e lima.entries.addTransaction=Ajouter transaction +lima.entries.lettering=Lettrage +lima.entries.lettering.add=Ajouter une lettre +lima.entries.lettering.noletterselected=Erreur \: Aucune lettre s\u00E9lectionn\u00E9e. +lima.entries.lettering.radiobutton.list=Lettres existantes +lima.entries.lettering.radiobutton.new=Nouvelle lettre +lima.entries.lettering.remove=Supprimer une lettre lima.entries.searchtransaction=Rechercher des \u00E9critures lima.entries.searchunbalancedtransaction=Entr\u00E9es incorrect lima.entries.writetransaction=Saisir des \u00E9critures @@ -91,6 +97,8 @@ lima.enum.comboboxamount.debit=D\u00E9bit lima.enum.comboboxentrybook.all=Tous les journaux lima.enum.comboboxentrybook.select_one=Journal +lima.enum.comboboxletter.all=Toutes les lettres +lima.enum.comboboxletter.selectone=Lettre lima.enum.comboboxoperator.equal=\u00C9gal lima.enum.comboboxoperator.inferior=Inf\u00E9rieur lima.enum.comboboxoperator.inferiororequal=Inf\u00E9rieur ou \u00E9gal @@ -223,4 +231,6 @@ lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=\u00C0 propos de Lima... lima.title.about.description=Logiciel de comptabilit\u00E9 Libre +lima.tooltip.filter=<html>Expression r\u00E9guli\u00E8re \:<br/>- intervalle de compte i..j <br/>- liste de compte i,j,k <br/>- Exclure un compte -i</html> +lima.tooltip.lettering=<html>Pour ajouter une lettre \u00E0 plusieurs \u00E9critures <br/>S\u00E9lectionner plusieurs lignes avec la combinaison ctrl + click</html> lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9
participants (1)
-
jpepin@users.chorem.org