Author: echatellier Date: 2012-04-25 14:25:38 +0200 (Wed, 25 Apr 2012) New Revision: 3396 Url: http://chorem.org/repositories/revision/lima/3396 Log: Begin unbalanced transaction refactoring Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2012-04-25 11:39:33 UTC (rev 3395) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2012-04-25 12:25:38 UTC (rev 3396) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 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 @@ -48,7 +48,6 @@ import java.math.BigDecimal; import java.util.Date; - /** * Table des transaction qui ajoute des comportement (keys). * 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-04-25 11:39:33 UTC (rev 3395) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-04-25 12:25:38 UTC (rev 3396) @@ -49,7 +49,6 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.DialogHelper; /** * Basic transaction table model. @@ -388,10 +387,7 @@ financialTransactionService. updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update financial transaction", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); + throw new LimaRuntimeException("Can't update financial transaction", eee); } //update the financial transaction in entire // financialTransactionRow = @@ -423,10 +419,7 @@ try { financialTransactionService.updateEntry(currentEntry); } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update entry", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); + throw new LimaRuntimeException("Can't update entry", eee); } //update the financial transaction in entire // financialTransactionRow = Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2012-04-25 11:39:33 UTC (rev 3395) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2012-04-25 12:25:38 UTC (rev 3396) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2008 - 2010 CodeLutin + Copyright (C) 2008 - 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 @@ -28,7 +28,6 @@ javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel - org.chorem.lima.ui.LimaRendererUtil </import> <FinancialTransactionUnbalancedViewHandler id="handler" javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/> @@ -42,26 +41,17 @@ ]]> </script> - <!-- <JPopupMenu id="MenuRightPanel"> - <JMenuItem text="lima.add.transaction" onActionPerformed='addEmptyTransaction()'/> - <JMenuItem text="lima.print"/> - </JPopupMenu> - <JPopupMenu id="MenuRightTransaction"> - <JMenuItem text="lima.add" onActionPerformed='addEmptyTransaction()'/> - <JMenuItem text="lima.print"/> - </JPopupMenu> --> - <row weightx="1" weighty="0" anchor="center"> <cell anchor="west"> - <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/> + <JButton text="lima.ui.common.refresh" onActionPerformed="getHandler().refresh()"/> </cell> <cell anchor="east"> - <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> + <JLabel id="fiscalPeriodLabel" text="lima.ui.financialtransaction.fiscalyear"/> </cell> <cell anchor="west"> <JComboBox id="fiscalPeriodComboBox" model="{modelFiscalPeriod}" - renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" + renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}" onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem()); getHandler().refresh()" editable="false"/> 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-04-25 11:39:33 UTC (rev 3395) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2012-04-25 12:25:38 UTC (rev 3396) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 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 @@ -25,18 +25,18 @@ package org.chorem.lima.ui.financialtransactionunbalanced; +import static org.nuiton.i18n.I18n._; + +import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; + 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; -import org.chorem.lima.util.DialogHelper; -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; - -import static org.nuiton.i18n.I18n._; - /** * Handler associated with financial transaction view. * @@ -54,12 +54,6 @@ protected FinancialTransactionUnbalancedView view; - protected FinancialTransactionUnbalancedTable table; - - protected FinancialTransactionUnbalancedTableModel tableModel; - - protected FiscalPeriodComboBoxModel comboBoxModel; - protected FinancialTransactionUnbalancedViewHandler(FinancialTransactionUnbalancedView view) { this.view = view; } @@ -68,8 +62,8 @@ //add a new entry to the selected transaction public void addEmptyEntry() { - table = view.getFinancialTransactionUnbalancedTable(); - tableModel = view.getFinancialTransactionUnbalancedTableModel(); + FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable(); + FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { @@ -86,11 +80,7 @@ table.changeSelection(index, 1, false, false); table.requestFocusInWindow(); } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add emptyentry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); - + throw new LimaRuntimeException("Can't add emptyentry", eee); } } else { if (log.isWarnEnabled()) { @@ -103,13 +93,11 @@ * Delete selected row in table (could be transaction or entry). * <p/> * Called by tableModel. - * - * @throws LimaException */ public void deleteSelectedRow() { - table = view.getFinancialTransactionUnbalancedTable(); - tableModel = view.getFinancialTransactionUnbalancedTableModel(); + FinancialTransactionUnbalancedTable table = view.getFinancialTransactionUnbalancedTable(); + FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { @@ -134,10 +122,7 @@ table.getSelectionModel(); selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't remove transaction or entry", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + throw new LimaRuntimeException("Can't remove transaction or entry", eee); } } } else { @@ -148,10 +133,10 @@ } public void refresh() { - tableModel = view.getFinancialTransactionUnbalancedTableModel(); + FinancialTransactionUnbalancedTableModel tableModel = view.getFinancialTransactionUnbalancedTableModel(); tableModel.refresh(); - comboBoxModel = view.getModelFiscalPeriod(); + FiscalPeriodComboBoxModel comboBoxModel = view.getModelFiscalPeriod(); comboBoxModel.refresh(); } }