r2932 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports lima-swing/src/main/java/org/chorem/lima/ui/financialperiod lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction lima-sw
Author: jpepin Date: 2010-06-04 10:43:32 +0200 (Fri, 04 Jun 2010) New Revision: 2932 Url: http://chorem.org/repositories/revision/lima/2932 Log: Ajout message d'erreur dans l'ui. Tri des entr?\195?\169es dans l'?\195?\169dition de journal par date et transaction. Added: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -44,6 +44,8 @@ */ public void createAccountRules(Account masterAccount, Account account) throws LimaException; public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException; + public void updateAccountRules(Account account) throws LimaException; + public void updateSubLedgerRules(Account account) throws LimaException; public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException; /** @@ -70,7 +72,7 @@ * @throws LimaException */ public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException; - public void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException; + public void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException, LimaBusinessException; /** * Financialperiod/entrybook rules * @param financialTransaction Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -318,7 +318,7 @@ } catch (TopiaException eee) { doCatch(topiaContext, eee, log); - } + } } @@ -345,4 +345,22 @@ throw new LimaException("Exception during query", cause); } + @Override + public void updateAccountRules(Account account) throws LimaException { + // Check if the numberaccount is not blank + if (StringUtils.isBlank(account.getAccountNumber())) { + throw new LimaBusinessException("Invalid AccountNumber : " + + account.getAccountNumber()); + } + } + + @Override + public void updateSubLedgerRules(Account account) throws LimaException { + // check the number account is not empty + if (StringUtils.isBlank(account.getAccountNumber())) { + throw new LimaBusinessException("Invalid AccountNumber : " + + account.getAccountNumber()); + } + } + } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -17,6 +17,7 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FinancialPeriodImpl; +import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FiscalPeriodDAO; import org.chorem.lima.entity.LimaCallaoDAOHelper; @@ -26,6 +27,7 @@ import org.nuiton.topia.framework.TopiaQuery.Op; public class FranceAccountingRules extends DefaultAccountingRules { + protected static final Log log = LogFactory.getLog(DefaultAccountingRules.class); @@ -60,6 +62,14 @@ } + public void updateAccountRules(Account account) throws LimaException { + super.updateAccountRules(account); + } + + public void updateSubLedgerRules(Account account) throws LimaException { + super.updateSubLedgerRules(account); + } + /** * Règles de vérification d'ouverture d'un exercice, appliquées à la comptabilité française * Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -148,7 +148,6 @@ accountDAO.create(account); - log.debug(masterAccount+" "+account); // check if the masteraccount exist; if (masterAccount != null) { masterAccount.addSubLedgers(account); @@ -344,7 +343,17 @@ TopiaContext transaction = null; try { - transaction = beginTransaction(); + transaction = beginTransaction(); + + //TODO if account + //check rules account if ledger or account + if (account.getGeneralLedger()==null){ + accountingRules.updateAccountRules(account); + } + else { + accountingRules.updateSubLedgerRules(account); + } + // update account AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction); 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-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -305,34 +305,29 @@ try { topiaTransaction = beginTransaction(); EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction); - TopiaQuery query = entryDAO.createQuery("E"); - String transactionDateProperty = - TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.TRANSACTION_DATE); - String amountCreditProperty = - TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.AMOUNT_CREDIT); - String amountDebitProperty = - TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, - FinancialTransaction.AMOUNT_DEBIT); - query - .addWhere(amountCreditProperty+" = "+amountDebitProperty) - .addEquals(Entry.ENTRY_BOOK, entryBook) - .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate") - .addParam("beginDate", beginDate) - .addParam("endDate", endDate); + TopiaQuery entriesQuery = createEntryBookReportsQuery( + entryBook, beginDate, endDate, entryDAO, "E"); //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION - query.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION); - List<Entry> entries = entryDAO.findAllByQuery(query); + entriesQuery.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION); + String orderDateProperty = + TopiaQuery.getProperty("E", Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE); + String orderIdProperty = + TopiaQuery.getProperty("E", Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TOPIA_ID); + entriesQuery.addOrder(orderDateProperty) + .addOrder(orderIdProperty); + reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery)); + + //TODO 20100603 PEPIN imbriqué les deux conditions de comparator // tri sur date, tri sur topiaid - Collections.sort(entries, new EntryFinancialTransactionDateComparator()); - Collections.sort(entries, new EntryFinancialTransactionComparator()); - reportsDatas.setListEntry(entries); + //Collections.sort(entries, new EntryFinancialTransactionDateComparator()); + //Collections.sort(entries, new EntryFinancialTransactionComparator()); - query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")"); - query.addGroup("E."+Entry.DEBIT); - results = query.execute(topiaTransaction); + TopiaQuery amountsQuery = + createEntryBookReportsQuery(entryBook, beginDate, endDate, entryDAO, "E"); + amountsQuery.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")"); + amountsQuery.addGroup("E."+Entry.DEBIT); + results = amountsQuery.execute(topiaTransaction); int nbAmount = results.size(); if(nbAmount==2){ debit = (Double)results.get(0)[1]; @@ -371,6 +366,31 @@ return reportsDatas; } + /** + * Query for find entries for accountsreports and balancereports + * Just balanced transaction are calculated + */ + public TopiaQuery createEntryBookReportsQuery(EntryBook entryBook, Date beginDate, Date endDate, EntryDAO entryDAO, String queryAlias) throws LimaException{ + TopiaQuery query = entryDAO.createQuery(queryAlias); + String transactionDateProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.TRANSACTION_DATE); + String amountCreditProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_CREDIT); + String amountDebitProperty = + TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION, + FinancialTransaction.AMOUNT_DEBIT); + query + .addWhere(amountCreditProperty+" = "+amountDebitProperty) + .addEquals(Entry.ENTRY_BOOK, entryBook) + .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate") + .addParam("beginDate", beginDate) + .addParam("endDate", endDate); + + return query; + } + /** * Get balance trial * Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -27,10 +27,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountService; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; import org.jdesktop.swingx.treetable.AbstractTreeTableModel; /** @@ -61,12 +63,6 @@ accountService = LimaServiceFactory.getInstance().getAccountService(); } - /** - * @deprecated can't be used - */ - public Account getData() { - return (Account) root; - } @Override public int getColumnCount() { @@ -213,7 +209,6 @@ if (parentAccount == getRoot()) { parentAccount = null; } - accountService.createAccount(parentAccount, account); int index = getIndexOfChild(path.getLastPathComponent(), account); modelSupport.fireTreeStructureChanged(path); @@ -232,7 +227,7 @@ Account parentAccount = (Account)path.getLastPathComponent(); if (parentAccount == getRoot()) { parentAccount = null; - } + } accountService.createSubLedger(parentAccount, account); int index = getIndexOfChild(path.getLastPathComponent(), account); modelSupport.fireTreeStructureChanged(path); @@ -264,8 +259,8 @@ // Calling account service int index = getIndexOfChild( path.getParentPath().getLastPathComponent(), account); - accountService.removeAccount(account); - modelSupport.fireChildRemoved(path.getParentPath(), index, account); + accountService.removeAccount(account); + modelSupport.fireChildRemoved(path.getParentPath(), index, account); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -32,6 +32,7 @@ import org.chorem.lima.ui.account.AccountForm; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.account.SubLedgerForm; +import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTreeTable; @@ -86,11 +87,12 @@ // add it try { accountsTreeTableModel.addAccount(treePath, newAccount); - } catch (LimaBusinessException ex) { + } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { - log.error("Can't add account", ex); + log.error("Can't add account", eee); } - ErrorHelper.showErrorDialog(ex.getMessage(), ex); + DialogHelper.showMessageDialog(eee.getMessage()); + } catch (LimaException ex) { @@ -125,18 +127,18 @@ try { accountsTreeTableModel. addSubLedger(treePath, newAccount); - } catch (LimaBusinessException ex) { + } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { - log.error("Can't add subledger", ex); + log.error("Can't add subledger", eee); } - ErrorHelper.showErrorDialog(ex.getMessage(), ex); + DialogHelper.showMessageDialog(eee.getMessage()); } - catch (LimaException ex) { + catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add subledger", ex); + log.error("Can't add subledger", eee); } - ErrorHelper.showErrorDialog("Can't add subledger", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } @@ -191,11 +193,11 @@ accountsTreeTableModel. updateAccount(treePath, selectedObject); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add update", ex); + log.error("Can't add update", eee); } - ErrorHelper.showErrorDialog("Can't add update", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } @@ -228,11 +230,11 @@ try{ accountsTreeTableModel.removeAccount(treePath, account); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't delete account", ex); + log.error("Can't delete account", eee); } - ErrorHelper.showErrorDialog("Can't delete account", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -26,9 +26,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.EntryBookService; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; /** * Entry book table model. @@ -108,16 +110,7 @@ return entryBook; } - /* - * @param row - * @return - * @Override - public Object getRow(int row) { - return data.get(row); - }*/ - - @Override public Object getValueAt(int row, int column) { Object result = null; @@ -144,37 +137,9 @@ return result; } - - @Override - public void setValueAt(Object value, int row, int column) { - - try { - EntryBook entryBook = getEntryBookAtRow(row); - - switch (column) { - case 0: - entryBook.setCode((String)value); - break; - case 1: - entryBook.setLabel((String)value); - break; - case 2: - entryBook.setType((String)value); - break; - } - - // update on remote service - entryBookService.updateEntryBook(entryBook); - } catch (LimaException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - // TODO why false ? + // Ne cells editable return false; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -27,6 +27,7 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; +import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTable; @@ -69,11 +70,11 @@ // add it try { entryBookTableModel.addEntryBook(newEntryBook); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add entry book", ex); + log.error("Can't add entry book", eee); } - ErrorHelper.showErrorDialog("Can't add entry book", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } @@ -100,11 +101,11 @@ if (selectedEntryBook != null) { entryBookTableModel.updateEntryBook(selectedEntryBook); } - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add update book", ex); + log.error("Can't add update book", eee); } - ErrorHelper.showErrorDialog("Can't update entry book", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } @@ -129,11 +130,11 @@ if (response == JOptionPane.YES_OPTION) { entryBookTableModel.removeEntryBook(selectedEntryBook); } - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't delete update book", ex); + log.error("Can't delete update book", eee); } - ErrorHelper.showErrorDialog("Can't delete entry book", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -86,6 +86,9 @@ highlighterReportsDatasBoolean = !highlighterReportsDatasBoolean; } oldRow = financialTransaction; + if (adapter.row ==0){ + highlighterReportsDatasBoolean=false; + } return highlighterReportsDatasBoolean; } }; 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-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -73,8 +73,7 @@ /** * Constructor. */ - public EntryBooksReportsTableModel() { - + public EntryBooksReportsTableModel() { reportService = LimaServiceFactory.getInstance().getReportService(); } @@ -183,17 +182,13 @@ } public void setBeginDate(Date date){ - log.debug("setBeginDate"); selectedBeginDate = date; - log.debug(selectedBeginDate); cacheDataList=getDataList(); fireTableDataChanged(); } public void setEndDate(Date date){ - log.debug("setEndDate"); selectedEndDate = date; - log.debug(selectedEndDate); cacheDataList=getDataList(); fireTableDataChanged(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -27,6 +27,7 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.util.DialogHelper; /** * TODO add comment here. @@ -61,12 +62,11 @@ if (response == JOptionPane.YES_OPTION) { model.blockFinancialPeriod(closedPeriodicEntryBook); } - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't block financialperiod", ex); + log.error("Can't block financialperiod", eee); } - JOptionPane.showMessageDialog(view, - _("Can't block financialperiod")); + DialogHelper.showMessageDialog(eee.getMessage()); } } 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-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -26,6 +26,7 @@ import java.util.Date; import java.util.List; +import javax.swing.JOptionPane; import javax.swing.table.AbstractTableModel; import org.apache.commons.lang.time.DateUtils; @@ -45,8 +46,11 @@ import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; +import com.sun.xml.bind.Util; + /** * Basic transaction table model. * @@ -83,7 +87,7 @@ /** data cache */ protected List<Object> cacheDataList; - + /** collection @@ -126,8 +130,7 @@ if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } - - ErrorHelper.showErrorDialog("Can't get transaction list", eee); + ErrorHelper.showErrorDialog("Can't get transaction list", eee); } return results; @@ -372,8 +375,9 @@ actualCalendar.get(Calendar.DAY_OF_MONTH)); // set date to the financial transaction financialTransaction.setTransactionDate(transactionDate); - // create it + // create it financialTransactionService.createFinancialTransaction(financialTransaction); + //on recharge la liste cacheDataList = getDataList(); int row = getDataList().indexOf(financialTransaction); @@ -406,6 +410,7 @@ //create it entry.setFinancialTransaction(currentTransaction); financialTransactionService.createEntry(entry); + //on recharge la liste cacheDataList = getDataList(); fireTableDataChanged(); @@ -433,10 +438,11 @@ try { financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); - } catch (LimaException e) { + } catch (LimaException eee) { if (log.isDebugEnabled()){ - log.debug("Can't update financial transaction", e); + log.debug("Can't update financial transaction", eee); } + DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire financialTransactionRow = @@ -472,10 +478,11 @@ try { financialTransactionService.updateEntry(currentEntry); - } catch (LimaException e) { + } catch (LimaException eee) { if (log.isDebugEnabled()){ - log.debug("Can't update entry", e); + log.debug("Can't update entry", eee); } + DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire financialTransactionRow = Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-04 08:43:32 UTC (rev 2932) @@ -77,7 +77,7 @@ <cell fill="both" weightx="1" weighty="1" rows="3" columns="7"> <JScrollPane> <org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel - id="financialTransactionTableModel" /> + id="financialTransactionTableModel"/> <org.chorem.lima.ui.financialtransaction.FinancialTransactionTable id="financialTransactionTable" sortable="false" rowHeight="22" constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -29,6 +29,7 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.financialtransaction.FinancialTransactionView; +import org.chorem.lima.util.DialogHelper; /** * Handler associated with financial transaction view. @@ -68,12 +69,11 @@ //focus on first column table.changeSelection(numberRow-1, 0, false, false); table.requestFocusInWindow(); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add financialtransaction", ex); + log.error("Can't add financialtransaction", eee); } - JOptionPane.showMessageDialog(view, - _("lima.warning.entrybookscloded")); + DialogHelper.showMessageDialog(eee.getMessage()); } } @@ -98,12 +98,11 @@ //focus on second column table.changeSelection(indexSelectedRow+1, 1, false, false); table.requestFocusInWindow(); - } catch (LimaException ex){ + } catch (LimaException eee){ if (log.isErrorEnabled()) { - log.error("Can't add emptyentry", ex); + log.error("Can't add emptyentry", eee); } - JOptionPane.showMessageDialog(view, - _("lima.warning.entrybookscloded")); + DialogHelper.showMessageDialog(eee.getMessage()); } } else { @@ -149,12 +148,11 @@ ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", ex); + log.error("Can't remove transaction or entry", eee); } - JOptionPane.showMessageDialog(view, - _("lima.warning.entrybookscloded")); + DialogHelper.showMessageDialog(eee.getMessage()); } } } 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-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -45,6 +45,7 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; /** @@ -396,10 +397,11 @@ try { financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); - } catch (LimaException e) { + } catch (LimaException eee) { if (log.isDebugEnabled()){ - log.debug("Can't update financial transaction", e); + log.debug("Can't update financial transaction", eee); } + DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire financialTransactionRow = @@ -434,10 +436,11 @@ } try { financialTransactionService.updateEntry(currentEntry); - } catch (LimaException e) { + } catch (LimaException eee) { if (log.isDebugEnabled()){ - log.debug("Can't update entry", e); + log.debug("Can't update entry", eee); } + DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire financialTransactionRow = Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.util.DialogHelper; /** * Handler associated with financial transaction view. @@ -71,12 +72,12 @@ //focus on second column table.changeSelection(indexSelectedRow+1, 1, false, false); table.requestFocusInWindow(); - } catch (LimaException ex){ + } catch (LimaException eee){ if (log.isErrorEnabled()) { - log.error("Can't add emptyentry", ex); + log.error("Can't add emptyentry", eee); } - JOptionPane.showMessageDialog(view, - _("lima.warning.entrybookscloded")); + DialogHelper.showMessageDialog(eee.getMessage()); + } } else { @@ -122,12 +123,11 @@ ListSelectionModel selectionModel = table.getSelectionModel(); selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", ex); + log.error("Can't remove transaction or entry", eee); } - JOptionPane.showMessageDialog(view, - _("lima.warning.entrybookscloded")); + DialogHelper.showMessageDialog(eee.getMessage()); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -26,9 +26,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodService; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; /** * TODO add comment here. @@ -111,26 +113,19 @@ return result; } - /* - * @see javax.swing.table.TableModel#getColumnClass(int) - */ + @Override public Class<?> getColumnClass(int columnIndex) { // both String return String.class; } - /* - * @see javax.swing.table.TableModel#isCellEditable(int, int) - */ + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } - /* - * @see javax.swing.table.TableModel#getValueAt(int, int) - */ @Override public Object getValueAt(int rowIndex, int columnIndex) { @@ -172,15 +167,6 @@ return result; } - - /* - * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int) - */ - @Override - public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - - } - public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException { FiscalPeriod fiscalPeriod = null; @@ -207,6 +193,7 @@ } public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { + fiscalPeriodService.blockFiscalPeriod(fiscalPeriod); fireTableDataChanged(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -31,6 +31,7 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.ui.fiscalperiod.AddPeriod; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; +import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; /** @@ -81,11 +82,11 @@ if (n == JOptionPane.YES_OPTION || nbMonth ==11){ try { model.addFiscalPeriod(fiscalPeriod); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't add fiscal period", ex); + log.error("Can't add fiscal period", eee); } - ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } } @@ -110,11 +111,11 @@ if (response == JOptionPane.YES_OPTION) { model.blockFiscalPeriod(selectedFiscalPeriod); } - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't block fiscalperiod", ex); + log.error("Can't block fiscalperiod", eee); } - ErrorHelper.showErrorDialog("Can't block fiscalperiod", ex); + DialogHelper.showMessageDialog(eee.getMessage()); } } @@ -124,11 +125,11 @@ (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); try { model.removeAllFiscalPeriods(); - } catch (LimaException ex) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.error("Can't delete all fiscal period", ex); + log.error("Can't delete all fiscal period", eee); } - ErrorHelper.showErrorDialog(_("Can't delete all fiscal period")); + DialogHelper.showMessageDialog(eee.getMessage()); } } Copied: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -0,0 +1,80 @@ +/** + * *##% 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.util; + +import static org.nuiton.i18n.I18n._; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.nuiton.util.Resource; + +/** + * @author ore + * @author Rémi Chapelet + */ +public class DialogHelper { + + /** + * log + */ + private static final Log log = LogFactory.getLog(DialogHelper.class); + + public static int showConfirmDialog(String message) { + String[] response = {_("lima.response.yes"), _("lima.response.no")}; + return JOptionPane.showOptionDialog(null, + message, + _("lima.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, //do not use a custom Icon + response, //the titles of buttons + response[0]); //default button title + } + + public static void showMessageDialog(String message) { + JFrame f = new JFrame(); + f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); + JOptionPane.showMessageDialog( + f, + message, + _("lima.error"), + JOptionPane.ERROR_MESSAGE); + f.dispose(); + } + + /** + * Permet d'afficher une boite de dialogue. + * @param message + * @param titre + * @param type + */ + public static void showMessageDialog (String message,String titre,int type) + { + JFrame f = new JFrame(); + f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); + JOptionPane.showMessageDialog( + f, + message, + titre, + type); + f.dispose(); + } +} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-06-03 16:45:18 UTC (rev 2931) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-06-04 08:43:32 UTC (rev 2932) @@ -1,224 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* - */ - -package org.chorem.lima.util; - -import static org.nuiton.i18n.I18n._; - -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Locale; - -import javax.swing.JFrame; -import javax.swing.JOptionPane; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Resource; - -/** - * @author ore - * @author Rémi Chapelet - * - * @deprecated since 0.4.0 with no replacement - */ -public class Util { - - /** - * log - */ - private static final Log log = LogFactory.getLog(Util.class); - - /** - * @param sDate - * @param sFormat - * @return - * @throws java.lang.Exception - */ - public static Date stringToDate(String sDate, String sFormat) { - Date d = null; - try { - SimpleDateFormat sdf = new SimpleDateFormat(sFormat); - d = sdf.parse(sDate); - } catch (Exception e) {} - return d; - } - - /** - * Permet de transformer une date au format Date au format String - * Il est précisé dans cette méthode le format de date attendue. - * @param d - * @param sFormat - * @return - */ - public static String DateToString(Date d, String sFormat) { - String result = ""; - try { - SimpleDateFormat sdf = new SimpleDateFormat(sFormat); - result = sdf.format(d); - } catch (Exception e) {} - return result; - } - - /** - * @param date - * @return - */ - public static String dateToString(Date date) { - // 1. Choix de la langue - Locale locale = Locale.getDefault(); - DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale); - return dateFormat.format(date); - } - - /** - * Adds all of the elements in the second collection to the first collection if they're not already present. - * - * @param c1 collection who receives elements - * @param c2 collection whose elements are to be added to first collection. - * @return true if this collection changed as a result of the call. - */ - public static boolean addAll(Collection c1, Collection c2) { - boolean modified = false; - for (Object aC2 : c2) { - if (!c1.contains(aC2)) { - if (c1.add(aC2)) { - modified = true; - } - } - } - return modified; - } - - public static int showConfirmDialog(String message) { - String[] response = {_("lima.response.yes"), _("lima.response.no")}; - return JOptionPane.showOptionDialog(null, - message, - _("lima.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, //do not use a custom Icon - response, //the titles of buttons - response[0]); //default button title - } - - public static void showMessageDialog(String message) { - JFrame f = new JFrame(); - f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JOptionPane.showMessageDialog( - f, - message, - _("lima.error"), - JOptionPane.ERROR_MESSAGE); - f.dispose(); - } - - /** - * Permet d'afficher une boite de dialogue. - * @param message - * @param titre - * @param type - */ - public static void showMessageDialog (String message,String titre,int type) - { - JFrame f = new JFrame(); - f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JOptionPane.showMessageDialog( - f, - message, - titre, - type); - f.dispose(); - } - - /** - * Permet de découper une date dans un tableau. - * Indices : - * 0 : année - * 1 : mois - * 2 : jour - * @param d - * @return - */ - public static String[] arrayDate (Date d) - { - String dateTab[] = new String[3]; - // année - dateTab[0] = Integer.toString(d.getYear()+1900); - // mois - dateTab[1] = Integer.toString(d.getMonth()); - // jour - dateTab[2] = Integer.toString(d.getDate()); - return dateTab; - } - - /** - * Initialise la date d'entrée le premier du mois à minuit. - * Exemple : 15 janvier 2009, alors date de sortie 1 Janvier 2009 00h00m00s - * @param d date - * @return - */ - public static Date InitDateFirstDayMonth (Date d) - { - Date date_result = new Date(d.getYear(),d.getMonth(),1,0,0,0); - return date_result; - } - - /** - * Permet de calculer la date sur le mois suivant. - * @param d - * @return - */ - public static Date nextMonth (Date d) - { - Date date_result = new Date(d.getYear(),d.getMonth()+1,1,0,0,0); - return date_result; - } - - /** - * Permet de retourner la date de fin de mois. Si on lui donne la date - * 5 Janv 2000, elle retourne alors 31 Jan 2000. - * @param d date de référence - * @return la date du fin de mois - */ - public static Date InitDateEndDayMonth (Date d) - { - Calendar c = new GregorianCalendar (d.getYear()+1900,d.getMonth(),d.getDate()); - // Calcul le dernier jour du mois, prend en compte les années bixestiles - Integer maxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH); - //Date dateEnd = new Date(d.getYear(),d.getMonth(),maxDay,23,59,59); - Calendar dateEnd = new GregorianCalendar (d.getYear()+1900,d.getMonth(),maxDay,23,59,59); - Date result = dateEnd.getTime(); - return result; - } - - - public static int compareTo (String a,String b) - { - float A = Float.parseFloat(a.replace(',','.')); - float B = Float.parseFloat(b.replace(',','.')); - int result = Float.compare(A,B); - return result; - } - -}
participants (1)
-
jpepin@users.chorem.org