Author: jpepin Date: 2010-07-21 16:02:18 +0200 (Wed, 21 Jul 2010) New Revision: 2979 Url: http://chorem.org/repositories/revision/lima/2979 Log: Impl?\195?\169mentation de ServiceListener dans les mod?\195?\168les de structures et de combobox. Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.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/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ImportService.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -65,7 +65,7 @@ * import CSV. * Return result log */ - public String importCSV(String path) throws LimaException; + public String importAllAsCSV(String path) throws LimaException; public String importAccountsChartAsCSV(String path) throws LimaException; Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -195,7 +195,7 @@ TopiaQuery query = fiscalPeriodDAO.createQuery(); fiscalPeriodDAO.findAllByQuery(query); - query.addEquals(FiscalPeriod.LOCKED, Op.EQ, false); + query.addWhere(FiscalPeriod.LOCKED, Op.EQ, false); query.addOrder(FiscalPeriod.END_DATE); FiscalPeriod oldestUnBlockedFiscalPeriod = Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialStatementServiceImpl.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -205,10 +205,7 @@ FinancialStatementDAO financialStatementDAO = LimaCallaoDAOHelper.getFinancialStatementDAO(transaction); - - - - + TopiaQuery query = financialStatementDAO.createQuery(); query.addEquals("masterFinancialStatement", masterFinancialStatement) .addOrder(FinancialStatement.LABEL); Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ImportServiceImpl.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -371,7 +371,7 @@ * Remote methode to call all entities import from UI */ @Override - public String importCSV(String datas) throws LimaException { + public String importAllAsCSV(String datas) throws LimaException { String result = ""; Map<String, AccountImport> accounts = new TreeMap<String, AccountImport>(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -100,7 +100,7 @@ } } InvocationHandler handler = new ServiceMonitorableHandler(ejbHome); - M result = (M) Proxy.newProxyInstance( + result = (M) Proxy.newProxyInstance( serviceMonitorableClass.getClassLoader(), new Class[]{serviceMonitorableClass}, handler); services.put(serviceMonitorableClass, result); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -51,6 +51,7 @@ Object result = null; if (method.getName().equals("addListener")){ addServiceListener((ServiceListener) args[0]); + log.debug("addListener"); } else if (method.getName().equals("removeListener")){ removeServiceListener((ServiceListener) args[0]); @@ -58,10 +59,9 @@ else { result = method.invoke(service, args); if (!method.getName().startsWith("get")){ - log.debug("nb listeners : " + listeners.size()); - // previent listeners + log.debug(service.toString()+" "+method.getName()); for (ServiceListener serviceListener : listeners) { - serviceListener.notifyMethod(service.getClass().getSimpleName(), method.getName()); + serviceListener.notifyMethod(service.toString(), method.getName()); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -26,7 +26,6 @@ import org.chorem.lima.business.AccountServiceMonitorable; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.service.LimaServiceFactory; @@ -42,7 +41,7 @@ * Last update : $Date$ * By : $Author$ */ -public class AccountTreeTableModel extends AbstractTreeTableModel implements ServiceListener { +public class AccountTreeTableModel extends AbstractTreeTableModel { /** log. */ private static final Log log = LogFactory.getLog(AccountViewHandler.class); @@ -262,13 +261,4 @@ accountService.removeAccount(account); modelSupport.fireChildRemoved(path.getParentPath(), index, account); } - - - @Override - public void notifyMethod(String serviceName, String methodName) { - log.debug("ssalut !"); - // TODO Auto-generated method stub - - } - } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,10 +23,11 @@ import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.AccountService; import org.chorem.lima.business.AccountServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.service.LimaServiceFactory; @@ -49,14 +50,14 @@ * Last update : $Date$ * By : $Author$ */ -public class AccountViewHandler { +public class AccountViewHandler implements ServiceListener { /** log. */ private static final Log log = LogFactory.getLog(AccountViewHandler.class); protected AccountView view; - protected AccountService accountService; + protected AccountServiceMonitorable accountService; protected AccountViewHandler(AccountView view) { this.view = view; @@ -64,6 +65,9 @@ accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); + accountService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -249,6 +253,21 @@ } } + public void refresh(){ + JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); + AccountTreeTableModel accountsTreeTableModel = + (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + try { + accountsTreeTableModel.refreshTree(); + } catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't refresh model", eee); + } + } + //refresh view + view.repaint(); + } + public void defaultAccountsChart(MainView mainView){ try { @@ -275,4 +294,13 @@ } } } + + @Override + public void notifyMethod(String serviceName, String methodName) { + + if (methodName.contains("importAccounts") || methodName.contains("importAll")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -48,8 +48,8 @@ tableModel = view.getModelAccountsReportsTable(); tableModel.refresh(); - comboBoxModel = view.getModelAccounts(); - comboBoxModel.refresh(); + //comboBoxModel = view.getModelAccounts(); + //comboBoxModel.refresh(); /** * set text and amounts of labels credit, debit, solde Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -1,4 +1,4 @@ -/** +/* * *##% Lima Main * Copyright (C) 2008 CodeLutin * @@ -42,7 +42,7 @@ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); private final JWideComboBox comboBox; - private static final long serialVersionUID = 2580476608066111095L; + private static final long serialVersionUID = 1L; private static AccountTableCellEditor editor; private static SubAccountComboBoxModel accountComboBoxModel; private static boolean keyPressed = false; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -1,4 +1,4 @@ -/** +/* * *##% Lima Main * Copyright (C) 2008 CodeLutin * @@ -35,7 +35,7 @@ public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor { private final JXDatePicker datePicker; - private static final long serialVersionUID = -8455896587828255307L; + private static final long serialVersionUID = 1L; private static DateTableCellEditor editor; /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -1,4 +1,4 @@ -/** +/* * *##% Lima Main * Copyright (C) 2008 CodeLutin * @@ -42,7 +42,7 @@ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); private final JWideComboBox comboBox; - private static final long serialVersionUID = 2580476608066111095L; + private static final long serialVersionUID = 1L; private static EntryBookTableCellEditor editor; private static boolean keyPressed = false; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,9 +23,10 @@ import javax.swing.ComboBoxModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.AccountService; import org.chorem.lima.business.AccountServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -34,9 +35,9 @@ * Account combo box model. */ -public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel { +public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = -4513156210596401121L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); @@ -45,12 +46,15 @@ protected List<Account> datasCache; - protected AccountService accountService; + protected AccountServiceMonitorable accountService; public AccountComboBoxModel() { accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); + accountService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -95,5 +99,12 @@ fireContentsChanged(this, 0, datasCache.size()); } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("Account") || methodeName.contains("importAll")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -28,7 +28,7 @@ public class AccountRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = -2756100193253351274L; + private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -22,9 +22,10 @@ import javax.swing.DefaultComboBoxModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.EntryBookServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -38,16 +39,16 @@ * Last update : $Date$ * By : $Author$ */ -public class EntryBookComboBoxModel extends DefaultComboBoxModel { +public class EntryBookComboBoxModel extends DefaultComboBoxModel implements ServiceListener { - private static final long serialVersionUID = -2198896334751124051L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedEntryBook; - protected EntryBookService entryBookService; + protected EntryBookServiceMonitorable entryBookService; protected List<EntryBook> cacheDatas; @@ -55,6 +56,9 @@ entryBookService = LimaServiceFactory.getInstance().getService( EntryBookServiceMonitorable.class); + entryBookService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); cacheDatas = getDataList(); } @@ -98,4 +102,11 @@ cacheDatas = getDataList(); fireContentsChanged(this, 0, cacheDatas.size()); } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("EntryBook") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -12,7 +12,7 @@ public class EntryBookRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 8415102235262629812L; + private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -29,7 +29,7 @@ */ public class EntryBookTypeListModel extends AbstractListModel implements ComboBoxModel { - private static final long serialVersionUID = 3777447499815020502L; + private static final long serialVersionUID = 1L; protected Object selectedObject; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,9 +23,11 @@ import javax.swing.ComboBoxModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.FinancialPeriodServiceMonitorable; +import org.chorem.lima.business.FiscalPeriodServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -40,9 +42,9 @@ * Last update : $Date$ * By : $Author$ */ -public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel { +public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final long serialVersionUID = 5272891704755358592L; + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); @@ -51,7 +53,7 @@ protected List<FinancialPeriod> datasCache; - protected FinancialPeriodService financialPeriodService; + protected FinancialPeriodServiceMonitorable financialPeriodService; protected FiscalPeriod selectedFiscalPeriod; @@ -59,6 +61,11 @@ financialPeriodService = LimaServiceFactory.getInstance().getService( FinancialPeriodServiceMonitorable.class); + financialPeriodService.addListener(this); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache=getDataList(); } @@ -110,4 +117,11 @@ datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("Period") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -28,7 +28,7 @@ public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = -6130397429740718196L; + private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -19,19 +19,19 @@ package org.chorem.lima.ui.combobox; import java.util.List; - import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; -public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel{ +public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener{ private static final long serialVersionUID = 1L; @@ -39,7 +39,7 @@ protected Object selectedFiscalPeriod; - protected FiscalPeriodService fiscalPeriodService; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; protected List<FiscalPeriod> datasCache; @@ -48,6 +48,9 @@ fiscalPeriodService = LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); + fiscalPeriodService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -91,4 +94,10 @@ fireContentsChanged(this, 0, datasCache.size()); } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + refresh(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -27,7 +27,7 @@ public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 7131001128874614788L; + private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -20,13 +20,15 @@ import java.util.ArrayList; import java.util.List; +import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; import javax.swing.event.ListDataListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.AccountService; import org.chorem.lima.business.AccountServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -35,20 +37,28 @@ * Account combo box model. */ -public class SubAccountComboBoxModel implements ComboBoxModel { +public class SubAccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); + /** + * + */ + private static final long serialVersionUID = 1L; + + private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedAccount; protected List<Account> datasCache; - protected AccountService accountService; + protected AccountServiceMonitorable accountService; public SubAccountComboBoxModel() { accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); + accountService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); datasCache = getDataList(); } @@ -97,6 +107,18 @@ return result; } + + public void refresh(){ + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); + } + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (serviceName.contains("Account") || methodeName.contains("importAll")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,9 +23,10 @@ import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.EntryBookServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; @@ -39,7 +40,7 @@ * Last update : $Date$ * By : $Author$ */ -public class EntryBookTableModel extends AbstractTableModel { +public class EntryBookTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 7578692417919755647L; @@ -48,7 +49,7 @@ private static final Log log = LogFactory.getLog(EntryBookTableModel.class); /** Services. */ - protected EntryBookService entryBookService; + protected EntryBookServiceMonitorable entryBookService; /** * Constructor. @@ -57,6 +58,8 @@ entryBookService = LimaServiceFactory.getInstance().getService( EntryBookServiceMonitorable.class); + entryBookService.addListener(this); + LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addListener(this); } @Override @@ -135,11 +138,6 @@ return false; } - - public void refreshTable(){ - fireTableDataChanged(); - } - /** * @param entryBook * @throws LimaException @@ -174,4 +172,13 @@ entryBookService.removeEntryBook(entryBook); fireTableRowsDeleted(row, row); } + + @Override + public void notifyMethod(String serviceName, String methodName) { + + //refresh on import datas + if (methodName.contains("importEntryBooks") || methodName.contains("importAll")){ + fireTableDataChanged(); + } + } } 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 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -50,8 +50,8 @@ tableModel = view.getModelTable(); tableModel.refresh(); - comboBoxModel = view.getModelEntryBook(); - comboBoxModel.refresh(); + // comboBoxModel = view.getModelEntryBook(); + // comboBoxModel.refresh(); /** * set text and amounts of labels credit, debit, solde Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -19,16 +19,17 @@ package org.chorem.lima.ui.financialperiod; import static org.nuiton.i18n.I18n._; - import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FinancialPeriodService; import org.chorem.lima.business.FinancialPeriodServiceMonitorable; +import org.chorem.lima.business.FiscalPeriodServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; @@ -43,7 +44,7 @@ * Last update : $Date: 2010-05-06 11:57:19 +0200 (jeu. 06 mai 2010) $ * By : $Author: jpepin $ */ -public class FinancialPeriodTableModel extends AbstractTableModel { +public class FinancialPeriodTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 77027335135838258L; @@ -52,7 +53,7 @@ LogFactory.getLog(FinancialPeriodTableModel.class); /** service */ - protected FinancialPeriodService financialPeriodService; + protected FinancialPeriodServiceMonitorable financialPeriodService; /** Datas cache */ protected List<ClosedPeriodicEntryBook> cacheDataList; @@ -61,12 +62,16 @@ financialPeriodService = LimaServiceFactory.getInstance().getService( FinancialPeriodServiceMonitorable.class); + financialPeriodService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class).addListener(this); } @Override public int getRowCount() { - //cacheDataList=getDataList(); return cacheDataList.size(); } @@ -177,4 +182,13 @@ blockClosedPeriodicEntryBook(closedPeriodicEntryBook); fireTableDataChanged(); } + + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + getDataList(); + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,10 +23,8 @@ import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FinancialStatementService; import org.chorem.lima.business.FinancialStatementServiceMonitorable; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.FinancialStatement; import org.chorem.lima.entity.FinancialStatementImpl; import org.chorem.lima.service.LimaServiceFactory; @@ -42,12 +40,12 @@ * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ * By : $Author: jpepin $ */ -public class FinancialStatementChartTreeTableModel extends AbstractTreeTableModel implements ServiceListener { +public class FinancialStatementChartTreeTableModel extends AbstractTreeTableModel { /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); - /** Account service. */ + /** Services. */ protected final FinancialStatementServiceMonitorable financialStatementService; /** @@ -60,7 +58,6 @@ financialStatementService = LimaServiceFactory.getInstance().getService( FinancialStatementServiceMonitorable.class); - financialStatementService.addListener(this); } @@ -186,7 +183,7 @@ */ public void refreshTree() throws LimaException { - modelSupport.fireNewRoot(); + modelSupport.fireNewRoot(); } @@ -224,7 +221,6 @@ } - /** * Remove financialStatement * @@ -239,20 +235,4 @@ financialStatementService.removeFinancialStatement(financialStatement); modelSupport.fireChildRemoved(path.getParentPath(), index, financialStatement); } - - - @Override - public void notifyMethod(String serviceName, String methodName) { - - - try { - refreshTree(); - log.debug(serviceName + " " + methodName); - } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't refresh model", eee); - } - } - } - } 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 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -23,10 +23,11 @@ import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FinancialStatementService; import org.chorem.lima.business.FinancialStatementServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.FinancialStatement; import org.chorem.lima.entity.FinancialStatementImpl; import org.chorem.lima.service.LimaServiceFactory; @@ -48,12 +49,12 @@ * Last update : $Date: 2010-06-08 11:55:04 +0200 (mar., 08 juin 2010) $ * By : $Author: jpepin $ */ -public class FinancialStatementChartViewHandler { +public class FinancialStatementChartViewHandler implements ServiceListener { /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); - protected FinancialStatementService financialStatementService; + protected FinancialStatementServiceMonitorable financialStatementService; protected FinancialStatementChartView view; @@ -63,6 +64,9 @@ financialStatementService = LimaServiceFactory.getInstance().getService( FinancialStatementServiceMonitorable.class); + financialStatementService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } /** @@ -256,9 +260,22 @@ } } + public void refresh(){ + 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); + } + } + //refresh view + view.repaint(); + } public void defaultFinancialStatementChart(MainView mainView){ - try { if (financialStatementService.getAllFinancialStatements().size() == 0){ DefaultFinancialStatementChartForm form = @@ -283,4 +300,12 @@ } } + @Override + public void notifyMethod(String serviceName, String methodName) { + + if (methodName.contains("importFinancialStatements") || methodName.contains("importAll")){ + refresh(); + } + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -19,15 +19,15 @@ package org.chorem.lima.ui.fiscalperiod; import static org.nuiton.i18n.I18n._; - import java.text.SimpleDateFormat; import java.util.List; import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -40,19 +40,22 @@ * Last update : $Date$ * By : $Author$ */ -public class FiscalPeriodTableModel extends AbstractTableModel { +public class FiscalPeriodTableModel extends AbstractTableModel implements ServiceListener{ /** serialVersionUID. */ private static final long serialVersionUID = 77027335135838258L; private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class); - protected FiscalPeriodService fiscalPeriodService; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; public FiscalPeriodTableModel() { fiscalPeriodService = LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); + fiscalPeriodService.addListener(this); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class).addListener(this); } @Override @@ -166,7 +169,6 @@ return fiscalPeriod; } - /** * @param period */ @@ -189,4 +191,12 @@ fiscalPeriodService.blockFiscalPeriod(fiscalPeriod); fireTableDataChanged(); } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + //refresh on import datas + if (methodeName.contains("importAll")){ + fireTableDataChanged(); + } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeViewHandler.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -14,7 +14,6 @@ import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; @@ -23,7 +22,7 @@ import org.chorem.lima.ui.MainView; -public class HomeViewHandler implements HyperlinkListener, ServiceListener { +public class HomeViewHandler implements HyperlinkListener { private static final Log log = LogFactory.getLog(HomeViewHandler.class); @@ -224,10 +223,4 @@ log.debug("Can't get datas home", eee); } } - - @Override - public void notifyMethod(String serviceName, String methodName) { - log.debug("salut"); - } - } 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 2010-07-21 09:58:03 UTC (rev 2978) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2010-07-21 14:02:18 UTC (rev 2979) @@ -45,7 +45,7 @@ import org.chorem.lima.util.FileChooseView; import org.jdesktop.swingx.painter.BusyPainter; -public class ImportExport implements ServiceListener { +public class ImportExport { private static ImportExport exchanger; @@ -125,7 +125,7 @@ break; case LIMA_ALL_IMPORT: datas = extractFile(filePath, charset); - result = importService.importCSV(datas); + result = importService.importAllAsCSV(datas); break; case LIMA_ACCOUNTCHARTS_IMPORT: datas = extractFile(filePath, charset); @@ -248,13 +248,6 @@ return new String(datas); } - @Override - public void notifyMethod(String serviceName, String methodName) { - log.debug("listener : "+serviceName+" "+methodName); - // TODO Auto-generated method stub - - } - public static ImportExport getInstance(Component view) { if (exchanger == null) { exchanger = new ImportExport(view);