Author: tchemit Date: 2011-09-20 16:51:40 +0200 (Tue, 20 Sep 2011) New Revision: 3295 Url: http://chorem.org/repositories/revision/lima/3295 Log: - Improve images usages (JAXX is your friend) - Continue cleaning ui stuff (should be able to remove ServiceMonitorable stuff soon...) - Evolution #444: [Saisie ?\195?\169criture] Saisie d'une transaction lourde - Evolution #442: [Saisie ?\195?\169criture] Utiliser la description du compte client - Anomalie #443: [Saisie ?\195?\169criture] Non prise en compte de la modification de la description d'une transaction Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaModelUtil.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaRendererUtil.java trunk/lima-swing/src/main/resources/icons/accounts.png trunk/lima-swing/src/main/resources/icons/entries.png trunk/lima-swing/src/main/resources/icons/entrybooks.png trunk/lima-swing/src/main/resources/icons/fiscalperiods.png trunk/lima-swing/src/main/resources/icons/identity.png trunk/lima-swing/src/main/resources/icons/puzzle_icon.png trunk/lima-swing/src/main/resources/icons/puzzle_splash.png Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.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/FiscalPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java trunk/lima-swing/src/main/resources/images/accounts.png trunk/lima-swing/src/main/resources/images/entries.png trunk/lima-swing/src/main/resources/images/entrybooks.png trunk/lima-swing/src/main/resources/images/fiscalperiods.png trunk/lima-swing/src/main/resources/images/identity.png trunk/lima-swing/src/main/resources/images/puzzle_icon.png trunk/lima-swing/src/main/resources/images/puzzle_splash.png Modified: trunk/lima-swing/pom.xml trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.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/account/UpdateAccountForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.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/EntryBookComboBoxModel.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/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.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/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.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/FinancialPeriodTable.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/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.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/fiscalperiod/AddPeriod.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java trunk/lima-swing/src/main/resources/log4j.properties Modified: trunk/lima-swing/pom.xml =================================================================== --- trunk/lima-swing/pom.xml 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/pom.xml 2011-09-20 14:51:40 UTC (rev 3295) @@ -222,7 +222,7 @@ <classpathPrefix>./lib/</classpathPrefix> </manifest> <manifestEntries> - <SplashScreen-Image>images/puzzle_splash.png</SplashScreen-Image> + <SplashScreen-Image>icons/puzzle_splash.png</SplashScreen-Image> </manifestEntries> </archive> </configuration> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -574,7 +574,7 @@ } optionsService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( OptionsServiceMonitorable.class); if (!serverProp.isEmpty()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -135,18 +135,6 @@ } } - /* init date converter - Converter converter = ConverterUtil.getConverter(java.util.Date.class); - if (converter != null) { - ConvertUtils.deregister(java.util.Date.class); - DateConverter dateConverter = new DateConverter(); - dateConverter.setUseLocaleFormat(true); - ConvertUtils.register(dateConverter, java.util.Date.class); - } - - if (log.isDebugEnabled()) { - log.debug("Context init done in " + (StringUtil.convertTime(t0, System.nanoTime()))); - }*/ return context; } @@ -169,11 +157,10 @@ splash.updateProgression(0.7, _("lima.splash.2")); //start http server - LimaServiceFactory.getInstance().getService(HttpServerServiceMonitorable.class).start(); + LimaServiceFactory.getService(HttpServerServiceMonitorable.class).start(); AccountService accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getService(AccountServiceMonitorable.class); List<Account> accounts = accountService.getChildrenAccounts(null); if (accounts.isEmpty()) { @@ -209,7 +196,7 @@ super.run(); LimaContext.get().close(); - LimaServiceFactory.getInstance().destroy(); + LimaServiceFactory.destroy(); // force to kill main thread if (log.isInfoEnabled()) { 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -33,6 +33,8 @@ import org.apache.openejb.assembler.classic.Assembler; import org.apache.openejb.loader.SystemInstance; import org.chorem.lima.LimaMain; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ServiceMonitorable; import javax.naming.Context; import javax.naming.InitialContext; @@ -99,30 +101,37 @@ } - /** - * Return service factory singleton instance. - * <p/> - * Init it at first call. - * - * @return singleton instance - */ - public static LimaServiceFactory getInstance() { - if (instance == null) { - instance = new LimaServiceFactory(); - } - return instance; - } - - public <M> M getService(Class<M> serviceMonitorableClass) { + public static <M> M getService(Class<M> serviceMonitorableClass) { + LimaServiceFactory factory = getInstance(); + Map<Class<?>, Object> services = factory.getServices(); M result = (M) services.get(serviceMonitorableClass); if (result == null) { - result = newService(serviceMonitorableClass); + result = factory.newService(serviceMonitorableClass); services.put(serviceMonitorableClass, result); } return result; } + public static <M> void addServiceListener(Class<M> serviceClass, ServiceListener listener) { + M service = getService(serviceClass); + addServiceListener(service, listener); + } + + public static <M> void addServiceListener(M service, ServiceListener listener) { + if (!(service instanceof ServiceMonitorable)) { + throw new IllegalArgumentException( + "service " + service + " does not implement " + ServiceMonitorable.class); + } + ((ServiceMonitorable) service).addServiceListener(listener); + } + + + public static <M> void removeServiceListener(Class<M> serviceClass, ServiceListener listener) { + ServiceMonitorable service = (ServiceMonitorable) getService(serviceClass); + service.removeServiceListener(listener); + } + /** * Destroy openejb jndi context. * <p/> @@ -131,7 +140,7 @@ * * @throws Exception when trying to destroy a non existent application */ - public void destroy() throws Exception { + public static void destroy() throws Exception { // destroy code (only in embedded mode) Assembler assembler = SystemInstance.get().getComponent(Assembler.class); @@ -141,6 +150,24 @@ OpenEJB.destroy(); } + /** + * Return service factory singleton instance. + * <p/> + * Init it at first call. + * + * @return singleton instance + */ + protected static LimaServiceFactory getInstance() { + if (instance == null) { + instance = new LimaServiceFactory(); + } + return instance; + } + + protected Map<Class<?>, Object> getServices() { + return getInstance().services; + } + protected <M> M newService(Class<M> serviceMonitorableClass) { M result; Object ejbHome; @@ -156,7 +183,7 @@ ClassLoader classLoader = serviceMonitorableClass.getClassLoader(); result = (M) Proxy.newProxyInstance( classLoader, - new Class[]{serviceMonitorableClass}, + new Class[]{ServiceMonitorable.class, serviceMonitorableClass}, handler ); return result; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaModelUtil.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaModelUtil.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaModelUtil.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -0,0 +1,12 @@ +package org.chorem.lima.ui; + +/** + * Util to create ui models. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.5.2 + */ +public class LimaModelUtil { + + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaModelUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaRendererUtil.java (from rev 3291, trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaRendererUtil.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaRendererUtil.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -0,0 +1,31 @@ +package org.chorem.lima.ui; + +import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; +import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; +import org.chorem.lima.LimaContext; +import org.nuiton.util.decorator.Decorator; +import org.nuiton.util.decorator.DecoratorProvider; + +import javax.swing.ListCellRenderer; + +/** + * Helper class to deal with renderers. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.5.2 + */ +public class LimaRendererUtil { + + public static ListCellRenderer newDecoratorProviderListCellRenderer() { + DecoratorProvider decoratorProvider = LimaContext.get().getDecoratorProvider(); + return new DecoratorProviderListCellRenderer(decoratorProvider); + } + + public static ListCellRenderer newDecoratorListCellRenderer(Class<?> type) { + + DecoratorProvider decoratorProvider = LimaContext.get().getDecoratorProvider(); + Decorator<?> decorator = decoratorProvider.getDecoratorByType(type); + return new DecoratorListCellRenderer(decorator); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaRendererUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,31 +28,21 @@ undecorated='{getConfig().isFullScreen()}' resizable="true" width="800" height="600" extendedState='{this.MAXIMIZED_BOTH}' - iconImage='{new ImageIcon(getClass().getResource("/images/puzzle_icon.png")).getImage()}'> + iconImage='puzzle_icon.png'> <import> - java.awt.Component - java.awt.Desktop - java.io.IOException - java.net.URI - java.net.URISyntaxException java.util.Locale - javax.swing.BoxLayout - javax.swing.border.EtchedBorder - javax.swing.ImageIcon javax.swing.JButton + jaxx.runtime.SwingUtil org.chorem.lima.LimaConfig - org.chorem.lima.business.HttpServerServiceMonitorable + org.chorem.lima.LimaContext org.chorem.lima.enums.ImportExportEnum - org.chorem.lima.service.LimaServiceFactory </import> - <Desktop id='desktop' javaBean='Desktop.getDesktop()'/> - <script><![CDATA[ public LimaConfig getConfig() { - return getContextValue(LimaConfig.class); + return LimaContext.CONFIG_DEF.getContextValue(getDelegateContext()); } public MainViewHandler getHandler() { @@ -62,61 +52,6 @@ public boolean acceptLocale(Locale l, String expected) { return l != null && l.toString().equals(expected); } - - public void loadURI(){ - try { - int port = LimaServiceFactory.getInstance().getService( - HttpServerServiceMonitorable.class).getHttpPort(); - String address = LimaConfig.getInstance().getHostAdress(); - String url = "http://"+address+":"+port+"/"; - desktop.browse(new URI(url)); - } catch (IOException e) { - log.error("Can't open browser",e); - } catch (URISyntaxException e) { - log.error("Can't create URI",e); - } - } - -/** - * Show a new closable tab. - * - * @param name name of tab to show - * @param container the tab container - * @param canClose {@code false} if tab can't be closed - */ -protected void showTab(String name, Component container, boolean canClose) { - // if contentTabbedPane doesnot yet contains tab - if (contentTabbedPane.indexOfTab(name) == -1) { - ClosableTabHeader closableHeader = new ClosableTabHeader(); - closableHeader.setTitle(name); - closableHeader.setCanClose(canClose); - contentTabbedPane.addTab(name, container); - contentTabbedPane.setSelectedComponent(container); - contentTabbedPane.setTabComponentAt(contentTabbedPane.indexOfTab(name), closableHeader); - closableHeader.getCloseTab().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JButton button = (JButton) e.getSource(); - ClosableTabHeader closableTab = (ClosableTabHeader) button.getParent(); - String name = closableTab.getTitle(); - contentTabbedPane.remove(contentTabbedPane.indexOfTab(name)); - } - }); - // if contentTabbedPane contains tab - } else { - contentTabbedPane.setSelectedIndex(contentTabbedPane.indexOfTab(name)); - } -} - -/** - * Show a new closable tab. - * - * @param name name of tab to show - * @param container the tab container - */ -protected void showTab(String name, Component container) { - showTab(name, container, true); -} ]]> </script> @@ -165,7 +100,7 @@ </JMenu> <JSeparator/> <JMenuItem actionIcon='documents' text="lima.documents" - onActionPerformed="loadURI()"/> + onActionPerformed="getHandler().loadURI(this)"/> <JSeparator/> <JMenuItem text="lima.identity" actionIcon="identity" @@ -261,8 +196,8 @@ <JMenu text="lima.menu.help" mnemonic="{'H'}"> - <JMenuItem id="help" text='lima.menu.help.help' actionIcon="help" - onActionPerformed="getHandler().showHelp(this, null)"/> + <!--<JMenuItem id="help" text='lima.menu.help.help' actionIcon="help"--> + <!--onActionPerformed="getHandler().showHelp(this, null)"/>--> <JMenuItem id="site" text='lima.menu.help.site' actionIcon="site" onActionPerformed="getHandler().gotoSite(this)"/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -26,13 +26,16 @@ package org.chorem.lima.ui; import jaxx.runtime.JAXXContext; +import jaxx.runtime.SwingUtil; import jaxx.runtime.swing.AboutPanel; import jaxx.runtime.swing.editor.config.ConfigUIHelper; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; import org.chorem.lima.LimaContext; +import org.chorem.lima.business.HttpServerServiceMonitorable; import org.chorem.lima.enums.ImportExportEnum; +import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.accountsreports.AccountsReportsView; import org.chorem.lima.ui.balance.BalanceView; @@ -54,7 +57,11 @@ import org.chorem.lima.ui.vatreports.VatReportView; import org.chorem.lima.util.ErrorHelper; -import java.awt.Desktop; +import javax.swing.JButton; +import javax.swing.JTabbedPane; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.net.URL; import java.util.Locale; @@ -158,7 +165,7 @@ public void showConfig(JAXXContext context) { MainView ui = getUI(context); - LimaConfig config = context.getContextValue(LimaConfig.class); + LimaConfig config = ui.getConfig(); //TODO pepin 2010-08-20 add all options @@ -178,35 +185,41 @@ helper.displayUI(ui, false); } - public void showHelp(JAXXContext context, String helpId) { +// public void showHelp(JAXXContext context, String helpId) { +// +// } +// +// public void closeHelp(JAXXContext context) { +// +// } - } + public void gotoSite(JAXXContext context) { - public void closeHelp(JAXXContext context) { + LimaConfig config = getUI(context).getConfig(); - } - - public void gotoSite(JAXXContext rootContext) { - - LimaConfig config = rootContext.getContextValue(LimaConfig.class); - URL siteURL = config.getOptionAsURL("application.site.url"); - - log.info("goto " + siteURL); - if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { - try { - Desktop.getDesktop().browse(siteURL.toURI()); - } catch (Exception ex) { - if (log.isDebugEnabled()) { - log.error("Can't open lima website", ex); - } - ErrorHelper.showErrorDialog("Can't open lima website", ex); - } + String url = siteURL.toString(); + try { + SwingUtil.openLink(url); + } catch (Exception e) { + ErrorHelper.showErrorDialog("Can't open lima website at " + url, e); } +// log.info("goto " + siteURL); +// if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { +// try { +// Desktop.getDesktop().browse(siteURL.toURI()); +// } catch (Exception ex) { +// if (log.isErrorEnabled()) { +// log.error("Can't open lima website", ex); +// } +// ErrorHelper.showErrorDialog("Can't open lima website", ex); +// } +// } } - public void showAbout(MainView ui) { + public void showAbout(JAXXContext context) { + MainView ui = getUI(context); AboutPanel about = new AboutPanel(); about.setTitle(_("lima.title.about")); about.setAboutText(_("lima.title.about.description")); @@ -227,7 +240,7 @@ protected void reloadUI(LimaContext rootContext, boolean fullscreen) { // must remove all properties listener on config - rootContext.getContextValue(LimaConfig.class).removeJaxxPropertyChangeListener(); + LimaContext.CONFIG_DEF.getContextValue(rootContext).removeJaxxPropertyChangeListener(); // scan main ui MainView ui = getUI(rootContext); @@ -278,7 +291,7 @@ public void showHomeView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); HomeView homeView = new HomeView(mainView); - mainView.showTab(_("lima.tab.home"), homeView, false); + showTab(mainView, _("lima.tab.home"), homeView, false); } public void showIdentity(JAXXContext rootContext) { @@ -291,152 +304,224 @@ /** * Show account tree table view to create or modify accounts * - * @param rootContext + * @param rootContext the root application context */ public void showAccountView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); AccountView accountView = new AccountView(mainView); - mainView.showTab(_("lima.charts.account"), accountView); + showTab(mainView, _("lima.charts.account"), accountView); } /** * Show account tree table view to create or modify accounts * - * @param rootContext + * @param rootContext the root application context */ public void showEntryBookView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); EntryBookView entryBookView = new EntryBookView(mainView); - mainView.showTab(_("lima.common.entrybooks"), entryBookView); + showTab(mainView, _("lima.common.entrybooks"), entryBookView); } /** * Show fiscal period view to create or block a period * - * @param rootContext + * @param rootContext the root application context */ public void showFiscalPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView); - mainView.showTab(_("lima.charts.fiscalyear"), fiscalPeriodView); + showTab(mainView, _("lima.charts.fiscalyear"), fiscalPeriodView); } /** * Show financial period view to create or block a period * - * @param rootContext + * @param rootContext the root application context */ public void showFinancialPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialPeriodView financialPeriodView = new FinancialPeriodView(mainView); - mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView); + showTab(mainView, _("lima.charts.financialperiod"), financialPeriodView); } /** * Show financial statement view to generate balance sheet and income statement * - * @param rootContext + * @param rootContext the root application context */ public void showFinancialStatementView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialStatementChartView financialStatementView = new FinancialStatementChartView(mainView); - mainView.showTab(_("lima.charts.financialstatement"), financialStatementView); + showTab(mainView, _("lima.charts.financialstatement"), financialStatementView); } /** * Show vat chart to generate vat document * - * @param rootContext + * @param rootContext the root application context */ public void showVatChartView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); VatChartView vatChartView = new VatChartView(mainView); - mainView.showTab(_("lima.charts.vatstatement"), vatChartView); + showTab(mainView, _("lima.charts.vatstatement"), vatChartView); } /** * Show account table report to view an account on a period * - * @param rootContext + * @param rootContext the root application context */ public void showAccountReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); AccountsReportsView accountsReportsView = new AccountsReportsView(mainView); - mainView.showTab(_("lima.reports.accounts"), accountsReportsView); + showTab(mainView, _("lima.reports.accounts"), accountsReportsView); } /** * Show entry book table report to view an account on a period * - * @param rootContext + * @param rootContext the root application context */ public void showEntryBookReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - EntryBooksReportsView entryBooksReportsView = new EntryBooksReportsView(mainView); - mainView.showTab(_("lima.reports.entrybooks"), entryBooksReportsView); + EntryBooksReportsView entryBooksReportsView = + new EntryBooksReportsView(mainView); + showTab(mainView, _("lima.reports.entrybooks"), entryBooksReportsView); } /** * Show financial transactions view to create entries * - * @param rootContext + * @param rootContext the root application context */ public void showTransactionView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialTransactionView transactionView = new FinancialTransactionView(mainView); - mainView.showTab(_("lima.entries.writetransaction"), transactionView); + FinancialTransactionView transactionView = + new FinancialTransactionView(mainView); + showTab(mainView, _("lima.entries.writetransaction"), + transactionView); } public void showTransactionUnbalancedView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialTransactionUnbalancedView searchResultView = new FinancialTransactionUnbalancedView(mainView); - mainView.showTab(_("lima.entries.searchunbalancedtransaction"), searchResultView); + FinancialTransactionUnbalancedView searchResultView = + new FinancialTransactionUnbalancedView(mainView); + showTab(mainView, _("lima.entries.searchunbalancedtransaction"), + searchResultView); } public void showTransactionSearchView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialTransactionSearchView searchView = new FinancialTransactionSearchView(mainView); - mainView.showTab(_("lima.entries.searchtransaction"), searchView); + FinancialTransactionSearchView searchView = + new FinancialTransactionSearchView(mainView); + showTab(mainView, _("lima.entries.searchtransaction"), searchView); } public void showLetteringView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); LetteringView letteringView = new LetteringView(mainView); - mainView.showTab(_("lima.entries.lettering"), letteringView); + showTab(mainView, _("lima.entries.lettering"), letteringView); } public void showBalanceView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); BalanceView balanceView = new BalanceView(mainView); - mainView.showTab(_("lima.reports.balance"), balanceView); + showTab(mainView, _("lima.reports.balance"), balanceView); } public void showLedgerView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); LedgerView ledgerView = new LedgerView(mainView); - mainView.showTab(_("lima.reports.ledger"), ledgerView); + showTab(mainView, _("lima.reports.ledger"), ledgerView); } public void showFinancialStatementReportsView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - FinancialStatementReportView financialStatementReportView = new FinancialStatementReportView(mainView); - mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView); + FinancialStatementReportView financialStatementReportView = + new FinancialStatementReportView(mainView); + showTab(mainView, _("lima.reports.financialstatement"), + financialStatementReportView); } public void showVatReportView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); VatReportView vatReportView = new VatReportView(mainView); - mainView.showTab(_("lima.reports.vat"), vatReportView); + showTab(mainView, _("lima.reports.vat"), vatReportView); } - public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) { + public void showImportExportView(JAXXContext rootContext, + ImportExportEnum type) { MainView mainView = getUI(rootContext); ImportExport importExport = ImportExport.getInstance(mainView); importExport.importExport(type, "", true); } + + public void loadURI(MainView ui) { + int port = LimaServiceFactory.getService( + HttpServerServiceMonitorable.class).getHttpPort(); + String address = LimaConfig.getInstance().getHostAdress(); + String url = "http://" + address + ":" + port + "/"; + + try { + SwingUtil.openLink(url); + } catch (Exception e) { + ErrorHelper.showErrorDialog("Can't open lima website at " + url, e); + } + } + + /** + * Show a new closable tab. + * + * @param ui main ui + * @param name name of tab to show + * @param container the tab container + * @param canClose {@code false} if tab can't be closed + */ + protected void showTab(MainView ui, + String name, + Component container, + boolean canClose) { + final JTabbedPane contentTabbedPane = ui.getContentTabbedPane(); + + // if contentTabbedPane doesnot yet contains tab + if (contentTabbedPane.indexOfTab(name) == -1) { + ClosableTabHeader closableHeader = new ClosableTabHeader(); + closableHeader.setTitle(name); + closableHeader.setCanClose(canClose); + contentTabbedPane.addTab(name, container); + contentTabbedPane.setSelectedComponent(container); + contentTabbedPane.setTabComponentAt( + contentTabbedPane.indexOfTab(name), closableHeader); + closableHeader.getCloseTab().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JButton button = (JButton) e.getSource(); + ClosableTabHeader closableTab = + (ClosableTabHeader) button.getParent(); + String name = closableTab.getTitle(); + contentTabbedPane.remove(contentTabbedPane.indexOfTab(name)); + } + }); + // if contentTabbedPane contains tab + } else { + contentTabbedPane.setSelectedIndex(contentTabbedPane.indexOfTab(name)); + } + } + + /** + * Show a new closable tab. + * + * @param ui main ui + * @param name name of tab to show + * @param container the tab container + */ + protected void showTab(MainView ui, String name, Component container) { + showTab(ui, name, container, true); + } } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -64,8 +64,7 @@ super(new AccountImpl()); // Gets factory service accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getService(AccountServiceMonitorable.class); } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -68,17 +68,12 @@ protected AccountViewHandler(AccountView view) { this.view = view; // Gets factory service - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + accountService = LimaServiceFactory.getService(AccountServiceMonitorable.class); } /** * Add new account with account form. - * - * @throws LimaException */ public void addAccount() { @@ -140,8 +135,6 @@ } } - ; - public void addSubLedger() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -48,7 +48,7 @@ protected void performOk() { if (getMasterAccountTextField().getText().length() != 0) { AccountServiceMonitorable accountService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( AccountServiceMonitorable.class); Account masterAccount = new AccountImpl(); try { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateSubLedgerForm.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -48,7 +48,7 @@ protected void performOk() { if (getMasterAccountTextField().getText().length() != 0) { AccountServiceMonitorable accountService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( AccountServiceMonitorable.class); Account masterAccount = new AccountImpl(); try { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -111,7 +111,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -134,7 +134,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - renderer = RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + renderer = LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -77,12 +77,11 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(ReportServiceMonitorable.class); + LimaServiceFactory.addServiceListener( + ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener( + FinancialTransactionServiceMonitorable.class, this); } public void setBeginDate(Date date) { @@ -110,7 +109,7 @@ selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.accountsreports.listerror"), eee); } @@ -140,7 +139,7 @@ view.amountSoldeLabel.setText(amountSolde.toString()); - if (amountSolde == BigDecimal.ZERO) { + if (BigDecimal.ZERO.equals(amountSolde)) { view.soldeLabel.setText(_("lima.common.solde")); } else { // set label solde: credit or debit Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -112,7 +112,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); @@ -137,7 +137,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -96,17 +96,14 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); - port = LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService(ReportServiceMonitorable.class); + port = LimaServiceFactory.getService( HttpServerServiceMonitorable.class).getHttpPort(); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FinancialTransactionServiceMonitorable.class, this); } @@ -137,7 +134,7 @@ results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected()); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.balance.listerror"), eee); } @@ -191,7 +188,7 @@ blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Enable to create document ", eee); + log.error("Enable to create document ", eee); } ErrorHelper.showErrorDialog(_("lima.balance.documentcreationerror"), eee); } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.EntryBookToString; import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -63,7 +63,7 @@ EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); comboBox.setModel(entryBookComboBoxModel); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(EntryBook.class); + LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class); comboBox.setRenderer(renderer); // AutoCompletion Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -29,8 +29,8 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Letter; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -64,7 +64,7 @@ LetterComboBoxModel comboBoxModel = new LetterComboBoxModel(); comboBox.setModel(comboBoxModel); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(Letter.class); + LimaRendererUtil.newDecoratorListCellRenderer(Letter.class); comboBox.setRenderer(renderer); AutoCompleteDecorator.decorate(comboBox, LetterToString.getInstance()); comboBox.getEditor().getEditorComponent().addKeyListener(this); 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.AccountService; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -52,15 +53,14 @@ protected List<Account> datasCache; - protected AccountServiceMonitorable accountService; + protected AccountService accountService; public AccountComboBoxModel() { accountService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( AccountServiceMonitorable.class); - accountService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(accountService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); datasCache = getDataList(); } @@ -106,7 +106,8 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Account") || methodeName.contains("importAll")) { + if (methodeName.contains("Account") || + methodeName.contains("importAll")) { refresh(); } } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.EntryBookService; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -57,17 +58,15 @@ protected Object selectedEntryBook; - protected EntryBookServiceMonitorable entryBookService; + protected EntryBookService entryBookService; protected List<EntryBook> cacheDatas; public EntryBookComboBoxModel() { entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); - entryBookService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(EntryBookServiceMonitorable.class); + LimaServiceFactory.addServiceListener(EntryBookServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); cacheDatas = getDataList(); } Deleted: 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,65 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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.ui.combobox; - -import org.chorem.lima.entity.EntryBook; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; -import java.awt.Component; - -@Deprecated -public class EntryBookRenderer extends DefaultListCellRenderer { - - private static final long serialVersionUID = 1L; - - @Override - public Component getListCellRendererComponent(JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { - - JLabel label = (JLabel) super.getListCellRendererComponent(list, - value, - index, - isSelected, - cellHasFocus - ); - String text; - if (value == null) { - text = "\t"; - } else { - EntryBook entrybook = (EntryBook) value; - text = entrybook.getCode() + " - " + entrybook.getLabel(); - } - label.setText(text); - return this; - } - - -} 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -32,6 +32,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialPeriodService; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -61,7 +62,7 @@ protected List<FinancialPeriod> datasCache; - protected FinancialPeriodServiceMonitorable financialPeriodService; + protected FinancialPeriodService financialPeriodService; protected FiscalPeriod selectedFiscalPeriod; @@ -75,7 +76,7 @@ /** * Constructor for period list. * - * @param all if {@code true}, display all available period, otherwize + * @param displayAllPeriods if {@code true}, display all available period, otherwize * display only locked ones */ public FinancialPeriodComboBoxModel(boolean displayAllPeriods) { @@ -83,13 +84,11 @@ this.displayAllPeriods = displayAllPeriods; financialPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialPeriodServiceMonitorable.class); - financialPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(financialPeriodService, this); + LimaServiceFactory.addServiceListener(FiscalPeriodServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); if (displayAllPeriods) { datasCache = getAllDataList(); } else { @@ -97,7 +96,7 @@ } } - public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { + public void setSelectedFiscalPeriod(FiscalPeriod fiscalPeriod) { selectedFiscalPeriod = fiscalPeriod; if (displayAllPeriods) { datasCache = getAllDataList(); @@ -161,7 +160,6 @@ return result; } - public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); Deleted: 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,65 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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.ui.combobox; - -import org.chorem.lima.entity.FinancialPeriod; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; -import java.awt.Component; -import java.text.SimpleDateFormat; - -@Deprecated -public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { - - private static final long serialVersionUID = 1L; - - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yy"); - - @Override - public Component getListCellRendererComponent(JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { - - JLabel label = (JLabel) super.getListCellRendererComponent(list, - value, - index, - isSelected, - cellHasFocus - ); - if (value != null) { - FinancialPeriod financialPeriod = (FinancialPeriod) value; - - label.setText(simpleDateFormat.format(financialPeriod.getBeginDate()) + " - " + simpleDateFormat.format(financialPeriod.getEndDate())); - } - return label; - } - - -} \ No newline at end of file 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -47,29 +48,27 @@ protected Object selectedFiscalPeriod; - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; protected List<FiscalPeriod> datasCache; //constructor for blocked fiscal period only public FiscalPeriodComboBoxModel() { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(fiscalPeriodService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); datasCache = getDataList(); } //constructor for all fiscal period public FiscalPeriodComboBoxModel(boolean all) { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(fiscalPeriodService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); datasCache = getAllDataList(); } Deleted: 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,66 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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.ui.combobox; - -import org.chorem.lima.entity.FiscalPeriod; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; -import java.awt.Component; -import java.text.SimpleDateFormat; - -@Deprecated -public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { - - private static final long serialVersionUID = 1L; - - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yy"); - - @Override - public Component getListCellRendererComponent(JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { - - JLabel label = (JLabel) super.getListCellRendererComponent(list, - value, - index, - isSelected, - cellHasFocus - ); - if (value != null) { - FiscalPeriod fiscalPeriod = (FiscalPeriod) value; - - label.setText(simpleDateFormat.format(fiscalPeriod.getBeginDate()) - + " - " + simpleDateFormat.format(fiscalPeriod.getEndDate())); - } - return label; - } - - -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; @@ -52,15 +53,14 @@ protected List<Letter> datasCache; - protected FinancialTransactionServiceMonitorable service; + protected FinancialTransactionService service; public LetterComboBoxModel() { service = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); - service.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(service, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); datasCache = getDataList(); } Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,56 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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.ui.combobox; - -import org.chorem.lima.entity.Letter; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; -import java.awt.Component; - -@Deprecated -public class LetterRenderer extends DefaultListCellRenderer { - - private static final long serialVersionUID = 1L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - - JLabel label = (JLabel) super.getListCellRendererComponent(list, - value, - index, - isSelected, - cellHasFocus - ); - if (value != null) { - Letter letter = (Letter) value; - label.setText(letter.getCode()); - } - return label; - } - -} 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.AccountService; import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; @@ -51,15 +52,13 @@ protected List<Account> datasCache; - protected AccountServiceMonitorable accountService; + protected AccountService accountService; public SubAccountComboBoxModel() { accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); - accountService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(AccountServiceMonitorable.class); + LimaServiceFactory.addServiceListener(accountService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); datasCache = getDataList(); } @@ -104,7 +103,8 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("Account") || methodeName.contains("importAll")) { + 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -62,9 +62,9 @@ /** Constructor. */ public EntryBookTableModel() { entryBookService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( EntryBookServiceMonitorable.class); - LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } @Override 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -63,7 +63,7 @@ public EntryBookViewHandler(EntryBookView view) { this.view = view; entryBookService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( EntryBookServiceMonitorable.class); } @@ -91,7 +91,7 @@ if (log.isErrorEnabled()) { log.error("Can't add entry book", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -122,7 +122,7 @@ if (log.isErrorEnabled()) { log.error("Can't add update book", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } @@ -151,7 +151,7 @@ if (log.isErrorEnabled()) { log.error("Can't delete update book", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.EntryBookToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -51,7 +51,7 @@ this.handler = handler; EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); setModel(entryBookComboBoxModel); - setRenderer(RendererUtil.newDecoratorListCellRenderer(EntryBook.class)); + setRenderer(LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class)); setEditable(true); AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); getEditor().getEditorComponent().addKeyListener(this); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -111,7 +111,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); @@ -136,7 +136,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -98,20 +98,18 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( ReportServiceMonitorable.class); - port = LimaServiceFactory.getInstance().getService( + port = LimaServiceFactory.getService( HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( DocumentServiceMonitorable.class); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FinancialTransactionServiceMonitorable.class, this); } public void setBeginDate(Date date) { @@ -139,7 +137,7 @@ selectedEntryBook, selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.entrybooksreports.listerror"), eee); } @@ -169,7 +167,7 @@ BigDecimal amountSolde = datasList.getAmountSolde(); view.amountSoldeLabel.setText(String.valueOf(amountSolde)); - if (amountSolde == BigDecimal.ZERO) { + if (BigDecimal.ZERO.equals(amountSolde)) { view.soldeLabel.setText(_("lima.common.solde")); } else { // set label solde: credit or debit @@ -194,7 +192,7 @@ blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Enable to create document ", eee); + log.error("Enable to create document ", eee); } ErrorHelper.showErrorDialog(_("lima.entrybooksreports.documentcreationerror"), eee); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -75,7 +75,7 @@ model = this.handler.getView().modelFinancialPeriodTable; financialPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialPeriodServiceMonitorable.class); //highlight financial financial transactions 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -71,12 +71,10 @@ public FinancialPeriodTableModel() { financialPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialPeriodServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FiscalPeriodServiceMonitorable.class, this); } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -63,7 +63,7 @@ super(new FinancialStatementImpl()); // Gets factory service financialStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialStatementServiceMonitorable.class); } @@ -216,7 +216,7 @@ * Add FinancialStatement(path can be null). * * @param path - * @param account + * @param financialStatement * @throws LimaException */ public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException { @@ -236,7 +236,7 @@ * Update financialStatement * * @param path - * @param account + * @param financialStatement * @throws LimaException */ public void updateFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException { @@ -250,7 +250,7 @@ * Remove financialStatement * * @param path - * @param object + * @param financialStatement * @throws LimaException */ public void removeFinancialStatementObject(TreePath path, FinancialStatement financialStatement) throws LimaException { 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -69,10 +69,9 @@ this.view = view; financialStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialStatementServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } /** Add new account with account form. */ @@ -111,7 +110,7 @@ if (log.isErrorEnabled()) { log.error("Can't add financialStatementHeader", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } catch (LimaException ex) { if (log.isErrorEnabled()) { @@ -122,8 +121,6 @@ } } - ; - public void addFinancialStatementMovement() { JXTreeTable treeTable = view.getTreeTable(); @@ -154,12 +151,12 @@ if (log.isErrorEnabled()) { log.error("Can't add FinancialStatementMovement", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add FinancialStatementMovement", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -221,7 +218,7 @@ if (log.isErrorEnabled()) { log.error("Can't add update", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -254,7 +251,7 @@ if (log.isErrorEnabled()) { log.error("Can't delete account", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -111,7 +111,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -135,7 +135,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -36,6 +36,8 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.DocumentService; +import org.chorem.lima.business.ejbinterface.FinancialStatementService; import org.chorem.lima.business.utils.DocumentsEnum; import org.chorem.lima.business.utils.FormatsEnum; import org.chorem.lima.service.LimaServiceFactory; @@ -72,9 +74,9 @@ private static final Log log = LogFactory.getLog(FinancialStatementReportTableModel.class); /** Services. */ - protected FinancialStatementServiceMonitorable financialStatementService; + protected FinancialStatementService financialStatementService; - protected DocumentServiceMonitorable documentService; + protected DocumentService documentService; /** DatePicker Begin Date. */ protected Date selectedBeginDate; @@ -93,17 +95,15 @@ /** Constructor. */ public FinancialStatementReportTableModel() { financialStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialStatementServiceMonitorable.class); - financialStatementService.addServiceListener(this); - port = LimaServiceFactory.getInstance().getService( + LimaServiceFactory.addServiceListener(financialStatementService, this); + port = LimaServiceFactory.getService( HttpServerServiceMonitorable.class).getHttpPort(); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addServiceListener(this); - documentService = LimaServiceFactory.getInstance().getService(DocumentServiceMonitorable.class); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FinancialTransactionServiceMonitorable.class, this); + documentService = LimaServiceFactory.getService(DocumentServiceMonitorable.class); } @Override @@ -258,7 +258,7 @@ results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.financialstatementreport.listerror"), eee); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -64,7 +64,7 @@ protected FinancialStatementReportViewHandler(FinancialStatementReportView view) { this.view = view; fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); } @@ -90,7 +90,7 @@ blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Enable to create document ", eee); + log.error("Enable to create document ", eee); } ErrorHelper.showErrorDialog("Enable to create document ", eee); } Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,69 +0,0 @@ -/* - * #%L - * Lima Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2010 CodeLutin - * %% - * 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.ui.financialtransaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.entity.FinancialPeriod; - -import javax.swing.JComboBox; - -public class FinancialPeriodComboBox extends JComboBox { - - private static final long serialVersionUID = 1L; - - private static final Log log = - LogFactory.getLog(FinancialPeriodComboBox.class); - - protected FinancialTransactionViewHandler handler; - - public FinancialPeriodComboBox(FinancialTransactionViewHandler handler) { - this.handler = handler; - } - - public void back() { - int row = getSelectedIndex(); - log.debug(row); - if (row > 0) { - setSelectedItem(getItemAt(row - 1)); - repaint(); - handler.tableModel.setFinancialPeriod((FinancialPeriod) getSelectedItem()); - } - } - - public void next() { - int size = getModel().getSize(); - int row = getSelectedIndex(); - log.debug(row); - - if (row < size - 1) { - setSelectedItem(getItemAt(row + 1)); - repaint(); - //FIXME - handler.tableModel.setFinancialPeriod((FinancialPeriod) getSelectedItem()); - } - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -25,8 +25,6 @@ package org.chorem.lima.ui.financialtransaction; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; @@ -46,10 +44,10 @@ import javax.swing.SwingWorker; import java.awt.Color; import java.awt.Component; +import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.math.BigDecimal; import java.util.Date; @@ -59,22 +57,19 @@ * * @author jpepin */ -public class FinancialTransactionTable extends JXTable - implements KeyListener, MouseListener { +public class FinancialTransactionTable extends JXTable { /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - /** log. */ - private static final Log log = LogFactory - .getLog(FinancialTransactionTable.class); +// /** log. */ +// private static final Log log = LogFactory +// .getLog(FinancialTransactionTable.class); protected FinancialTransactionViewHandler handler; - private Highlighter colorTransaction; +// private ColorHighlighter colorBalance; - private ColorHighlighter colorBalance; - private int x_tab; private int y_tab; @@ -83,41 +78,35 @@ this.handler = handler; - addKeyListener(this); - addMouseListener(this); + addKeyListener(new MyKeyAdapter()); + addMouseListener(new MyMouseAdapter()); + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); + //Get new entry book editor setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor()); + //Get new account editor setDefaultEditor(Account.class, new AccountTableCellEditor()); + //Get new amount editor setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); + //get new String renderer for empty cells setDefaultRenderer(String.class, new EmptyCellRenderer()); + //get new Account renderer for empty cells setDefaultRenderer(Account.class, new EmptyCellRenderer()); + //get new EntryBook renderer for empty cells setDefaultRenderer(EntryBook.class, new EmptyCellRenderer()); //highlight financial financial transactions - addColorTransaction(); - // highlight unbalanced financial transactions - addColorNonBalancedTransaction(); - } - - /** - * Cette méthode permet de colorer toutes les transactions dans le tableau - * afin de bien distinguer les transactions et entrées comptables. - * On récupère la première cellule, on vérifie que c'est une date - */ - protected void addColorTransaction() { - if (colorTransaction != null) { - removeHighlighter(colorTransaction); - } HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, @@ -125,23 +114,15 @@ return adapter.getValueAt(adapter.row, 0) instanceof Date; } }; - colorTransaction = + Highlighter colorTransaction = new ColorHighlighter(predicate, new Color(222, 222, 222), null); addHighlighter(colorTransaction); - } - - - /** - * Permet de surligner une transaction dans le tableau lorsque - * cette dernière n'est pas équilibrée. - * On récupère la dernière cellule de la ligne - * et on vérifie si la valeur est différente de 0 - */ - protected void addColorNonBalancedTransaction() { - if (colorBalance != null) { - removeHighlighter(colorBalance); - } - HighlightPredicate predicate = new HighlightPredicate() { + + // highlight unbalanced financial transactions +// if (colorBalance != null) { +// removeHighlighter(colorBalance); +// } + predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { @@ -163,186 +144,392 @@ addHighlighter(colorTransaction); } - /** - * for each action combination key are think - * for extend keyboard and laptop keyboard - */ - @Override - public void keyPressed(KeyEvent e) { + public FinancialTransactionViewHandler getHandler() { + return handler; + } - //TODO combinaison de touches dans la config +// /** +// * Cette méthode permet de colorer toutes les transactions dans le tableau +// * afin de bien distinguer les transactions et entrées comptables. +// * On récupère la première cellule, on vérifie que c'est une date +// */ +// protected void addColorTransaction() { +// if (colorTransaction != null) { +// removeHighlighter(colorTransaction); +// } +// HighlightPredicate predicate = new HighlightPredicate() { +// @Override +// public boolean isHighlighted(Component renderer, +// ComponentAdapter adapter) { +// return adapter.getValueAt(adapter.row, 0) instanceof Date; +// } +// }; +// colorTransaction = +// new ColorHighlighter(predicate, new Color(222, 222, 222), null); +// addHighlighter(colorTransaction); +// } - // delete selected row with the key : delete or ctrl + clear - // ou de l'entree - if (e.getKeyCode() == KeyEvent.VK_DELETE - || e.getKeyCode() == KeyEvent.VK_CLEAR - && e.getModifiers() == KeyEvent.CTRL_MASK) { - handler.deleteSelectedRow(); - } +// /** +// * Permet de surligner une transaction dans le tableau lorsque +// * cette dernière n'est pas équilibrée. +// * On récupère la dernière cellule de la ligne +// * et on vérifie si la valeur est différente de 0 +// */ +// protected void addColorNonBalancedTransaction() { +// if (colorBalance != null) { +// removeHighlighter(colorBalance); +// } +// HighlightPredicate predicate = new HighlightPredicate() { +// @Override +// public boolean isHighlighted(Component renderer, +// ComponentAdapter adapter) { +// boolean isHighlighted = false; +// Object value = adapter.getValueAt(adapter.row, 8); +// if (value instanceof BigDecimal) { +// BigDecimal currentBalance = (BigDecimal) value; +// // can compare two BigDecimals with different scales +// // e.g: 3.1 == 3.10 +// if (currentBalance.compareTo(BigDecimal.ZERO) != 0) { +// isHighlighted = true; +// } +// } +// return isHighlighted; +// } +// }; +// colorTransaction = +// new ColorHighlighter(predicate, new Color(255, 198, 209), null); +// addHighlighter(colorTransaction); +// } - // add entry with the key combination : insert or ctrl + enter - if (e.getKeyCode() == KeyEvent.VK_INSERT - || e.getKeyCode() == KeyEvent.VK_ENTER - && e.getModifiers() == KeyEvent.CTRL_MASK) { - handler.addEmptyEntry(); - } +// /** +// * for each action combination key are think +// * for extend keyboard and laptop keyboard +// */ +// @Override +// public void keyPressed(KeyEvent e) { +// +// //TODO combinaison de touches dans la config +// +// // delete selected row with the key : delete or ctrl + clear +// // ou de l'entree +// if (e.getKeyCode() == KeyEvent.VK_DELETE +// || e.getKeyCode() == KeyEvent.VK_CLEAR +// && e.getModifiers() == KeyEvent.CTRL_MASK) { +// handler.deleteSelectedRow(); +// } +// +// // add entry with the key combination : insert or ctrl + enter +// if (e.getKeyCode() == KeyEvent.VK_INSERT +// || e.getKeyCode() == KeyEvent.VK_ENTER +// && e.getModifiers() == KeyEvent.CTRL_MASK) { +// handler.addEntry(); +// } +// +// // copy : ctrl + c +// +// // add financial transaction with the key combination : ctrl + c +// if (e.getKeyCode() == KeyEvent.VK_C +// && e.getModifiers() == KeyEvent.CTRL_MASK) { +// handler.copyRow(); +// } +// +// // paste : ctrl + v +// +// // add financial transaction with the key combination : ctrl + v +// if (e.getKeyCode() == KeyEvent.VK_V +// && e.getModifiers() == KeyEvent.CTRL_MASK) { +// handler.pasteRow(); +// } +// +// // add financial transaction with the key combination : ctrl + tab +// if (e.getKeyCode() == KeyEvent.VK_TAB +// && e.getModifiers() == KeyEvent.CTRL_MASK) { +// handler.addFinancialTransaction(); +// } +// +// // clear row selection with the key: escape +// if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { +// if (!isEditing()) { +// clearSelection(); +// } +// } +// +// /** +// * Touche tab +// * Incrémente le curseur de case tant que la case n'est pas editable +// * Ajoute une entrée comptable si tab est sur +// * la dernière cellule et si la transaction est non équilibré +// * sinon rajoute une transaction +// */ +// +// if (e.getKeyChar() == KeyEvent.VK_TAB) { +// int max_x = getColumnCount(); +// int max_y = getRowCount(); +// x_tab = getSelectedColumn(); +// y_tab = getSelectedRow(); +// Boolean end = true; +// +// if (x_tab < max_x - 1) { +// x_tab++; +// } +// //end of row +// else { +// x_tab = 0; +// y_tab++; +// } +// +// //skip all cell while not editable or if end of table add entry or transaction or end of table +// while (!isCellEditable(y_tab, x_tab) && end) { +// //if end of row +// if (x_tab == max_x - 1) { +// Object object = handler.tableModel.getElementAt(y_tab); +// +// //if transaction, add entry +// if (object instanceof FinancialTransaction) { +// FinancialTransaction financialTransaction = (FinancialTransaction) object; +// if (financialTransaction.getEntry().size() == 0) { +// handler.addEntry(); +// setColumnSelectionInterval(1, 1); +// } +// } +// //if entry +// else { +// //FIXME set value is doing after key pressed +// // so update not terminated before get balanced +// //Swing Worker stop the UI 500ms +// // found best solution ? +// final JXTable table = this; +// final int y_t = y_tab; +// final int m_t = max_y; +// new SwingWorker<Void, Void>() { +// @Override +// protected Void doInBackground() throws InterruptedException { +// Thread.sleep(500); +// return null; +// } +// +// @Override +// protected void done() { +// Object object = handler.tableModel.getElementAt(y_tab - 1); +// FinancialTransaction financialTransaction = null; +// if (object instanceof Entry) { +// financialTransaction = ((Entry) object).getFinancialTransaction(); +// } else if (object instanceof FinancialTransaction) { +// financialTransaction = (FinancialTransaction) object; +// } +// BigDecimal amountC = financialTransaction.getAmountCredit(); +// BigDecimal amountD = financialTransaction.getAmountDebit(); +// if (amountC == amountD) { +// if (y_t == m_t - 1) { +// handler.addFinancialTransaction(); +// table.setColumnSelectionInterval(0, 0); +// } +// } else { +// handler.addEntry(); +// table.setColumnSelectionInterval(1, 1); +// y_tab++; +// // positionne la sélection sur la nouvelle ligne créée +// table.setRowSelectionInterval(y_tab, y_tab); +// x_tab = 0; +// } +// } +// }.execute(); +// } +// end = false; +// } else { +// if (x_tab < max_x) { +// setRowSelectionInterval(y_tab, y_tab); +// setColumnSelectionInterval(x_tab, x_tab); +// x_tab++; +// } +// } +// } +// } +// } +// +// +// @Override +// public void keyTyped(KeyEvent e) { +// } +// +// +// @Override +// public void keyReleased(KeyEvent e) { +// } +// +// @Override +// public void mouseClicked(MouseEvent e) { +// } +// +// @Override +// public void mousePressed(MouseEvent e) { +// if (rowAtPoint(e.getPoint()) == -1) { +// clearSelection(); +// } +// } +// +// @Override +// public void mouseReleased(MouseEvent e) { +// } +// +// @Override +// public void mouseEntered(MouseEvent e) { +// } +// +// @Override +// public void mouseExited(MouseEvent e) { +// } - // copy : ctrl + c + private class MyKeyAdapter extends KeyAdapter { - // add financial transaction with the key combination : ctrl + c - if (e.getKeyCode() == KeyEvent.VK_C - && e.getModifiers() == KeyEvent.CTRL_MASK) { - handler.copyRow(); - } + @Override + public void keyPressed(KeyEvent e) { - // paste : ctrl + v + final FinancialTransactionViewHandler handler = getHandler(); - // add financial transaction with the key combination : ctrl + v - if (e.getKeyCode() == KeyEvent.VK_V - && e.getModifiers() == KeyEvent.CTRL_MASK) { - handler.pasteRow(); - } + // delete selected row with the key : delete or ctrl + clear + // ou de l'entree + if (e.getKeyCode() == KeyEvent.VK_DELETE + || e.getKeyCode() == KeyEvent.VK_CLEAR + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.deleteSelectedRow(); + } - // add financial transaction with the key combination : ctrl + tab - if (e.getKeyCode() == KeyEvent.VK_TAB - && e.getModifiers() == KeyEvent.CTRL_MASK) { - handler.addFinancialTransaction(); - } + // add entry with the key combination : insert or ctrl + enter + if (e.getKeyCode() == KeyEvent.VK_INSERT + || e.getKeyCode() == KeyEvent.VK_ENTER + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.addEntry(); + } - // clear row selection with the key: escape - if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { - clearSelection(); + // copy : ctrl + c + + // add financial transaction with the key combination : ctrl + c + if (e.getKeyCode() == KeyEvent.VK_C + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.copyRow(getSelectedRow()); } - } - /** - * Touche tab - * Incrémente le curseur de case tant que la case n'est pas editable - * Ajoute une entrée comptable si tab est sur - * la dernière cellule et si la transaction est non équilibré - * sinon rajoute une transaction - */ + // paste : ctrl + v - if (e.getKeyChar() == KeyEvent.VK_TAB) { - int max_x = getColumnCount(); - int max_y = getRowCount(); - x_tab = getSelectedColumn(); - y_tab = getSelectedRow(); - Boolean end = true; + // add financial transaction with the key combination : ctrl + v + if (e.getKeyCode() == KeyEvent.VK_V + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.pasteRow(getSelectedRow()); + } - if (x_tab < max_x - 1) { - x_tab++; + // add financial transaction with the key combination : ctrl + tab + if (e.getKeyCode() == KeyEvent.VK_TAB + && e.getModifiers() == KeyEvent.CTRL_MASK) { + handler.addFinancialTransaction(); } - //end of row - else { - x_tab = 0; - y_tab++; + + // clear row selection with the key: escape + if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { + if (!isEditing()) { + clearSelection(); + } } - //skip all cell while not editable or if end of table add entry or transaction or end of table - while (!isCellEditable(y_tab, x_tab) && end) { - //if end of row - if (x_tab == max_x - 1) { - Object object = handler.tableModel.getElementAt(y_tab); + /** + * Touche tab + * Incrémente le curseur de case tant que la case n'est pas editable + * Ajoute une entrée comptable si tab est sur + * la dernière cellule et si la transaction est non équilibré + * sinon rajoute une transaction + */ - //if transaction, add entry - if (object instanceof FinancialTransaction) { - FinancialTransaction financialTransaction = (FinancialTransaction) object; - if (financialTransaction.getEntry().size() == 0) { - handler.addEmptyEntry(); - setColumnSelectionInterval(1, 1); + if (e.getKeyChar() == KeyEvent.VK_TAB) { + int max_x = getColumnCount(); + int max_y = getRowCount(); + x_tab = getSelectedColumn(); + y_tab = getSelectedRow(); + Boolean end = true; + + if (x_tab < max_x - 1) { + x_tab++; + } + //end of row + else { + x_tab = 0; + y_tab++; + } + + //skip all cell while not editable or if end of table add entry or transaction or end of table + while (!isCellEditable(y_tab, x_tab) && end) { + //if end of row + if (x_tab == max_x - 1) { + Object object = handler.getTableModel().getElementAt(y_tab); + + //if transaction, add entry + if (object instanceof FinancialTransaction) { + FinancialTransaction financialTransaction = (FinancialTransaction) object; + if (financialTransaction.getEntry().size() == 0) { + handler.addEntry(); + setColumnSelectionInterval(1, 1); + } } - } - //if entry - else { - //FIXME set value is doing after key pressed - // so update not terminated before get balanced - //Swing Worker stop the UI 500ms - // found best solution ? - final JXTable table = this; - final int y_t = y_tab; - final int m_t = max_y; - new SwingWorker<Void, Void>() { - @Override - protected Void doInBackground() throws InterruptedException { - Thread.sleep(500); - return null; - } + //if entry + else { + //FIXME set value is doing after key pressed + // so update not terminated before get balanced + //Swing Worker stop the UI 500ms + // found best solution ? + final int y_t = y_tab; + final int m_t = max_y; + new SwingWorker<Void, Void>() { + @Override + protected Void doInBackground() throws InterruptedException { + Thread.sleep(500); + return null; + } - @Override - protected void done() { - Object object = handler.tableModel.getElementAt(y_tab - 1); - FinancialTransaction financialTransaction = null; - if (object instanceof Entry) { - financialTransaction = ((Entry) object).getFinancialTransaction(); - } else if (object instanceof FinancialTransaction) { - financialTransaction = (FinancialTransaction) object; - } - BigDecimal amountC = financialTransaction.getAmountCredit(); - BigDecimal amountD = financialTransaction.getAmountDebit(); - if (amountC == amountD) { - if (y_t == m_t - 1) { - handler.addFinancialTransaction(); - table.setColumnSelectionInterval(0, 0); + @Override + protected void done() { + Object object = handler.getTableModel().getElementAt(y_tab - 1); + FinancialTransaction financialTransaction = null; + if (object instanceof Entry) { + financialTransaction = ((Entry) object).getFinancialTransaction(); + } else if (object instanceof FinancialTransaction) { + financialTransaction = (FinancialTransaction) object; } - } else { - handler.addEmptyEntry(); - table.setColumnSelectionInterval(1, 1); - y_tab++; - // positionne la sélection sur la nouvelle ligne créée - table.setRowSelectionInterval(y_tab, y_tab); - x_tab = 0; + BigDecimal amountC = financialTransaction.getAmountCredit(); + BigDecimal amountD = financialTransaction.getAmountDebit(); + if (amountC == amountD) { + if (y_t == m_t - 1) { + handler.addFinancialTransaction(); + setColumnSelectionInterval(0, 0); + } + } else { + handler.addEntry(); + setColumnSelectionInterval(1, 1); + y_tab++; + // positionne la sélection sur la nouvelle ligne créée + setRowSelectionInterval(y_tab, y_tab); + x_tab = 0; + } } - } - }.execute(); + }.execute(); + } + end = false; + } else { + if (x_tab < max_x) { + setRowSelectionInterval(y_tab, y_tab); + setColumnSelectionInterval(x_tab, x_tab); + x_tab++; + } } - end = false; - } else { - if (x_tab < max_x) { - setRowSelectionInterval(y_tab, y_tab); - setColumnSelectionInterval(x_tab, x_tab); - x_tab++; - } } } } - - } - - @Override - public void keyTyped(KeyEvent e) { - - } - - - @Override - public void keyReleased(KeyEvent e) { - } - - @Override - public void mouseClicked(MouseEvent e) { - } - - @Override - public void mousePressed(MouseEvent e) { - if (rowAtPoint(e.getPoint()) == -1) { - clearSelection(); + private class MyMouseAdapter extends MouseAdapter { + @Override + public void mousePressed(MouseEvent e) { + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); + } } } - - @Override - public void mouseReleased(MouseEvent e) { - } - - @Override - public void mouseEntered(MouseEvent e) { - } - - @Override - public void mouseExited(MouseEvent e) { - } - } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -33,6 +33,7 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -43,7 +44,6 @@ import org.chorem.lima.entity.FinancialTransactionImpl; import org.chorem.lima.entity.Letter; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import javax.swing.table.AbstractTableModel; @@ -65,13 +65,9 @@ * @author ore * @author chatellier * @version $Revision$ - * <p/> - * Last update : $Date$ - * By : $Author$ */ public class FinancialTransactionTableModel extends AbstractTableModel implements ServiceListener { - /** serialVersionUID. */ private static final long serialVersionUID = 1L; /** log. */ @@ -79,33 +75,22 @@ .getLog(FinancialTransactionTableModel.class); /** Transaction service. */ - protected final FinancialTransactionServiceMonitorable financialTransactionService; + protected final FinancialTransactionService financialTransactionService; /** selected financial period */ protected FinancialPeriod selectedFinancialPeriod; /** data cache */ - protected List<Object> cacheDataList; + protected List<?> cacheDataList; protected EntryBook selectedEntryBook; - /** - * collection - * <p/> - * <p/> - * /** - * Model constructor. - * <p/> - * Just init service proxies. - */ public FinancialTransactionTableModel() { /* Services */ - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + financialTransactionService = LimaServiceFactory.getService( + FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.addServiceListener(financialTransactionService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } /** @@ -113,7 +98,7 @@ * * @return */ - protected List<Object> getDataList() { + protected List<?> getDataList() { List<Object> results = new ArrayList<Object>(); if (selectedFinancialPeriod != null) { try { @@ -193,11 +178,9 @@ result = BigDecimal.class; break; } - return result; } - @Override public String getColumnName(int column) { String result = "n/a"; @@ -231,15 +214,16 @@ result = _("lima.table.balance"); break; } - return result; } @Override public int getRowCount() { - int result = 0; + int result; - if (cacheDataList != null) { + if (cacheDataList == null) { + result = 0; + } else { result = cacheDataList.size(); } @@ -331,13 +315,15 @@ result = null; break; } - } } return result; } - public void setFinancialPeriod(FinancialPeriod financialPeriod) { + public void setSelectedFinancialPeriod(FinancialPeriod financialPeriod) { + if (log.isDebugEnabled()) { + log.debug("New selected financial period " + financialPeriod); + } selectedFinancialPeriod = financialPeriod; refresh(); } @@ -374,6 +360,43 @@ } /** + * Obtain the first entry book of the current transaction. + * + * @param selectedRow + * @return + */ + public int getFirstEntry(int selectedRow) { + int result = -1; + int currentRow = selectedRow; + while (currentRow > -1) { + Object o = cacheDataList.get(currentRow); + if (o instanceof Entry) { + + // current row is still a entry book + currentRow--; + continue; + } + if (o instanceof FinancialTransaction) { + // got the begin of a transaction + if (currentRow == selectedRow) { + + // the selected row is on the transaction + // + // look out if there is a next line and if then look out if + // this is a entry book + result = -1; + } else { + + // the next row is an entry book row + result = currentRow + 1; + } + break; + } + } + return result; + } + + /** * @return int: indexOf new FianancialTransaction * @throws LimaException */ @@ -430,14 +453,15 @@ } /** - * @param value * @param voucher * @param description * @param row * @return int: indexOf new Entry * @throws LimaException */ - public int addEmptyEntry(Object value, String voucher, String description, int row) throws LimaException { + public int addEmptyEntry(String voucher, + String description, + int row) throws LimaException { FinancialTransaction currentTransaction = null; Object currentRow = cacheDataList.get(row); Entry entry = new EntryImpl(); @@ -468,13 +492,12 @@ } /** - * @param value * @param entry * @param row * @return int: indexOf new Entry * @throws LimaException */ - public int addEntry(Object value, Entry entry, int row) throws LimaException { + public int addEntry(Entry entry, int row) throws LimaException { FinancialTransaction currentTransaction = null; int financialTransactionRow = 0; Object currentRow = cacheDataList.get(row); @@ -528,33 +551,73 @@ currentFinancialTransaction.setEntryBook((EntryBook) value); break; } - // notify service for modification - try { - financialTransactionService. - updateFinancialTransaction(currentFinancialTransaction); - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update financial transaction", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } + // update transaction + updateFinancialTransaction(currentFinancialTransaction); + //update the financial transaction in entire financialTransactionRow = getDataList().indexOf(currentRow); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry) currentRow; + FinancialTransaction financialTransaction = + currentEntry.getFinancialTransaction(); + boolean updateTransaction = false; switch (column) { case 2: - currentEntry.setVoucher(((String) value).trim()); + String voucher = ((String) value).trim(); + + int firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + + // let's update the voucher of all entries of + // the transaction + + for (Entry entry : financialTransaction.getEntry()) { + entry.setVoucher(voucher); + } + updateTransaction = true; + } else { + + // not on first row, just update this entry voucher + currentEntry.setVoucher(voucher); + } break; case 3: Account account = (Account) value; currentEntry.setAccount(account); // let's copy the account description - currentEntry.setDescription(account.getLabel()); + String description1 = account.getLabel(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + // let's update the description of all entries of + // the transaction + + for (Entry entry : financialTransaction.getEntry()) { + entry.setDescription(description1); + } + updateTransaction = true; + } else { + // not on first row, just update this entry description + currentEntry.setDescription(description1); + } break; case 4: - currentEntry.setDescription(((String) value).trim()); + String description = ((String) value).trim(); + firstEntryRow = getFirstEntry(row); + if (row == firstEntryRow) { + + // let's update the description of all entries of + // the transaction + + for (Entry entry : financialTransaction.getEntry()) { + entry.setDescription(description); + } + updateTransaction = true; + } else { + + // not on first row, just update this entry description + currentEntry.setDescription(description); + } break; case 5: currentEntry.setLetter((Letter) value); @@ -568,19 +631,19 @@ currentEntry.setDebit(false); break; } - try { - financialTransactionService.updateEntry(currentEntry); + if (updateTransaction) { - } catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't update entry", eee); + for (Entry entry : financialTransaction.getEntry()) { + updateEntry(entry); } - DialogHelper.showMessageDialog(eee.getMessage()); + } else { + + updateEntry(currentEntry); } + //update the financial transaction in entire financialTransactionRow = - getDataList().indexOf(((Entry) currentRow). - getFinancialTransaction()); + getDataList().indexOf(financialTransaction); } //on recharge la liste cacheDataList = getDataList(); @@ -588,6 +651,28 @@ } } + protected void updateFinancialTransaction(FinancialTransaction transaction) { + try { + financialTransactionService.updateFinancialTransaction(transaction); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't update financial transaction", eee); + } + ErrorHelper.showErrorDialog("Can't update financial transaction", eee); + } + } + + protected void updateEntry(Entry entry) { + try { + financialTransactionService.updateEntry(entry); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't update entry", eee); + } + ErrorHelper.showErrorDialog("Can't update entry", eee); + } + } + public Object getElementAt(int row) { Object result = null; if (cacheDataList != null) { @@ -601,11 +686,10 @@ * <p/> * Called by model. * - * @param object * @param row * @throws LimaException */ - public void removeObject(Object object, int row) throws LimaException { + public void removeObject(int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -24,114 +24,84 @@ --> <Table> - <FinancialTransactionViewHandler id="handler" - javaBean="new FinancialTransactionViewHandler(this)"/> <import> javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod org.chorem.lima.entity.FinancialPeriod org.chorem.lima.entity.EntryBook - org.chorem.lima.LimaContext org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel - org.chorem.lima.ui.renderers.RendererUtil + org.chorem.lima.ui.LimaRendererUtil </import> + <FinancialTransactionViewHandler id="handler" constructorParams="this"/> <Boolean id="selectedRow" javaBean="false"/> - <FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> - <FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> + <FinancialTransactionTableModel id="financialTransactionTableModel"/> + <FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> + <FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> <script> <![CDATA[ void $afterCompleteSetup() { - getHandler().initEntryBookModel(entryBookComboBox); - getHandler().refresh(); + handler.initEntryBookModel(entryBookComboBox); + handler.refresh(); } - ]]> </script> <row weightx="1" weighty="0" anchor="center"> <cell anchor="east"> - <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> + <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear" + labelFor='{fiscalPeriodComboBox}'/> </cell> <cell anchor="west"> <JComboBox id="fiscalPeriodComboBox" - model="{getModelFiscalPeriod()}" - renderer="{RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" - onActionPerformed="getModelFinancialPeriod().setFiscalPeriod((FiscalPeriod)fiscalPeriodComboBox.getSelectedItem())" - editable="false"/> + model="{fiscalPeriodComboBoxModel}" + renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" + onItemStateChanged="if ( event.getStateChange() == 1 ) financialPeriodComboBoxModel.setSelectedFiscalPeriod( (FiscalPeriod) event.getItem() );"/> </cell> <cell anchor="east"> - <JLabel id="financialPeriodLabel" text="lima.common.period"/> + <JLabel id="financialPeriodLabel" text="lima.common.period" + labelFor='{financialPeriodComboBox}'/> </cell> <cell anchor="west"> <JPanel> - <FinancialPeriodComboBox id="financialPeriodComboBox" - constructorParams="getHandler()" - model="{getModelFinancialPeriod()}" - renderer="{RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class)}" - onActionPerformed="financialTransactionTableModel.setFinancialPeriod((FinancialPeriod)financialPeriodComboBox.getSelectedItem())"/> + <JComboBox id="financialPeriodComboBox" + model="{financialPeriodComboBoxModel}" + renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class)}" + onItemStateChanged="if ( event.getStateChange() == 1 ) financialTransactionTableModel.setSelectedFinancialPeriod( (FinancialPeriod) event.getItem() );"/> <JButton id="back" text="lima.common.buttonback" - onActionPerformed="financialPeriodComboBox.back()"/> + onActionPerformed="handler.back(financialPeriodComboBox)"/> <JButton id="next" text="lima.common.buttonnext" - onActionPerformed="financialPeriodComboBox.next()"/> + onActionPerformed="handler.next(financialPeriodComboBox)"/> </JPanel> </cell> - <!--cell> - <JButton id="back" text="lima.common.buttonback" - onActionPerformed="financialPeriodComboBox.back()"/> - </cell> - <cell> - <JButton id="next" text="lima.common.buttonnext" - onActionPerformed="financialPeriodComboBox.next()"/> - </cell--> <cell anchor="east"> <JLabel id="entryBookComboBoxLabel" text="lima.common.entrybook" labelFor='{entryBookComboBox}'/> </cell> <cell anchor="west"> <JComboBox id="entryBookComboBox" - renderer="{RendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" - onActionPerformed="financialTransactionTableModel.setSelectedEntryBook((EntryBook)entryBookComboBox.getSelectedItem())"/> + renderer="{LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" + onItemStateChanged="if ( event.getStateChange() == 1 ) financialTransactionTableModel.setSelectedEntryBook( (EntryBook) event.getItem() );"/> </cell> - <!--cell> - <JButton text="lima.common.copy" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().copyRow()"/> - </cell> - <cell> - <JButton text="lima.common.paste" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().pasteRow()"/> - </cell> - <cell> - <JButton text="lima.entries.addTransaction" - onActionPerformed="getHandler().addFinancialTransaction()"/> - </cell> - <cell> - <JButton text="lima.entries.addEntry" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().addEmptyEntry()"/> - </cell> - <cell> - <JButton text="lima.common.remove" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().deleteSelectedRow()"/> - </cell--> </row> <row> <cell weightx="1" columns="8"> <JToolBar floatable="false"> <JPanel layout='{new GridLayout(1,0)}'> <JButton text="lima.common.copy" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().copyRow()"/> + onActionPerformed="handler.copyRow(financialTransactionTable.getSelectedRow())"/> <JButton text="lima.common.paste" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().pasteRow()"/> + onActionPerformed="handler.pasteRow(financialTransactionTable.getSelectedRow())"/> <JButton text="lima.entries.addTransaction" - onActionPerformed="getHandler().addFinancialTransaction()"/> + onActionPerformed="handler.addFinancialTransaction()"/> <JButton text="lima.entries.addEntry" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().addEmptyEntry()"/> + onActionPerformed="handler.addEntry()"/> <JButton text="lima.common.remove" enabled="{isSelectedRow()}" - onActionPerformed="getHandler().deleteSelectedRow()"/> + onActionPerformed="handler.deleteSelectedRow()"/> </JPanel> </JToolBar> @@ -140,15 +110,14 @@ <row> <cell fill="both" weightx="1" weighty="1" rows="3" columns="8"> <JScrollPane> - <FinancialTransactionTableModel - id="financialTransactionTableModel"/> + <FinancialTransactionTable id="financialTransactionTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" - model="{getFinancialTransactionTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + constructorParams='handler' + model='{financialTransactionTableModel}' + selectionMode='{ListSelectionModel.SINGLE_SELECTION}'/> <ListSelectionModel - javaBean="getFinancialTransactionTable().getSelectionModel()" + initializer="financialTransactionTable.getSelectionModel()" onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> </JScrollPane> </cell> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -63,24 +63,31 @@ protected FinancialTransactionView view; - protected FinancialTransactionTable table; + protected Object clipBoard; - protected FinancialTransactionTableModel tableModel; + protected FinancialTransactionViewHandler(FinancialTransactionView view) { + this.view = view; + } - protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; + public FinancialTransactionTable getTable() { + return view.getFinancialTransactionTable(); + } - protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; + public FinancialTransactionTableModel getTableModel() { + return view.getFinancialTransactionTableModel(); + } - protected Object clipBoard; + public FiscalPeriodComboBoxModel getFiscalPeriodComboBoxModel() { + return view.getFiscalPeriodComboBoxModel(); + } - protected FinancialTransactionViewHandler(FinancialTransactionView view) { - this.view = view; + public FinancialPeriodComboBoxModel getFinancialPeriodComboBoxModel() { + return view.getFinancialPeriodComboBoxModel(); } public void initEntryBookModel(JComboBox comboBox) { EntryBookServiceMonitorable service = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getService(EntryBookServiceMonitorable.class); try { List<EntryBook> allEntryBooks = service.getAllEntryBooks(); allEntryBooks.add(0, null); @@ -91,28 +98,23 @@ } //copy entry - public void copyRow() { - table = view.getFinancialTransactionTable(); - int indexSelectedRow = table.getSelectedRow(); - + public void copyRow(int indexSelectedRow) { if (indexSelectedRow != -1) { - clipBoard = tableModel.getElementAt(indexSelectedRow); + clipBoard = getTableModel().getElementAt(indexSelectedRow); } } //paste entry - public void pasteRow() { - table = view.getFinancialTransactionTable(); - int indexSelectedRow = table.getSelectedRow(); + public void pasteRow(int indexSelectedRow) { + FinancialTransactionTable table = getTable(); + FinancialTransactionTableModel tableModel = getTableModel(); if (indexSelectedRow != -1) { - Object selectedValue = tableModel.getElementAt(indexSelectedRow); if (clipBoard instanceof Entry) { try { - int index = tableModel.addEntry(selectedValue, - (Entry) clipBoard, - indexSelectedRow - ); + int index = tableModel.addEntry((Entry) clipBoard, + indexSelectedRow); + //select the new line ListSelectionModel selectionModel = table.getSelectionModel(); @@ -128,26 +130,23 @@ DialogHelper.showErrorMessageDialog(view, eee); } } - } - } //add a new transaction public void addFinancialTransaction() { - table = view.getFinancialTransactionTable(); - tableModel = view.getFinancialTransactionTableModel(); + FinancialTransactionTable table = getTable(); + FinancialTransactionTableModel tableModel = getTableModel(); + ListSelectionModel selectionModel = table.getSelectionModel(); try { int index = tableModel.addFinancialTransaction(); //select the new line int numberRow = table.getRowCount(); - ListSelectionModel selectionModel = - table.getSelectionModel(); selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); //focus on first column table.changeSelection(index, 0, false, false); - table.requestFocusInWindow(); +// table.requestFocusInWindow(); table.scrollCellToVisible(index, 0); } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -159,33 +158,50 @@ //implement new transaction button //add a new entry to the selected transaction - public void addEmptyEntry() { + public void addEntry() { - table = view.getFinancialTransactionTable(); - tableModel = view.getFinancialTransactionTableModel(); + FinancialTransactionTable table = getTable(); + FinancialTransactionTableModel tableModel = getTableModel(); + ListSelectionModel selectionModel = table.getSelectionModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { - Object selectedValue = tableModel.getElementAt(indexSelectedRow); - try { - //copy + paste the voucher and the description - String voucher = (String) + + int firstentryBookrow = + tableModel.getFirstEntry(indexSelectedRow); + + String voucher; + String description; + if (firstentryBookrow == -1) { + + // no entry book for this transaction + voucher = null; + description = null; + + } else { + + // there is no first entry, grab the voucher and + voucher = (String) tableModel.getValueAt(indexSelectedRow, 2); - String description = (String) + description = (String) tableModel.getValueAt(indexSelectedRow, 4); - int index = tableModel.addEmptyEntry(selectedValue, - voucher, - description, - indexSelectedRow + } + try { + + // creates the new entry + + int index = tableModel.addEmptyEntry( + voucher, + description, + indexSelectedRow ); + //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); selectionModel.setSelectionInterval( indexSelectedRow + 1, indexSelectedRow + 1); //focus on second column table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); +// table.requestFocusInWindow(); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); @@ -206,8 +222,8 @@ */ public void deleteSelectedRow() { - table = view.getFinancialTransactionTable(); - tableModel = view.getFinancialTransactionTableModel(); + FinancialTransactionTable table = getTable(); + FinancialTransactionTableModel tableModel = getTableModel(); int indexSelectedRow = table.getSelectedRow(); if (indexSelectedRow != -1) { @@ -227,7 +243,7 @@ if (response == JOptionPane.YES_OPTION) { try { - tableModel.removeObject(selectedValue, indexSelectedRow); + tableModel.removeObject(indexSelectedRow); //select the upper line ListSelectionModel selectionModel = table.getSelectionModel(); @@ -247,13 +263,36 @@ } } - public void refresh() { - tableModel = view.getFinancialTransactionTableModel(); - tableModel.refresh(); - fiscalPeriodComboBoxModel = view.getModelFiscalPeriod(); - fiscalPeriodComboBoxModel.refresh(); + public void back(JComboBox comboBox) { + int row = comboBox.getSelectedIndex(); + if (log.isDebugEnabled()) { + log.debug(row); + } - financialPeriodComboBoxModel = view.getModelFinancialPeriod(); - financialPeriodComboBoxModel.refresh(); + if (row > 0) { + comboBox.setSelectedIndex(row - 1); + //FIXME tchemit-2011-09-20 Should never referesh ui by hand + comboBox.repaint(); + } } + + public void next(JComboBox comboBox) { + int size = comboBox.getModel().getSize(); + int row = comboBox.getSelectedIndex(); + if (log.isDebugEnabled()) { + log.debug(row); + } + + if (row < size - 1) { + comboBox.setSelectedIndex(row + 1); + //FIXME tchemit-2011-09-20 Should never referesh ui by hand + comboBox.repaint(); + } + } + + public void refresh() { + getTableModel().refresh(); + getFiscalPeriodComboBoxModel().refresh(); + getFinancialPeriodComboBoxModel().refresh(); + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.EntryBookToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -52,7 +52,7 @@ this.handler = handler; EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(EntryBook.class); + LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class); setModel(entryBookComboBoxModel); setRenderer(renderer); setEditable(true); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxPeriodEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -131,7 +131,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -153,7 +153,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -255,7 +255,7 @@ if (object instanceof FinancialTransaction){ FinancialTransaction financialTransaction = (FinancialTransaction) object; if (financialTransaction.getEntry().size() == 0){ - handler.addEmptyEntry(); + handler.addEntry(); this.setColumnSelectionInterval(1, 1); } } @@ -291,7 +291,7 @@ } } else { - handler.addEmptyEntry(); + handler.addEntry(); table.setColumnSelectionInterval(1, 1); y_tab++; // positionne la sélection sur la nouvelle ligne créée Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -34,6 +34,8 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialPeriodService; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; @@ -77,10 +79,10 @@ .getLog(FinancialTransactionSearchTableModel.class); /** Transaction service. */ - protected final FinancialTransactionServiceMonitorable financialTransactionService; + protected final FinancialTransactionService financialTransactionService; /** Financial service */ - protected final FinancialPeriodServiceMonitorable financialPeriodService; + protected final FinancialPeriodService financialPeriodService; /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; @@ -99,11 +101,11 @@ public FinancialTransactionSearchTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); + LimaServiceFactory.addServiceListener(financialTransactionService, this); financialPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialPeriodServiceMonitorable.class); } @@ -374,7 +376,7 @@ throw new LimaException("Can't set new transaction"); } financialTransaction.setFinancialPeriod(financialPeriod); - //financialTransaction.setFinancialPeriod(selectedFiscalPeriod); + //financialTransaction.setSelectedFinancialPeriod(selectedFiscalPeriod); // get today Calendar actualCalendar = Calendar.getInstance(); // get the financial period date Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -84,7 +84,7 @@ /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); financialTransactionSearch = new FinancialTransactionSearchImpl(); @@ -185,8 +185,6 @@ * Delete selected row in table (could be transaction or entry). * <p/> * Called by model. - * - * @throws LimaException */ public void deleteSelectedRow() { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Letter; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -52,7 +52,7 @@ this.handler = handler; LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(Letter.class); + LimaRendererUtil.newDecoratorListCellRenderer(Letter.class); setModel(letterComboBoxModel); setRenderer(renderer); setEditable(true); 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -47,6 +47,7 @@ import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -90,7 +91,7 @@ .getLog(FinancialTransactionUnbalancedTableModel.class); /** Transaction service. */ - protected final FinancialTransactionServiceMonitorable financialTransactionService; + protected final FinancialTransactionService financialTransactionService; /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; @@ -110,9 +111,9 @@ public FinancialTransactionUnbalancedTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); + LimaServiceFactory.addServiceListener(financialTransactionService, this); } /** @@ -419,8 +420,8 @@ DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire - financialTransactionRow = - cacheDataList.indexOf(currentRow); +// financialTransactionRow = +// cacheDataList.indexOf(currentRow); } else if (currentRow instanceof Entry) { Entry currentEntry = (Entry) currentRow; switch (column) { @@ -454,9 +455,9 @@ DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire - financialTransactionRow = - cacheDataList.indexOf(((Entry) currentRow). - getFinancialTransaction()); +// financialTransactionRow = +// cacheDataList.indexOf(((Entry) currentRow). +// getFinancialTransaction()); } //on recharge la liste cacheDataList = getDataList(); @@ -496,7 +497,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")) { + if (serviceName.contains("FinancialTransaction") || + methodeName.contains("importEntries") || + methodeName.contains("importAll")) { refresh(); } } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,7 +28,7 @@ javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel - org.chorem.lima.ui.renderers.RendererUtil + org.chorem.lima.ui.LimaRendererUtil </import> <FinancialTransactionUnbalancedViewHandler id="handler" javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/> @@ -61,7 +61,7 @@ <cell anchor="west"> <JComboBox id="fiscalPeriodComboBox" model="{modelFiscalPeriod}" - renderer="{RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" + renderer="{LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem()); getHandler().refresh()" editable="false"/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -44,7 +44,7 @@ getRootPane().setDefaultButton(okButton); protected FiscalPeriodServiceMonitorable fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); // set begin date picker 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -32,6 +32,8 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; import org.chorem.lima.business.utils.FiscalPeriodComparator; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; @@ -65,24 +67,23 @@ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class); - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; - protected FinancialTransactionServiceMonitorable financialTransactionService; + protected FinancialTransactionService financialTransactionService; /** data cache */ - protected List<Object> cacheDataList; + protected List<?> cacheDataList; public FiscalPeriodTableModel() { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(fiscalPeriodService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); + LimaServiceFactory.addServiceListener(financialTransactionService, this); cacheDataList = null; } @@ -95,7 +96,7 @@ results.addAll(fiscalPeriod); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.fiscalperiod.listerror"), eee); } @@ -169,7 +170,7 @@ Object result = "n/a"; - List<Object> periods; + List<?> periods; periods = cacheDataList; FiscalPeriod fiscalPeriod = (FiscalPeriod) periods.get(rowIndex); @@ -202,7 +203,10 @@ return fiscalPeriod; } - /** @param period */ + /** + * @param period + * @throws LimaException + */ public void addFiscalPeriod(FiscalPeriod period) throws LimaException { try { @@ -214,7 +218,7 @@ fireTableRowsInserted(row, row); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't create FiscalPeriod", eee); + log.error("Can't create FiscalPeriod", eee); } ErrorHelper.showErrorDialog(_("lima.fiscalperiod.creationerror"), eee); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -75,11 +75,11 @@ this.view = view; fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -29,7 +29,7 @@ <import> javax.swing.text.Document org.chorem.lima.entity.EntryBook - org.chorem.lima.ui.renderers.RendererUtil + org.chorem.lima.ui.LimaRendererUtil org.chorem.lima.ui.combobox.EntryBookComboBoxModel </import> <EntryBook id="entryBook" javaBean="null"/> @@ -96,7 +96,7 @@ <EntryBookComboBoxModel id="modelEntryBookComboBox"/> <JComboBox id="entryBookComboBox" model="{getModelEntryBookComboBox()}" - renderer="{RendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" + renderer="{LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" editable="false" onItemStateChanged="getEntryBook().setCode(((EntryBook)getEntryBookComboBox().getSelectedItem()).getCode()); getEntryBook().setLabel(((EntryBook)getEntryBookComboBox().getSelectedItem()).getLabel())"/> </cell> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -63,11 +63,12 @@ public AccountsPane(HomeView view) { this.view = view; accountService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( AccountServiceMonitorable.class); - accountService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener( + AccountServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener( + ImportServiceMonitorable.class, this); //init setOpaque(true); @@ -80,7 +81,7 @@ @Override public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { if (e.getDescription().equals("#accountschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -32,6 +32,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.EntryBookService; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; @@ -53,7 +54,7 @@ protected HomeView view; - protected EntryBookServiceMonitorable entryBookService; + protected EntryBookService entryBookService; private static Color redBackground = new Color(0xff, 0xee, 0xee); @@ -63,11 +64,10 @@ this.view = view; entryBookService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( EntryBookServiceMonitorable.class); - entryBookService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(entryBookService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); //init setOpaque(true); @@ -81,7 +81,7 @@ @Override public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { if (e.getDescription().equals("#entrybookschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -33,6 +33,8 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; @@ -55,9 +57,9 @@ protected HomeView view; - protected FinancialTransactionServiceMonitorable financialTransactionService; + protected FinancialTransactionService financialTransactionService; - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; private static Color redBackground = new Color(0xff, 0xee, 0xee); @@ -67,13 +69,12 @@ this.view = view; financialTransactionService = - LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); + LimaServiceFactory.getService(FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.addServiceListener(financialTransactionService, this); fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.addServiceListener(fiscalPeriodService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); //init setOpaque(true); @@ -86,7 +87,7 @@ @Override public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { if (e.getDescription().equals("#financialtransactionunbalanced")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -32,6 +32,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; @@ -53,7 +54,7 @@ protected HomeView view; - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; private static Color redBackground = new Color(0xff, 0xee, 0xee); @@ -63,10 +64,9 @@ this.view = view; fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.addServiceListener(fiscalPeriodService, this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); //init setOpaque(true); @@ -79,7 +79,7 @@ @Override public void hyperlinkUpdate(HyperlinkEvent e) { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { if (e.getDescription().equals("#fiscalperiodschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); @@ -133,8 +133,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll") - || methodeName.contains("importAs")) { + if (methodeName.contains("FiscalPeriod") || + methodeName.contains("importAll") || + methodeName.contains("importAs")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/HomeView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -29,7 +29,7 @@ java.awt.Font javax.swing.BoxLayout javax.swing.border.EtchedBorder - javax.swing.ImageIcon + jaxx.runtime.SwingUtil static org.nuiton.i18n.I18n._ </import> @@ -48,7 +48,7 @@ <row> <cell weightx="0" weighty="0.1" anchor="northwest"> <JLabel - icon='{new ImageIcon(getClass().getResource("/images/accounts.png"))}'/> + icon='accounts.png'/> </cell> <cell weightx="1" weighty="0.1" anchor="center"> <JLabel foreground='{Color.DARK_GRAY}' @@ -76,7 +76,7 @@ <row> <cell weightx="0" weighty="0.1" anchor="northwest"> <JLabel - icon='{new ImageIcon(getClass().getResource("/images/entrybooks.png"))}'/> + icon='entrybooks.png'/> </cell> <cell weightx="1" weighty="0.1" anchor="center"> <JLabel foreground='{Color.DARK_GRAY}' @@ -106,7 +106,7 @@ <row> <cell weightx="0" weighty="0.1" anchor="northwest"> <JLabel - icon='{new ImageIcon(getClass().getResource("/images/fiscalperiods.png"))}'/> + icon='fiscalperiods.png'/> </cell> <cell weightx="1" weighty="0.1" anchor="center"> <JLabel foreground='{Color.DARK_GRAY}' @@ -134,7 +134,7 @@ <row> <cell weightx="0" weighty="0.1" anchor="northwest"> <JLabel - icon='{new ImageIcon(getClass().getResource("/images/entries.png"))}'/> + icon='entries.png'/> </cell> <cell weightx="1" weighty="0.1" anchor="center"> <JLabel foreground='{Color.DARK_GRAY}' @@ -144,8 +144,7 @@ </row> <row fill="both"> <cell columns="2" weightx="1" weighty="0.9"> - <JEditorPane - javaBean='new FinancialTransactionsPane(this)'/> + <JEditorPane initializer='new FinancialTransactionsPane(this)'/> </cell> </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -43,7 +43,7 @@ public IdentityHandler() { identityService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( IdentityServiceMonitorable.class); } 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 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -84,10 +84,10 @@ //services importService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( ImportServiceMonitorable.class); exportService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( ExportServiceMonitorable.class); //create the wait dialog panel @@ -103,6 +103,8 @@ * Call the appropriate methode in business service. * * @param importExportMethode + * @param file + * @param verbose */ public void importExport(ImportExportEnum importExportMethode, String file, Boolean verbose) { final ImportExportEnum importExportMethodeF = importExportMethode; @@ -233,7 +235,7 @@ log.error("Can't get result message", eee); } } catch (ExecutionException eee) { - DialogHelper.showMessageDialog(eee.getCause().getMessage()); + DialogHelper.showErrorMessageDialog(viewComponent, eee.getCause()); if (log.isErrorEnabled()) { log.error("Error on import", eee); } @@ -250,6 +252,7 @@ * folders for export or folders+files for import * * @param importMode + * @param importExportMethode * @return */ public String chooseFile(Boolean importMode, ImportExportEnum importExportMethode) { @@ -283,14 +286,21 @@ } - /** Get csv datas in string and write file */ + /** Get csv datas in string and write file + * @param filePath + * @param charset + * @param datas*/ public void createFile(String filePath, String charset, String datas) { + File file = new File(filePath); try { - File file = new File(filePath); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); - out.write(datas); - out.flush(); - out.close(); + try { + out.write(datas); + out.flush(); + out.close(); + } finally { + out.close(); + } } catch (IOException eee) { if (log.isErrorEnabled()) { log.error("Can't write file " + filePath, eee); @@ -298,7 +308,10 @@ } } - /** Open csv file and get his datas on a string. */ + /** Open csv file and get his datas on a string. + * @param filePath + * @param charset + * @return*/ public String extractFile(String filePath, String charset) { StringWriter sw = new StringWriter(); BufferedReader in = null; @@ -314,7 +327,11 @@ } in = new BufferedReader(new InputStreamReader(is, charset)); - IOUtils.copy(in, sw); + try { + IOUtils.copy(in, sw); + } finally { + in.close(); + } in.close(); } catch (IOException eee) { if (log.isErrorEnabled()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -111,7 +111,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -135,7 +135,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -30,7 +30,6 @@ import org.chorem.lima.LimaConfig; import org.chorem.lima.beans.BalanceTrial; import org.chorem.lima.beans.ReportsDatas; -import org.chorem.lima.business.DocumentServiceMonitorable; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; import org.chorem.lima.business.HttpServerServiceMonitorable; @@ -38,6 +37,8 @@ import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ReportServiceMonitorable; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; +import org.chorem.lima.business.ejbinterface.ReportService; import org.chorem.lima.business.utils.DocumentsEnum; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.business.utils.FormatsEnum; @@ -75,11 +76,11 @@ private static final Log log = LogFactory.getLog(LedgerTableModel.class); /** Services. */ - protected ReportServiceMonitorable reportService; + protected ReportService reportService; - protected DocumentServiceMonitorable documentService; +// protected DocumentService documentService; - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; /** Begin Date. */ protected Date selectedBeginDate; @@ -103,21 +104,16 @@ this.view = view; reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); - reportService.addServiceListener(this); - port = LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService(ReportServiceMonitorable.class); + LimaServiceFactory.addServiceListener(reportService, this); + port = LimaServiceFactory.getService( HttpServerServiceMonitorable.class).getHttpPort(); - documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); +// documentService = +// LimaServiceFactory.getService(DocumentServiceMonitorable.class); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener(FinancialTransactionServiceMonitorable.class, this); } public void setBeginDate(Date date) { @@ -156,7 +152,7 @@ } } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog("Can't get entries list", eee); } @@ -183,7 +179,7 @@ view.amountSoldeLabel.setText( String.valueOf(amountSolde)); - if (amountSolde == BigDecimal.ZERO) { + if (BigDecimal.ZERO.equals(amountSolde)) { view.soldeLabel.setText(_("lima.common.solde")); } else { // set label solde: credit or debit @@ -207,7 +203,7 @@ blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Enable to create document ", eee); + log.error("Enable to create document ", eee); } ErrorHelper.showErrorDialog(_("lima.ledger.documentcreationerror"), eee); } @@ -253,7 +249,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) { + if (serviceName.contains("FinancialTransaction") || + methodeName.contains("importAccount") || + methodeName.contains("importAll")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,8 +28,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Letter; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; @@ -48,7 +48,7 @@ LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(Letter.class); + LimaRendererUtil.newDecoratorListCellRenderer(Letter.class); setModel(letterComboBoxModel); setRenderer(renderer); setEditable(true); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -30,9 +30,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -110,7 +110,7 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -134,7 +134,7 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,6 +31,7 @@ import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; import org.chorem.lima.business.utils.EntryComparator; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -56,8 +57,8 @@ /** * Basic transaction table model. * <p/> - * Le modele est filtré sur {@link #selectedFinancialPeriod} et - * {@link #selectedFinancialPeriod} (montée en charge !). + * Le modele est filtré sur {@link #selectedBeginDate} et + * {@link #selectedEndDate} (montée en charge !). * * @author ore * @author chatellier @@ -76,7 +77,7 @@ .getLog(LetteringTableModel.class); /** Transaction service. */ - protected final FinancialTransactionServiceMonitorable financialTransactionService; + protected final FinancialTransactionService financialTransactionService; /** Begin Date. */ protected Date selectedBeginDate; @@ -99,11 +100,10 @@ public LetteringTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(financialTransactionService,this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } public void setSelectedBeginDate(Date date) { @@ -425,7 +425,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")) { + if (serviceName.contains("FinancialTransaction") || + methodeName.contains("importEntries") || + methodeName.contains("importAll")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -77,7 +77,7 @@ /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FinancialTransactionServiceMonitorable.class); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/CreateFiscalPeriodPanel.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -37,7 +37,7 @@ <![CDATA[ protected FiscalPeriodServiceMonitorable fiscalPeriodService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class); // set begin date picker Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningView.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -28,9 +28,10 @@ <import> javax.swing.BorderFactory javax.swing.ImageIcon + jaxx.runtime.SwingUtil </import> - <OpeningViewHandler id="handler" javaBean="new OpeningViewHandler(this)"/> + <OpeningViewHandler id="handler" constructorParams="this"/> <script> <![CDATA[ @@ -51,7 +52,7 @@ <row> <cell weightx="0.1"> <JLabel id='identityIcon' - icon='{new ImageIcon(getClass().getResource("/images/identity.png"))}'/> + icon='identity.png'/> </cell> <cell weightx="0.9" rows="4" fill="both"> <JPanel id='panel'> @@ -63,20 +64,17 @@ </row> <row> <cell> - <JLabel id='accountsIcon' - icon='{new ImageIcon(getClass().getResource("/images/accounts.png"))}'/> + <JLabel id='accountsIcon' icon='accounts.png'/> </cell> </row> <row> <cell> - <JLabel id='entrybooksIcon' - icon='{new ImageIcon(getClass().getResource("/images/entrybooks.png"))}'/> + <JLabel id='entrybooksIcon' icon='entrybooks.png'/> </cell> </row> <row> <cell> - <JLabel id='fiscalperiodsIcon' - icon='{new ImageIcon(getClass().getResource("/images/fiscalperiods.png"))}'/> + <JLabel id='fiscalperiodsIcon' icon='fiscalperiods.png'/> </cell> </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -191,7 +191,7 @@ fiscalPeriod.setBeginDate(fsPanel.getBeginDatePicker().getDate()); fiscalPeriod.setEndDate(fsPanel.getEndDatePicker().getDate()); - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( FiscalPeriodServiceMonitorable.class). createFiscalPeriod(fiscalPeriod); Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -1,31 +0,0 @@ -package org.chorem.lima.ui.renderers; - -import jaxx.runtime.swing.renderer.DecoratorListCellRenderer; -import jaxx.runtime.swing.renderer.DecoratorProviderListCellRenderer; -import org.chorem.lima.LimaContext; -import org.nuiton.util.decorator.Decorator; -import org.nuiton.util.decorator.DecoratorProvider; - -import javax.swing.ListCellRenderer; - -/** - * Helper class to deal with renderers. - * - * @author tchemit <chemit@codelutin.com> - * @since 0.5.2 - */ -public class RendererUtil { - - public static ListCellRenderer newDecoratorProviderListCellRenderer() { - DecoratorProvider decoratorProvider = LimaContext.get().getDecoratorProvider(); - return new DecoratorProviderListCellRenderer(decoratorProvider); - } - - public static ListCellRenderer newDecoratorListCellRenderer(Class<?> type) { - - DecoratorProvider decoratorProvider = LimaContext.get().getDecoratorProvider(); - Decorator<?> decorator = decoratorProvider.getDecoratorByType(type); - return new DecoratorListCellRenderer(decorator); - } - -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -52,7 +52,7 @@ super(new VatStatementImpl()); // Gets factory service vatStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( VatStatementServiceMonitorable.class); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -58,10 +58,9 @@ this.view = view; vatStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( VatStatementServiceMonitorable.class); - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addServiceListener(this); + LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); } public void addVatStatementMovement() { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -30,9 +30,9 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; +import org.chorem.lima.ui.LimaRendererUtil; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; @@ -80,14 +80,17 @@ //handler().setEndDate(endDate); JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + final VatReportTableModel tableModel = handler.getTableModel(); + ActionListener beginDateActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - handler.tableModel.setBeginDate(beginDatePicker.getDate()); + + tableModel.setBeginDate(beginDatePicker.getDate()); handler.refresh(); } }; - handler.tableModel.setBeginDate(beginDatePicker.getDate()); + tableModel.setBeginDate(beginDatePicker.getDate()); beginDatePicker.addActionListener(beginDateActionListener); JLabel endDateLabel = new JLabel(_("lima.common.enddate")); @@ -95,11 +98,11 @@ ActionListener endDateActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - handler.tableModel.setEndDate(endDatePicker.getDate()); + tableModel.setEndDate(endDatePicker.getDate()); handler.refresh(); } }; - handler.tableModel.setEndDate(endDatePicker.getDate()); + tableModel.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); @@ -111,9 +114,10 @@ break; case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); + FiscalPeriodComboBoxModel fiscalModel = + new FiscalPeriodComboBoxModel(true); ListCellRenderer renderer = - RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); @@ -122,8 +126,8 @@ public void actionPerformed(ActionEvent e) { FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); if (fPeriod != null) { - handler.tableModel.setBeginDate(fPeriod.getBeginDate()); - handler.tableModel.setEndDate(fPeriod.getEndDate()); + handler.getTableModel().setBeginDate(fPeriod.getBeginDate()); + handler.getTableModel().setEndDate(fPeriod.getEndDate()); handler.refresh(); } } @@ -135,9 +139,10 @@ break; case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + FinancialPeriodComboBoxModel financialModel = + new FinancialPeriodComboBoxModel(true); renderer = - RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); @@ -146,8 +151,8 @@ public void actionPerformed(ActionEvent e) { FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); if (fPeriod != null) { - handler.tableModel.setBeginDate(fPeriod.getBeginDate()); - handler.tableModel.setEndDate(fPeriod.getEndDate()); + handler.getTableModel().setBeginDate(fPeriod.getBeginDate()); + handler.getTableModel().setEndDate(fPeriod.getEndDate()); handler.refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -24,31 +24,31 @@ */ package org.chorem.lima.ui.vatreports; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.jdesktop.swingx.JXTable; import java.math.BigDecimal; +/** @deprecated since 0.5.2 : Ne sert à rien! */ +@Deprecated public class VatReportTable extends JXTable { /** serialVersionUID. */ private static final long serialVersionUID = 4042515416850867834L; - /** log. */ - private static final Log log = LogFactory.getLog(VatReportTable.class); +// /** log. */ +// private static final Log log = LogFactory.getLog(VatReportTable.class); protected VatReportViewHandler handler; - protected VatReportTableModel model; +// protected VatReportTableModel model; public VatReportTable(VatReportViewHandler handler) { this.handler = handler; - model = this.handler.getView().getVatReportTableModel(); +// model = this.handler.getTableModel(); //Get new BigDecimal editor setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -30,9 +30,9 @@ import org.chorem.lima.business.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.ImportServiceMonitorable; import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ReportServiceMonitorable; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.VatStatementServiceMonitorable; +import org.chorem.lima.business.ejbinterface.VatStatementService; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; import org.nuiton.topia.TopiaException; @@ -54,14 +54,14 @@ .getLog(VatReportTableModel.class); /** Services. */ - protected ReportServiceMonitorable reportService; +// protected ReportServiceMonitorable reportService; - protected VatStatementServiceMonitorable vatStatementService; + protected VatStatementService vatStatementService; - protected FinancialTransactionServiceMonitorable financialTransactionService; +// protected FinancialTransactionServiceMonitorable financialTransactionService; +// +// protected ImportServiceMonitorable importService; - protected ImportServiceMonitorable importService; - /** selected financial period */ protected Date selectedBeginDate; @@ -70,35 +70,31 @@ /** data cache */ protected List<VatStatementAmounts> cacheDataList; - /** - * variable used for the document edition, - * if "true" then the document will be automatically filled in - * if "false" the the document will be empty - */ - protected String autocomplete; +// /** +// * variable used for the document edition, +// * if "true" then the document will be automatically filled in +// * if "false" the the document will be empty +// */ +// protected String autocomplet; public VatReportTableModel() { - reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); +// reportService = +// LimaServiceFactory.getService( +// ReportServiceMonitorable.class); //add listeners vatStatementService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( VatStatementServiceMonitorable.class); - vatStatementService.addServiceListener(this); - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addServiceListener(this); - importService = - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class); - importService.addServiceListener(this); + LimaServiceFactory.addServiceListener(vatStatementService, this); + LimaServiceFactory.addServiceListener( + FinancialTransactionServiceMonitorable.class, this); + LimaServiceFactory.addServiceListener( + ImportServiceMonitorable.class, this); - //sets autocomplete mode to true on start - autocomplete = "true"; +// //sets autocomplete mode to true on start +// autocomplete = "true"; } protected List<VatStatementAmounts> getDataList() throws TopiaException { @@ -112,7 +108,7 @@ getEndDate()); } catch (LimaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.vatreport.listerror"), eee); } @@ -125,7 +121,7 @@ cacheDataList = getDataList(); } catch (TopiaException eee) { if (log.isErrorEnabled()) { - log.debug("Can't update model", eee); + log.error("Can't update model", eee); } ErrorHelper.showErrorDialog("Can't get VAT list", eee); } @@ -224,18 +220,18 @@ return selectedEndDate; } - public String getAutocomplete() { - return autocomplete; - } +// public String getAutocomplete() { +// return autocomplete; +// } +// +// public void setAutocomplete() { +// if (getAutocomplete().equals("true")) { +// autocomplete = "false"; +// } else { +// autocomplete = "true"; +// } +// } - public void setAutocomplete() { - if (getAutocomplete().equals("true")) { - autocomplete = "false"; - } else { - autocomplete = "true"; - } - } - @Override public boolean isCellEditable(int row, int column) { return false; @@ -244,7 +240,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { //automatic refresh when FinancialTransaction, VatStatement chart or import for VAT services have been used by the user - if (serviceName.contains("FinancialTransaction") || methodeName.contains("VatStatement") || methodeName.contains("import")) { + if (serviceName.contains("FinancialTransaction") || + methodeName.contains("VatStatement") || + methodeName.contains("import")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2011-09-20 14:51:40 UTC (rev 3295) @@ -23,27 +23,24 @@ #L% --> <Table> - <VatReportViewHandler id="handler" javaBean="new VatReportViewHandler(this)"/> - <Boolean id="selectedRow" javaBean="false"/> + <VatReportViewHandler id="handler" + initializer="new VatReportViewHandler(this)"/> + <import> + javax.swing.ListSelectionModel + org.jdesktop.swingx.JXTable + org.chorem.lima.entity.FiscalPeriod + org.chorem.lima.entity.FinancialPeriod + org.chorem.lima.enums.ComboBoxDatesEnum + </import> + + <Boolean id="autoComplete" javaBean="false"/> + <script> <![CDATA[ - import org.chorem.lima.entity.FiscalPeriod; - import org.chorem.lima.entity.FinancialPeriod; - import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; - import org.chorem.lima.ui.financialtransaction.FinancialPeriodComboBox; - import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; - import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; - import org.chorem.lima.ui.vatreports.VatTableModel; - import org.chorem.lima.ui.vatreports.VatTable; - - import org.chorem.lima.enums.ComboBoxDatesEnum; - VatReportPeriodSearchPanel periodSearchPanel = new VatReportPeriodSearchPanel(handler); - void $afterCompleteSetup() { - getHandler().refresh(); + getHandler().init(); } - ]]> </script> @@ -52,20 +49,19 @@ <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> </cell> <cell anchor="west"> - <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel - id="modelFiscalPeriod"/> <JComboBox id="periodComboBox" javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())" onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); validate(); repaint()"/> </cell> <cell> - <VatReportPeriodSearchPanel javaBean="periodSearchPanel"/> + <VatReportPeriodSearchPanel id="periodSearchPanel" + constructorParams="handler"/> </cell> <cell> - <JCheckBox id='autocomplete' text='lima.common.autocomplete' + <JCheckBox id='autocompleteCheckBox' text='lima.common.autocomplete' selected='true' - onActionPerformed="getVatReportTableModel().setAutocomplete()"/> + onActionPerformed="setAutoComplete(!autoComplete)"/> </cell> <cell> <JButton id="editVatButton" text="lima.reports.vat" @@ -75,15 +71,13 @@ <row> <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> <JScrollPane> - <org.chorem.lima.ui.vatreports.VatReportTableModel - id="vatReportTableModel"/> - <org.chorem.lima.ui.vatreports.VatReportTable - id="vatReportTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" model="{getVatReportTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> - <javax.swing.ListSelectionModel - javaBean="getVatReportTable().getSelectionModel()" - onValueChanged="setSelectedRow(vatReportTable.getSelectedRow() != -1)"/> + <!--<VatReportTableModel id="vatReportTableModel"/>--> + <JXTable id="vatReportTable" sortable="false" rowHeight="22" + model="{new VatReportTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + <!--<ListSelectionModel--> + <!--initializer="getVatReportTable().getSelectionModel()"--> + <!--onValueChanged="setSelectedRow(vatReportTable.getSelectedRow() != -1)"/>--> </JScrollPane> </cell> </row> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -31,9 +31,12 @@ import org.chorem.lima.business.HttpServerServiceMonitorable; import org.chorem.lima.business.utils.DocumentsEnum; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import java.awt.Desktop; import java.io.IOException; +import java.math.BigDecimal; import java.net.URI; import java.net.URISyntaxException; import java.text.SimpleDateFormat; @@ -45,10 +48,6 @@ protected VatReportView view; - protected VatReportTable table; - - protected VatReportTableModel tableModel; - protected DocumentServiceMonitorable documentService; private static SimpleDateFormat dateFormat = @@ -59,21 +58,36 @@ protected VatReportViewHandler(VatReportView view) { this.view = view; - port = LimaServiceFactory.getInstance().getService( + port = LimaServiceFactory.getService( HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getService( DocumentServiceMonitorable.class); } + public void init() { + //Get new BigDecimal editor + view.getVatReportTable().setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); + + //Get new BigDecimal renderer + view.getVatReportTable().setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); + + // do refresh (TODO check if required...) + refresh(); + } /** @return VatView */ public VatReportView getView() { return view; } + public VatReportTableModel getTableModel() { + return (VatReportTableModel) view.getVatReportTable().getModel(); + } + /** Edit VAT document */ public void editVat() { + VatReportTableModel tableModel = getTableModel(); if (tableModel.getBeginDate() != null || tableModel.getEndDate() != null) { String address = LimaConfig.getInstance().getHostAdress(); @@ -82,7 +96,7 @@ + dateFormat.format(tableModel.getBeginDate()) + "&endDate=" + dateFormat.format(tableModel.getEndDate()) + "&format=.pdf&model=" + DocumentsEnum.VAT.getFileName() - + "&autocomplete=" + tableModel.getAutocomplete(); + + "&autocomplete=" + view.getAutoComplete(); Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { log.error("Can't open browser", e); @@ -94,7 +108,7 @@ /** Refresh VatTableModel */ public void refresh() { - tableModel = view.getVatReportTableModel(); + VatReportTableModel tableModel = getTableModel(); tableModel.refresh(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2011-09-20 14:51:40 UTC (rev 3295) @@ -63,7 +63,7 @@ * JOptionPane.INFORMATION_MESSAGE); * * @param message - * @deprecated since 0.5, prefer use the method {@link #showErrorMessageDialog(Component, Exception)} + * @deprecated since 0.5, prefer use the method {@link #showErrorMessageDialog(Component, Throwable)} */ @Deprecated public static void showMessageDialog(String message) { @@ -77,7 +77,7 @@ f.dispose(); } - public static void showErrorMessageDialog(Component view, Exception e) { + public static void showErrorMessageDialog(Component view, Throwable e) { JOptionPane.showMessageDialog( view, e.getMessage(), Copied: trunk/lima-swing/src/main/resources/icons/accounts.png (from rev 3288, trunk/lima-swing/src/main/resources/images/accounts.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/accounts.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/entries.png (from rev 3288, trunk/lima-swing/src/main/resources/images/entries.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/entries.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/entrybooks.png (from rev 3288, trunk/lima-swing/src/main/resources/images/entrybooks.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/entrybooks.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/fiscalperiods.png (from rev 3288, trunk/lima-swing/src/main/resources/images/fiscalperiods.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/fiscalperiods.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/identity.png (from rev 3288, trunk/lima-swing/src/main/resources/images/identity.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/identity.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/puzzle_icon.png (from rev 3288, trunk/lima-swing/src/main/resources/images/puzzle_icon.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/puzzle_icon.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/lima-swing/src/main/resources/icons/puzzle_splash.png (from rev 3288, trunk/lima-swing/src/main/resources/images/puzzle_splash.png) =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/puzzle_splash.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: svn:keywords + Author Date Id Revision HeadURL Deleted: trunk/lima-swing/src/main/resources/images/accounts.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/entries.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/entrybooks.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/fiscalperiods.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/identity.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/puzzle_icon.png =================================================================== (Binary files differ) Deleted: trunk/lima-swing/src/main/resources/images/puzzle_splash.png =================================================================== (Binary files differ) Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2011-09-20 14:47:53 UTC (rev 3294) +++ trunk/lima-swing/src/main/resources/log4j.properties 2011-09-20 14:51:40 UTC (rev 3295) @@ -37,4 +37,4 @@ log4j.appender.file.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n # package level -#log4j.logger.org.chorem.lima=DEBUG \ No newline at end of file +log4j.logger.org.chorem.lima=INFO \ No newline at end of file