Author: echatellier Date: 2012-05-16 15:02:27 +0200 (Wed, 16 May 2012) New Revision: 3426 Url: http://chorem.org/repositories/revision/lima/3426 Log: Move LimaException to Runtime. Delete LimaRuntimeException. Removed: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaRuntimeException.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.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/EntryBooksReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.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/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.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/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java Deleted: trunk/lima-business/src/main/java/org/chorem/lima/business/LimaRuntimeException.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/LimaRuntimeException.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/LimaRuntimeException.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -1,60 +0,0 @@ -/* - * #%L - * Lima business - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2012 CodeLutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package org.chorem.lima.business; - -/** - * Lima runtime exception. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class LimaRuntimeException extends RuntimeException { - - /** serialVersionUID. */ - private static final long serialVersionUID = -6876236663940184462L; - - /** - * Constructs a new exception with the specified detail message. - * - * @param message message - */ - public LimaRuntimeException(String message) { - super(message); - } - - /** - * Constructs a new exception with the specified detail message and cause. - * - * @param message message - * @param cause cause - */ - public LimaRuntimeException(String message, Throwable cause) { - super(message, cause); - } -} Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/LimaException.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -34,7 +34,7 @@ * Last update : $Date$ * By : $Author$ */ -public class LimaException extends Exception { +public class LimaException extends RuntimeException { /** * serialVersionUID. 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 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -45,7 +45,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; import org.chorem.lima.LimaContext; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.api.HttpServerService; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; @@ -196,7 +195,7 @@ try { DesktopUtil.browse(siteURL.toURI()); } catch (Exception e) { - throw new LimaRuntimeException("Can't open lima website at " + siteURL, e); + throw new RuntimeException("Can't open lima website at " + siteURL, e); } } @@ -450,11 +449,7 @@ String address = LimaConfig.getInstance().getHostAdress(); String url = "http://" + address + ":" + port + "/"; - try { - SwingUtil.openLink(url); - } catch (Exception e) { - throw new LimaRuntimeException("Can't open lima website at " + url, e); - } + SwingUtil.openLink(url); } /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -46,8 +46,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.ImportService; @@ -152,45 +150,41 @@ * Load all accounts from service and display it into tree table. */ protected void loadAllAccounts() { - try { - // default data load - List<Account> accounts = accountService.getAllAccounts(); - Collections.sort(accounts, accountLengthComparator); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d accounts from service", accounts.size())); - } + // default data load + List<Account> accounts = accountService.getAllAccounts(); + Collections.sort(accounts, accountLengthComparator); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d accounts from service", accounts.size())); + } - // render in tree node hierarchy for DefaultTreeTableModel - SortedMap<String, DefaultMutableTreeTableNode> nodeCache = new TreeMap<String, DefaultMutableTreeTableNode>(reverseAccountLengthComparator); - DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(null); - for (Account account : accounts) { - // find parent - DefaultMutableTreeTableNode parentNode = root; - Iterator<Map.Entry<String, DefaultMutableTreeTableNode>> itNodes = nodeCache.entrySet().iterator(); - while (itNodes.hasNext()) { - Map.Entry<String, DefaultMutableTreeTableNode> entry = itNodes.next(); - String accountNumber = entry.getKey(); - if (account.getAccountNumber().startsWith(accountNumber)) { - parentNode = entry.getValue(); - break; - } + // render in tree node hierarchy for DefaultTreeTableModel + SortedMap<String, DefaultMutableTreeTableNode> nodeCache = new TreeMap<String, DefaultMutableTreeTableNode>(reverseAccountLengthComparator); + DefaultMutableTreeTableNode root = new DefaultMutableTreeTableNode(null); + for (Account account : accounts) { + // find parent + DefaultMutableTreeTableNode parentNode = root; + Iterator<Map.Entry<String, DefaultMutableTreeTableNode>> itNodes = nodeCache.entrySet().iterator(); + while (itNodes.hasNext()) { + Map.Entry<String, DefaultMutableTreeTableNode> entry = itNodes.next(); + String accountNumber = entry.getKey(); + if (account.getAccountNumber().startsWith(accountNumber)) { + parentNode = entry.getValue(); + break; } - - // make current node - DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(account); - parentNode.add(node); - - nodeCache.put(account.getAccountNumber(), node); } - // refreshing tree's model - DefaultTreeTableModel model = new AccountTreeTableModel(root); - model.setColumnIdentifiers(Arrays.asList(_("lima.table.number"), _("lima.table.label"))); - JXTreeTable table = view.getAccountsTreeTable(); - table.setTreeTableModel(model); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't load accounts from service"); + // make current node + DefaultMutableTreeTableNode node = new DefaultMutableTreeTableNode(account); + parentNode.add(node); + + nodeCache.put(account.getAccountNumber(), node); } + + // refreshing tree's model + DefaultTreeTableModel model = new AccountTreeTableModel(root); + model.setColumnIdentifiers(Arrays.asList(_("lima.table.number"), _("lima.table.label"))); + JXTreeTable table = view.getAccountsTreeTable(); + table.setTreeTableModel(model); } /** @@ -208,8 +202,8 @@ * @param dialog the account form */ public void addAccount(AccountForm dialog) { - try { + try { Account newAccount = dialog.getAccount(); newAccount = accountService.createAccount(newAccount); @@ -227,8 +221,6 @@ model.insertNodeInto(newNode, node, node.getChildCount()); treeTable.expandPath(new TreePath(model.getPathToRoot(node))); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't add account", ex); } finally { dialog.dispose(); } @@ -320,10 +312,7 @@ //lastPathComponent.setUserObject(account); model.valueForPathChanged(treePath, account); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't update account", ex); } finally { - // close dialog dialog.dispose(); } @@ -347,22 +336,18 @@ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { - try { - accountService.removeAccount(account); + accountService.removeAccount(account); - // add all sub accounts to parent - DefaultTreeTableModel model = (DefaultTreeTableModel)treeTable.getTreeTableModel(); - MutableTreeTableNode parent = (MutableTreeTableNode)lastNode.getParent(); - for (int childIndex = lastNode.getChildCount() -1 ; childIndex >= 0 ; childIndex--) { - MutableTreeTableNode child = (MutableTreeTableNode)lastNode.getChildAt(childIndex); - model.insertNodeInto(child, parent, parent.getChildCount()); - } - - // remove node - model.removeNodeFromParent(lastNode); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't remove account", ex); + // add all sub accounts to parent + DefaultTreeTableModel model = (DefaultTreeTableModel)treeTable.getTreeTableModel(); + MutableTreeTableNode parent = (MutableTreeTableNode)lastNode.getParent(); + for (int childIndex = lastNode.getChildCount() -1 ; childIndex >= 0 ; childIndex--) { + MutableTreeTableNode child = (MutableTreeTableNode)lastNode.getChildAt(childIndex); + model.insertNodeInto(child, parent, parent.getChildCount()); } + + // remove node + model.removeNodeFromParent(lastNode); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -33,7 +33,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -43,8 +42,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; import org.chorem.lima.beans.BalanceTrial; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; @@ -56,7 +53,6 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; - /** * Handler associated with accounts reports view. * By : $Author$ @@ -126,13 +122,7 @@ * @return */ public BalanceTrial getDataList() { - BalanceTrial results = null; - - try { - results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected()); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.balance.listerror"), eee); - } + BalanceTrial results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected()); return results; } @@ -178,12 +168,7 @@ if (selectedBeginDate != null & selectedEndDate != null) { //looks for all blocked fiscal periods - List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); - try { - blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.balance.documentcreationerror"), eee); - } + List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); //tells if the fiscaPeriod as been found and is blocked boolean error = true; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -33,8 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.ImportService; @@ -77,19 +75,15 @@ * Load all available entry book into table. */ protected void loadAllEntryBooks() { - - try { - List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d entry books from service", entryBooks.size())); - } - - EntryBookTableModel model = new EntryBookTableModel(entryBooks); - EntryBookTable table = view.getEntryBooksTable(); - table.setModel(model); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't load entry books", ex); + + List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d entry books from service", entryBooks.size())); } + + EntryBookTableModel model = new EntryBookTableModel(entryBooks); + EntryBookTable table = view.getEntryBooksTable(); + table.setModel(model); } /** @@ -107,17 +101,13 @@ // null == cancel action if (newEntryBook != null) { - try { - // service call - newEntryBook = entryBookService.createEntryBook(newEntryBook); - - // ui refresh - JXTable entryBookTable = view.getEntryBooksTable(); - EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel(); - entryBookTableModel.addEntryBook(newEntryBook); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't add entry book", ex); - } + // service call + newEntryBook = entryBookService.createEntryBook(newEntryBook); + + // ui refresh + JXTable entryBookTable = view.getEntryBooksTable(); + EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel(); + entryBookTableModel.addEntryBook(newEntryBook); } } @@ -140,15 +130,11 @@ // null == cancel action selectedEntryBook = entryBookForm.getEntryBook(); if (selectedEntryBook != null) { - try { - // service call - selectedEntryBook = entryBookService.updateEntryBook(selectedEntryBook); + // service call + selectedEntryBook = entryBookService.updateEntryBook(selectedEntryBook); - // ui refresh - entryBookTableModel.updateEntryBook(selectedEntryBook); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't update entry book", ex); - } + // ui refresh + entryBookTableModel.updateEntryBook(selectedEntryBook); } } @@ -168,13 +154,9 @@ JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { - - try { - entryBookService.removeEntryBook(selectedEntryBook); - entryBookTableModel.removeEntryBook(selectedEntryBook); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't delete entry book", ex); - } + + entryBookService.removeEntryBook(selectedEntryBook); + entryBookTableModel.removeEntryBook(selectedEntryBook); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -33,7 +33,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.text.SimpleDateFormat; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -43,8 +42,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; import org.chorem.lima.beans.ReportsDatas; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.DocumentService; import org.chorem.lima.business.api.FinancialTransactionService; @@ -124,13 +121,8 @@ public ReportsDatas getDataList() { ReportsDatas results = null; if (selectedEntryBook != null) { - try { - results = - reportService.generateEntryBooksReports( - selectedEntryBook, selectedBeginDate, selectedEndDate); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.entrybooksreports.listerror"), eee); - } + results = reportService.generateEntryBooksReports( + selectedEntryBook, selectedBeginDate, selectedEndDate); } return results; } @@ -177,12 +169,7 @@ if (selectedBeginDate != null && selectedEndDate != null) { //looks for all blocked fiscal periods - List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); - try { - blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.entrybooksreports.documentcreationerror"), eee); - } + List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); //tells if the fiscaPeriod as been found and is blocked boolean error = true; 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 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -35,7 +35,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.FiscalPeriodService; @@ -74,20 +73,17 @@ * Init view. */ public void init() { - try { - // get data from service - List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = financialPeriodService. - getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); - Collections.sort(closedPeriodicEntryBooks, new FinancialPeriodComparator()); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d closed periodic entry book", closedPeriodicEntryBooks.size())); - } - // notify ui - view.getFinancialPeriodTableModel().setClosedPeriodicEntryBooks(closedPeriodicEntryBooks); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't get closed periodic eb list", ex); + // get data from service + List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks = financialPeriodService. + getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); + Collections.sort(closedPeriodicEntryBooks, new FinancialPeriodComparator()); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d closed periodic entry book", closedPeriodicEntryBooks.size())); } + + // notify ui + view.getFinancialPeriodTableModel().setClosedPeriodicEntryBooks(closedPeriodicEntryBooks); } /** @@ -99,18 +95,14 @@ FinancialPeriodTableModel model = (FinancialPeriodTableModel) view.getFinancialPeriodTable().getModel(); // blocked it - try { - ClosedPeriodicEntryBook closedPeriodicEntryBook = model.getElementAt(selectedRow); - int response = JOptionPane.showConfirmDialog(view, _("lima.ui.financialperiod.blockmessage"), - _("lima.ui.financialperiod.blocktitle"), - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + ClosedPeriodicEntryBook closedPeriodicEntryBook = model.getElementAt(selectedRow); + int response = JOptionPane.showConfirmDialog(view, _("lima.ui.financialperiod.blockmessage"), + _("lima.ui.financialperiod.blocktitle"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - if (response == JOptionPane.YES_OPTION) { - financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook); - model.fireTableRowsUpdated(selectedRow, selectedRow); - } - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't block financialperiod", eee); + if (response == JOptionPane.YES_OPTION) { + financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook); + model.fireTableRowsUpdated(selectedRow, selectedRow); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -32,9 +32,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaBusinessException; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialStatementService; import org.chorem.lima.business.api.ImportService; @@ -104,17 +101,7 @@ } // add it - try { - treeTableModel.addFinancialStatement(treePath, newFinancialStatementHeader); - } catch (LimaBusinessException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add financialStatementHeader", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - - } catch (LimaException ex) { - throw new LimaRuntimeException(_("lima.financialstatement.addfinancialStatementHeadererror"), ex); - } + treeTableModel.addFinancialStatement(treePath, newFinancialStatementHeader); } } @@ -141,20 +128,7 @@ int selectedRow = view.treeTable.getSelectedRow(); treePath = view.treeTable.getPathForRow(selectedRow); // add it - try { - treeTableModel. - addFinancialStatement(treePath, newFinancialStatementMovement); - } catch (LimaBusinessException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + treeTableModel.addFinancialStatement(treePath, newFinancialStatementMovement); } } @@ -208,15 +182,7 @@ //if action confirmed if (financialStatement != null) { // update it - try { - treeTableModel.updateFinancialStatement( - treePath, financialStatement); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + treeTableModel.updateFinancialStatement(treePath, financialStatement); } } } @@ -241,15 +207,7 @@ FinancialStatement financialStatement = (FinancialStatement) treePath.getLastPathComponent(); - try { - treeTableModel.removeFinancialStatementObject( - treePath, financialStatement); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't delete account", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } + treeTableModel.removeFinancialStatementObject(treePath, financialStatement); } } } @@ -258,13 +216,7 @@ JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); - try { - treeTableModel.refreshTree(); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't refresh model", eee); - } - } + treeTableModel.refreshTree(); //refresh view view.repaint(); } @@ -279,14 +231,7 @@ // if action confirmed if (value != null) { if (form.getDeleteFinancialStatementChart().isSelected()) { - try { - financialStatementService.removeAllFinancialStatement(); - - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't delete financial statement chart", eee); - } - } + financialStatementService.removeAllFinancialStatement(); } FinancialStatementsChartEnum defaultFinancialStatementsEnum = (FinancialStatementsChartEnum) value; @@ -298,15 +243,8 @@ public void financialStatementChartCheck() { - String result; - try { - result = financialStatementService.checkFinancialStatementChart(); - DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); - - } catch (LimaException e) { - log.error("Can't check financialstatement chart", e); - } - + String result = financialStatementService.checkFinancialStatementChart(); + DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -42,8 +42,6 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; import org.chorem.lima.beans.FinancialStatementAmounts; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.DocumentService; import org.chorem.lima.business.api.FinancialStatementService; @@ -246,18 +244,14 @@ } /** - * get all account fot the selected period + * get all account for the selected period * * @return */ public List<FinancialStatementAmounts> getDataList() { List<FinancialStatementAmounts> results = null; if (selectedBeginDate != null && selectedEndDate != null) { - try { - results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.financialstatementreport.listerror"), eee); - } + results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); } return results; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -27,7 +27,6 @@ import static org.nuiton.i18n.I18n._; -import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -35,8 +34,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.api.FiscalPeriodService; import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.entity.FiscalPeriod; @@ -86,12 +83,7 @@ if (selectedBeginDate != null && selectedEndDate != null) { //looks for all blocked fiscal periods - List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); - try { - blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - } catch (LimaException eee) { - throw new LimaRuntimeException("Enable to create document ", eee); - } + List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); //tells if the fiscaPeriod as been found and is blocked boolean error = true; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -33,8 +33,6 @@ import javax.swing.table.AbstractTableModel; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -298,132 +296,127 @@ @Override public void setValueAt(Object value, int row, int column) { - try { - Object currentRow = transactionAndEntries.get(row); + Object currentRow = transactionAndEntries.get(row); - FinancialTransaction currentFinancialTransaction = null; - if (currentRow instanceof FinancialTransaction) { - currentFinancialTransaction = (FinancialTransaction) currentRow; - switch (column) { - case 0: - //update - currentFinancialTransaction.setTransactionDate((Date) value); - break; - case 1: - // FIXME echatellier 20120515 je ne comprend pas pourquoi - // il n'est pas possible de changer le journal si la transaction - // a des entrées - // update : autorisation si le journal est null au moins - if (currentFinancialTransaction.getEntry() != null - && currentFinancialTransaction.getEntryBook() != null) { - // not authorized to change the value - return; + FinancialTransaction currentFinancialTransaction = null; + if (currentRow instanceof FinancialTransaction) { + currentFinancialTransaction = (FinancialTransaction) currentRow; + switch (column) { + case 0: + //update + currentFinancialTransaction.setTransactionDate((Date) value); + break; + case 1: + // FIXME echatellier 20120515 je ne comprend pas pourquoi + // il n'est pas possible de changer le journal si la transaction + // a des entrées + // update : autorisation si le journal est null au moins + if (currentFinancialTransaction.getEntry() != null + && currentFinancialTransaction.getEntryBook() != null) { + // not authorized to change the value + return; + } + currentFinancialTransaction.setEntryBook((EntryBook) value); + break; + } + + // update transaction + financialTransactionService.updateFinancialTransaction(currentFinancialTransaction); + + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; + currentFinancialTransaction = currentEntry.getFinancialTransaction(); + boolean updateTransaction = false; + switch (column) { + case 2: + String voucher = ((String) value).trim(); + + int firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + + // let's update the voucher of all entries of + // the transaction + + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setVoucher(voucher); } - currentFinancialTransaction.setEntryBook((EntryBook) value); - break; - } - - // update transaction - financialTransactionService.updateFinancialTransaction(currentFinancialTransaction); - - } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - currentFinancialTransaction = currentEntry.getFinancialTransaction(); - boolean updateTransaction = false; - switch (column) { - case 2: - String voucher = ((String) value).trim(); - - int firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { - - // let's update the voucher of all entries of - // the transaction - - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setVoucher(voucher); - } - updateTransaction = true; - } else { - - // not on first row, just update this entry voucher - currentEntry.setVoucher(voucher); + updateTransaction = true; + } else { + + // not on first row, just update this entry voucher + currentEntry.setVoucher(voucher); + } + break; + case 3: + Account account = (Account) value; + currentEntry.setAccount(account); + // let's copy the account description + String description1 = account.getLabel(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + // let's update the description of all entries of + // the transaction + + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setDescription(description1); } - break; - case 3: - Account account = (Account) value; - currentEntry.setAccount(account); - // let's copy the account description - String description1 = account.getLabel(); - firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { - // let's update the description of all entries of - // the transaction - - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setDescription(description1); - } - updateTransaction = true; - } else { - // not on first row, just update this entry description - currentEntry.setDescription(description1); + updateTransaction = true; + } else { + // not on first row, just update this entry description + currentEntry.setDescription(description1); + } + break; + case 4: + String description = ((String) value).trim(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + + // let's update the description of all entries of + // the transaction + + for (Entry entry : currentFinancialTransaction.getEntry()) { + entry.setDescription(description); } - break; - case 4: - String description = ((String) value).trim(); - firstEntryRow = getFirstEntry(row); - if (row == firstEntryRow) { - - // let's update the description of all entries of - // the transaction - - for (Entry entry : currentFinancialTransaction.getEntry()) { - entry.setDescription(description); - } - updateTransaction = true; - } else { - - // not on first row, just update this entry description - currentEntry.setDescription(description); - } - break; - case 5: - currentEntry.setLettering((String) value); - break; - case 6: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(true); - break; - case 7: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(false); - break; - } - - // some modification must update all other - // first row modification update following rows - if (updateTransaction) { - // FIXME echatellier 20120413 make a single service call - for (Entry entry : currentFinancialTransaction.getEntry()) { - financialTransactionService.updateEntry(entry); + updateTransaction = true; + } else { + + // not on first row, just update this entry description + currentEntry.setDescription(description); } - } else { - financialTransactionService.updateEntry(currentEntry); + break; + case 5: + currentEntry.setLettering((String) value); + break; + case 6: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(true); + break; + case 7: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(false); + break; + } + + // some modification must update all other + // first row modification update following rows + if (updateTransaction) { + // FIXME echatellier 20120413 make a single service call + for (Entry entry : currentFinancialTransaction.getEntry()) { + financialTransactionService.updateEntry(entry); } + } else { + financialTransactionService.updateEntry(currentEntry); } - - // FIXME echatellier 20120413 une modification des dates fait que l'ordre - // devient faux - int trIndex = indexOf(currentFinancialTransaction); - int endIndex = trIndex; - if (currentFinancialTransaction.getEntry() != null) { - endIndex += currentFinancialTransaction.getEntry().size(); - } - fireTableRowsUpdated(trIndex, endIndex); + } - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't propagate data modification to service", ex); + // FIXME echatellier 20120413 une modification des dates fait que l'ordre + // devient faux + int trIndex = indexOf(currentFinancialTransaction); + int endIndex = trIndex; + if (currentFinancialTransaction.getEntry() != null) { + endIndex += currentFinancialTransaction.getEntry().size(); } + fireTableRowsUpdated(trIndex, endIndex); } public Object getElementAt(int row) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -41,8 +41,6 @@ import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.EntryBookService; import org.chorem.lima.business.api.FinancialPeriodService; @@ -100,26 +98,23 @@ * Init all combo box in view. */ public void init() { - try { - // fiscal periods - List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); - } - if (!fiscalPeriods.isEmpty()) { - view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(0)); - } - // entry books - List<EntryBook> allEntryBooks = entryBookService.getAllEntryBooks(); - view.getEntryBookComboBoxModel().setObjects(allEntryBooks); - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); - } - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't init financial transaction view", ex); + // fiscal periods + List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + view.getFiscalPeriodComboBoxModel().setObjects(fiscalPeriods); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d fiscal periods", fiscalPeriods.size())); } + if (!fiscalPeriods.isEmpty()) { + view.getFiscalPeriodComboBoxModel().setSelectedItem(fiscalPeriods.get(0)); + } + + // entry books + List<EntryBook> allEntryBooks = entryBookService.getAllEntryBooks(); + view.getEntryBookComboBoxModel().setObjects(allEntryBooks); + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); + } } /** @@ -131,20 +126,16 @@ if ( event.getStateChange() == ItemEvent.SELECTED ) { FiscalPeriod selectedFiscalPeriod = (FiscalPeriod) event.getItem(); - try { - List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), - selectedFiscalPeriod.getEndDate()); - - if (log.isDebugEnabled()) { - log.debug(String.format("Loaded %d financial periods", financialPeriods.size())); - } - view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); - - // update transactions - updateFinancialTransactions(); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't update financial period list", ex); + List<FinancialPeriod> financialPeriods = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), + selectedFiscalPeriod.getEndDate()); + + if (log.isDebugEnabled()) { + log.debug(String.format("Loaded %d financial periods", financialPeriods.size())); } + view.getFinancialPeriodComboBoxModel().setObjects(financialPeriods); + + // update transactions + updateFinancialTransactions(); } } @@ -185,27 +176,23 @@ return; } - try { - List<Object> transAndEntries = new ArrayList<Object>(); - List<FinancialTransaction> transactions; - if (entryBook == null) { - transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod); - } else { - transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook); - } - - // move it to unique collection for table rendering - for (FinancialTransaction transaction : transactions) { - transAndEntries.add(transaction); - List<Entry> entries = (List<Entry>) transaction.getEntry(); - Collections.sort(entries, new EntryComparator()); - transAndEntries.addAll(entries); - } - - view.getFinancialTransactionTableModel().setTransactionAndEntries(transAndEntries); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't get transactions list", ex); + List<Object> transAndEntries = new ArrayList<Object>(); + List<FinancialTransaction> transactions; + if (entryBook == null) { + transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod); + } else { + transactions = financialTransactionService.getAllFinancialTransactions(financialPeriod, entryBook); } + + // move it to unique collection for table rendering + for (FinancialTransaction transaction : transactions) { + transAndEntries.add(transaction); + List<Entry> entries = (List<Entry>) transaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + transAndEntries.addAll(entries); + } + + view.getFinancialTransactionTableModel().setTransactionAndEntries(transAndEntries); } /** @@ -226,18 +213,14 @@ FinancialTransactionTable table = view.getFinancialTransactionTable(); if (clipBoard instanceof Entry) { - try { - int index = addEntry((Entry) clipBoard, indexSelectedRow); + int index = addEntry((Entry) clipBoard, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't past entry", eee); - } + //select the new line + ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); } } @@ -245,9 +228,8 @@ * @param entry * @param row * @return int: indexOf new Entry - * @throws LimaException */ - protected int addEntry(Entry entry, int row) throws LimaException { + protected int addEntry(Entry entry, int row) { FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); FinancialTransaction currentTransaction = null; int financialTransactionRow = 0; @@ -285,25 +267,19 @@ FinancialTransactionTable table = view.getFinancialTransactionTable(); ListSelectionModel selectionModel = table.getSelectionModel(); - try { - addFinancialTransaction2(); - //select the new line - int numberRow = table.getRowCount(); - selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); - //focus on first column - table.changeSelection(numberRow, 0, false, false); - table.scrollCellToVisible(numberRow, 0); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't add financialtransaction", eee); - } + addFinancialTransaction2(); + //select the new line + int numberRow = table.getRowCount(); + selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); + //focus on first column + table.changeSelection(numberRow, 0, false, false); + table.scrollCellToVisible(numberRow, 0); } /** * Add new transaction after calling service. - * - * @throws LimaException */ - public void addFinancialTransaction2() throws LimaException { + public void addFinancialTransaction2() { FinancialPeriod financialPeriod = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem(); EntryBook entryBook = (EntryBook)view.getEntryBookComboBox().getSelectedItem(); @@ -366,40 +342,36 @@ defaultDescription = (String) tableModel.getValueAt(firstentryBookrow, 4); } - try { - // creates the new entry - Entry entry = new EntryImpl(); - entry.setVoucher(defaultVoucher); - entry.setDescription(defaultDescription); - // check if current row is a transaction or an entry - FinancialTransaction currentTransaction = null; - Object currentRow = tableModel.getElementAt(indexSelectedRow); - if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction) currentRow; - } else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry) currentRow; - //get back the parent transaction of the entry - currentTransaction = currentEntry.getFinancialTransaction(); - } - // create it in service - entry.setFinancialTransaction(currentTransaction); - Entry newEntry = financialTransactionService.createEntry(entry); - currentTransaction.addEntry(newEntry); + // creates the new entry + Entry entry = new EntryImpl(); + entry.setVoucher(defaultVoucher); + entry.setDescription(defaultDescription); + // check if current row is a transaction or an entry + FinancialTransaction currentTransaction = null; + Object currentRow = tableModel.getElementAt(indexSelectedRow); + if (currentRow instanceof FinancialTransaction) { + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); + } + // create it in service + entry.setFinancialTransaction(currentTransaction); + Entry newEntry = financialTransactionService.createEntry(entry); + currentTransaction.addEntry(newEntry); - // add it in ui - int addIndex = tableModel.indexOf(currentTransaction) + - currentTransaction.getEntry().size(); - tableModel.addRow(newEntry, addIndex); + // add it in ui + int addIndex = tableModel.indexOf(currentTransaction) + + currentTransaction.getEntry().size(); + tableModel.addRow(newEntry, addIndex); - //select the new line - ListSelectionModel selectionModel = table.getSelectionModel(); - selectionModel.setSelectionInterval( - addIndex, addIndex); - table.changeSelection(addIndex, 1, false, false); + //select the new line + ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval( + addIndex, addIndex); + table.changeSelection(addIndex, 1, false, false); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't add emptyentry", ex); - } } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); @@ -434,25 +406,21 @@ } if (response == JOptionPane.YES_OPTION) { - try { - if (selectedValue instanceof FinancialTransaction) { - FinancialTransaction currentTransaction = - (FinancialTransaction) selectedValue; - financialTransactionService.removeFinancialTransaction(currentTransaction); - - } else if (selectedValue instanceof Entry) { - Entry currentEntry = (Entry) selectedValue; - financialTransactionService.removeEntry(currentEntry); - currentEntry.getFinancialTransaction().removeEntry(currentEntry); - } - tableModel.deleteRow(indexSelectedRow); - - //select the upper line - ListSelectionModel selectionModel = table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't remove transaction or entry", ex); + if (selectedValue instanceof FinancialTransaction) { + FinancialTransaction currentTransaction = + (FinancialTransaction) selectedValue; + financialTransactionService.removeFinancialTransaction(currentTransaction); + + } else if (selectedValue instanceof Entry) { + Entry currentEntry = (Entry) selectedValue; + financialTransactionService.removeEntry(currentEntry); + currentEntry.getFinancialTransaction().removeEntry(currentEntry); } + tableModel.deleteRow(indexSelectedRow); + + //select the upper line + ListSelectionModel selectionModel = table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); } } else { if (log.isWarnEnabled()) { 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 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -38,9 +38,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.FinancialTransactionSearch; -import org.chorem.lima.business.LimaBusinessException; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialPeriodService; import org.chorem.lima.business.api.FinancialTransactionService; @@ -53,7 +50,6 @@ import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.DialogHelper; /** * Basic transaction table model. @@ -120,11 +116,8 @@ || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null || financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null || financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null)) { - try { - results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't get transaction list", eee); - } + + results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); } return results; @@ -347,23 +340,18 @@ /** * @return int: indexOf new FianancialTransaction - * @throws LimaException */ - public int addFinancialTransaction() throws LimaException { + public int addFinancialTransaction() { /* Calling transaction service */ FinancialTransaction financialTransaction = new FinancialTransactionImpl(); + int index = -1; //if a period is selected if (selectedFiscalPeriod != null) { List<FinancialPeriod> financialPeriodsList = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - FinancialPeriod financialPeriod; - if (financialPeriodsList != null) { - financialPeriod = financialPeriodsList.get(0); - } else { - throw new LimaException("Can't set new transaction"); - } + FinancialPeriod financialPeriod = financialPeriodsList.get(0); //financialTransaction.setSelectedFinancialPeriod(selectedFiscalPeriod); // get today @@ -396,22 +384,19 @@ //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); - int row = cacheDataList.indexOf(fTransaction); - fireTableRowsInserted(row, row); - return row; + index = cacheDataList.indexOf(fTransaction); + fireTableRowsInserted(index, index); //fireTableDataChanged(); - } else { - throw new LimaBusinessException("No financial period selected"); } + return index; } /** * @param value * @param row * @return int: indexOf new Entry - * @throws LimaException */ - public int addEmptyEntry(Object value, int row) throws LimaException { + public int addEmptyEntry(Object value, int row) { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -453,15 +438,8 @@ break; } // notify service for modification - try { - financialTransactionService. + financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update financial transaction", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } //update the financial transaction in entire financialTransactionRow = cacheDataList.indexOf(currentRow); @@ -489,14 +467,9 @@ currentEntry.setLettering((String) value); break; } - try { - financialTransactionService.updateEntry(currentEntry); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update entry", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } + + financialTransactionService.updateEntry(currentEntry); + //update the financial transaction in entire financialTransactionRow = cacheDataList.indexOf(((Entry) currentRow). @@ -520,9 +493,8 @@ * * @param object * @param row - * @throws LimaException */ - public void removeObject(Object object, int row) throws LimaException { + public void removeObject(Object object, int row) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = @@ -542,9 +514,8 @@ * @param description * @param row * @return int: indexOf new Entry - * @throws LimaException */ - public int addEmptyEntry(Object value, String description, int row) throws LimaException { + public int addEmptyEntry(Object value, String description, int row) { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -576,9 +547,8 @@ * @param entry * @param row * @return int: indexOf new Entry - * @throws LimaException */ - public int addEntry(Object value, Entry entry, int row) throws LimaException { + public int addEntry(Object value, Entry entry, int row) { FinancialTransaction currentTransaction = null; int financialTransactionRow = 0; Object currentRow = cacheDataList.get(row); 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 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -37,8 +37,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.utils.EntryComparator; @@ -105,17 +103,13 @@ protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); if (selectedFiscalPeriod != null) { - try { - List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); - for (FinancialTransaction financialtransaction : financialtransactions) { - results.add(financialtransaction); - List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't get transaction list", eee); + List<FinancialTransaction> financialtransactions = + financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); + for (FinancialTransaction financialtransaction : financialtransactions) { + results.add(financialtransaction); + List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); } } @@ -336,9 +330,8 @@ * @param description * @param row * @return int: indexOf new Entry - * @throws LimaException */ - public int addEmptyEntry(Object value, String description, int row) throws LimaException { + public int addEmptyEntry(Object value, String description, int row) { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -383,12 +376,9 @@ break; } // notify service for modification - try { - financialTransactionService. + financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't update financial transaction", eee); - } + //update the financial transaction in entire // financialTransactionRow = // cacheDataList.indexOf(currentRow); @@ -416,11 +406,9 @@ currentEntry.setLettering((String) value); break; } - try { - financialTransactionService.updateEntry(currentEntry); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't update entry", eee); - } + + financialTransactionService.updateEntry(currentEntry); + //update the financial transaction in entire // financialTransactionRow = // cacheDataList.indexOf(((Entry) currentRow). @@ -446,9 +434,8 @@ * * @param object * @param row - * @throws LimaException */ - public void removeObject(Object object, int row) throws LimaException { + public void removeObject(Object object, int row) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = 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 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -32,8 +32,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; @@ -68,20 +66,16 @@ int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - try { - //copy + paste the description - String description = (String) tableModel.getValueAt(indexSelectedRow, 4); - int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); - //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't add emptyentry", eee); - } + //copy + paste the description + String description = (String) tableModel.getValueAt(indexSelectedRow, 4); + int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); + //select the new line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); @@ -114,16 +108,11 @@ _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - - try { - tableModel.removeObject(selectedValue, indexSelectedRow); - //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't remove transaction or entry", eee); - } + tableModel.removeObject(selectedValue, indexSelectedRow); + //select the upper line + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); } } else { if (log.isWarnEnabled()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -39,7 +39,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; @@ -95,12 +94,8 @@ * Reload fiscal period list from service and update ui. */ public void loadAllFiscalPeriod() { - try { - List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods(); - view.getFiscalPeriodTableModel().setFiscalPeriods(periods); - } catch (LimaException ex) { - throw new LimaRuntimeException("Cant get fiscal perdiods", ex); - } + List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods(); + view.getFiscalPeriodTableModel().setFiscalPeriods(periods); } /** @@ -128,12 +123,8 @@ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); } if (response == JOptionPane.YES_OPTION) { - try { - fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod); - model.addFiscalPeriod(fiscalPeriod); - } catch (LimaException ex) { - throw new LimaRuntimeException("Can't add fiscal period", ex); - } + fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod); + model.addFiscalPeriod(fiscalPeriod); } } } @@ -181,43 +172,35 @@ FiscalPeriodTableModel model = view.getFiscalPeriodTableModel(); FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow); - try { - - //check if the user want to block the fiscal year - int response = JOptionPane.showConfirmDialog(view, - _("lima.ui.fiscalperiod.block.confirmation"), - _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE); - if (response == JOptionPane.YES_OPTION) { - //use to tell if the user wants to create a new fiscal year - boolean newyear = false; - //check if two fiscal periods are open - if (model.getRowCount() - 1 != selectedRow) { - newyear = true; //two are open - } else { - //check if the user wants to create a new fiscal year - response = JOptionPane.showConfirmDialog(view, - _("lima.ui.fiscalperiod.block.newyear"), - _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - // create a new fiscal year - if (response == JOptionPane.YES_OPTION) { - addFiscalPeriod(); - newyear = true; - } + //check if the user want to block the fiscal year + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.confirmation"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE); + if (response == JOptionPane.YES_OPTION) { + //use to tell if the user wants to create a new fiscal year + boolean newyear = false; + //check if two fiscal periods are open + if (model.getRowCount() - 1 != selectedRow) { + newyear = true; //two are open + } else { + //check if the user wants to create a new fiscal year + response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.newyear"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + // create a new fiscal year + if (response == JOptionPane.YES_OPTION) { + addFiscalPeriod(); + newyear = true; } - - // FIXME report a nouveau et bloquage en une seule opération - // transactionnelle - addRetainedEarnings(selectedFiscalPeriod, newyear); - selectedFiscalPeriod = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod); - model.updateFiscalPeriod(selectedFiscalPeriod); } - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't block fiscalperiod", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + + // FIXME report a nouveau et bloquage en une seule opération + // transactionnelle + addRetainedEarnings(selectedFiscalPeriod, newyear); + selectedFiscalPeriod = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod); + model.updateFiscalPeriod(selectedFiscalPeriod); } } @@ -231,56 +214,48 @@ @Deprecated public void addRetainedEarnings(FiscalPeriod selectedFiscalPeriod, boolean newyear) { - try { - boolean found = false; - List<FinancialTransaction> financialTransactionsList = - financialTransactionService.getAllFinancialTransactions( - selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - //check if they are at least one transaction to be report - if (!financialTransactionsList.isEmpty()) { - int i = 0; - while (i < financialTransactionsList.size() && !found) { - Collection<Entry> entryList = financialTransactionsList.get(i).getEntry(); - for (Entry entry : entryList) { - if (Integer.valueOf(entry.getAccount().getAccountNumber().substring(0, 1)) < 6 - && !entry.getAmount().equals(BigDecimal.ZERO)) { - found = true; - } + boolean found = false; + List<FinancialTransaction> financialTransactionsList = + financialTransactionService.getAllFinancialTransactions( + selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); + //check if they are at least one transaction to be report + if (!financialTransactionsList.isEmpty()) { + int i = 0; + while (i < financialTransactionsList.size() && !found) { + Collection<Entry> entryList = financialTransactionsList.get(i).getEntry(); + for (Entry entry : entryList) { + if (Integer.valueOf(entry.getAccount().getAccountNumber().substring(0, 1)) < 6 + && !entry.getAmount().equals(BigDecimal.ZERO)) { + found = true; } - i++; } + i++; } - //report if they are at least one transaction to be report - if (found) { - //check if the user wants to report datas - int response = JOptionPane.showConfirmDialog(view, - _("lima.ui.fiscalperiod.block.addretainedearnings"), - _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - //ask user for the entrybook to use for retained earnings - if (response == JOptionPane.YES_OPTION) { - //Sets EntryBook - EntryBook newEntryBook = new EntryBookImpl(); - RetainedEarningsEntryBookForm entryBookForm = - new RetainedEarningsEntryBookForm(view); - entryBookForm.setEntryBook(newEntryBook); - // jaxx constructor don't call super() ? - entryBookForm.setLocationRelativeTo(view); - entryBookForm.setVisible(true); - // null == cancel action - EntryBook entryBook = entryBookForm.getEntryBook(); - if (entryBook != null) { - fiscalPeriodService.addRetainedEarnings( - selectedFiscalPeriod, newyear, entryBook); - } + } + //report if they are at least one transaction to be report + if (found) { + //check if the user wants to report datas + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.addretainedearnings"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + //ask user for the entrybook to use for retained earnings + if (response == JOptionPane.YES_OPTION) { + //Sets EntryBook + EntryBook newEntryBook = new EntryBookImpl(); + RetainedEarningsEntryBookForm entryBookForm = + new RetainedEarningsEntryBookForm(view); + entryBookForm.setEntryBook(newEntryBook); + // jaxx constructor don't call super() ? + entryBookForm.setLocationRelativeTo(view); + entryBookForm.setVisible(true); + // null == cancel action + EntryBook entryBook = entryBookForm.getEntryBook(); + if (entryBook != null) { + fiscalPeriodService.addRetainedEarnings( + selectedFiscalPeriod, newyear, entryBook); } } - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't set net income", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -53,8 +53,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.api.ExportService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.utils.ImportExportEntityEnum; @@ -122,7 +120,7 @@ final Boolean importMode = importExportMethode.getImportMode(); new SwingWorker<String, Void>() { @Override - protected String doInBackground() throws LimaException { + protected String doInBackground() { String datas; String result = ""; switch (importExportMethodeF) { @@ -234,12 +232,14 @@ } } } - } catch (InterruptedException eee) { + } catch (InterruptedException ex) { if (log.isErrorEnabled()) { - log.error("Can't get result message", eee); + log.error("Can't get result message", ex); } } catch (ExecutionException ex) { - throw new LimaRuntimeException("Error during import", ex); + if (log.isErrorEnabled()) { + log.error("Can't get result message", ex); + } } } }.execute(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -45,8 +45,6 @@ import org.chorem.lima.LimaConfig; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.ReportsDatas; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.FiscalPeriodService; @@ -131,23 +129,20 @@ */ public List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); - try { - balanceTrialCache = reportService.generateLedger(selectedBeginDate, - selectedEndDate, selectedAccounts, - view.getMovmentedFilter().isSelected()); - if (balanceTrialCache.getReportsDatas() != null) { - for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { - results.add(reportsDatas); - List<Entry> entries = reportsDatas.getListEntry(); - if (entries != null) { - Collections.sort(entries, new EntryComparator()); - results.addAll(entries); - } + balanceTrialCache = reportService.generateLedger(selectedBeginDate, + selectedEndDate, selectedAccounts, + view.getMovmentedFilter().isSelected()); + if (balanceTrialCache.getReportsDatas() != null) { + for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { + results.add(reportsDatas); + List<Entry> entries = reportsDatas.getListEntry(); + if (entries != null) { + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); } } - } catch (LimaException eee) { - throw new LimaRuntimeException("Can't get entries list", eee); } + return results; } @@ -190,12 +185,7 @@ if (selectedBeginDate != null && selectedEndDate != null) { //looks for all blocked fiscal periods - List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); - try { - blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.ledger.documentcreationerror"), eee); - } + List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); //tells if the fiscaPeriod as been found and is blocked boolean error = true; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -37,8 +37,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.ImportService; @@ -48,7 +46,6 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.DialogHelper; /** * Basic transaction table model. @@ -118,18 +115,14 @@ protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); if (selectedBeginDate != null && selectedEndDate != null) { - try { - List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllFinancialTransactions( - selectedBeginDate, selectedEndDate); - 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) { - throw new LimaRuntimeException(_("lima.lettering.listerror"), eee); + List<FinancialTransaction> financialtransactions = + financialTransactionService.getAllFinancialTransactions( + selectedBeginDate, selectedEndDate); + for (FinancialTransaction financialtransaction : financialtransactions) { + results.add(financialtransaction); + List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); } } return results; @@ -392,15 +385,9 @@ currentEntry.setLettering((String) value); break; } - try { - financialTransactionService.updateEntry(currentEntry); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.error("Can't update entry", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } + financialTransactionService.updateEntry(currentEntry); + //update the financial transaction in entire financialTransactionRow = getDataList().indexOf(((Entry) currentRow). Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2012-05-16 12:41:14 UTC (rev 3425) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2012-05-16 13:02:27 UTC (rev 3426) @@ -35,14 +35,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.VatStatementAmounts; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.LimaRuntimeException; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.business.api.ImportService; import org.chorem.lima.business.api.VatStatementService; import org.chorem.lima.service.LimaServiceFactory; -import org.nuiton.topia.TopiaException; public class VatReportTableModel extends AbstractTableModel implements ServiceListener { @@ -88,28 +85,19 @@ LimaServiceFactory.addServiceListener(ImportService.class, this); } - protected List<VatStatementAmounts> getDataList() throws TopiaException { + protected List<VatStatementAmounts> getDataList() { List<VatStatementAmounts> list = null; if (selectedBeginDate != null || selectedEndDate != null) { - try { - list = vatStatementService.vatStatementReport( - getBeginDate(), - getEndDate()); - } catch (LimaException eee) { - throw new LimaRuntimeException(_("lima.vatreport.listerror"), eee); - } + list = vatStatementService.vatStatementReport( + getBeginDate(), getEndDate()); } return list; } public void refresh() { - try { - cacheDataList = getDataList(); - } catch (TopiaException eee) { - throw new LimaRuntimeException("Can't get VAT list", eee); - } + cacheDataList = getDataList(); fireTableDataChanged(); }