Author: echatellier Date: 2012-04-05 16:09:35 +0200 (Thu, 05 Apr 2012) New Revision: 3354 Url: http://chorem.org/repositories/revision/lima/3354 Log: Modification (modele/service) de la gestion des journaux. Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/package-info.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/package-info.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountImportForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookImportForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -130,7 +130,7 @@ try { FinancialTransactionDAO financialTransactionDAO = LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaTransaction); // Check if entrybook have entries - int nbfinancialtransaction = financialTransactionDAO.findAllByEntryBook(entryBook).size(); + long nbfinancialtransaction = financialTransactionDAO.getCountByEntryBook(entryBook); if (nbfinancialtransaction != 0) { throw new LimaBusinessException(_("lima-business.defaultaccountingrules.deleteentrybookerror")); } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -25,6 +25,13 @@ package org.chorem.lima.business.ejb; +import static org.nuiton.i18n.I18n._; + +import java.util.ArrayList; +import java.util.List; + +import javax.ejb.Stateless; + import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaConfig; @@ -42,12 +49,6 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; -import javax.ejb.Stateless; -import java.util.ArrayList; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - /** * Implémente la fonction multi-EntryBook. Il est possible de créer ici le * EntryBook des ventes, le EntryBook des achats, etc. @@ -64,10 +65,11 @@ } @Override - public void createEntryBookWithTransaction(EntryBook entryBook, + public EntryBook createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) throws LimaException { + EntryBook result = null; try { // check if entrybook with is name already exist @@ -82,7 +84,7 @@ } // creation du EntryBook - entryBookDAO.create(entryBook); + result = entryBookDAO.create(entryBook); //create ClosedPeriodicEntryBook for all unblocked financial period ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = @@ -107,22 +109,25 @@ } catch (TopiaException ex) { doCatch(topiaContext, ex); } - + return result; } @Override - public void createEntryBook(EntryBook entryBook) throws LimaException { + public EntryBook createEntryBook(EntryBook entryBook) throws LimaException { TopiaContext transaction = beginTransaction(rootContext); + EntryBook result = null; try { - createEntryBookWithTransaction(entryBook, transaction); + result = createEntryBookWithTransaction(entryBook, transaction); } catch (Exception ex) { doCatch(transaction, ex); } finally { doFinally(transaction); } + + return result; } @Override @@ -147,16 +152,17 @@ } @Override - public void updateEntryBook(EntryBook entryBook) throws LimaException { + public EntryBook updateEntryBook(EntryBook entryBook) throws LimaException { TopiaContext transaction = beginTransaction(rootContext); + EntryBook result = null; try { EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction); // creation du EntryBook - entryBookDAO.update(entryBook); + result = entryBookDAO.update(entryBook); commitTransaction(transaction); } catch (Exception ex) { @@ -164,6 +170,8 @@ } finally { doFinally(transaction); } + + return result; } @Override Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookService.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -66,7 +66,7 @@ * @param entryBook * @throws LimaException */ - void createEntryBook(EntryBook entryBook) throws LimaException; + EntryBook createEntryBook(EntryBook entryBook) throws LimaException; /** * Permet de modifier un journal. @@ -74,7 +74,7 @@ * @param entryBook journal * @throws LimaException */ - void updateEntryBook(EntryBook entryBook) throws LimaException; + EntryBook updateEntryBook(EntryBook entryBook) throws LimaException; /** * Permet d'effacer un EntryBook dans la base de données. Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejbinterface/EntryBookServiceLocal.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -45,6 +45,6 @@ @Local public interface EntryBookServiceLocal extends EntryBookService { - void createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) throws LimaException; + EntryBook createEntryBookWithTransaction(EntryBook entryBook, TopiaContext topiaContext) throws LimaException; } Added: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java (rev 0) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -0,0 +1,54 @@ +/* + * #%L + * Lima callao + * + * $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.entity; + +import org.nuiton.topia.TopiaException; + +/** + * Ajout de requetes specifiques aux financial transaction sur le DAO. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FinancialTransactionDAO extends FinancialTransactionDAOImpl<FinancialTransaction> { + + /** + * Return how many transaction are found with specified entryBook. + * + * @param entryBook entry book + * @return transaction referencing entry book + * @throws TopiaException + */ + public long getCountByEntryBook(EntryBook entryBook) throws TopiaException { + String query = "SELECT count(*) FROM " + FinancialTransaction.class.getName() + " t WHERE t.entryBook = :entryBook"; + Number count = (Number)context.find(query, "entryBook", entryBook).get(0); + return count.longValue(); + } + +} //FinancialTransactionDAO Property changes on: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAO.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -76,4 +76,4 @@ </cell> </row> </Table> -</JDialog> \ No newline at end of file +</JDialog> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountImportForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountImportForm.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountImportForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -22,8 +22,7 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> - -<JDialog modal="true" +<JDialog title="lima.ui.account.importtitle" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> @@ -51,7 +50,7 @@ </cell> </row> <row> - <cell> + <cell anchor="west"> <JRadioButton text='lima.ui.account.shortened' value='{AccountsChartEnum.SHORTENED}' buttonGroup="{buttonGroup}" @@ -59,35 +58,31 @@ </cell> </row> <row> - <cell> + <cell anchor="west"> <JRadioButton text='lima.ui.account.base' value='{AccountsChartEnum.BASE}' - buttonGroup="{buttonGroup}" - selected='true'/> + buttonGroup="{buttonGroup}"/> </cell> </row> <row> - <cell> + <cell anchor="west"> <JRadioButton text='lima.ui.account.developed' value='{AccountsChartEnum.DEVELOPED}' - buttonGroup="{buttonGroup}" - selected='true'/> + buttonGroup="{buttonGroup}"/> </cell> </row> <row> - <cell> + <cell anchor="west"> <JRadioButton text='lima.ui.importexport.importcsv' value='{AccountsChartEnum.IMPORT}' - buttonGroup="{buttonGroup}" - selected='true'/> + buttonGroup="{buttonGroup}"/> </cell> </row> <row> - <cell> + <cell anchor="west"> <JRadioButton text='lima.ui.importexport.importebp' value='{AccountsChartEnum.IMPORTEBP}' - buttonGroup="{buttonGroup}" - selected='true'/> + buttonGroup="{buttonGroup}"/> </cell> </row> <row> @@ -107,4 +102,4 @@ </cell> </row> </Table> -</JDialog> \ No newline at end of file +</JDialog> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -41,7 +41,7 @@ ]]></script> <row> - <cell fill="both" weightx="1" weighty="1" rows='5'> + <cell fill="both" weightx="1" weighty="1" rows='4'> <JScrollPane> <JXTreeTable id="accountsTreeTable" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" @@ -52,7 +52,7 @@ </JScrollPane> </cell> <cell fill="horizontal"> - <JButton id="addButton" text="lima.ui.account.addAccount" + <JButton id="addButton" text="lima.ui.account.addaccount" onActionPerformed="handler.addAccount()"/> </cell> </row> @@ -71,9 +71,9 @@ </cell> </row> <row> - <cell fill="horizontal"> + <cell fill="horizontal" anchor="north" weighty="1"> <JButton id="importButton" text="lima.iu.importexport.import" onActionPerformed="handler.importAccountsChart()"/> </cell> </row> -</Table> \ No newline at end of file +</Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -73,4 +73,4 @@ </cell> </row> </Table> -</JDialog> \ No newline at end of file +</JDialog> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/package-info.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/package-info.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/package-info.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -0,0 +1,31 @@ +/* + * #%L + * + * + * $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 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>. + * #L% + */ +/** + * Gestion des creations. + * + * Onglet presentant la liste des comptes en arbre, avec action de creation, + * modification, suppression... + */ +package org.chorem.lima.ui.account; Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -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 @@ -22,7 +22,7 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JDialog modal="true" +<JDialog title="lima.ui.entrybook.entrybooktile" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> @@ -46,10 +46,10 @@ <Table> <row> <cell> - <JLabel text="lima.common.code"/> + <JLabel text="lima.ui.entrybook.code"/> </cell> <cell> - <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}"/> + <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}" editable='{isAddState()}' /> <Document javaBean="getEntryBookCodeField().getDocument()" onInsertUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())' onRemoveUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'/> @@ -57,10 +57,10 @@ </row> <row> <cell> - <JLabel text="lima.common.label"/> + <JLabel text="lima.ui.entrybook.label"/> </cell> <cell> - <JTextField id="entryBookLabelField" editable='{isAddState()}' + <JTextField id="entryBookLabelField" text="{getEntryBook().getLabel()}"/> <Document javaBean="getEntryBookLabelField().getDocument()" onInsertUpdate='getEntryBook().setLabel(getEntryBookLabelField().getText())' @@ -69,14 +69,13 @@ </row> <row> <cell> - <JButton id="cancelButton" text="lima.common.cancel" + <JButton id="cancelButton" text="lima.ui.common.cancel" onActionPerformed="performCancel()"/> </cell> <cell> - <JButton id="okButton" text="lima.common.ok" + <JButton id="okButton" text="lima.ui.common.ok" onActionPerformed="dispose()"/> </cell> - </row> </Table> -</JDialog> \ No newline at end of file +</JDialog> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookImportForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookImportForm.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookImportForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -22,23 +22,22 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> - -<JDialog modal="true" +<JDialog title="lima.ui.entrybook.importtitle" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> <import> - jaxx.runtime.swing.JAXXButtonGroup org.chorem.lima.enums.EntryBooksChartEnum </import> - <JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> - <Boolean id="addState" javaBean='true'/> + <javax.swing.ButtonGroup id="buttonGroup" /> + <Boolean id="addState" javaBean='true' /> + <script> <![CDATA[ - getRootPane().setDefaultButton(ok); + getRootPane().setDefaultButton(okButton); protected void performCancel() { - getRadioButtons().setSelectedValue(null); + buttonGroup.setSelectedValue(null); dispose(); } ]]> @@ -47,16 +46,15 @@ <Table> <row> <cell> - <JRadioButton text='lima.charts.entrybook.default' + <JRadioButton text='lima.ui.entrybook.default' value='{EntryBooksChartEnum.DEFAULT}' - buttonGroup="{getRadioButtons()}" + buttonGroup="{buttonGroup}" selected='true'/> </cell> <cell> - <JRadioButton text='lima.charts.entrybook.import' + <JRadioButton text='lima.ui.entrybook.import' value='{EntryBooksChartEnum.IMPORT}' - buttonGroup="{getRadioButtons()}" - selected='true'/> + buttonGroup="{buttonGroup}"/> </cell> </row> <row> @@ -64,11 +62,11 @@ <Table> <row> <cell fill="none"> - <JButton text="lima.common.cancel" + <JButton text="lima.ui.common.cancel" onActionPerformed="performCancel()"/> </cell> <cell fill="none"> - <JButton id="ok" text="lima.common.ok" + <JButton id="okButton" text="lima.ui.common.ok" onActionPerformed="dispose()"/> </cell> </row> @@ -76,4 +74,4 @@ </cell> </row> </Table> -</JDialog> \ No newline at end of file +</JDialog> 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 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -25,21 +25,16 @@ package org.chorem.lima.ui.entrybook; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; -import org.chorem.lima.business.monitorable.EntryBookServiceMonitorable; -import org.chorem.lima.business.monitorable.ImportServiceMonitorable; -import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.service.LimaServiceFactory; +import static org.nuiton.i18n.I18n._; +import java.util.List; + import javax.swing.table.AbstractTableModel; -import static org.nuiton.i18n.I18n._; +import org.chorem.lima.entity.EntryBook; /** - * Entry book table model. + * Entry book table model only rendering entry book list. * * @author ore * @author chatellier @@ -48,37 +43,20 @@ * Last update : $Date$ * By : $Author$ */ -public class EntryBookTableModel extends AbstractTableModel implements ServiceListener { +public class EntryBookTableModel extends AbstractTableModel { /** serialVersionUID. */ private static final long serialVersionUID = 7578692417919755647L; - /** log. */ - private static final Log log = LogFactory.getLog(EntryBookTableModel.class); + protected List<EntryBook> entryBooks; - /** Services. */ - protected EntryBookServiceMonitorable entryBookService; - - /** Constructor. */ - public EntryBookTableModel() { - entryBookService = - LimaServiceFactory.getService( - EntryBookServiceMonitorable.class); - LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + public EntryBookTableModel(List<EntryBook> entryBooks) { + this.entryBooks = entryBooks; } @Override public int getRowCount() { - int result = 0; - - try { - result = entryBookService.getAllEntryBooks().size(); - } catch (LimaException e) { - if (log.isDebugEnabled()) { - log.debug("Can't get all entrybooks", e); - } - } - + int result = entryBooks.size(); return result; } @@ -92,19 +70,17 @@ String res = "n/a"; switch (column) { case 0: - res = _("lima.table.code"); + res = _("lima.ui.entrybook.code"); break; case 1: - res = _("lima.table.label"); + res = _("lima.ui.entrybook.label"); break; } return res; } - public EntryBook getEntryBookAtRow(int row) throws LimaException { - EntryBook entryBook; - entryBook = entryBookService.getAllEntryBooks().get(row); - + public EntryBook getEntryBookAtRow(int row) { + EntryBook entryBook = entryBooks.get(row); return entryBook; } @@ -112,21 +88,15 @@ public Object getValueAt(int row, int column) { Object result = null; - try { - EntryBook entryBook = getEntryBookAtRow(row); + EntryBook entryBook = getEntryBookAtRow(row); - switch (column) { - case 0: - result = entryBook.getCode(); - break; - case 1: - result = entryBook.getLabel(); - break; - } - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't get EntryBook", eee); - } + switch (column) { + case 0: + result = entryBook.getCode(); + break; + case 1: + result = entryBook.getLabel(); + break; } return result; @@ -134,51 +104,23 @@ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - // Ne cells editable return false; } - /** - * @param entryBook - * @throws LimaException - */ - public void addEntryBook(EntryBook entryBook) throws LimaException { - /* Calling journal service */ - entryBookService.createEntryBook(entryBook); - int row = entryBookService.getAllEntryBooks().indexOf(entryBook); + public void addEntryBook(EntryBook entryBook) { + entryBooks.add(entryBook); + int row = entryBooks.indexOf(entryBook); fireTableRowsInserted(row, row); } - /** - * @param entryBook - * @throws LimaException - */ - public void updateEntryBook(EntryBook entryBook) throws LimaException { - /* Calling journal service */ - entryBookService.updateEntryBook(entryBook); - int row = entryBookService.getAllEntryBooks().indexOf(entryBook); + public void updateEntryBook(EntryBook entryBook) { + int row = entryBooks.indexOf(entryBook); fireTableRowsUpdated(row, row); } - /** - * @param entryBook - * @throws LimaException - */ - public void removeEntryBook(EntryBook entryBook) throws LimaException { - /* Calling journal service */ - int row = entryBookService.getAllEntryBooks().indexOf(entryBook); - entryBookService.removeEntryBook(entryBook); + public void removeEntryBook(EntryBook entryBook) { + int row = entryBooks.indexOf(entryBook); + entryBooks.remove(entryBook); fireTableRowsDeleted(row, row); } - - @Override - public void notifyMethod(String serviceName, String methodeName) { - - //refresh on import datas - if (methodeName.contains("importEntryBooks") - || methodeName.contains("importAll") - || methodeName.contains("importAs")) { - fireTableDataChanged(); - } - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2012-04-05 14:09:35 UTC (rev 3354) @@ -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 @@ -34,44 +34,47 @@ <!-- Selected row bindings --> <Boolean id="selectedRow" javaBean="false"/> + <script><![CDATA[ + void $afterCompleteSetup() { + handler.init(); + } + ]]></script> + <row> - <cell fill="both" weightx="1" weighty="1" rows='5'> + <cell fill="both" weightx="1" weighty="1" rows='4'> <JScrollPane> <EntryBookTable id="entryBooksTable" rowHeight="24" constructorParams="getHandler()" - model="{new org.chorem.lima.ui.entrybook.EntryBookTableModel()}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" + highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(233,233,233))}" selectionMode="{ListSelectionModel.SINGLE_SELECTION}" columnControlVisible="true"/> <ListSelectionModel javaBean="getEntryBooksTable().getSelectionModel()" onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> - </row> - <row> <cell fill="horizontal"> - <JButton id="addButton" text="lima.charts.entrybook.add" + <JButton id="addButton" text="lima.ui.entrybook.add" onActionPerformed="getHandler().addEntryBook()"/> </cell> </row> <row> <cell fill="horizontal"> - <JButton id="updateButton" text="lima.common.update" + <JButton id="updateButton" text="lima.ui.entrybook.update" enabled="{isSelectedRow()}" onActionPerformed="getHandler().updateEntryBook()"/> </cell> </row> <row> <cell fill="horizontal"> - <JButton id="removeButton" text="lima.common.remove" + <JButton id="removeButton" text="lima.ui.entrybook.remove" enabled="{isSelectedRow()}" onActionPerformed="getHandler().deleteEntryBook()"/> </cell> </row> <row> - <cell fill="horizontal"> + <cell fill="horizontal" anchor="north" weighty="1"> <JButton id="importButton" text="lima.importexport.import" onActionPerformed="getHandler().importEntryBooks()"/> </cell> </row> -</Table> \ No newline at end of file +</Table> 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-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -25,24 +25,28 @@ package org.chorem.lima.ui.entrybook; +import static org.nuiton.i18n.I18n._; + +import java.util.List; + +import javax.swing.JOptionPane; + 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.ejbinterface.EntryBookService; import org.chorem.lima.business.monitorable.EntryBookServiceMonitorable; +import org.chorem.lima.business.monitorable.ImportServiceMonitorable; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryBookImpl; import org.chorem.lima.enums.EntryBooksChartEnum; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.importexport.ImportExport; -import org.chorem.lima.util.DialogHelper; import org.jdesktop.swingx.JXTable; -import javax.swing.JOptionPane; - -import static org.nuiton.i18n.I18n._; - /** * Handler for entry book view. * @@ -52,7 +56,7 @@ * Last update : $Date$ * By : $Author$ */ -public class EntryBookViewHandler { +public class EntryBookViewHandler implements ServiceListener { private static final Log log = LogFactory.getLog(EntryBookViewHandler.class); @@ -65,114 +69,149 @@ entryBookService = LimaServiceFactory.getService( EntryBookServiceMonitorable.class); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } + public void init() { + loadAllEntryBooks(); + } + + /** + * 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); + } + } + + /** + * Add new entry book (display blocking dialog and perform add). + */ public void addEntryBook() { - JXTable entryBookTable = view.getEntryBooksTable(); - EntryBookTableModel entryBookTableModel = - (EntryBookTableModel) entryBookTable.getModel(); - EntryBook newEntryBook = new EntryBookImpl(); EntryBookForm entryBookForm = new EntryBookForm(view); entryBookForm.setEntryBook(newEntryBook); - // jaxx constructor don't call super() ? entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); + newEntryBook = entryBookForm.getEntryBook(); // null == cancel action - newEntryBook = entryBookForm.getEntryBook(); if (newEntryBook != null) { - // add it try { + // service call + newEntryBook = entryBookService.createEntryBook(newEntryBook); + + // ui refresh + JXTable entryBookTable = view.getEntryBooksTable(); + EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel(); entryBookTableModel.addEntryBook(newEntryBook); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add entry book", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't add entry book", ex); } } } + /** + * Update existing entry book. + */ public void updateEntryBook() { JXTable entryBookTable = view.getEntryBooksTable(); + EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel(); int selectedRow = entryBookTable.getSelectedRow(); - EntryBookTableModel entryBookTableModel = - (EntryBookTableModel) entryBookTable.getModel(); - // add it - try { - EntryBook selectedEntryBook = - entryBookTableModel.getEntryBookAtRow(selectedRow); - EntryBookForm entryBookForm = new EntryBookForm(view); - entryBookForm.setEntryBook(selectedEntryBook); - // jaxx constructor don't call super() ? - entryBookForm.setLocationRelativeTo(view); - entryBookForm.setVisible(true); + EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow); + EntryBookForm entryBookForm = new EntryBookForm(view); + entryBookForm.setAddState(false); + entryBookForm.setEntryBook(selectedEntryBook); + entryBookForm.setLocationRelativeTo(view); + entryBookForm.setVisible(true); - // null == cancel action - selectedEntryBook = entryBookForm.getEntryBook(); - if (selectedEntryBook != null) { + // null == cancel action + selectedEntryBook = entryBookForm.getEntryBook(); + if (selectedEntryBook != null) { + try { + // service call + selectedEntryBook = entryBookService.updateEntryBook(selectedEntryBook); + + // ui refresh entryBookTableModel.updateEntryBook(selectedEntryBook); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't update entry book", ex); } - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update book", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); } } + /** + * Delete selected entry book. + */ public void deleteEntryBook() { JXTable entryBookTable = view.getEntryBooksTable(); int selectedRow = entryBookTable.getSelectedRow(); - EntryBookTableModel entryBookTableModel = - (EntryBookTableModel) entryBookTable.getModel(); + EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel(); - // add it - try { - EntryBook selectedEntryBook = - entryBookTableModel.getEntryBookAtRow(selectedRow); + EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow); - int response = - JOptionPane.showConfirmDialog(view, - _("lima.charts.entrybook.confirmation", - selectedEntryBook.getLabel()), - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.entrybook.deletemessage", selectedEntryBook.getLabel()), + _("lima.ui.entrybook.deletetitle"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); - if (response == JOptionPane.YES_OPTION) { + if (response == JOptionPane.YES_OPTION) { + + try { + entryBookService.removeEntryBook(selectedEntryBook); entryBookTableModel.removeEntryBook(selectedEntryBook); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't delete entry book", ex); } - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't delete update book", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); } + } - + /** + * Import entry book. + * + * UI will be refreshed by {@link #notifyMethod(String, String)} called + * by service listener. + */ public void importEntryBooks() { - EntryBookImportForm form = - new EntryBookImportForm(); + EntryBookImportForm form = new EntryBookImportForm(view); form.setLocationRelativeTo(view); form.setVisible(true); - Object value = form.getRadioButtons().getSelectedValue(); + Object value = form.getButtonGroup().getSelectedValue(); // if action confirmed if (value != null) { - EntryBooksChartEnum defaultEntryBooksEnum = - (EntryBooksChartEnum) value; + EntryBooksChartEnum defaultEntryBooksEnum = (EntryBooksChartEnum) value; ImportExport importExport = new ImportExport(view); importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, defaultEntryBooksEnum.getFilePath(), true); } } + @Override + public void notifyMethod(String serviceName, String methodeName) { + + //refresh on import datas + if (methodeName.contains("importEntryBooks") + || methodeName.contains("importAll") + || methodeName.contains("importAs")) { + loadAllEntryBooks(); + } + } } - Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/package-info.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/package-info.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/package-info.java 2012-04-05 14:09:35 UTC (rev 3354) @@ -0,0 +1,31 @@ +/* + * #%L + * + * + * $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 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>. + * #L% + */ +/** + * Gestion des journaux. + * + * Onglet presentant la liste des journaux en table avec action de creation, + * modification, suppression... + */ +package org.chorem.lima.ui.entrybook; Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-04-05 14:09:35 UTC (rev 3354) @@ -267,9 +267,11 @@ lima.tooltip.filter=<html>Regular expression \:<br/>- accounts interval i..j <br/>- accounts list i,j,k <br/>- Exclude an account -i</html> lima.tooltip.lettering=<html>Add a letter on many entries <br/>Select many rows with combination ctrl + click</html> lima.ui.account.addAccount= +lima.ui.account.addaccount= lima.ui.account.addaccounttitle= lima.ui.account.base= lima.ui.account.developed= +lima.ui.account.importtitle= lima.ui.account.label= lima.ui.account.number= lima.ui.account.removeaccountconfirm= @@ -280,6 +282,17 @@ lima.ui.common.ok= lima.ui.common.remove= lima.ui.common.update= +lima.ui.entrybook.add= +lima.ui.entrybook.code= +lima.ui.entrybook.default= +lima.ui.entrybook.deletemessage= +lima.ui.entrybook.deletetitle= +lima.ui.entrybook.entrybooktile= +lima.ui.entrybook.import= +lima.ui.entrybook.importtitle= +lima.ui.entrybook.label= +lima.ui.entrybook.remove= +lima.ui.entrybook.update= lima.ui.importexport.importcsv= lima.ui.importexport.importebp= lima.vatreport.listerror=Can't get entries list Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-04-05 10:58:58 UTC (rev 3353) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-04-05 14:09:35 UTC (rev 3354) @@ -266,10 +266,11 @@ lima.title.about.description=Logiciel de comptabilité Libre lima.tooltip.filter=<html>Expression régulière \:<br/>- intervalle de compte i..j <br/>- liste de compte i,j,k <br/>- Exclure un compte -i</html> lima.tooltip.lettering=<html>Pour ajouter une lettre à plusieurs écritures <br/>Sélectionner plusieurs lignes avec la combinaison ctrl + click</html> -lima.ui.account.addAccount=Nouveau compte +lima.ui.account.addaccount=Nouveau compte lima.ui.account.addaccounttitle=Ajout d'un compte lima.ui.account.base=Plan comptable de base lima.ui.account.developed=Plan comptable développé +lima.ui.account.importtitle=Importer lima.ui.account.label=Libellé lima.ui.account.number=Numéro de compte lima.ui.account.removeaccountconfirm=Voulez-vous supprimer le compte %s ? @@ -280,6 +281,17 @@ lima.ui.common.ok=Ok lima.ui.common.remove=Supprimer lima.ui.common.update=Modifier +lima.ui.entrybook.add=Ajout de journal +lima.ui.entrybook.code=Code +lima.ui.entrybook.default=Journaux par défault +lima.ui.entrybook.deletemessage=Êtes vous sûr de vouloir supprimer le journal %s ? +lima.ui.entrybook.deletetitle=Suppression de journal +lima.ui.entrybook.entrybooktile=Journal +lima.ui.entrybook.import=Importer +lima.ui.entrybook.importtitle=Import +lima.ui.entrybook.label=Libellé +lima.ui.entrybook.remove=Supprimer +lima.ui.entrybook.update=Modifier lima.ui.importexport.importcsv=Import/Export CSV lima.ui.importexport.importebp=Import/Export EBP lima.vatreport.listerror=Erreur lors de la récupération des données de la liste