r3291 - in trunk: . lima-swing lima-swing/src/main/java/org/chorem/lima lima-swing/src/main/java/org/chorem/lima/actions lima-swing/src/main/java/org/chorem/lima/enums lima-swing/src/main/java/org/chorem/lima/service lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/accountsreports lima-swing/src/main/java/org/chorem/lima/ui/balance lima-swing/src/main/java/org/chorem/lima/ui/celleditor lima-swing/src/ma
Author: tchemit Date: 2011-09-17 14:59:34 +0200 (Sat, 17 Sep 2011) New Revision: 3291 Url: http://chorem.org/repositories/revision/lima/3291 Log: T?\195?\162che #437: Can not launch via jnlp T?\195?\162che #457: Updates to nuiton-utils 2.3 Evolution #456: Nettoyage du code des ui (debut...) Evolution #444: [Saisie ?\195?\169criture] Saisie d'une transaction lourde Evolution #441: [Saisie ?\195?\169criture] Ouvrir un journal et le modifier Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java Modified: trunk/lima-swing/pom.xml trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/VatStatementsChartEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.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/BalanceTable.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/AccountTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.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/AccountRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.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/EntryBookTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/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/EntryBooksReportsTable.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/FinancialStatementChartTreeTable.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/FinancialStatementReportTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.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/FinancialPeriodComboBox.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/AccountSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.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/EntryBookSearchPanel.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/FinancialTransactionSearchView.jaxx 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/financialtransactionsearch/LetterSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 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/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/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/LedgerTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.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/LetteringPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.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/VatReportTableModel.java 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/java/org/chorem/lima/widgets/JWideComboBox.java trunk/pom.xml Modified: trunk/lima-swing/pom.xml =================================================================== --- trunk/lima-swing/pom.xml 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/pom.xml 2011-09-17 12:59:34 UTC (rev 3291) @@ -59,27 +59,11 @@ <artifactId>nuiton-i18n</artifactId> </dependency> - <!-- other dependencies --> - <!--dependency> - <groupId>dom4j</groupId> - <artifactId>dom4j</artifactId> - </dependency--> - - <!--dependency> - <groupId>net.sf.opencsv</groupId> - <artifactId>opencsv</artifactId> - </dependency--> - <dependency> <groupId>org.swinglabs</groupId> <artifactId>swingx-core</artifactId> </dependency> - <!--dependency> - <groupId>org.jdom</groupId> - <artifactId>jdom</artifactId> - </dependency--> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-email</artifactId> @@ -128,19 +112,17 @@ <properties> <!--Main class in JAR --> <maven.jar.main.class>org.chorem.lima.LimaMain</maven.jar.main.class> - <webstartPluginVersion>1.0-beta-2-SNAPSHOT</webstartPluginVersion> - + <redmine.releaseFiles> target/lima-${project.version}-bin.zip, </redmine.releaseFiles> <license.generateBundle>true</license.generateBundle> - <license.bundleLicensePath>META-INF/lima-swing-LICENSE.txt</license.bundleLicensePath> - <license.bundleThirdPartyPath>META-INF/lima-swing-THIRD-PARTY.txt</license.bundleThirdPartyPath> + <license.bundleLicensePath>META-INF/lima-LICENSE.txt</license.bundleLicensePath> + <license.bundleThirdPartyPath>META-INF/lima-THIRD-PARTY.txt</license.bundleThirdPartyPath> <i18n.bundles>fr_FR,en_GB</i18n.bundles> <i18n.bundleOutputName>lima</i18n.bundleOutputName> - <jnlp.codebase>${project.url}/jnlp</jnlp.codebase> </properties> @@ -249,11 +231,14 @@ <plugin> <groupId>org.codehaus.mojo.webstart</groupId> <artifactId>webstart-maven-plugin</artifactId> - <version>${webstartPluginVersion}</version> <configuration> <libPath>lib</libPath> <makeArchive>false</makeArchive> <verbose>false</verbose> + <gzip>true</gzip> + <canUnsign>false</canUnsign> + <!--<unsign>true</unsign>--> + <pack200>true</pack200> <jnlp> <mainClass>${maven.jar.main.class}</mainClass> @@ -294,7 +279,7 @@ <profiles> <profile> - <id>reporting</id> + <id>myreporting</id> <activation> <property> <name>performRelease</name> @@ -306,7 +291,7 @@ <plugin> <groupId>org.codehaus.mojo.webstart</groupId> <artifactId>webstart-maven-plugin</artifactId> - <version>${webstartPluginVersion}</version> + <version>${jnlpPluginVersion}</version> </plugin> </plugins> </reporting> @@ -432,7 +417,6 @@ <plugin> <groupId>org.bluestemsoftware.open.maven.plugin</groupId> <artifactId>launch4j-plugin</artifactId> - <version>1.5.0.0</version> <executions> <execution> <id>launch4j</id> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaContext.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -26,9 +26,11 @@ package org.chorem.lima; import jaxx.runtime.JAXXUtil; +import jaxx.runtime.context.DefaultApplicationContext; import jaxx.runtime.context.JAXXContextEntryDef; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.LimaDecoratorProvider; import org.chorem.lima.ui.MainView; import org.chorem.lima.ui.MainViewHandler; import org.nuiton.i18n.I18n; @@ -36,19 +38,16 @@ import org.nuiton.i18n.init.UserI18nInitializer; import org.nuiton.util.FileUtil; import org.nuiton.util.StringUtil; +import org.nuiton.util.decorator.DecoratorProvider; import java.io.File; import java.io.IOException; import java.util.Locale; -/** - * @author chemit - */ -public class LimaContext extends jaxx.runtime.context.DefaultApplicationContext { +/** @author chemit */ +public class LimaContext extends DefaultApplicationContext { - /** - * to use log facility, just put in your code: log.info(\"...\"); - */ + /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(LimaContext.class); /** @@ -59,6 +58,10 @@ public static JAXXContextEntryDef<MainView> MAIN_UI_ENTRY_DEF = JAXXUtil.newContextEntryDef("mainUI", MainView.class); + public static JAXXContextEntryDef<DecoratorProvider> DECORATOR_PROVIDER_DEF = JAXXUtil.newContextEntryDef("decoratorProvider", DecoratorProvider.class); + + public static JAXXContextEntryDef<LimaConfig> CONFIG_DEF = JAXXUtil.newContextEntryDef("limaConfig", LimaConfig.class); + /** * @return <code>true</code> si le context a été initialisé via la méthode * {@link #init()}, <ocde>false</code> autrement. @@ -76,14 +79,14 @@ * @return l'instance partagée * @throws IllegalStateException si un contexte applicatif a déja été positionné. */ - public static synchronized LimaContext init() throws IllegalStateException { + public static LimaContext init() throws IllegalStateException { if (isInit()) { throw new IllegalStateException("there is already a application context registred."); } instance = new LimaContext(); - instance.setContextValue(new LimaConfig()); instance.setContextValue(new MainViewHandler()); - + CONFIG_DEF.setContextValue(instance, new LimaConfig()); + DECORATOR_PROVIDER_DEF.setContextValue(instance, new LimaDecoratorProvider()); return instance; } @@ -102,11 +105,15 @@ } public LimaConfig getConfig() { - return getContextValue(LimaConfig.class); + return CONFIG_DEF.getContextValue(this); } + public DecoratorProvider getDecoratorProvider() { + return DECORATOR_PROVIDER_DEF.getContextValue(this); + } + public void initI18n(LimaConfig config) { - + I18n.close(); File i18nDirectory = config.getI18nDirectory(); @@ -126,32 +133,34 @@ new UserI18nInitializer( i18nDirectory, new DefaultI18nInitializer("lima") - ); + ); Locale locale = config.getLocale(); I18n.init(i18nInitializer, locale); - + // Default Locale for DatePicker Locale.setDefault(locale); - + + getDecoratorProvider().reload(); + long t00 = System.nanoTime(); - + if (log.isDebugEnabled()) { log.debug("i18n language : " + locale); log.debug("i18n loading time : " + - StringUtil.convertTime(t00, System.nanoTime())); + StringUtil.convertTime(t00, System.nanoTime())); } } public MainView getMainUI() { - return (MainView) MAIN_UI_ENTRY_DEF.getContextValue(this); + return MAIN_UI_ENTRY_DEF.getContextValue(this); } /** * close the application's context. * - * @throws java.lang.Exception if any pb while closing + * @throws Exception if any pb while closing */ public void close() throws Exception { if (log.isDebugEnabled()) { 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaMain.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,9 +25,6 @@ package org.chorem.lima; -import static org.nuiton.i18n.I18n._; -import java.util.List; -import javax.swing.SwingUtilities; import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,14 +38,18 @@ import org.chorem.lima.ui.opening.OpeningView; import org.chorem.lima.util.ErrorHelper; +import javax.swing.SwingUtilities; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** - * Lima main. - * + * Lima GUI main class. + * * @author ore * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ */ public class LimaMain { @@ -60,26 +61,26 @@ /** splash */ private static LimaSplash splash; - + /** * Lima main method. - * + * * @param args program args */ public static void main(String[] args) { - + if (log.isInfoEnabled()) { - log.info("Lima start at " + new java.util.Date()); - log.info("Args: " + java.util.Arrays.toString(args)); + log.info("Lima starts at " + new Date()); + log.info("Args: " + Arrays.toString(args)); } - + try { - + // init root context - final LimaContext context = init(args); + LimaContext context = init(args); // do actions - config = context.getContextValue(LimaConfig.class); + config = context.getConfig(); config.doAction(LimaConfig.Action.AFTER_INIT_STEP); // display main ui @@ -104,35 +105,22 @@ * @return le context de l'application * @throws Exception pour toute erreur pendant l'init */ - public static synchronized LimaContext init(String... args) throws Exception { + public static LimaContext init(String... args) throws Exception { // update splash splash = new LimaSplash(); splash.initSplash(); - + // to enable javassist on webstart, must remove any securityManager, // see if this can be dangerous (should not be since jnlp is signed ?) // moreover it speeds up the loading :) System.setSecurityManager(null); - // init i18n - //long t0 = System.nanoTime(); - - // FIXME cause NPE - // I18n.setInitializer(new DefaultI18nInitializer("lima-swing-i18n")); - - // FIXME echatellier 20110502 duplicated code with context.initI18n(); - //I18n.init(Locale.FRANCE); - //if (log.isDebugEnabled()) { - // log.debug("i18n loading time : " + (StringUtil.convertTime(t0, System.nanoTime()))); - //} - - Runtime.getRuntime().addShutdownHook(new ShutdownHook()); // init root context LimaContext context = LimaContext.init(); - LimaConfig config = context.getContextValue(LimaConfig.class); + LimaConfig config = context.getConfig(); config.parse(args); context.initI18n(config); @@ -161,10 +149,10 @@ }*/ return context; } - + protected static void launch(LimaContext context) throws Exception { - + splash.drawVersion(config.getVersion()); splash.updateProgression(0.1, _("lima.splash.1")); @@ -179,14 +167,14 @@ // load accounts and test if there is an account plan defined // if not, call #loadDefaultAccount() splash.updateProgression(0.7, _("lima.splash.2")); - + //start http server LimaServiceFactory.getInstance().getService(HttpServerServiceMonitorable.class).start(); - + AccountService accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); + List<Account> accounts = accountService.getChildrenAccounts(null); if (accounts.isEmpty()) { if (log.isInfoEnabled()) { @@ -196,8 +184,8 @@ openingView.setSize(800, 400); openingView.setLocationRelativeTo(null); openingView.setVisible(true); - }else { - splash.updateProgression(1, _("lima.splash.3")); + } else { + splash.updateProgression(1, _("lima.splash.3")); } // show ui SwingUtilities.invokeLater(new Runnable() { @@ -206,7 +194,7 @@ ui.setVisible(true); } }); - + } public static class ShutdownHook extends Thread { @@ -225,7 +213,7 @@ // force to kill main thread if (log.isInfoEnabled()) { - log.info(_("lima.init.closed", new java.util.Date())); + log.info(_("lima.init.closed", new Date())); } Runtime.getRuntime().halt(0); } catch (Exception ex) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -30,6 +30,8 @@ import org.chorem.lima.LimaConfig; import org.chorem.lima.LimaMain; +import java.util.Arrays; + /** * Les actions appellables via {@link LimaMain}. * @@ -56,7 +58,7 @@ System.out.println("Actions:"); for (LimaConfig.Action a : LimaConfig.Action.values()) { - System.out.println("\t" + java.util.Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description); + System.out.println("\t" + Arrays.toString(a.aliases) + "(" + a.action + "):" + a.description); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -31,14 +31,14 @@ private final String filePath; - private AccountsChartEnum(String filePath) { + AccountsChartEnum(String filePath) { this.filePath = filePath; } public String getFilePath() { String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); + if (!filePath.equals("")){ + result=getClass().getResource("/import/"+ filePath).getPath(); } return result; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -36,12 +36,12 @@ private final String description; - private ComboBoxAccountsEnum(String description) { + ComboBoxAccountsEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -36,12 +36,12 @@ private final String description; - private ComboBoxDatesEnum(String description) { + ComboBoxDatesEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -35,12 +35,12 @@ private final String description; - private ComboBoxEntryBooksEnum(String description) { + ComboBoxEntryBooksEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -35,12 +35,12 @@ private final String description; - private ComboBoxLetterEnum(String description) { + ComboBoxLetterEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -41,17 +41,17 @@ private final String description; private final String symbol; - private ComboBoxOperatorsEnum(String description, String symbol) { + ComboBoxOperatorsEnum(String description, String symbol) { this.description = description; this.symbol = symbol; } public String getDescription() { - return this.description; + return description; } public String getSymbol(){ - return this.symbol; + return symbol; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -37,12 +37,12 @@ private final String description; - private ComboBoxPeriodEnum(String description) { + ComboBoxPeriodEnum(String description) { this.description = description; } public String getDescription() { - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -33,17 +33,17 @@ private final String encoding; private final String description; - private EncodingEnum(String encoding, String description) { + EncodingEnum(String encoding, String description) { this.encoding = encoding; this.description = description; } public String getEncoding() { - return this.encoding; + return encoding; } public String getDescription(){ - return this.description; + return description; } public static String[] descriptions(){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -31,14 +31,14 @@ private final String filePath; - private EntryBooksChartEnum(String filePath) { + EntryBooksChartEnum(String filePath) { this.filePath = filePath; } public String getFilePath() { String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); + if (!filePath.equals("")){ + result=getClass().getResource("/import/"+ filePath).getPath(); } return result; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -31,15 +31,15 @@ private final String filePath; - private FinancialStatementsChartEnum(String filePath) { + FinancialStatementsChartEnum(String filePath) { this.filePath = filePath; } public String getFilePath() { String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); + if (!filePath.equals("")){ + result=getClass().getResource("/import/"+ filePath).getPath(); } return result; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -47,7 +47,7 @@ * import mode : * true if import, false if export */ - private ImportExportEnum(Boolean importMode, Boolean encodingOption) { + ImportExportEnum(Boolean importMode, Boolean encodingOption) { this.importMode = importMode; this.encodingOption = encodingOption; } @@ -57,10 +57,10 @@ * true if import or export methode let encoding option */ public Boolean getEncodingOption(){ - return this.encodingOption; + return encodingOption; } public Boolean getImportMode() { - return this.importMode; + return importMode; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/enums/VatStatementsChartEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/VatStatementsChartEnum.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/VatStatementsChartEnum.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -31,15 +31,15 @@ private final String filePath; - private VatStatementsChartEnum(String filePath) { + VatStatementsChartEnum(String filePath) { this.filePath = filePath; } public String getFilePath() { String result = ""; - if (!this.filePath.equals("")){ - result=getClass().getResource("/import/"+this.filePath).getPath(); + if (!filePath.equals("")){ + result=getClass().getResource("/import/"+ filePath).getPath(); } return result; } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -45,9 +45,7 @@ import java.util.Map; import java.util.Properties; -/** - * This class is a service factory based on embedded openejb container. - */ +/** This class is a service factory based on embedded openejb container. */ public class LimaServiceFactory { /** Log. */ @@ -55,14 +53,13 @@ /** Single instance. */ private static LimaServiceFactory instance; + protected Map<Class<?>, Object> services = new HashMap<Class<?>, Object>(); /** JNDI context used to look for EJB. */ protected static InitialContext ctx; - /** - * Init openejb jndi context. - */ + /** Init openejb jndi context. */ protected LimaServiceFactory() { // TODO EC-20100407 maybe put all options in LimaConfig and allow user to configure it (remove getFlatOptions use) @@ -80,15 +77,15 @@ if (log.isErrorEnabled()) { log.error("Can't find log4j properties file", ex); } - } - finally { + } finally { IOUtils.closeQuietly(log4jFile); } // Context.INITIAL_CONTEXT_FACTORY is a mandatory option // containsKey() does'nt work :( if (!props.containsKey(Context.INITIAL_CONTEXT_FACTORY)) { - throw new RuntimeException("Application configuration is missing mandatory property " + throw new IllegalStateException( + "Application configuration is missing mandatory property " + Context.INITIAL_CONTEXT_FACTORY); } @@ -104,9 +101,9 @@ /** * Return service factory singleton instance. - * + * <p/> * Init it at first call. - * + * * @return singleton instance */ public static LimaServiceFactory getInstance() { @@ -115,38 +112,27 @@ } return instance; } - - public <M> M getService(Class<M> serviceMonitorableClass){ + + public <M> M getService(Class<M> serviceMonitorableClass) { M result = (M) services.get(serviceMonitorableClass); if (result == null) { - Object ejbHome; - String serviceName = serviceMonitorableClass.getSimpleName().replace("Monitorable", "ImplRemote"); - try { - ejbHome = ctx.lookup(serviceName); - } catch (NamingException eee) { - throw new RuntimeException( - "Can't lookup for service : " + serviceName, eee); + result = newService(serviceMonitorableClass); - } - InvocationHandler handler = new ServiceMonitorableHandler(ejbHome); - result = (M) Proxy.newProxyInstance( serviceMonitorableClass.getClassLoader(), new Class[]{serviceMonitorableClass}, handler); - services.put(serviceMonitorableClass, result); } return result; } - /** * Destroy openejb jndi context. - * + * <p/> * Code taken from openEJB faq : * http://openejb.apache.org/faq.html - * + * * @throws Exception when trying to destroy a non existent application */ public void destroy() throws Exception { - + // destroy code (only in embedded mode) Assembler assembler = SystemInstance.get().getComponent(Assembler.class); for (AppInfo appInfo : assembler.getDeployedApplications()) { @@ -154,4 +140,25 @@ } OpenEJB.destroy(); } + + protected <M> M newService(Class<M> serviceMonitorableClass) { + M result; + Object ejbHome; + String serviceName = serviceMonitorableClass.getSimpleName().replace("Monitorable", "ImplRemote"); + try { + ejbHome = ctx.lookup(serviceName); + } catch (NamingException eee) { + throw new RuntimeException( + "Can't lookup for service : " + serviceName, eee); + + } + InvocationHandler handler = new ServiceMonitorableHandler(ejbHome); + ClassLoader classLoader = serviceMonitorableClass.getClassLoader(); + result = (M) Proxy.newProxyInstance( + classLoader, + new Class[]{serviceMonitorableClass}, + handler + ); + return result; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/ServiceMonitorableHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,58 +25,67 @@ package org.chorem.lima.service; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.ServiceListener; + import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.ServiceListener; public class ServiceMonitorableHandler implements InvocationHandler { - private static final Log log = LogFactory.getLog(ServiceMonitorableHandler.class); - + private static final Log log = + LogFactory.getLog(ServiceMonitorableHandler.class); + + /** The proxied service. */ private Object service; + + /** Listeners on the service. */ private List<ServiceListener> listeners; - - public ServiceMonitorableHandler(Object service){ + + public ServiceMonitorableHandler(Object service) { this.service = service; listeners = new ArrayList<ServiceListener>(); } - - public void addServiceListener(ServiceListener serviceListener){ - listeners.add(serviceListener); - } - public void removeServiceListener(ServiceListener serviceListener){ - listeners.remove(serviceListener); - } - @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { Object result = null; - if (method.getName().equals("addListener")){ + if (method.getName().equals("addServiceListener")) { addServiceListener((ServiceListener) args[0]); - } - else if (method.getName().equals("removeListener")){ + } else if (method.getName().equals("removeServiceListener")) { removeServiceListener((ServiceListener) args[0]); - } - else { + } else { try { - result = method.invoke(service, args); - }catch (InvocationTargetException eee){ + result = method.invoke(service, args); + } catch (InvocationTargetException eee) { throw eee.getCause(); } - if (!method.getName().startsWith("get")){ - for (ServiceListener serviceListener : listeners) { - serviceListener.notifyMethod(service.toString(), method.getName()); - log.debug("proxy : " + service.toString() + " " + method.getName()); - } - } + notifyMethod(method); } return result; } + protected void addServiceListener(ServiceListener serviceListener) { + listeners.add(serviceListener); + } + + protected void removeServiceListener(ServiceListener serviceListener) { + listeners.remove(serviceListener); + } + + protected void notifyMethod(Method method) { + String methodName = method.getName(); + //TODO tchemit-2011-09-16 Could we have an explanation of this test ? + if (!methodName.startsWith("get")) { + for (ServiceListener serviceListener : listeners) { + serviceListener.notifyMethod(service.toString(), methodName); + log.debug("proxy : " + service.toString() + " " + methodName); + } + } + } + } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -0,0 +1,29 @@ +package org.chorem.lima.ui; + +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; +import org.nuiton.util.decorator.DecoratorProvider; + +/** + * To provide decorations for entities. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.5.2 + */ +public class LimaDecoratorProvider extends DecoratorProvider { + + @Override + protected void loadDecorators() { + + registerJXPathDecorator(EntryBook.class, "${code}$s - ${label}$s"); + + registerJXPathDecorator( + FiscalPeriod.class, + "${beginDate}$td/%1$tm/%1$tY - ${endDate}$td/%1$tm/%1$tY"); + + registerJXPathDecorator( + FinancialPeriod.class, + "${beginDate}$td/%1$tm/%1$tY - ${endDate}$td/%1$tm/%1$tY"); + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -147,7 +147,7 @@ * @param ui l'ui principale de l'application * @param fullscreen le nouvel état requis. */ - public void changeScreen(MainView ui, final boolean fullscreen) { + public void changeScreen(MainView ui, boolean fullscreen) { boolean canContinue = ensureModification(ui); if (!canContinue) { return; @@ -214,8 +214,8 @@ about.setAboutText(_("lima.title.about.description")); about.setBottomText(ui.getConfig().getCopyrightText()); about.setIconPath("/icons/lima.png"); - about.setLicenseFile("META-INF/lima-swing-LICENSE.txt"); - about.setThirdpartyFile("META-INF/lima-swing-THIRD-PARTY.txt"); + about.setLicenseFile("META-INF/lima-LICENSE.txt"); + about.setThirdpartyFile("META-INF/lima-THIRD-PARTY.txt"); about.init(); about.showInDialog(ui, true); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.account; import java.awt.event.KeyEvent; @@ -60,8 +60,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -89,8 +89,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,10 +25,6 @@ package org.chorem.lima.ui.account; -import static org.nuiton.i18n.I18n._; - -import javax.swing.JOptionPane; -import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountServiceMonitorable; @@ -41,16 +37,16 @@ import org.chorem.lima.enums.AccountsChartEnum; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.account.AccountForm; -import org.chorem.lima.ui.account.AccountView; -import org.chorem.lima.ui.account.SubLedgerForm; -import org.chorem.lima.ui.account.UpdateAccountForm; -import org.chorem.lima.ui.account.UpdateSubLedgerForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; import org.jdesktop.swingx.JXTreeTable; +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with account view. * @@ -73,7 +69,7 @@ this.view = view; // Gets factory service LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); @@ -132,7 +128,7 @@ if (log.isErrorEnabled()) { log.error("Can't add account", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } @@ -191,14 +187,14 @@ if (log.isErrorEnabled()) { log.error("Can't add subledger", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add subledger", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -254,7 +250,7 @@ if (log.isErrorEnabled()) { log.error("Can't add update", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -291,7 +287,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/accountsreports/AccountComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -38,7 +38,7 @@ import org.chorem.lima.util.AccountToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -public class AccountComboBox extends JComboBox implements KeyListener, ActionListener { +public class AccountComboBox extends JComboBox implements KeyListener { private static final long serialVersionUID = 1L; @@ -55,35 +55,35 @@ setRenderer(accountRenderer); setEditable(true); AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); } public void back(){ - int row = this.getSelectedIndex(); + int row = getSelectedIndex(); log.debug(row); if (row > 0){ - this.getEditor().setItem(this.getItemAt(row-1)); - handler.setAccount((Account) this.getSelectedItem()); + getEditor().setItem(getItemAt(row-1)); + handler.setAccount((Account) getSelectedItem()); } } public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); + int size = getModel().getSize(); + int row = getSelectedIndex(); log.debug(row); if (row < size-1){ - this.getEditor().setItem(this.getItemAt(row+1)); - handler.setAccount((Account) this.getSelectedItem()); + getEditor().setItem(getItemAt(row+1)); + handler.setAccount((Account) getSelectedItem()); } } @Override public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); + Object object = getSelectedItem(); if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); + handler.setAccount((Account) getSelectedItem()); } } @@ -95,9 +95,9 @@ @Override public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); + Object object = getSelectedItem(); if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); + handler.setAccount((Account) getSelectedItem()); } // delegate popup list menu 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -100,12 +100,12 @@ handler.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -127,8 +127,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -149,8 +149,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.accountsreports; import java.awt.event.KeyEvent; @@ -67,8 +67,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -96,8 +96,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -79,9 +79,9 @@ LimaServiceFactory.getInstance().getService( ReportServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + FinancialTransactionServiceMonitorable.class).addServiceListener(this); } public void setBeginDate(Date date){ 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -101,12 +101,12 @@ handler.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -128,8 +128,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -150,8 +150,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.balance; import java.awt.event.KeyEvent; @@ -64,8 +64,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -93,8 +93,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -102,9 +102,9 @@ LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + FinancialTransactionServiceMonitorable.class).addServiceListener(this); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,18 +25,6 @@ package org.chorem.lima.ui.celleditor; -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.util.EventObject; - -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableCellEditor; -import javax.swing.text.JTextComponent; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; @@ -46,22 +34,32 @@ import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.util.EventObject; + public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener { protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); private final JWideComboBox comboBox; private static final long serialVersionUID = 1L; - private static AccountTableCellEditor editor; - private static SubAccountComboBoxModel accountComboBoxModel; - private static boolean keyPressed = false; +// private static AccountTableCellEditor editor; + private static boolean keyPressed; + /** * constructor */ public AccountTableCellEditor() { - super(); comboBox = new JWideComboBox(); - accountComboBoxModel = new SubAccountComboBoxModel(); + SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel(); comboBox.setModel(accountComboBoxModel); AccountRenderer accountRenderer = new AccountRenderer(); comboBox.setRenderer(accountRenderer); @@ -72,7 +70,7 @@ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value instanceof Account){ - comboBox.setSelectedItem((Account) value); + comboBox.setSelectedItem(value); } return comboBox; } @@ -110,7 +108,7 @@ } } keyPressed = false; - return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 ); + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } @@ -123,7 +121,7 @@ public void keyReleased(KeyEvent e) { // Vérifie si c'est la première frappe au clavier - if ( keyPressed == false ) + if (!keyPressed) { // Récupère l'editor de la comboBox JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); @@ -144,11 +142,11 @@ } - public static AccountTableCellEditor getInstance() { - if (editor == null) { - editor = new AccountTableCellEditor(); - } - return editor; - } +// public static AccountTableCellEditor getInstance() { +// if (editor == null) { +// editor = new AccountTableCellEditor(); +// } +// return editor; +// } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,37 +1,32 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.celleditor; -import java.awt.Component; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.math.BigDecimal; -import java.util.EventObject; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaContext; import javax.swing.AbstractCellEditor; import javax.swing.JTable; @@ -41,12 +36,15 @@ import javax.swing.event.AncestorEvent; import javax.swing.event.AncestorListener; import javax.swing.table.TableCellEditor; +import java.awt.Component; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.math.BigDecimal; +import java.util.EventObject; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import org.chorem.lima.business.LimaException; - public class BigDecimalTableCellEditor extends AbstractCellEditor implements TableCellEditor, FocusListener, AncestorListener, KeyListener { @@ -82,16 +80,16 @@ textValue = textValue.replaceAll(",", "."); if (textValue.equals("")) { return BigDecimal.ZERO; - } else { - //set 0 in case the user type in a non number format - BigDecimal bdValue = BigDecimal.ZERO; + } else { + //set 0 in case the user type in a non number format + BigDecimal bdValue = BigDecimal.ZERO; try { - bdValue = new BigDecimal(textValue); - } catch (NumberFormatException eee) { - if (log.isErrorEnabled()) { - log.error("Can't set " + textValue + " to a BigDecimal", eee); - } - } + bdValue = new BigDecimal(textValue); + } catch (NumberFormatException eee) { + if (log.isErrorEnabled()) { + log.error("Can't set " + textValue + " to a BigDecimal", eee); + } + } //round half up the number using the scale given by the configuration bdValue = bdValue.setScale(LimaContext.getContext().getConfig().getScale(), BigDecimal.ROUND_HALF_UP); @@ -122,7 +120,7 @@ } @Override - public void ancestorAdded(final AncestorEvent e) { + public void ancestorAdded(AncestorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { textField.requestFocus(); @@ -148,20 +146,20 @@ } @Override - public void keyReleased(KeyEvent e) { + public void keyReleased(KeyEvent e) { // replace all the cell content only if all the text has been selected - if (keyPressed == false - && textField.getSelectionStart() == 0 - && textField.getSelectionEnd() == textField.getText().length()) { - // delete the the cell content - if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE) { - textField.setText(""); - keyPressed = true; - // replace the content by the char typed in - } else if (String.valueOf(e.getKeyChar()).matches("[a-zA-z0-9]")) { - textField.setText(String.valueOf(e.getKeyChar())); - keyPressed = true; - } + if (!keyPressed + && textField.getSelectionStart() == 0 + && textField.getSelectionEnd() == textField.getText().length()) { + // delete the the cell content + if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE) { + textField.setText(""); + keyPressed = true; + // replace the content by the char typed in + } else if (String.valueOf(e.getKeyChar()).matches("[a-zA-z0-9]")) { + textField.setText(String.valueOf(e.getKeyChar())); + keyPressed = true; + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,47 +1,40 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.celleditor; +import org.chorem.lima.LimaConfig; +import org.chorem.lima.LimaContext; + +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.table.DefaultTableCellRenderer; import java.awt.Component; -import java.awt.Font; import java.math.BigDecimal; import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; -import java.text.NumberFormat; -import java.util.Locale; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.TableCellRenderer; -import javax.swing.table.DefaultTableCellRenderer; - -import org.chorem.lima.LimaConfig; -import org.chorem.lima.LimaContext; -import org.chorem.lima.beans.FinancialStatementAmounts; -import org.chorem.lima.ui.financialstatementreport.FinancialStatementReportTableModel; - public class BigDecimalTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = -2499433026151065390L; @@ -54,7 +47,7 @@ boolean isSelected, boolean hasFocus, int row, int column) { - Component cell = super.getTableCellRendererComponent( + super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); setHorizontalAlignment(SwingConstants.RIGHT); setValue(value); @@ -63,7 +56,7 @@ public void setValue(Object aValue) { Object result = aValue; - if (( aValue != null) && (aValue instanceof BigDecimal)) { + if (aValue != null && aValue instanceof BigDecimal) { LimaConfig config = LimaContext.getContext().getConfig(); String scale = ""; for (int i = 0; i < config.getScale(); i++) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -37,8 +37,6 @@ import java.awt.Component; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.util.Date; @@ -52,7 +50,7 @@ private final JXDatePicker datePicker; private static final long serialVersionUID = 1L; - private static DateTableCellEditor editor; +// private static DateTableCellEditor editor; //used to tell if the user has pressed a key private Date date; @@ -106,12 +104,12 @@ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } - public static DateTableCellEditor getInstance() { - if (editor == null) { - editor = new DateTableCellEditor(); - } - return editor; - } +// public static DateTableCellEditor getInstance() { +// if (editor == null) { +// editor = new DateTableCellEditor(); +// } +// return editor; +// } /** * Listeners @@ -128,7 +126,7 @@ } @Override - public void ancestorAdded(final AncestorEvent e) { + public void ancestorAdded(AncestorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { datePicker.requestFocus(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,42 +1,39 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.celleditor; -import java.awt.Color; -import java.awt.Component; +import sun.swing.DefaultLookup; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; +import java.awt.Color; +import java.awt.Component; -import org.chorem.lima.entity.EntryBook; - -import sun.swing.DefaultLookup; - @SuppressWarnings("restriction") public class EmptyCellRenderer extends DefaultTableCellRenderer { @@ -74,7 +71,7 @@ // if empty or null, colour background in red // else setText if (value instanceof String) { - if (String.valueOf(value).isEmpty() || (String.valueOf(value) == null)) { + if (String.valueOf(value).isEmpty() || String.valueOf(value) == null) { mycell.setBackground(new Color(255, 198, 209)); } else { mycell.setText(value.toString()); 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.celleditor; -import java.awt.Component; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.util.EventObject; -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableCellEditor; -import javax.swing.text.JTextComponent; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; @@ -44,17 +34,29 @@ import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; +import java.awt.Component; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; +import java.util.EventObject; + public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor { protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private final JWideComboBox comboBox; + private static final long serialVersionUID = 1L; - private static EntryBookTableCellEditor editor; - private static boolean keyPressed = false; - /** - * constructor - */ + // private static EntryBookTableCellEditor editor; + private static boolean keyPressed; + + /** constructor */ public EntryBookTableCellEditor() { comboBox = new JWideComboBox(); EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); @@ -64,7 +66,7 @@ // AutoCompletion AutoCompleteDecorator.decorate(comboBox, EntryBookToString.getInstance()); - + /** * Ajout d'un listener pour la frappe au clavier seulement, permettant * de déplacer la sélection (et le caret) du fait que la première touche @@ -75,8 +77,7 @@ @Override public void keyReleased(KeyEvent e) { // Vérifie si c'est la première frappe au clavier - if ( keyPressed == false ) - { + if (!keyPressed) { // Récupère l'editor de la comboBox JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); // Met en place le curseur et la selection après la première lettre @@ -84,19 +85,18 @@ keyPressed = true; } // Validate editing with enter key - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { stopCellEditing(); } } }); - + } @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof EntryBook){ - comboBox.setSelectedItem((EntryBook) value); + if (value instanceof EntryBook) { + comboBox.setSelectedItem(value); } return comboBox; } @@ -105,11 +105,12 @@ public Object getCellEditorValue() { return comboBox.getSelectedItem(); } - - + + /** * Vérifie si la cellule peut être éditable : * seulement si il y a une frappe au clavier ou un double clic. + * * @param evt * @return */ @@ -119,16 +120,14 @@ if (evt instanceof KeyEvent) { final KeyEvent keyEvent = (KeyEvent) evt; // Empèche la touche echap - if ( keyEvent.getKeyChar() != KeyEvent.VK_ESCAPE ) - { + if (keyEvent.getKeyChar() != KeyEvent.VK_ESCAPE) { // Permet de placer le focus sur l'editor de la comboBox SwingUtilities.invokeLater(new Runnable() { @Override public void run() { comboBox.getEditor().getEditorComponent().requestFocus(); JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); - if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) - { + if (!Character.isIdentifierIgnorable(keyEvent.getKeyChar())) { edit.setText(Character.toString(keyEvent.getKeyChar())); } } @@ -137,13 +136,13 @@ } // Remet à faux pour la premiere lettre tapée au clavier keyPressed = false; - return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 ); + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } - public static EntryBookTableCellEditor getInstance() { - if (editor == null) { - editor = new EntryBookTableCellEditor(); - } - return editor; - } +// public static EntryBookTableCellEditor getInstance() { +// if (editor == null) { +// editor = new EntryBookTableCellEditor(); +// } +// return editor; +// } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.celleditor; -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.util.EventObject; -import javax.swing.AbstractCellEditor; -import javax.swing.JTable; -import javax.swing.SwingUtilities; -import javax.swing.table.TableCellEditor; -import javax.swing.text.JTextComponent; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; @@ -44,22 +34,33 @@ import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; +import javax.swing.table.TableCellEditor; +import javax.swing.text.JTextComponent; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.util.EventObject; + public class LetterTableCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener { protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); - private final JWideComboBox comboBox; private static final long serialVersionUID = 1L; - private static LetterTableCellEditor editor; - private static LetterComboBoxModel comboBoxModel; - private static boolean keyPressed = false; + private final JWideComboBox comboBox; +// private static LetterTableCellEditor editor; + + private static boolean keyPressed; + /** * constructor */ public LetterTableCellEditor() { - super(); comboBox = new JWideComboBox(); - comboBoxModel = new LetterComboBoxModel(); + LetterComboBoxModel comboBoxModel = new LetterComboBoxModel(); comboBox.setModel(comboBoxModel); LetterRenderer renderer = new LetterRenderer(); comboBox.setRenderer(renderer); @@ -70,7 +71,7 @@ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { if (value instanceof Account){ - comboBox.setSelectedItem((Account) value); + comboBox.setSelectedItem(value); } return comboBox; } @@ -108,7 +109,7 @@ } } keyPressed = false; - return ( !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2 ); + return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } @@ -121,7 +122,7 @@ public void keyReleased(KeyEvent e) { // Vérifie si c'est la première frappe au clavier - if ( keyPressed == false ) + if (!keyPressed) { // Récupère l'editor de la comboBox JTextComponent edit = (JTextComponent) comboBox.getEditor().getEditorComponent(); @@ -142,11 +143,11 @@ } - public static LetterTableCellEditor getInstance() { - if (editor == null) { - editor = new LetterTableCellEditor(); - } - return editor; - } +// public static LetterTableCellEditor getInstance() { +// if (editor == null) { +// editor = new LetterTableCellEditor(); +// } +// return editor; +// } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -59,9 +59,9 @@ accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); - accountService.addListener(this); + accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -28,6 +28,7 @@ import org.chorem.lima.entity.Account; import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; import javax.swing.JList; import java.awt.Component; @@ -42,14 +43,20 @@ boolean isSelected, boolean cellHasFocus) { - Account account = (Account) value; - if (account != null) { + JLabel label = (JLabel) super.getListCellRendererComponent(list, + value, + index, + isSelected, + cellHasFocus + ); + if (value != null) { + Account account = (Account) value; String accountLabel = account.getLabel(); int nbChars = 30; if (accountLabel != null && accountLabel.length() > nbChars) { accountLabel = accountLabel.substring(0, nbChars) + "…"; } - setText(account.getAccountNumber() + " - " + accountLabel); + label.setText(account.getAccountNumber() + " - " + accountLabel); } return this; } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -64,9 +64,9 @@ entryBookService = LimaServiceFactory.getInstance().getService( EntryBookServiceMonitorable.class); - entryBookService.addListener(this); + entryBookService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); cacheDatas = getDataList(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,35 +25,40 @@ package org.chorem.lima.ui.combobox; -import java.awt.Component; +import org.chorem.lima.entity.EntryBook; import javax.swing.DefaultListCellRenderer; import javax.swing.JLabel; import javax.swing.JList; +import java.awt.Component; -import org.chorem.lima.entity.EntryBook; +public class EntryBookRenderer extends DefaultListCellRenderer { -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) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - EntryBook entrybook = (EntryBook) value; - if (entrybook != null){ - label.setText(entrybook.getCode()+" - "+entrybook.getLabel()); + 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(); } - return label; - + 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -86,11 +86,11 @@ financialPeriodService = LimaServiceFactory.getInstance().getService( FinancialPeriodServiceMonitorable.class); - financialPeriodService.addListener(this); + financialPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addListener(this); + FiscalPeriodServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); if (displayAllPeriods) { datasCache=getAllDataList(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,35 +25,41 @@ package org.chorem.lima.ui.combobox; -import java.awt.Component; -import java.text.SimpleDateFormat; +import org.chorem.lima.entity.FinancialPeriod; + import javax.swing.DefaultListCellRenderer; import javax.swing.JLabel; import javax.swing.JList; -import org.chorem.lima.entity.FinancialPeriod; +import java.awt.Component; +import java.text.SimpleDateFormat; 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) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - FinancialPeriod financialPeriod = (FinancialPeriod) value; - if (financialPeriod != null){ - SimpleDateFormat simpleDateFormat - = new SimpleDateFormat("dd MMM yy"); - label.setText(simpleDateFormat.format(financialPeriod.getBeginDate())+" - "+simpleDateFormat.format(financialPeriod.getEndDate())); + 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; + 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,9 +25,6 @@ package org.chorem.lima.ui.combobox; -import java.util.List; -import javax.swing.AbstractListModel; -import javax.swing.ComboBoxModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; @@ -38,6 +35,10 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.List; + public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener{ private static final long serialVersionUID = 1L; @@ -55,9 +56,9 @@ fiscalPeriodService = LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); + fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } @@ -66,9 +67,9 @@ fiscalPeriodService = LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); + fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); datasCache = getAllDataList(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,35 +25,41 @@ package org.chorem.lima.ui.combobox; -import java.awt.Component; -import java.text.SimpleDateFormat; +import org.chorem.lima.entity.FiscalPeriod; + import javax.swing.DefaultListCellRenderer; import javax.swing.JLabel; import javax.swing.JList; -import org.chorem.lima.entity.FiscalPeriod; +import java.awt.Component; +import java.text.SimpleDateFormat; 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) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - FiscalPeriod fiscalPeriod = (FiscalPeriod) value; - if (fiscalPeriod != null){ - SimpleDateFormat simpleDateFormat = - new SimpleDateFormat("dd MMM yy"); + 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())); + + " - " + simpleDateFormat.format(fiscalPeriod.getEndDate())); } - return label; + 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -59,9 +59,9 @@ service = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); - service.addListener(this); + service.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } Modified: 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,25 +25,31 @@ package org.chorem.lima.ui.combobox; -import java.awt.Component; +import org.chorem.lima.entity.Letter; + import javax.swing.DefaultListCellRenderer; import javax.swing.JLabel; import javax.swing.JList; -import org.chorem.lima.entity.Letter; +import java.awt.Component; -public class LetterRenderer extends DefaultListCellRenderer { +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 = new JLabel(); - Letter letter = (Letter) value; - if (letter != null){ + + JLabel label = (JLabel) super.getListCellRendererComponent(list, + value, + index, + isSelected, + cellHasFocus + ); + if (value != null) { + Letter letter = (Letter) value; label.setText(letter.getCode()); } - return label; + 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -58,9 +58,9 @@ accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); - accountService.addListener(this); + accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.entrybook; import java.awt.event.KeyEvent; @@ -60,8 +60,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -89,8 +89,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -64,7 +64,7 @@ entryBookService = LimaServiceFactory.getInstance().getService( EntryBookServiceMonitorable.class); - LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addListener(this); + LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addServiceListener(this); } @Override @@ -102,7 +102,7 @@ } public EntryBook getEntryBookAtRow(int row) throws LimaException { - EntryBook entryBook = null; + EntryBook entryBook; entryBook = entryBookService.getAllEntryBooks().get(row); return entryBook; 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -38,7 +38,7 @@ import org.chorem.lima.util.EntryBookToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -public class EntryBookComboBox extends JComboBox implements KeyListener, ActionListener { +public class EntryBookComboBox extends JComboBox implements KeyListener { private static final long serialVersionUID = 1L; @@ -55,35 +55,35 @@ setRenderer(entryBookRenderer); setEditable(true); AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); } public void back(){ - int row = this.getSelectedIndex(); + int row = getSelectedIndex(); log.debug(row); if (row > 0){ - this.getEditor().setItem(this.getItemAt(row-1)); - handler.setEntryBook((EntryBook) this.getSelectedItem()); + getEditor().setItem(getItemAt(row-1)); + handler.setEntryBook((EntryBook) getSelectedItem()); } } public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); + int size = getModel().getSize(); + int row = getSelectedIndex(); log.debug(row); if (row < size-1){ - this.getEditor().setItem(this.getItemAt(row+1)); - handler.setEntryBook((EntryBook) this.getSelectedItem()); + getEditor().setItem(getItemAt(row+1)); + handler.setEntryBook((EntryBook) getSelectedItem()); } } @Override public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); + Object object = getSelectedItem(); if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.setEntryBook((EntryBook) getSelectedItem()); } } @@ -95,9 +95,9 @@ @Override public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); + Object object = getSelectedItem(); if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); + handler.setEntryBook((EntryBook) getSelectedItem()); } // delegate popup list menu if ( e.getKeyChar() == KeyEvent.VK_ENTER ) 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -100,12 +100,12 @@ handler.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -127,8 +127,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -149,8 +149,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -113,8 +113,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -142,8 +142,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -107,9 +107,9 @@ LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + FinancialTransactionServiceMonitorable.class).addServiceListener(this); } public void setBeginDate(Date date){ 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -97,7 +97,7 @@ int month = Integer.parseInt(simpleDateFormat.format( closedPeriodicEntryBook.getFinancialPeriod().getBeginDate())); // true if month is even - return ((month % 2)==0); + return month % 2 ==0; } }; @@ -127,7 +127,7 @@ } catch (LimaException eee) { log.debug("Can't get closePeriodicEntryBook",eee); } - return (closedPeriodicEntryBook.getLocked()); + return closedPeriodicEntryBook.getLocked(); } }; colorTransaction = @@ -141,8 +141,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -170,8 +170,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -72,9 +72,9 @@ LimaServiceFactory.getInstance().getService( FinancialPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class).addListener(this); + FiscalPeriodServiceMonitorable.class).addServiceListener(this); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.financialstatementchart; import java.awt.event.KeyEvent; @@ -59,8 +59,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -88,8 +88,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -41,8 +41,6 @@ import org.chorem.lima.enums.FinancialStatementsChartEnum; import org.chorem.lima.enums.ImportExportEnum; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.financialstatementchart.FinancialStatementHeaderForm; -import org.chorem.lima.ui.financialstatementchart.FinancialStatementMovementForm; import org.chorem.lima.ui.importexport.ImportExport; import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; @@ -73,7 +71,7 @@ LimaServiceFactory.getInstance().getService( FinancialStatementServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); } /** @@ -99,7 +97,7 @@ if (newFinancialStatementHeader != null) { newFinancialStatementHeader.setHeader(true); // get current selection path - TreePath treePath = null; + TreePath treePath; int selectedRow = treeTable.getSelectedRow(); if ( selectedRow != -1) { treePath = treeTable.getPathForRow(selectedRow); @@ -146,7 +144,7 @@ // null == cancel action if (newFinancialStatementMovement != null) { // get current selection path - TreePath treePath = null; + TreePath treePath; int selectedRow = view.treeTable.getSelectedRow(); treePath = view.treeTable.getPathForRow(selectedRow); // add it 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -100,12 +100,12 @@ model.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); model.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -127,8 +127,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -149,8 +149,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -128,8 +128,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -157,8 +157,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -92,7 +92,7 @@ public void setValue(Object aValue) { Object result = aValue; - if (( aValue != null) && (aValue instanceof BigDecimal)) { + if (aValue != null && aValue instanceof BigDecimal) { LimaConfig config = LimaContext.getContext().getConfig(); String scale = ""; for (int i = 0; i < config.getScale(); i++) { 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -96,13 +96,13 @@ LimaServiceFactory.getInstance().getService( FinancialStatementServiceMonitorable.class); - financialStatementService.addListener(this); + financialStatementService.addServiceListener(this); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + FinancialTransactionServiceMonitorable.class).addServiceListener(this); documentService = LimaServiceFactory.getInstance().getService(DocumentServiceMonitorable.class); } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -84,7 +84,7 @@ Date selectedBeginDate = model.getBeginDate(); Date selectedEndDate = model.getEndDate(); - if ((selectedBeginDate != null) && (selectedEndDate != null)) { + if (selectedBeginDate != null && selectedEndDate != null) { //looks for all blocked fiscal periods List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); try { Modified: 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialPeriodComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,44 +25,45 @@ package org.chorem.lima.ui.financialtransaction; -import javax.swing.JComboBox; 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); - + LogFactory.getLog(FinancialPeriodComboBox.class); + protected FinancialTransactionViewHandler handler; - + public FinancialPeriodComboBox(FinancialTransactionViewHandler handler) { this.handler = handler; } - public void back(){ - int row = this.getSelectedIndex(); + public void back() { + int row = getSelectedIndex(); log.debug(row); - if (row > 0){ - this.setSelectedItem(this.getItemAt(row-1)); + if (row > 0) { + setSelectedItem(getItemAt(row - 1)); repaint(); - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + handler.tableModel.setFinancialPeriod((FinancialPeriod) getSelectedItem()); } } - - public void next(){ - int size = this.getModel().getSize(); - int row = this.getSelectedIndex(); + + public void next() { + int size = getModel().getSize(); + int row = getSelectedIndex(); log.debug(row); - - if (row < size-1){ - this.setSelectedItem(this.getItemAt(row+1)); + + if (row < size - 1) { + setSelectedItem(getItemAt(row + 1)); repaint(); //FIXME - handler.tableModel.setFinancialPeriod( (FinancialPeriod) this.getSelectedItem()); + 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,15 +25,6 @@ package org.chorem.lima.ui.financialtransaction; -import java.awt.Color; -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.math.BigDecimal; -import java.util.Date; -import javax.swing.SwingWorker; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; @@ -41,21 +32,31 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.chorem.lima.ui.celleditor.DateTableCellEditor; import org.chorem.lima.ui.celleditor.EmptyCellRenderer; import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; -import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; +import javax.swing.SwingWorker; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.math.BigDecimal; +import java.util.Date; + /** * Table des transaction qui ajoute des comportement (keys). - * + * * @author jpepin */ public class FinancialTransactionTable extends JXTable @@ -63,7 +64,7 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - + /** log. */ private static final Log log = LogFactory .getLog(FinancialTransactionTable.class); @@ -73,17 +74,18 @@ private Highlighter colorTransaction; private ColorHighlighter colorBalance; - + private int x_tab; + private int y_tab; public FinancialTransactionTable(FinancialTransactionViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); //Get new entry book editor @@ -100,36 +102,35 @@ 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, - ComponentAdapter adapter) { - return adapter.getValueAt(adapter.row, 0) instanceof 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); + 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. @@ -143,7 +144,7 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { @@ -157,8 +158,8 @@ return isHighlighted; } }; - colorTransaction = - new ColorHighlighter(predicate, new Color(255, 198, 209), null); + colorTransaction = + new ColorHighlighter(predicate, new Color(255, 198, 209), null); addHighlighter(colorTransaction); } @@ -170,51 +171,51 @@ 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)){ + 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)) { + if (e.getKeyCode() == KeyEvent.VK_INSERT + || e.getKeyCode() == KeyEvent.VK_ENTER + && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.addEmptyEntry(); } - + // copy : ctrl + c // add financial transaction with the key combination : ctrl + c - if (e.getKeyCode() == KeyEvent.VK_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 + 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 + 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 (!this.isEditing()) { - this.clearSelection(); - } + if (!isEditing()) { + clearSelection(); + } } - + /** * Touche tab * Incrémente le curseur de case tant que la case n'est pas editable @@ -222,36 +223,36 @@ * la dernière cellule et si la transaction est non équilibré * sinon rajoute une transaction */ - + if (e.getKeyChar() == KeyEvent.VK_TAB) { - int max_x = this.getColumnCount(); - int max_y = this.getRowCount(); - x_tab = this.getSelectedColumn(); - y_tab = this.getSelectedRow(); + int max_x = getColumnCount(); + int max_y = getRowCount(); + x_tab = getSelectedColumn(); + y_tab = getSelectedRow(); Boolean end = true; - - if (x_tab < max_x - 1){ + + if (x_tab < max_x - 1) { x_tab++; } //end of row else { - x_tab=0; + 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 ){ + while (!isCellEditable(y_tab, x_tab) && end) { //if end of row - if (x_tab == max_x-1) { - Object object = this.handler.tableModel.getElementAt(y_tab); - + if (x_tab == max_x - 1) { + Object object = handler.tableModel.getElementAt(y_tab); + //if transaction, add entry - if (object instanceof FinancialTransaction){ + if (object instanceof FinancialTransaction) { FinancialTransaction financialTransaction = (FinancialTransaction) object; - if (financialTransaction.getEntry().size() == 0){ + if (financialTransaction.getEntry().size() == 0) { handler.addEmptyEntry(); - this.setColumnSelectionInterval(1, 1); - } + setColumnSelectionInterval(1, 1); + } } //if entry else { @@ -262,58 +263,58 @@ 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 { + 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); + + @Override + protected void done() { + Object object = handler.tableModel.getElementAt(y_tab - 1); FinancialTransaction financialTransaction = null; - if (object instanceof Entry){ + if (object instanceof Entry) { financialTransaction = ((Entry) object).getFinancialTransaction(); - } - else if (object instanceof FinancialTransaction){ + } 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){ + if (amountC == amountD) { + if (y_t == m_t - 1) { handler.addFinancialTransaction(); table.setColumnSelectionInterval(0, 0); } - } - else { + } 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; + x_tab = 0; } } }.execute(); } end = false; - } - else { - if (x_tab < max_x){ - this.setRowSelectionInterval(y_tab, y_tab); - this.setColumnSelectionInterval(x_tab, x_tab); + } else { + if (x_tab < max_x) { + setRowSelectionInterval(y_tab, y_tab); + setColumnSelectionInterval(x_tab, x_tab); x_tab++; } } } } - - + + } @Override public void keyTyped(KeyEvent e) { - + } @@ -327,8 +328,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,15 +25,6 @@ package org.chorem.lima.ui.financialtransaction; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import javax.swing.table.AbstractTableModel; import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -48,27 +39,37 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.EntryImpl; import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FinancialTransactionImpl; -import org.chorem.lima.entity.FinancialTransaction; 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; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Basic transaction table model. - * + * <p/> * Le modele est filtré sur {@link #selectedFinancialPeriod} et * {@link #selectedFinancialPeriod} (montée en charge !). - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ -public class FinancialTransactionTableModel extends AbstractTableModel implements ServiceListener{ +public class FinancialTransactionTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 1L; @@ -79,62 +80,76 @@ /** Transaction service. */ protected final FinancialTransactionServiceMonitorable financialTransactionService; - + /** selected financial period */ protected FinancialPeriod selectedFinancialPeriod; - + /** data cache */ protected List<Object> cacheDataList; - - /** collection - + protected EntryBook selectedEntryBook; + /** + * collection + * <p/> + * <p/> + * /** * Model constructor. - * + * <p/> * Just init service proxies. */ public FinancialTransactionTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); } /** * Le model est une combinaison de Transaction/Entries. - * - * + * * @return */ protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); - if (selectedFinancialPeriod != null){ + if (selectedFinancialPeriod != null) { try { - List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllFinancialTransactionsForFinancialPeriod( + List<FinancialTransaction> transactions; + + if (selectedEntryBook == null) { + + // get all transactions for all entry books + transactions = financialTransactionService.getAllFinancialTransactionsForFinancialPeriod( selectedFinancialPeriod); - for (FinancialTransaction financialtransaction : financialtransactions) { - results.add(financialtransaction); - List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); + } else { + + // get all transactions for selected entry book + transactions = financialTransactionService.getAllFinancialTransactionsForEntryBookAndFinancialPeriod( + selectedEntryBook, + selectedFinancialPeriod + ); + } + + for (FinancialTransaction transaction : transactions) { + results.add(transaction); + List<Entry> entries = (List<Entry>) transaction.getEntry(); Collections.sort(entries, new EntryComparator()); results.addAll(entries); } - } - catch (LimaException eee) { + } 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 transaction list", eee); - } - } + ErrorHelper.showErrorDialog("Can't get transaction list", eee); + } + } return results; } - - public void refresh(){ + + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } @@ -150,72 +165,71 @@ Class<?> result = null; switch (column) { - case 0: - result = Date.class; - break; - case 1: - result = EntryBook.class; - break; - case 2: - result = String.class; - break; - case 3: - result = Account.class; - break; - case 4: - result = String.class; - break; - case 5: - result = Letter.class; - break; - case 6: - result = BigDecimal.class; - break; - case 7: - result = BigDecimal.class; - break; - case 8: - result = BigDecimal.class; - break; + case 0: + result = Date.class; + break; + case 1: + result = EntryBook.class; + break; + case 2: + result = String.class; + break; + case 3: + result = Account.class; + break; + case 4: + result = String.class; + break; + case 5: + result = Letter.class; + break; + case 6: + result = BigDecimal.class; + break; + case 7: + result = BigDecimal.class; + break; + case 8: + result = BigDecimal.class; + break; } return result; } - - + @Override public String getColumnName(int column) { String result = "n/a"; switch (column) { - case 0: - result = _("lima.table.date"); - break; - case 1: - result = _("lima.table.entrybook"); - break; - case 2: - result = _("lima.table.voucher"); - break; - case 3: - result = _("lima.table.account"); - break; - case 4: - result = _("lima.table.description"); - break; - case 5: - result = _("lima.table.letter"); - break; - case 6: - result = _("lima.table.debit"); - break; - case 7: - result = _("lima.table.credit"); - break; - case 8: - result = _("lima.table.balance"); - break; + case 0: + result = _("lima.table.date"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.voucher"); + break; + case 3: + result = _("lima.table.account"); + break; + case 4: + result = _("lima.table.description"); + break; + case 5: + result = _("lima.table.letter"); + break; + case 6: + result = _("lima.table.debit"); + break; + case 7: + result = _("lima.table.credit"); + break; + case 8: + result = _("lima.table.balance"); + break; } return result; @@ -224,7 +238,7 @@ @Override public int getRowCount() { int result = 0; - + if (cacheDataList != null) { result = cacheDataList.size(); } @@ -235,181 +249,189 @@ @Override public Object getValueAt(int row, int column) { Object result = null; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.get(row); - + if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction) result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { - case 0: - result = currentRow.getTransactionDate(); - break; - case 1: - if (currentRow.getEntryBook() != null){ - result = currentRow.getEntryBook().getCode(); - } - else { - result = null; - } - break; - case 2: - result = null; //voucher - break; - case 3: - result = null; // account - break; - case 4: - result = null; // description - break; - case 5 : - result = null; // letter - break; - case 6: - result = amountDebit; - break; - case 7: - result = amountCredit; - break; - case 8: - result = amountDebit.subtract(amountCredit); - break; + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null) { + result = currentRow.getEntryBook().getCode(); + } else { + result = null; + } + break; + case 2: + result = null; //voucher + break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5: + result = null; // letter + break; + case 6: + result = amountDebit; + break; + case 7: + result = amountCredit; + break; + case 8: + result = amountDebit.subtract(amountCredit); + break; } - } - else if (result instanceof Entry) { - Entry currentEntry = (Entry)result; + } else if (result instanceof Entry) { + Entry currentEntry = (Entry) result; switch (column) { - case 0: - result = null; // date - break; - case 1 : // entry book - result = null; - break; - case 2: - result = currentEntry.getVoucher(); - break; - case 3: // account - if (currentEntry.getAccount() != null){ - result = currentEntry.getAccount().getAccountNumber(); - } - else { + case 0: + result = null; // date + break; + case 1: // entry book result = null; - } - break; - case 4: - result = currentEntry.getDescription(); - break; - case 5 : - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { + break; + case 2: + result = currentEntry.getVoucher(); + break; + case 3: // account + if (currentEntry.getAccount() != null) { + result = currentEntry.getAccount().getAccountNumber(); + } else { + result = null; + } + break; + case 4: + result = currentEntry.getDescription(); + break; + case 5: + if (currentEntry.getLetter() != null) { + result = currentEntry.getLetter().getCode(); + } else { + result = null; + } + break; + case 6: + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; + break; + case 7: + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); + break; + case 8: result = null; - } - break; - case 6: - result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; - break; - case 7: - result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); - break; - case 8: - result = null; - break; + break; } - + } } return result; } - - - public void setFinancialPeriod(FinancialPeriod financialPeriod){ + + public void setFinancialPeriod(FinancialPeriod financialPeriod) { selectedFinancialPeriod = financialPeriod; refresh(); } - + + public void setSelectedEntryBook(EntryBook selectedEntryBook) { + this.selectedEntryBook = selectedEntryBook; + refresh(); + } + /** * To set cells editable or not * different condition for entry or financial transaction */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - boolean editableCell=false; + boolean editableCell = false; Object currentRow = cacheDataList.get(rowIndex); // cells editable for the entry row, all cells exclude the date - if ((currentRow instanceof Entry) && !((columnIndex==0) || (columnIndex==1) || (columnIndex==8))) { - editableCell=true; + if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1 || columnIndex == 8)) { + editableCell = true; } // cells editable for the financialtransaction row, no cells exclude the date - if ((currentRow instanceof FinancialTransaction) && ((columnIndex==0) || (columnIndex==1))){ - editableCell=true; + if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) { + +// if (selectedEntryBook == null || columnIndex == 0) { +// +// // can only edit the transaction entry book only if there is +// // no entry book selected (otherwise we will loose the transaction +// editableCell = true; +// } + editableCell = true; } return editableCell; } - - /** * @return int: indexOf new FianancialTransaction * @throws LimaException */ - public int addFinancialTransaction() throws LimaException{ + public int addFinancialTransaction() throws LimaException { /* Calling transaction service */ FinancialTransaction financialTransaction = new FinancialTransactionImpl(); financialTransaction.setAmountDebit(BigDecimal.ZERO); financialTransaction.setAmountCredit(BigDecimal.ZERO); //if a period is selected - if (selectedFinancialPeriod != null){ - financialTransaction.setFinancialPeriod(selectedFinancialPeriod); - // get today - Calendar actualCalendar = Calendar.getInstance(); - // get the financial period date - Date transactionDate = selectedFinancialPeriod.getBeginDate(); - - Calendar calEnd = Calendar.getInstance(); - calEnd.setTime(selectedFinancialPeriod.getEndDate()); - int dayMax = calEnd.get(Calendar.DAY_OF_MONTH); - Calendar calBegin = Calendar.getInstance(); - calBegin.setTime(selectedFinancialPeriod.getBeginDate()); - int dayMin = calBegin.get(Calendar.DAY_OF_MONTH); - int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); - - if ((toDay>dayMax) || (toDay<dayMin)){ - // change the day - transactionDate = DateUtils.setDays(transactionDate, dayMax); - } - else{ - // change the day - transactionDate = DateUtils.setDays(transactionDate, toDay); - } - + if (selectedFinancialPeriod == null) { + throw new LimaBusinessException("No financial period selected"); + } - // set date to the financial transaction - financialTransaction.setTransactionDate(transactionDate); - // create it - FinancialTransaction fTransaction = - financialTransactionService.createFinancialTransaction(financialTransaction); + financialTransaction.setFinancialPeriod(selectedFinancialPeriod); - //on recharge la liste - cacheDataList = getDataList(); - int row = cacheDataList.indexOf(fTransaction); - fireTableRowsInserted(row, row); - return row; - //fireTableDataChanged(); + if (selectedEntryBook != null) { + financialTransaction.setEntryBook(selectedEntryBook); } - else { - throw new LimaBusinessException("No financial period selected"); + + // get today + Calendar actualCalendar = Calendar.getInstance(); + + // get the financial period date + Date transactionDate = selectedFinancialPeriod.getBeginDate(); + + Calendar calEnd = Calendar.getInstance(); + calEnd.setTime(selectedFinancialPeriod.getEndDate()); + int dayMax = calEnd.get(Calendar.DAY_OF_MONTH); + Calendar calBegin = Calendar.getInstance(); + calBegin.setTime(selectedFinancialPeriod.getBeginDate()); + int dayMin = calBegin.get(Calendar.DAY_OF_MONTH); + int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); + + if (toDay > dayMax || toDay < dayMin) { + // change the day + transactionDate = DateUtils.setDays(transactionDate, dayMax); + } else { + // change the day + transactionDate = DateUtils.setDays(transactionDate, toDay); } + + + // set date to the financial transaction + financialTransaction.setTransactionDate(transactionDate); + // create it + FinancialTransaction fTransaction = + financialTransactionService.createFinancialTransaction(financialTransaction); + + //on recharge la liste + cacheDataList = getDataList(); + int row = cacheDataList.indexOf(fTransaction); + fireTableRowsInserted(row, row); + return row; } - + /** - * * @param value + * @param voucher * @param description * @param row * @return int: indexOf new Entry @@ -428,10 +450,9 @@ } //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); } @@ -445,9 +466,8 @@ fireTableRowsInserted(newrow, newrow); return newrow; } - + /** - * * @param value * @param entry * @param row @@ -460,24 +480,23 @@ Object currentRow = cacheDataList.get(row); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction) currentRow; //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(((FinancialTransaction) currentRow)); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + financialTransactionRow = + getDataList().indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(((Entry) currentRow). - getFinancialTransaction()); + financialTransactionRow = + getDataList().indexOf(((Entry) currentRow). + getFinancialTransaction()); } //create it entry.setFinancialTransaction(currentTransaction); Entry newEntry = financialTransactionService.createEntry(entry); - fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); //on recharge la liste cacheDataList = getDataList(); @@ -485,10 +504,8 @@ fireTableRowsInserted(newrow, newrow); return newrow; } - - /** - * to modifiy financialtransaction or entry - */ + + /** to modifiy financialtransaction or entry */ @Override public void setValueAt(Object value, int row, int column) { int financialTransactionRow = 0; @@ -496,99 +513,106 @@ Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; + (FinancialTransaction) currentRow; switch (column) { - case 0: - //update - currentFinancialTransaction.setTransactionDate((Date)value); - break; - case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); - break; + case 0: + //update + currentFinancialTransaction.setTransactionDate((Date) value); + break; + case 1: + if (selectedEntryBook != null) { + + // not authorized to change the value + return; + } + currentFinancialTransaction.setEntryBook((EntryBook) value); + break; } // notify service for modification try { financialTransactionService. - updateFinancialTransaction(currentFinancialTransaction); + updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't update financial transaction", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showMessageDialog(eee.getMessage()); } - //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(((FinancialTransaction) currentRow)); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + //update the financial transaction in entire + financialTransactionRow = + getDataList().indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; switch (column) { - case 2 : - currentEntry.setVoucher(((String)value).trim()); - break; - case 3: - currentEntry.setAccount((Account)value); - break; - case 4: - currentEntry.setDescription(((String)value).trim()); - break; - case 5 : - currentEntry.setLetter((Letter)value); - break; - case 6: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(true); - break; - case 7: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(false); - break; + case 2: + currentEntry.setVoucher(((String) value).trim()); + break; + case 3: + Account account = (Account) value; + currentEntry.setAccount(account); + // let's copy the account description + currentEntry.setDescription(account.getLabel()); + break; + case 4: + currentEntry.setDescription(((String) value).trim()); + break; + case 5: + currentEntry.setLetter((Letter) value); + break; + case 6: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(true); + break; + case 7: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(false); + break; } try { financialTransactionService.updateEntry(currentEntry); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't update entry", eee); } DialogHelper.showMessageDialog(eee.getMessage()); } //update the financial transaction in entire - financialTransactionRow = - getDataList().indexOf(((Entry) currentRow). - getFinancialTransaction()); + financialTransactionRow = + getDataList().indexOf(((Entry) currentRow). + getFinancialTransaction()); } //on recharge la liste cacheDataList = getDataList(); - fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); } } - - public Object getElementAt(int row){ + + public Object getElementAt(int row) { Object result = null; - if (cacheDataList != null){ + if (cacheDataList != null) { result = cacheDataList.get(row); } return result; } - /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by model. - * @param Object, int - * @throws LimaException + * + * @param object + * @param row + * @throws LimaException */ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; + (FinancialTransaction) currentRow; financialTransactionService.removeFinancialTransaction(currentTransaction); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; financialTransactionService.removeEntry(currentEntry); } //on recharge la liste @@ -598,9 +622,11 @@ @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/financialtransaction/FinancialTransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2011-09-17 12:59:34 UTC (rev 3291) @@ -24,87 +24,133 @@ --> <Table> - <FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> + <FinancialTransactionViewHandler id="handler" + javaBean="new FinancialTransactionViewHandler(this)"/> - <script> + <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 + </import> + + <Boolean id="selectedRow" javaBean="false"/> + <FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> + <FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> + + <script> <![CDATA[ - import org.chorem.lima.entity.FiscalPeriod; - import org.chorem.lima.entity.FinancialPeriod; - import org.chorem.lima.ui.financialtransaction.FinancialPeriodComboBox; - import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; - void $afterCompleteSetup() { + getHandler().initEntryBookModel(entryBookComboBox); getHandler().refresh(); } ]]> - </script> - - <row weightx="1" weighty="0" anchor="center"> - <cell anchor="east"> - <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> - </cell> - <cell anchor="west"> - <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/> - <JComboBox id="fiscalPeriodComboBox" - model="{getModelFiscalPeriod()}" - renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}" - onActionPerformed="getModelFinancialPeriod().setFiscalPeriod((FiscalPeriod)fiscalPeriodComboBox.getSelectedItem())" - editable="false"/> - </cell> - <cell anchor="east"> - <JLabel id="financialPeriodLabel" text="lima.common.period" - /> - </cell> - <cell anchor="west"> - <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/> - <FinancialPeriodComboBox id="financialPeriodComboBox" - constructorParams="getHandler()" - model="{getModelFinancialPeriod()}" renderer="{new FinancialPeriodComboBoxRenderer()}" - onActionPerformed="financialTransactionTableModel.setFinancialPeriod((FinancialPeriod)financialPeriodComboBox.getSelectedItem())"/> - </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> - <JButton text="lima.common.copy" - onActionPerformed="getHandler().copyRow()" enabled="{isSelectedRow()}"/> - </cell> - <cell> - <JButton text="lima.common.paste" - onActionPerformed="getHandler().pasteRow()" enabled="{isSelectedRow()}"/> - </cell> - <cell> - <JButton text="lima.entries.addTransaction" - onActionPerformed="getHandler().addFinancialTransaction()"/> - </cell> - <cell> - <JButton text="lima.entries.addEntry" onActionPerformed="getHandler().addEmptyEntry()" enabled="{isSelectedRow()}"/> - </cell> - <cell> - <JButton text="lima.common.remove" - onActionPerformed="getHandler().deleteSelectedRow()" - enabled="{isSelectedRow()}"/> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> - <JScrollPane> - <org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel - id="financialTransactionTableModel"/> - <org.chorem.lima.ui.financialtransaction.FinancialTransactionTable - id="financialTransactionTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> - <javax.swing.ListSelectionModel javaBean="getFinancialTransactionTable().getSelectionModel()" - onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - </row> + </script> + + <row weightx="1" weighty="0" anchor="center"> + <cell anchor="east"> + <JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/> + </cell> + <cell anchor="west"> + + <JComboBox id="fiscalPeriodComboBox" + model="{getModelFiscalPeriod()}" + renderer="{RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" + onActionPerformed="getModelFinancialPeriod().setFiscalPeriod((FiscalPeriod)fiscalPeriodComboBox.getSelectedItem())" + editable="false"/> + </cell> + <cell anchor="east"> + <JLabel id="financialPeriodLabel" text="lima.common.period"/> + </cell> + <cell anchor="west"> + <JPanel> + <FinancialPeriodComboBox id="financialPeriodComboBox" + constructorParams="getHandler()" + model="{getModelFinancialPeriod()}" + renderer="{RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class)}" + onActionPerformed="financialTransactionTableModel.setFinancialPeriod((FinancialPeriod)financialPeriodComboBox.getSelectedItem())"/> + <JButton id="back" text="lima.common.buttonback" + onActionPerformed="financialPeriodComboBox.back()"/> + <JButton id="next" text="lima.common.buttonnext" + onActionPerformed="financialPeriodComboBox.next()"/> + </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())"/> + </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()"/> + <JButton text="lima.common.paste" enabled="{isSelectedRow()}" + onActionPerformed="getHandler().pasteRow()"/> + <JButton text="lima.entries.addTransaction" + onActionPerformed="getHandler().addFinancialTransaction()"/> + <JButton text="lima.entries.addEntry" enabled="{isSelectedRow()}" + onActionPerformed="getHandler().addEmptyEntry()"/> + <JButton text="lima.common.remove" enabled="{isSelectedRow()}" + onActionPerformed="getHandler().deleteSelectedRow()"/> + + </JPanel> + </JToolBar> + </cell> + </row> + <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}"/> + <ListSelectionModel + javaBean="getFinancialTransactionTable().getSelectionModel()" + onValueChanged="setSelectedRow(financialTransactionTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> </Table> \ No newline at end of file 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,93 +25,114 @@ package org.chorem.lima.ui.financialtransaction; -import static org.nuiton.i18n.I18n._; - - -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; - +import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.EntryBookServiceMonitorable; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.financialtransaction.FinancialTransactionView; import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.ErrorHelper; +import javax.swing.JComboBox; +import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with financial transaction view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialTransactionViewHandler { /** log. */ private static final Log log = - LogFactory.getLog(FinancialTransactionViewHandler.class); + LogFactory.getLog(FinancialTransactionViewHandler.class); protected FinancialTransactionView view; - + protected FinancialTransactionTable table; - + protected FinancialTransactionTableModel tableModel; - + protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; - + protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; - + protected Object clipBoard; protected FinancialTransactionViewHandler(FinancialTransactionView view) { this.view = view; - } - - //copy entry - public void copyRow(){ + } + + public void initEntryBookModel(JComboBox comboBox) { + EntryBookServiceMonitorable service = + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); + try { + List<EntryBook> allEntryBooks = service.getAllEntryBooks(); + allEntryBooks.add(0, null); + SwingUtil.fillComboBox(comboBox, allEntryBooks, null); + } catch (LimaException e) { + ErrorHelper.showErrorDialog(view, e.getMessage(), e.getCause()); + } + } + + //copy entry + public void copyRow() { table = view.getFinancialTransactionTable(); int indexSelectedRow = table.getSelectedRow(); - + if (indexSelectedRow != -1) { clipBoard = tableModel.getElementAt(indexSelectedRow); } } - + //paste entry - public void pasteRow(){ + public void pasteRow() { table = view.getFinancialTransactionTable(); int indexSelectedRow = table.getSelectedRow(); - + 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(selectedValue, + (Entry) clipBoard, + indexSelectedRow + ); //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow+1, indexSelectedRow+1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee){ + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't past entry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } - + } - + //add a new transaction public void addFinancialTransaction() { table = view.getFinancialTransactionTable(); @@ -121,24 +142,25 @@ int index = tableModel.addFinancialTransaction(); //select the new line int numberRow = table.getRowCount(); - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(numberRow-1, numberRow-1); + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); //focus on first column table.changeSelection(index, 0, false, false); table.requestFocusInWindow(); + table.scrollCellToVisible(index, 0); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add financialtransaction", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } - + //implement new transaction button //add a new entry to the selected transaction - public void addEmptyEntry(){ - + public void addEmptyEntry() { + table = view.getFinancialTransactionTable(); tableModel = view.getFinancialTransactionTableModel(); @@ -147,38 +169,42 @@ Object selectedValue = tableModel.getElementAt(indexSelectedRow); try { //copy + paste the voucher and the description - String voucher = (String) tableModel.getValueAt(indexSelectedRow, 2); - String description = (String) tableModel.getValueAt(indexSelectedRow, 4); - int index = tableModel.addEmptyEntry(selectedValue, voucher, description, indexSelectedRow); + String voucher = (String) + tableModel.getValueAt(indexSelectedRow, 2); + String description = (String) + tableModel.getValueAt(indexSelectedRow, 4); + int index = tableModel.addEmptyEntry(selectedValue, + 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(); - } catch (LimaException eee){ + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); } } } - + /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by model. - * @throws LimaException */ - public void deleteSelectedRow(){ + public void deleteSelectedRow() { table = view.getFinancialTransactionTable(); tableModel = view.getFinancialTransactionTableModel(); @@ -187,47 +213,46 @@ if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - String message = null; + String message; if (selectedValue instanceof FinancialTransaction) { message = _("lima.charts.financialtransaction.question.removetransaction"); - } - else { + } else { message = _("lima.charts.financialtransaction.question.removeentry"); } - int response = JOptionPane.showConfirmDialog(view, message, + int response = JOptionPane.showConfirmDialog( + view, message, _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - + try { tableModel.removeObject(selectedValue, indexSelectedRow); //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); + ListSelectionModel selectionModel = + table.getSelectionModel(); selectionModel.setSelectionInterval( - indexSelectedRow-1, indexSelectedRow-1); + indexSelectedRow - 1, indexSelectedRow - 1); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't remove transaction or entry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call delete selected row without selection"); } } } - - public void refresh(){ + + public void refresh() { tableModel = view.getFinancialTransactionTableModel(); - tableModel.refresh(); + tableModel.refresh(); fiscalPeriodComboBoxModel = view.getModelFiscalPeriod(); fiscalPeriodComboBoxModel.refresh(); - + financialPeriodComboBoxModel = view.getModelFinancialPeriod(); financialPeriodComboBoxModel.refresh(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,11 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import javax.swing.JComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; @@ -38,15 +33,20 @@ import org.chorem.lima.util.AccountToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -public class AccountSearchComboBox extends JComboBox implements KeyListener, ActionListener { +import javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +public class AccountSearchComboBox extends JComboBox implements KeyListener { + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(AccountSearchComboBox.class); - + LogFactory.getLog(AccountSearchComboBox.class); + protected FinancialTransactionSearchViewHandler handler; - + public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) { this.handler = handler; AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); @@ -55,48 +55,45 @@ setRenderer(accountRenderer); setEditable(true); AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); } - - + @Override public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - handler.setAccount((Account) this.getSelectedItem()); + Object object = getSelectedItem(); + if (object instanceof Account) { + handler.setAccount((Account) getSelectedItem()); } } - @Override public void keyPressed(KeyEvent e) { - + } @Override public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Account){ - Account account = (Account) this.getSelectedItem(); + Object object = getSelectedItem(); + if (object instanceof Account) { + Account account = (Account) getSelectedItem(); //to prevent useless call to service - if (!account.equals(handler.getAccount())){ + if (!account.equals(handler.getAccount())) { handler.setAccount(account); } } - + // delegate popup list menu - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { firePopupMenuCanceled(); } } @Override public void keyTyped(KeyEvent e) { - + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,72 +25,72 @@ package org.chorem.lima.ui.financialtransactionsearch; -import static org.nuiton.i18n.I18n._; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import javax.swing.JPanel; -import javax.swing.JTextField; import org.chorem.lima.entity.Account; import org.chorem.lima.enums.ComboBoxAccountsEnum; +import javax.swing.JPanel; +import javax.swing.JTextField; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +import static org.nuiton.i18n.I18n._; + public class AccountSearchPanel extends JPanel { - + protected FinancialTransactionSearchViewHandler handler; - + public AccountSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum){ - + public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum) { + switch (comboBoxAccountsEnum) { - case ALL: - handler.setAccount(null); - handler.refresh(); - this.removeAll(); - break; - - case ACCOUNT: - final AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); - handler.setAccount((Account) accountComboBox.getSelectedItem()); - handler.refresh(); - this.removeAll(); - this.add(accountComboBox); - break; - - case ACCOUNT_LIST: - final JTextField accountsList = new JTextField(16); - accountsList.setMinimumSize(accountsList.getPreferredSize()); - accountsList.setToolTipText(_("lima.tooltip.filter")); - KeyListener accountsListKeyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - String accounts = accountsList.getText(); - //to prevent useless call to service - if (!accounts.equals(handler.getAccountsList())){ - handler.setAccountsList(accounts); + case ALL: + handler.setAccount(null); + handler.refresh(); + removeAll(); + break; + + case ACCOUNT: + AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); + handler.setAccount((Account) accountComboBox.getSelectedItem()); + handler.refresh(); + removeAll(); + add(accountComboBox); + break; + + case ACCOUNT_LIST: + final JTextField accountsList = new JTextField(16); + accountsList.setMinimumSize(accountsList.getPreferredSize()); + accountsList.setToolTipText(_("lima.tooltip.filter")); + KeyListener accountsListKeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { } - } - - @Override - public void keyPressed(KeyEvent e) { - } - }; - accountsList.addKeyListener(accountsListKeyListener); - handler.setAccountsList(accountsList.getText()); - handler.setAccount(null); - this.removeAll(); - this.add(accountsList); - break; + + @Override + public void keyReleased(KeyEvent e) { + String accounts = accountsList.getText(); + //to prevent useless call to service + if (!accounts.equals(handler.getAccountsList())) { + handler.setAccountsList(accounts); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + accountsList.addKeyListener(accountsListKeyListener); + handler.setAccountsList(accountsList.getText()); + handler.setAccount(null); + removeAll(); + add(accountsList); + break; } - + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AmountSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,83 +25,84 @@ package org.chorem.lima.ui.financialtransactionsearch; +import org.chorem.lima.enums.ComboBoxOperatorsEnum; + +import javax.swing.JPanel; +import javax.swing.JTextField; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; -import javax.swing.JPanel; -import javax.swing.JTextField; -import org.chorem.lima.enums.ComboBoxOperatorsEnum; public class AmountSearchPanel extends JPanel { - + protected FinancialTransactionSearchViewHandler handler; - + public AmountSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; refresh(ComboBoxOperatorsEnum.EQUAL); } - + static final long serialVersionUID = 1L; - public void refresh(ComboBoxOperatorsEnum enums){ - + public void refresh(ComboBoxOperatorsEnum enums) { + final JTextField amountTextField = new JTextField(16); amountTextField.setMinimumSize(amountTextField.getPreferredSize()); KeyListener amountKeyListener = new KeyListener() { - + @Override - public void keyTyped(KeyEvent e) { + public void keyTyped(KeyEvent e) { } - + @Override public void keyReleased(KeyEvent e) { String amount = amountTextField.getText(); //to prevent useless call to service - if (!amount.equals(handler.getAmount())){ + if (!amount.equals(handler.getAmount())) { handler.setAmount(amount); } } - + @Override - public void keyPressed(KeyEvent e) { + public void keyPressed(KeyEvent e) { } }; amountTextField.addKeyListener(amountKeyListener); handler.setAmount2(""); handler.setOperator(enums.getSymbol()); handler.refresh(); - this.removeAll(); - this.add(amountTextField); - + removeAll(); + add(amountTextField); + switch (enums) { - case INTERVAL: - final JTextField amount2TextField = new JTextField(16); - amount2TextField.setMinimumSize(amount2TextField.getPreferredSize()); - KeyListener amount2KeyListener = new KeyListener() { - - @Override - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyReleased(KeyEvent e) { - - String amount2 = amount2TextField.getText(); - //to prevent useless call to service - if (!amount2.equals(handler.getAmount2())){ - handler.setAmount2(amount2); + case INTERVAL: + final JTextField amount2TextField = new JTextField(16); + amount2TextField.setMinimumSize(amount2TextField.getPreferredSize()); + KeyListener amount2KeyListener = new KeyListener() { + + @Override + public void keyTyped(KeyEvent e) { } - } - - @Override - public void keyPressed(KeyEvent e) { - } - }; - amount2TextField.addKeyListener(amount2KeyListener); - handler.setAmount(""); - this.add(amount2TextField); - break; + + @Override + public void keyReleased(KeyEvent e) { + + String amount2 = amount2TextField.getText(); + //to prevent useless call to service + if (!amount2.equals(handler.getAmount2())) { + handler.setAmount2(amount2); + } + } + + @Override + public void keyPressed(KeyEvent e) { + } + }; + amount2TextField.addKeyListener(amount2KeyListener); + handler.setAmount(""); + add(amount2TextField); + break; } - amountTextField.setText(handler.getAmount()); + amountTextField.setText(handler.getAmount()); } - + } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,11 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import javax.swing.JComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.EntryBook; @@ -38,15 +33,20 @@ import org.chorem.lima.util.EntryBookToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -public class EntryBookSearchComboBox extends JComboBox implements KeyListener, ActionListener { +import javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +public class EntryBookSearchComboBox extends JComboBox implements KeyListener { + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(EntryBookSearchComboBox.class); - + LogFactory.getLog(EntryBookSearchComboBox.class); + protected FinancialTransactionSearchViewHandler handler; - + public EntryBookSearchComboBox(FinancialTransactionSearchViewHandler handler) { this.handler = handler; EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); @@ -55,42 +55,40 @@ setRenderer(entryBookRenderer); setEditable(true); AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); } - - + @Override public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); + Object object = getSelectedItem(); + if (object instanceof EntryBook) { + handler.setEntryBook((EntryBook) getSelectedItem()); } } @Override public void keyPressed(KeyEvent e) { - + } @Override public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof EntryBook){ - handler.setEntryBook((EntryBook) this.getSelectedItem()); + Object object = getSelectedItem(); + if (object instanceof EntryBook) { + handler.setEntryBook((EntryBook) getSelectedItem()); } // delegate popup list menu - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { firePopupMenuCanceled(); } } @Override public void keyTyped(KeyEvent e) { - + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,35 +25,34 @@ package org.chorem.lima.ui.financialtransactionsearch; -import javax.swing.JPanel; import org.chorem.lima.enums.ComboBoxEntryBooksEnum; +import javax.swing.JPanel; + public class EntryBookSearchPanel extends JPanel { - + protected FinancialTransactionSearchViewHandler handler; - + public EntryBookSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxEntryBooksEnum enums){ - + public void refresh(ComboBoxEntryBooksEnum enums) { + switch (enums) { - case SELECT_ONE: - EntryBookSearchComboBox entryBookSearchComboBox = new EntryBookSearchComboBox(handler); - handler.setEntryBook(null); - this.removeAll(); - this.add(entryBookSearchComboBox); - break; - - case ALL: - handler.setEntryBook(null); - this.removeAll(); - break; + case SELECT_ONE: + EntryBookSearchComboBox entryBookSearchComboBox = new EntryBookSearchComboBox(handler); + handler.setEntryBook(null); + removeAll(); + add(entryBookSearchComboBox); + break; + + case ALL: + handler.setEntryBook(null); + removeAll(); + break; } - + } - + } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,15 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Calendar; -import java.util.Date; -import static org.nuiton.i18n.I18n._; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; - import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -46,131 +37,139 @@ import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Calendar; +import java.util.Date; + +import static org.nuiton.i18n.I18n._; + public class FinancialTransactionPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(FinancialTransactionPeriodSearchPanel.class); - + LogFactory.getLog(FinancialTransactionPeriodSearchPanel.class); + protected FinancialTransactionSearchViewHandler handler; - + public FinancialTransactionPeriodSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxPeriodEnum.PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxPeriodEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxPeriodEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - case DATE: - Calendar calendar = Calendar.getInstance(); - Date date = calendar.getTime(); - date = DateUtils.truncate(date, Calendar.DATE); - final JXDatePicker datePicker = new JXDatePicker(date); - ActionListener dateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(datePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(datePicker.getDate()); - handler.setEndDate(null); - handler.refresh(); - datePicker.addActionListener(dateActionListener); - this.removeAll(); - this.add(datePicker); - break; - - case PERIOD: - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); - //handler().setBeginDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - Date endDate = calendarEnd.getTime(); - //handler().setEndDate(endDate); - JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); - final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); - ActionListener beginDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setBeginDate(beginDatePicker.getDate()); - beginDatePicker.addActionListener(beginDateActionListener); - - JLabel endDateLabel = new JLabel(_("lima.common.enddate")); - final JXDatePicker endDatePicker = new JXDatePicker(endDate); - ActionListener endDateActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - handler.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); - final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); - fiscalPeriod.setEditable(false); - ActionListener fiscalPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + case DATE: + Calendar calendar = Calendar.getInstance(); + Date date = calendar.getTime(); + date = DateUtils.truncate(date, Calendar.DATE); + final JXDatePicker datePicker = new JXDatePicker(date); + ActionListener dateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(datePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(datePicker.getDate()); + handler.setEndDate(null); + handler.refresh(); + datePicker.addActionListener(dateActionListener); + removeAll(); + add(datePicker); + break; - this.removeAll(); - this.add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); - final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); - financialPeriod.setEditable(false); - ActionListener financialPeriodActionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); - break; + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.common.begindate")); + final JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + ActionListener beginDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); + + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.setEndDate(endDatePicker.getDate()); + handler.refresh(); + } + }; + handler.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + handler.refresh(); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + removeAll(); + add(financialPeriod); + break; } - + } - + } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,40 +25,35 @@ package org.chorem.lima.ui.financialtransactionsearch; -import java.awt.Color; -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.math.BigDecimal; -import java.util.Date; - -import javax.swing.SwingWorker; - 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; -import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.chorem.lima.ui.celleditor.DateTableCellEditor; import org.chorem.lima.ui.celleditor.EmptyCellRenderer; import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; -import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.math.BigDecimal; +import java.util.Date; + /** * Table des transaction qui ajoute des comportement (keys). - * + * * @author ore * @author Rémi Chapelet */ @@ -67,7 +62,7 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - + /** log. */ private static final Log log = LogFactory .getLog(FinancialTransactionSearchTable.class); @@ -77,19 +72,14 @@ private Highlighter colorTransaction; private ColorHighlighter colorBalance; - - private int x_tab; - private int y_tab; - /** - */ public FinancialTransactionSearchTable(FinancialTransactionSearchViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); //Get new entry book editor @@ -106,7 +96,7 @@ 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 @@ -118,24 +108,23 @@ * 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; - } - }; + 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); + 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. @@ -149,7 +138,7 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { @@ -163,8 +152,8 @@ return isHighlighted; } }; - colorTransaction = - new ColorHighlighter(predicate, new Color(255, 198, 209), null); + colorTransaction = + new ColorHighlighter(predicate, new Color(255, 198, 209), null); addHighlighter(colorTransaction); } @@ -178,54 +167,54 @@ */ @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)){ + 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)) { + if (e.getKeyCode() == KeyEvent.VK_INSERT + || e.getKeyCode() == KeyEvent.VK_ENTER + && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.addEmptyEntry(); } - + // paste : ctrl + c // add financial transaction with the key combination : ctrl + c - if (e.getKeyCode() == KeyEvent.VK_C + if (e.getKeyCode() == KeyEvent.VK_C && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.copyRow(); } - + // copy : ctrl + v - + // add financial transaction with the key combination : ctrl + v - if (e.getKeyCode() == KeyEvent.VK_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 + 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 (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } - - + + //FIXME 2011.06.11 //Needs fixing //Exception in thread "AWT-EventQueue-0" @@ -238,7 +227,7 @@ * la dernière cellule et si la transaction est non équilibré * sinon rajoute une transaction */ - + /*if (e.getKeyChar() == KeyEvent.VK_TAB) { int max_x = this.getColumnCount(); int max_y = this.getRowCount(); @@ -323,7 +312,7 @@ } } }*/ - + } @Override @@ -336,8 +325,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import static org.nuiton.i18n.I18n._; -import java.math.BigDecimal; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import javax.swing.table.AbstractTableModel; - import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -41,7 +34,6 @@ import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.ServiceListener; -import org.chorem.lima.business.ejb.FinancialPeriodServiceImpl; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; @@ -55,19 +47,27 @@ import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Basic transaction table model. - * + * <p/> * Le modele est filtré sur {@link #selectedFiscalPeriod} (montée en charge !). - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ -public class FinancialTransactionSearchTableModel extends AbstractTableModel implements ServiceListener{ +public class FinancialTransactionSearchTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 1L; @@ -78,64 +78,63 @@ /** Transaction service. */ protected final FinancialTransactionServiceMonitorable financialTransactionService; - + /** Financial service */ protected final FinancialPeriodServiceMonitorable financialPeriodService; - + /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; - + /** data cache */ protected FinancialTransactionSearch financialTransactionSearch; + protected List<Object> cacheDataList; - + /** * Model constructor. - * + * <p/> * Just init service proxies. */ public FinancialTransactionSearchTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); - financialPeriodService = - LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addServiceListener(this); + financialPeriodService = + LimaServiceFactory.getInstance().getService( + FinancialPeriodServiceMonitorable.class); } /** * Le model est une combinaison de Transaction/Entries. - * - * + * * @return */ protected List<Object> getDataList(FinancialTransactionSearch financialTransactionSearch) { List<Object> results = null; //prevent to much result if (financialTransactionSearch != null && (financialTransactionSearch.getVoucher() != null || financialTransactionSearch.getDescription() != null - || financialTransactionSearch.getLetter() != null || financialTransactionSearch.getAccountList() != null - || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null - || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null) - || (financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null))){ + || financialTransactionSearch.getLetter() != null || financialTransactionSearch.getAccountList() != null + || financialTransactionSearch.getAccount() != null || financialTransactionSearch.getEntryBook() != null + || financialTransactionSearch.getAmount() != null && financialTransactionSearch.getOperator() != null + || financialTransactionSearch.getAmount() != null && financialTransactionSearch.getAmount2() != null)) { try { results = financialTransactionService.searchFinancialTransaction(financialTransactionSearch); - } - catch (LimaException eee) { + } 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 transaction list", eee); - } + } } - + return results; } - - + + protected void refresh(FinancialTransactionSearch financialTransactionSearch) { this.financialTransactionSearch = financialTransactionSearch; cacheDataList = getDataList(financialTransactionSearch); @@ -154,33 +153,33 @@ Class<?> result = null; switch (column) { - case 0: - result = Date.class; //Date - break; - case 1: - result = EntryBook.class; //EntryBook - break; - case 2: - result = String.class; //Voucher - break; - case 3: - result = Account.class; //Account - break; - case 4: - result = String.class; //Description - break; - case 5: - result = Letter.class; //Letter - break; - case 6: - result = BigDecimal.class; //Debit - break; - case 7: - result = BigDecimal.class; //Credit - break; - case 8: - result = BigDecimal.class; //Balance - break; + case 0: + result = Date.class; //Date + break; + case 1: + result = EntryBook.class; //EntryBook + break; + case 2: + result = String.class; //Voucher + break; + case 3: + result = Account.class; //Account + break; + case 4: + result = String.class; //Description + break; + case 5: + result = Letter.class; //Letter + break; + case 6: + result = BigDecimal.class; //Debit + break; + case 7: + result = BigDecimal.class; //Credit + break; + case 8: + result = BigDecimal.class; //Balance + break; } @@ -192,33 +191,33 @@ String result = "n/a"; switch (column) { - case 0: - result = _("lima.table.date"); - break; - case 1: - result = _("lima.table.entrybook"); - break; - case 2: - result = _("lima.table.voucher"); - break; - case 3: - result = _("lima.table.account"); - break; - case 4: - result = _("lima.table.description"); - break; - case 5: - result = _("lima.table.letter"); - break; - case 6: - result = _("lima.table.debit"); - break; - case 7: - result = _("lima.table.credit"); - break; - case 8: - result = _("lima.table.balance"); - break; + case 0: + result = _("lima.table.date"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.voucher"); + break; + case 3: + result = _("lima.table.account"); + break; + case 4: + result = _("lima.table.description"); + break; + case 5: + result = _("lima.table.letter"); + break; + case 6: + result = _("lima.table.debit"); + break; + case 7: + result = _("lima.table.credit"); + break; + case 8: + result = _("lima.table.balance"); + break; } @@ -228,7 +227,7 @@ @Override public int getRowCount() { int result = 0; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.size(); @@ -240,141 +239,135 @@ @Override public Object getValueAt(int row, int column) { Object result = null; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.get(row); - + if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction) result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { - case 0: - result = currentRow.getTransactionDate(); - break; - case 1: - if (currentRow.getEntryBook() != null){ - result = currentRow.getEntryBook().getCode(); - } - else { - result = null; - } - break; - case 2: - result = null; //EntryBook - break; - case 3: - result = null; //Account - break; - case 4: - result = null; //Description - break; - case 5: - result = null; //Letter - break; - case 6 : - result = amountDebit; //Debit - break; - case 7: - result = amountCredit; //Credit - break; - case 8: - result = amountDebit.subtract(amountCredit); //Balance - break; + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null) { + result = currentRow.getEntryBook().getCode(); + } else { + result = null; + } + break; + case 2: + result = null; //EntryBook + break; + case 3: + result = null; //Account + break; + case 4: + result = null; //Description + break; + case 5: + result = null; //Letter + break; + case 6: + result = amountDebit; //Debit + break; + case 7: + result = amountCredit; //Credit + break; + case 8: + result = amountDebit.subtract(amountCredit); //Balance + break; } - } - else if (result instanceof Entry) { - Entry currentEntry = (Entry)result; + } else if (result instanceof Entry) { + Entry currentEntry = (Entry) result; switch (column) { - case 0: - result = null; //Date - break; - case 1 : //EntryBook - result = null; - break; - case 2: - result = currentEntry.getVoucher(); //Voucher - break; - case 3: // account - if (currentEntry.getAccount() != null){ - result = currentEntry.getAccount().getAccountNumber(); - } - else { + case 0: + result = null; //Date + break; + case 1: //EntryBook result = null; - } - break; - case 4: - result = currentEntry.getDescription(); //Description - break; - case 5: - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { - result = null; - } - break; - case 6: //Debit - result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; - break; - case 7: //Credit - result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); - break; - case 8: - result = null; //Balance - break; + break; + case 2: + result = currentEntry.getVoucher(); //Voucher + break; + case 3: // account + if (currentEntry.getAccount() != null) { + result = currentEntry.getAccount().getAccountNumber(); + } else { + result = null; + } + break; + case 4: + result = currentEntry.getDescription(); //Description + break; + case 5: + if (currentEntry.getLetter() != null) { + result = currentEntry.getLetter().getCode(); + } else { + result = null; + } + break; + case 6: //Debit + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; + break; + case 7: //Credit + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); + break; + case 8: + result = null; //Balance + break; } - + } } - + return result; } - - public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { selectedFiscalPeriod = fiscalPeriod; } - + /** * To set cells editable or not * different condition for entry or financial transaction */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - boolean editableCell=false; + boolean editableCell = false; Object currentRow = cacheDataList.get(rowIndex); // cells editable for the entry row, all cells exclude the date - if ((currentRow instanceof Entry) && !((columnIndex==0) || (columnIndex==1))) { - editableCell=true; + if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1)) { + editableCell = true; } // cells editable for the financialtransaction row, no cells exclude the date - if ((currentRow instanceof FinancialTransaction) && ((columnIndex==0) || (columnIndex==1))){ - editableCell=true; + if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) { + editableCell = true; } return editableCell; } - - + /** - * * @return int: indexOf new FianancialTransaction * @throws LimaException */ - public int addFinancialTransaction() throws LimaException{ + public int addFinancialTransaction() throws LimaException { /* Calling transaction service */ FinancialTransaction financialTransaction = new FinancialTransactionImpl(); financialTransaction.setAmountDebit(BigDecimal.ZERO); financialTransaction.setAmountCredit(BigDecimal.ZERO); //if a period is selected - if (selectedFiscalPeriod != null){ - List<FinancialPeriod> financialPeriodsList = - financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), - selectedFiscalPeriod.getEndDate()); - FinancialPeriod financialPeriod = null; + if (selectedFiscalPeriod != null) { + List<FinancialPeriod> financialPeriodsList = + financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), + selectedFiscalPeriod.getEndDate()); + FinancialPeriod financialPeriod; if (financialPeriodsList != null) { financialPeriod = financialPeriodsList.get(0); } else { @@ -386,7 +379,7 @@ Calendar actualCalendar = Calendar.getInstance(); // get the financial period date Date transactionDate = financialPeriod.getBeginDate(); - + Calendar calEnd = Calendar.getInstance(); calEnd.setTime(financialPeriod.getEndDate()); int dayMax = calEnd.get(Calendar.DAY_OF_MONTH); @@ -394,22 +387,21 @@ calBegin.setTime(financialPeriod.getBeginDate()); int dayMin = calBegin.get(Calendar.DAY_OF_MONTH); int toDay = actualCalendar.get(Calendar.DAY_OF_MONTH); - - if ((toDay>dayMax) || (toDay<dayMin)){ + + if (toDay > dayMax || toDay < dayMin) { // change the day transactionDate = DateUtils.setDays(transactionDate, dayMax); - } - else{ + } else { // change the day transactionDate = DateUtils.setDays(transactionDate, toDay); } - + // set date to the financial transaction financialTransaction.setTransactionDate(transactionDate); // create it - FinancialTransaction fTransaction = - financialTransactionService.createFinancialTransaction(financialTransaction); + FinancialTransaction fTransaction = + financialTransactionService.createFinancialTransaction(financialTransaction); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); @@ -417,14 +409,12 @@ fireTableRowsInserted(row, row); return row; //fireTableDataChanged(); - } - else { + } else { throw new LimaBusinessException("No financial period selected"); } } - + /** - * * @param value * @param row * @return int: indexOf new Entry @@ -437,10 +427,9 @@ entry.setAmount(BigDecimal.ZERO); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); } @@ -453,114 +442,111 @@ fireTableRowsInserted(newrow, newrow); return newrow; } - - /** - * to modifiy financialtransaction or entry - */ + + /** to modifiy financialtransaction or entry */ @Override public void setValueAt(Object value, int row, int column) { - int financialTransactionRow = 0; + int financialTransactionRow; // just prevent too much result - Object currentRow = cacheDataList.get(row); - if (currentRow instanceof FinancialTransaction) { - FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; - switch (column) { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof FinancialTransaction) { + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction) currentRow; + switch (column) { case 0: //update - currentFinancialTransaction.setTransactionDate((Date)value); + currentFinancialTransaction.setTransactionDate((Date) value); break; - case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); + case 1: + currentFinancialTransaction.setEntryBook((EntryBook) value); break; - } - // notify service for modification - try { - financialTransactionService. + } + // 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()); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't update financial transaction", eee); } - //update the financial transaction in entire - financialTransactionRow = - cacheDataList.indexOf(((FinancialTransaction) currentRow)); + DialogHelper.showMessageDialog(eee.getMessage()); } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; - switch (column) { - case 2 : - currentEntry.setVoucher((String)value); + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; + switch (column) { + case 2: + currentEntry.setVoucher((String) value); break; case 3: - currentEntry.setAccount((Account)value); + currentEntry.setAccount((Account) value); break; case 4: - currentEntry.setDescription((String)value); + currentEntry.setDescription((String) value); break; - case 5 : - currentEntry.setAmount((BigDecimal)value); + case 5: + currentEntry.setAmount((BigDecimal) value); currentEntry.setDebit(true); break; case 6: - currentEntry.setAmount((BigDecimal)value); + currentEntry.setAmount((BigDecimal) value); currentEntry.setDebit(false); break; case 8: - currentEntry.setLetter((Letter)value); + currentEntry.setLetter((Letter) value); break; + } + try { + financialTransactionService.updateEntry(currentEntry); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't update entry", eee); } - try { - financialTransactionService.updateEntry(currentEntry); - } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't update entry", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - //update the financial transaction in entire - financialTransactionRow = + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = cacheDataList.indexOf(((Entry) currentRow). getFinancialTransaction()); - } - //on recharge la liste - cacheDataList = getDataList(financialTransactionSearch); - fireTableDataChanged(); + } + //on recharge la liste + cacheDataList = getDataList(financialTransactionSearch); + fireTableDataChanged(); } - - public Object getElementAt(int row){ + + public Object getElementAt(int row) { Object currentRow = cacheDataList.get(row); return currentRow; } - + /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by model. - * @param Object, int - * @throws LimaException + * + * @param object + * @param row + * @throws LimaException */ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; + (FinancialTransaction) currentRow; financialTransactionService.removeFinancialTransaction(currentTransaction); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; financialTransactionService.removeEntry(currentEntry); } //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); fireTableDataChanged(); } - + /** - * * @param value * @param description * @param row @@ -577,16 +563,15 @@ } //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); } //create it entry.setFinancialTransaction(currentTransaction); - Entry newEntry = financialTransactionService.createEntry(entry); + Entry newEntry = financialTransactionService.createEntry(entry); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); @@ -594,9 +579,8 @@ fireTableRowsInserted(newrow, newrow); return newrow; } - + /** - * * @param value * @param entry * @param row @@ -609,24 +593,23 @@ Object currentRow = cacheDataList.get(row); //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; + currentTransaction = (FinancialTransaction) currentRow; //update the financial transaction in entire - financialTransactionRow = - getDataList(financialTransactionSearch).indexOf(((FinancialTransaction) currentRow)); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + financialTransactionRow = + getDataList(financialTransactionSearch).indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); //update the financial transaction in entire - financialTransactionRow = - getDataList(financialTransactionSearch).indexOf(((Entry) currentRow). - getFinancialTransaction()); + financialTransactionRow = + getDataList(financialTransactionSearch).indexOf(((Entry) currentRow). + getFinancialTransaction()); } //create it entry.setFinancialTransaction(currentTransaction); Entry newEntry = financialTransactionService.createEntry(entry); - fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1); //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); @@ -634,15 +617,15 @@ fireTableRowsInserted(newrow, newrow); return newrow; } - + @Override public void notifyMethod(String serviceName, String methodeName) { if ((serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") - || methodeName.contains("importAll")) && !methodeName.contains("search")){ + || methodeName.contains("importAll")) && !methodeName.contains("search")) { //on recharge la liste cacheDataList = getDataList(financialTransactionSearch); fireTableDataChanged(); } - } - + } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2011-09-17 12:59:34 UTC (rev 3291) @@ -24,18 +24,25 @@ --> <Table> - <FinancialTransactionSearchViewHandler id="handler" javaBean="new FinancialTransactionSearchViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> - <java.awt.Dimension id="fieldSize" javaBean="new java.awt.Dimension()" /> - <script> + <import> + java.awt.Dimension + javax.swing.ListSelectionModel + javax.swing.text.Document + org.chorem.lima.enums.ComboBoxPeriodEnum + org.chorem.lima.enums.ComboBoxAccountsEnum + org.chorem.lima.enums.ComboBoxEntryBooksEnum + org.chorem.lima.enums.ComboBoxLetterEnum + org.chorem.lima.FinancialStatementWayEnum + org.chorem.lima.enums.ComboBoxOperatorsEnum + org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTableModel + org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTable + </import> + <FinancialTransactionSearchViewHandler id="handler" + javaBean="new FinancialTransactionSearchViewHandler(this)"/> + <Boolean id="selectedRow" javaBean="false"/> + <Dimension id="fieldSize" javaBean="new java.awt.Dimension()"/> + <script> <![CDATA[ - import org.chorem.lima.enums.ComboBoxPeriodEnum; - import org.chorem.lima.enums.ComboBoxAccountsEnum; - import org.chorem.lima.enums.ComboBoxEntryBooksEnum; - import org.chorem.lima.enums.ComboBoxLetterEnum; - import org.chorem.lima.FinancialStatementWayEnum; - import org.chorem.lima.enums.ComboBoxOperatorsEnum; - AccountSearchPanel accountSearchPanel = new AccountSearchPanel(handler); AmountSearchPanel amountSearchPanel = new AmountSearchPanel(handler); EntryBookSearchPanel entryBookSearchPanel = new EntryBookSearchPanel(handler); @@ -50,75 +57,135 @@ } ]]> - </script> - - <row> - <cell fill='both'><Table><row> - <cell anchor="west"><JComboBox id="periodComboBox" javaBean="new JComboBox(ComboBoxPeriodEnum.descriptions())" - onActionPerformed="periodSearchPanel.refresh(ComboBoxPeriodEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><FinancialTransactionPeriodSearchPanel javaBean="periodSearchPanel"/></cell> - </row></Table></cell> - </row> - <row> - <cell fill='both'><Table><row> - <cell><JLabel text="lima.table.voucher"/></cell> - <cell><JTextField id='voucher' minimumSize="{voucher.getPreferredSize()}"/> - <javax.swing.text.Document javaBean="voucher.getDocument()" - onInsertUpdate='handler.setVoucher(voucher.getText())' - onRemoveUpdate='handler.setVoucher(voucher.getText())' /> - </cell> - <cell><JLabel text="lima.table.description"/></cell> - <cell><JTextField id='description' minimumSize='{description.getPreferredSize()}'/> - <javax.swing.text.Document javaBean="description.getDocument()" - onInsertUpdate='handler.setDescription(description.getText())' - onRemoveUpdate='handler.setDescription(description.getText())' /> - </cell> - <cell><JComboBox id="letterComboBox" javaBean="new JComboBox(ComboBoxLetterEnum.descriptions())" - onActionPerformed="letterSearchPanel.refresh(ComboBoxLetterEnum.valueOfDescription((String) letterComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><LetterSearchPanel javaBean="letterSearchPanel"/></cell> - </row></Table></cell> - </row> - <row> - <cell fill='both'><Table><row> - <cell><JComboBox id="accountComboBox" javaBean="new JComboBox(ComboBoxAccountsEnum.descriptions())" - onActionPerformed="accountSearchPanel.refresh(ComboBoxAccountsEnum.valueOfDescription((String) accountComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><AccountSearchPanel javaBean="accountSearchPanel"/></cell> - <cell><JComboBox id="entryBookComboBox" javaBean="new JComboBox(ComboBoxEntryBooksEnum.descriptions())" - onActionPerformed="entryBookSearchPanel.refresh(ComboBoxEntryBooksEnum.valueOfDescription((String) entryBookComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><EntryBookSearchPanel javaBean="entryBookSearchPanel"/></cell> - </row></Table></cell> - </row> - <row> - <cell fill='both'><Table><row> - <cell><JLabel text="lima.common.amount"/></cell> - <cell><JComboBox id="amountComboBox" javaBean="new JComboBox(FinancialStatementWayEnum.descriptions())" - onActionPerformed="handler.setAmountWayEnum(FinancialStatementWayEnum.valueOfDescription((String)amountComboBox.getSelectedItem())); - handler.refresh()"/></cell> - <cell><JComboBox id="operatorComboBox" javaBean="new JComboBox(ComboBoxOperatorsEnum.descriptions())" - onActionPerformed="amountSearchPanel.refresh(ComboBoxOperatorsEnum.valueOfDescription((String) operatorComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><AmountSearchPanel javaBean="amountSearchPanel"/></cell> - </row></Table></cell> - </row> - <row> - <cell><JButton id="validSearch" text='lima.common.search' onActionPerformed="handler.refresh()"/></cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1"> - <JScrollPane> - <org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTableModel - id="financialTransactionSearchTableModel" /> - <org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTable - id="financialTransactionSearchTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" model="{getFinancialTransactionSearchTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> - <javax.swing.ListSelectionModel javaBean="getFinancialTransactionSearchTable().getSelectionModel()" - onValueChanged="setSelectedRow(financialTransactionSearchTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - </row> + </script> + + <row> + <cell fill='both'> + <Table> + <row> + <cell anchor="west"> + <JComboBox id="periodComboBox" + javaBean="new JComboBox(ComboBoxPeriodEnum.descriptions())" + onActionPerformed="periodSearchPanel.refresh(ComboBoxPeriodEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <FinancialTransactionPeriodSearchPanel + javaBean="periodSearchPanel"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both'> + <Table> + <row> + <cell> + <JLabel text="lima.table.voucher"/> + </cell> + <cell> + <JTextField id='voucher' + minimumSize="{voucher.getPreferredSize()}"/> + <Document javaBean="voucher.getDocument()" + onInsertUpdate='handler.setVoucher(voucher.getText())' + onRemoveUpdate='handler.setVoucher(voucher.getText())'/> + </cell> + <cell> + <JLabel text="lima.table.description"/> + </cell> + <cell> + <JTextField id='description' + minimumSize='{description.getPreferredSize()}'/> + <Document javaBean="description.getDocument()" + onInsertUpdate='handler.setDescription(description.getText())' + onRemoveUpdate='handler.setDescription(description.getText())'/> + </cell> + <cell> + <JComboBox id="letterComboBox" + javaBean="new JComboBox(ComboBoxLetterEnum.descriptions())" + onActionPerformed="letterSearchPanel.refresh(ComboBoxLetterEnum.valueOfDescription((String) letterComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <LetterSearchPanel javaBean="letterSearchPanel"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both'> + <Table> + <row> + <cell> + <JComboBox id="accountComboBox" + javaBean="new JComboBox(ComboBoxAccountsEnum.descriptions())" + onActionPerformed="accountSearchPanel.refresh(ComboBoxAccountsEnum.valueOfDescription((String) accountComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <AccountSearchPanel javaBean="accountSearchPanel"/> + </cell> + <cell> + <JComboBox id="entryBookComboBox" + javaBean="new JComboBox(ComboBoxEntryBooksEnum.descriptions())" + onActionPerformed="entryBookSearchPanel.refresh(ComboBoxEntryBooksEnum.valueOfDescription((String) entryBookComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <EntryBookSearchPanel javaBean="entryBookSearchPanel"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell fill='both'> + <Table> + <row> + <cell> + <JLabel text="lima.common.amount"/> + </cell> + <cell> + <JComboBox id="amountComboBox" + javaBean="new JComboBox(FinancialStatementWayEnum.descriptions())" + onActionPerformed="handler.setAmountWayEnum(FinancialStatementWayEnum.valueOfDescription((String)amountComboBox.getSelectedItem())); + handler.refresh()"/> + </cell> + <cell> + <JComboBox id="operatorComboBox" + javaBean="new JComboBox(ComboBoxOperatorsEnum.descriptions())" + onActionPerformed="amountSearchPanel.refresh(ComboBoxOperatorsEnum.valueOfDescription((String) operatorComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <AmountSearchPanel javaBean="amountSearchPanel"/> + </cell> + </row> + </Table> + </cell> + </row> + <row> + <cell> + <JButton id="validSearch" text='lima.common.search' + onActionPerformed="handler.refresh()"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1"> + <JScrollPane> + <FinancialTransactionSearchTableModel + id="financialTransactionSearchTableModel"/> + <FinancialTransactionSearchTable + id="financialTransactionSearchTable" sortable="false" rowHeight="22" + constructorParams="getHandler()" + model="{getFinancialTransactionSearchTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + <ListSelectionModel + javaBean="getFinancialTransactionSearchTable().getSelectionModel()" + onValueChanged="setSelectedRow(financialTransactionSearchTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> </Table> \ No newline at end of file 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import static org.nuiton.i18n.I18n._; - -import java.util.Date; - -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.FinancialStatementWayEnum; @@ -49,146 +42,153 @@ import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; import org.chorem.lima.util.DialogHelper; +import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; +import java.util.Date; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with financial transaction view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialTransactionSearchViewHandler { /** log. */ private static final Log log = - LogFactory.getLog(FinancialTransactionSearchViewHandler.class); + LogFactory.getLog(FinancialTransactionSearchViewHandler.class); protected FinancialTransactionSearchView view; - + protected FinancialTransactionSearchTable table; - + protected FinancialTransactionSearchTableModel tableModel; - + protected FiscalPeriodComboBoxModel comboBoxModel; - + /** Transaction service. */ protected final FinancialTransactionService financialTransactionService; - + /** data cache */ protected FinancialTransactionSearch financialTransactionSearch; - + protected Object clipBoard; protected FinancialTransactionSearchViewHandler(FinancialTransactionSearchView view) { this.view = view; - + /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionSearch = new FinancialTransactionSearchImpl(); - + } - - public void setBeginDate(Date beginDate){ + + public void setBeginDate(Date beginDate) { financialTransactionSearch.setBeginDate(beginDate); } - - public void setEndDate(Date endDate){ + + public void setEndDate(Date endDate) { financialTransactionSearch.setEndDate(endDate); } - - public void setVoucher(String voucher){ + public void setVoucher(String voucher) { + String result = null; - if (!voucher.equals("")){ + if (!voucher.equals("")) { result = voucher; } financialTransactionSearch.setVoucher(result); } - - public void setDescription(String description){ + + public void setDescription(String description) { String result = null; - if (!description.equals("")){ + if (!description.equals("")) { result = description; } financialTransactionSearch.setDescription(result); } - - public void setLetter(Letter letter){ + + public void setLetter(Letter letter) { financialTransactionSearch.setLetter(letter); } - - public String getAccountsList(){ + + public String getAccountsList() { return financialTransactionSearch.getAccountList(); } - - public void setAccountsList(String accountsList){ + + public void setAccountsList(String accountsList) { String result = null; - if (!accountsList.equals("")){ + if (!accountsList.equals("")) { result = accountsList; } financialTransactionSearch.setAccountList(result); } - public Account getAccount(){ + public Account getAccount() { return financialTransactionSearch.getAccount(); } - - public void setAccount(Account account){ + + public void setAccount(Account account) { financialTransactionSearch.setAccount(account); } - - public void setEntryBook(EntryBook entryBook){ + + public void setEntryBook(EntryBook entryBook) { financialTransactionSearch.setEntryBook(entryBook); } - - public String getAmount(){ + + public String getAmount() { return financialTransactionSearch.getAmount(); } - - public void setAmount(String amount){ + + public void setAmount(String amount) { String result = null; - if (!amount.equals("")){ + if (!amount.equals("")) { result = amount; } financialTransactionSearch.setAmount(result); } - - public String getAmount2(){ + + public String getAmount2() { return financialTransactionSearch.getAmount2(); } - - public void setAmount2(String amount2){ + + public void setAmount2(String amount2) { String result = null; - if (!amount2.equals("")){ + if (!amount2.equals("")) { result = amount2; } financialTransactionSearch.setAmount2(result); } - - public void setAmountWayEnum(FinancialStatementWayEnum amountWayEnum){ + + public void setAmountWayEnum(FinancialStatementWayEnum amountWayEnum) { financialTransactionSearch.setAmountWayEnum(amountWayEnum); } - public void setOperator(String operator){ + public void setOperator(String operator) { String result = null; - if (!operator.equals("")){ + if (!operator.equals("")) { result = operator; } financialTransactionSearch.setOperator(result); } - + /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by model. - * @throws LimaException + * + * @throws LimaException */ - public void deleteSelectedRow(){ + public void deleteSelectedRow() { table = view.getFinancialTransactionSearchTable(); tableModel = view.getFinancialTransactionSearchTableModel(); @@ -197,46 +197,44 @@ if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - String message = null; + String message; if (selectedValue instanceof FinancialTransaction) { message = _("lima.charts.financialtransaction.question.removetransaction"); - } - else { + } else { message = _("lima.charts.financialtransaction.question.removeentry"); } int response = JOptionPane.showConfirmDialog(view, message, - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); + _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - + try { tableModel.removeObject(selectedValue, indexSelectedRow); //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); + ListSelectionModel selectionModel = + table.getSelectionModel(); selectionModel.setSelectionInterval( - indexSelectedRow-1, indexSelectedRow-1); + indexSelectedRow - 1, indexSelectedRow - 1); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't remove transaction or entry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call delete selected row without selection"); } } } - - + + //implement new transaction button //add a new entry to the selected transaction - public void addEmptyEntry(){ - + public void addEmptyEntry() { + table = view.getFinancialTransactionSearchTable(); tableModel = view.getFinancialTransactionSearchTableModel(); @@ -248,69 +246,68 @@ String description = (String) tableModel.getValueAt(indexSelectedRow, 4); int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow+1, indexSelectedRow+1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee){ + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); } } } - - + + //copy entry - public void copyRow(){ + public void copyRow() { table = view.getFinancialTransactionSearchTable(); int indexSelectedRow = table.getSelectedRow(); - + if (indexSelectedRow != -1) { clipBoard = tableModel.getElementAt(indexSelectedRow); } } - + //paste entry - public void pasteRow(){ + public void pasteRow() { table = view.getFinancialTransactionSearchTable(); int indexSelectedRow = table.getSelectedRow(); - + if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); if (clipBoard instanceof Entry) { try { int index = tableModel.addEntry(selectedValue, (Entry) clipBoard, indexSelectedRow); //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval( - indexSelectedRow+1, indexSelectedRow+1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee){ + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval( + indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't past entry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } - + } - - + + //add a new transaction public void addFinancialTransaction() { table = view.getFinancialTransactionSearchTable(); @@ -320,9 +317,9 @@ int index = tableModel.addFinancialTransaction(); //select the new line int numberRow = table.getRowCount(); - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(numberRow-1, numberRow-1); + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(numberRow - 1, numberRow - 1); //focus on first column table.changeSelection(index, 0, false, false); table.requestFocusInWindow(); @@ -330,14 +327,14 @@ if (log.isErrorEnabled()) { log.error("Can't add financialtransaction", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } - public void refresh(){ + public void refresh() { tableModel = view.getFinancialTransactionSearchTableModel(); - if (tableModel != null){ + if (tableModel != null) { tableModel.refresh(financialTransactionSearch); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,11 +25,6 @@ package org.chorem.lima.ui.financialtransactionsearch; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import javax.swing.JComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Letter; @@ -38,15 +33,20 @@ import org.chorem.lima.util.LetterToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; -public class LetterSearchComboBox extends JComboBox implements KeyListener, ActionListener { +import javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +public class LetterSearchComboBox extends JComboBox implements KeyListener { + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(LetterSearchComboBox.class); - + LogFactory.getLog(LetterSearchComboBox.class); + protected FinancialTransactionSearchViewHandler handler; - + public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { this.handler = handler; LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); @@ -55,40 +55,39 @@ setRenderer(letterRenderer); setEditable(true); AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); - this.getEditor().getEditorComponent().addKeyListener(this); - this.addActionListener(this); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); } - + @Override public void actionPerformed(ActionEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Letter){ - handler.setLetter((Letter) this.getSelectedItem()); + Object object = getSelectedItem(); + if (object instanceof Letter) { + handler.setLetter((Letter) getSelectedItem()); } } @Override public void keyPressed(KeyEvent e) { - + } @Override public void keyReleased(KeyEvent e) { - Object object = this.getSelectedItem(); - if (object instanceof Letter){ - handler.setLetter((Letter) this.getSelectedItem()); + Object object = getSelectedItem(); + if (object instanceof Letter) { + handler.setLetter((Letter) getSelectedItem()); } // delegate popup list menu - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { firePopupMenuCanceled(); } } @Override public void keyTyped(KeyEvent e) { - + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,36 +25,35 @@ package org.chorem.lima.ui.financialtransactionsearch; -import javax.swing.JPanel; import org.chorem.lima.enums.ComboBoxLetterEnum; +import javax.swing.JPanel; + public class LetterSearchPanel extends JPanel { - + protected FinancialTransactionSearchViewHandler handler; - + public LetterSearchPanel(FinancialTransactionSearchViewHandler handler) { this.handler = handler; } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxLetterEnum comboBoxEnum){ - + public void refresh(ComboBoxLetterEnum comboBoxEnum) { + switch (comboBoxEnum) { - case ALL: - handler.setLetter(null); - handler.refresh(); - this.removeAll(); - break; - - case SELECT_ONE: - LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); - this.removeAll(); - this.add(comboBox); - break; - + case ALL: + handler.setLetter(null); + handler.refresh(); + removeAll(); + break; + + case SELECT_ONE: + LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); + removeAll(); + add(comboBox); + break; + } - + } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.financialtransactionunbalanced; -import java.awt.Color; -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.math.BigDecimal; -import java.util.Date; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; @@ -41,17 +33,25 @@ import org.chorem.lima.ui.celleditor.DateTableCellEditor; import org.chorem.lima.ui.celleditor.EmptyCellRenderer; import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; -import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedViewHandler; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.decorator.Highlighter; +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.math.BigDecimal; +import java.util.Date; + /** * Table des transaction qui ajoute des comportement (keys). - * + * * @author ore * @author Rémi Chapelet */ @@ -67,15 +67,13 @@ private ColorHighlighter colorBalance; - /** - */ public FinancialTransactionUnbalancedTable(FinancialTransactionUnbalancedViewHandler handler) { this.handler = handler; addKeyListener(this); addMouseListener(this); - + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); //Get new entry book editor @@ -92,7 +90,7 @@ 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 @@ -104,24 +102,23 @@ * 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; - } - }; + 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); + 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. @@ -135,7 +132,7 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { boolean isHighlighted = false; Object value = adapter.getValueAt(adapter.row, 8); if (value instanceof BigDecimal) { @@ -149,8 +146,8 @@ return isHighlighted; } }; - colorTransaction = - new ColorHighlighter(predicate, new Color(255, 198, 209), null); + colorTransaction = + new ColorHighlighter(predicate, new Color(255, 198, 209), null); addHighlighter(colorTransaction); } @@ -162,27 +159,27 @@ 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)){ + 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)) { + if (e.getKeyCode() == KeyEvent.VK_INSERT + || e.getKeyCode() == KeyEvent.VK_ENTER + && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.addEmptyEntry(); } - + // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); - } + if (!isEditing()) { + clearSelection(); + } } /** @@ -190,21 +187,21 @@ * Ajoute une entrée comptable si tab est sur * la dernière cellule. */ - + //TODO 2010-08-19 verifier si la transaction est équilibré // cf. FinancialTransactionTable.java comme modèle if (e.getKeyChar() == KeyEvent.VK_TAB) { // Vérifie si la cellule sélectionnée est la dernière - int x = this.getSelectedColumn(); - int y = this.getSelectedRow(); - int max_x = this.getColumnCount() - 1; - int max_y = this.getRowCount() - 1; + int x = getSelectedColumn(); + int y = getSelectedRow(); + int max_x = getColumnCount() - 1; + int max_y = getRowCount() - 1; if (x == max_x && y == max_y) { - handler.addEmptyEntry(); + handler.addEmptyEntry(); // positionne la sélection sur la nouvelle ligne créée - this.setColumnSelectionInterval(0, 0); - this.setRowSelectionInterval(max_y + 1, max_y + 1); + setColumnSelectionInterval(0, 0); + setRowSelectionInterval(max_y + 1, max_y + 1); } } @@ -215,7 +212,7 @@ */ @Override public void keyTyped(KeyEvent e) { - + } @Override @@ -228,8 +225,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -42,13 +42,6 @@ package org.chorem.lima.ui.financialtransactionunbalanced; -import static org.nuiton.i18n.I18n._; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; @@ -66,19 +59,28 @@ import org.chorem.lima.util.DialogHelper; import org.chorem.lima.util.ErrorHelper; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Basic transaction table model. - * + * <p/> * Le modele est filtré sur {@link #selectedFiscalPeriod}(montée en charge !). - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ -public class FinancialTransactionUnbalancedTableModel extends AbstractTableModel implements ServiceListener{ +public class FinancialTransactionUnbalancedTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 3914954536809622358L; @@ -89,61 +91,60 @@ /** Transaction service. */ protected final FinancialTransactionServiceMonitorable financialTransactionService; - + /** selected financial period */ protected FiscalPeriod selectedFiscalPeriod; - + /** data cache */ protected List<Object> cacheDataList; - - /** collection - /** + * collection + * <p/> + * <p/> + * /** * Model constructor. - * + * <p/> * Just init service proxies. */ public FinancialTransactionUnbalancedTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + financialTransactionService.addServiceListener(this); } /** * Le model est une combinaison de Transaction/Entries. - * - * + * * @return */ protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); - if(selectedFiscalPeriod != null){ + if (selectedFiscalPeriod != null) { try { List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); + financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); for (FinancialTransaction financialtransaction : financialtransactions) { results.add(financialtransaction); List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); Collections.sort(entries, new EntryComparator()); results.addAll(entries); } - } - catch (LimaException eee) { + } 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 transaction list", eee); - } + } } - + return results; } - - public void refresh(){ + + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } @@ -159,33 +160,33 @@ Class<?> result = null; switch (column) { - case 0: - result = Date.class; - break; - case 1: - result = EntryBook.class; - break; - case 2: - result = String.class; - break; - case 3: - result = Account.class; - break; - case 4: - result = String.class; - break; - case 5: - result = BigDecimal.class; - break; - case 6: - result = BigDecimal.class; - break; - case 7: - result = BigDecimal.class; - break; - case 8: - result = Letter.class; - break; + case 0: + result = Date.class; + break; + case 1: + result = EntryBook.class; + break; + case 2: + result = String.class; + break; + case 3: + result = Account.class; + break; + case 4: + result = String.class; + break; + case 5: + result = BigDecimal.class; + break; + case 6: + result = BigDecimal.class; + break; + case 7: + result = BigDecimal.class; + break; + case 8: + result = Letter.class; + break; } return result; @@ -196,33 +197,33 @@ String result = "n/a"; switch (column) { - case 0: - result = _("lima.table.date"); - break; - case 1: - result = _("lima.table.entrybook"); - break; - case 2: - result = _("lima.table.voucher"); - break; - case 3: - result = _("lima.table.account"); - break; - case 4: - result = _("lima.table.description"); - break; - case 5: - result = _("lima.table.debit"); - break; - case 6: - result = _("lima.table.credit"); - break; - case 7: - result = _("lima.table.balance"); - break; - case 8: - result = _("lima.table.letter"); - break; + case 0: + result = _("lima.table.date"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.voucher"); + break; + case 3: + result = _("lima.table.account"); + break; + case 4: + result = _("lima.table.description"); + break; + case 5: + result = _("lima.table.debit"); + break; + case 6: + result = _("lima.table.credit"); + break; + case 7: + result = _("lima.table.balance"); + break; + case 8: + result = _("lima.table.letter"); + break; } return result; @@ -231,7 +232,7 @@ @Override public int getRowCount() { int result = 0; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.size(); @@ -243,126 +244,120 @@ @Override public Object getValueAt(int row, int column) { Object result = null; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.get(row); - + if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction) result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { - case 0: - result = currentRow.getTransactionDate(); - break; - case 1: - if (currentRow.getEntryBook() != null){ - result = currentRow.getEntryBook().getCode(); - } - else { + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null) { + result = currentRow.getEntryBook().getCode(); + } else { + result = null; + } + break; + case 2: + result = null; //entrybook + break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5: + result = amountDebit; + break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit.subtract(amountCredit); + break; + case 8: result = null; - } - break; - case 2: - result = null; //entrybook - break; - case 3: - result = null; // account - break; - case 4: - result = null; // description - break; - case 5 : - result = amountDebit; - break; - case 6: - result = amountCredit; - break; - case 7: - result = amountDebit.subtract(amountCredit); - break; - case 8: - result = null; - break; + break; } - } - else if (result instanceof Entry) { - Entry currentEntry = (Entry)result; + } else if (result instanceof Entry) { + Entry currentEntry = (Entry) result; switch (column) { - case 0: - result = null; // date - break; - case 1 : // entry book - result = null; - break; - case 2: - result = currentEntry.getVoucher(); - break; - case 3: // account - if (currentEntry.getAccount() != null){ - result = currentEntry.getAccount().getAccountNumber(); - } - else { + case 0: + result = null; // date + break; + case 1: // entry book result = null; - } - break; - case 4: - result = currentEntry.getDescription(); - break; - case 5 : - result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; - break; - case 6: - result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); - break; - case 7: - result = null; - break; - case 8: - if (currentEntry.getLetter() != null){ - result = currentEntry.getLetter().getCode(); - } - else { + break; + case 2: + result = currentEntry.getVoucher(); + break; + case 3: // account + if (currentEntry.getAccount() != null) { + result = currentEntry.getAccount().getAccountNumber(); + } else { + result = null; + } + break; + case 4: + result = currentEntry.getDescription(); + break; + case 5: + result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO; + break; + case 6: + result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount(); + break; + case 7: result = null; - } - break; + break; + case 8: + if (currentEntry.getLetter() != null) { + result = currentEntry.getLetter().getCode(); + } else { + result = null; + } + break; } - + } } - + return result; } - - public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { selectedFiscalPeriod = fiscalPeriod; } - + /** * To set cells editable or not * different condition for entry or financial transaction */ @Override public boolean isCellEditable(int rowIndex, int columnIndex) { - boolean editableCell=false; + boolean editableCell = false; Object currentRow = cacheDataList.get(rowIndex); // cells editable for the entry row, all cells exclude the date - if ((currentRow instanceof Entry) && !((columnIndex==0) || (columnIndex==1))) { - editableCell=true; + if (currentRow instanceof Entry && !(columnIndex == 0 || columnIndex == 1)) { + editableCell = true; } // cells editable for the financialtransaction row, no cells exclude the date - if ((currentRow instanceof FinancialTransaction) && ((columnIndex==0) || (columnIndex==1))){ - editableCell=true; + if (currentRow instanceof FinancialTransaction && (columnIndex == 0 || columnIndex == 1)) { + editableCell = true; } return editableCell; } - - + /** - * * @param value * @param description * @param row @@ -379,10 +374,9 @@ } //check if current row is a transaction or an entry if (currentRow instanceof FinancialTransaction) { - currentTransaction = (FinancialTransaction)currentRow; - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + currentTransaction = (FinancialTransaction) currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; //get back the parent transaction of the entry currentTransaction = currentEntry.getFinancialTransaction(); } @@ -394,118 +388,116 @@ fireTableRowsInserted(row, row); return newrow; } - - /** - * to modifiy financialtransaction or entry - */ + + /** to modifiy financialtransaction or entry */ @Override public void setValueAt(Object value, int row, int column) { - int financialTransactionRow=0; + int financialTransactionRow = 0; // just prevent too much result if (selectedFiscalPeriod != null) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentFinancialTransaction = - (FinancialTransaction)currentRow; + (FinancialTransaction) currentRow; switch (column) { - case 0: - //update - currentFinancialTransaction.setTransactionDate((Date)value); - break; - case 1 : - currentFinancialTransaction.setEntryBook((EntryBook)value); - break; + case 0: + //update + currentFinancialTransaction.setTransactionDate((Date) value); + break; + case 1: + currentFinancialTransaction.setEntryBook((EntryBook) value); + break; } // notify service for modification try { financialTransactionService. - updateFinancialTransaction(currentFinancialTransaction); + updateFinancialTransaction(currentFinancialTransaction); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't update financial transaction", eee); } DialogHelper.showMessageDialog(eee.getMessage()); } - //update the financial transaction in entire - financialTransactionRow = - cacheDataList.indexOf(((FinancialTransaction) currentRow)); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(currentRow); + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; switch (column) { - case 2 : - currentEntry.setVoucher((String)value); - break; - case 3: - currentEntry.setAccount((Account)value); - break; - case 4: - currentEntry.setDescription((String)value); - break; - case 5 : - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(true); - break; - case 6: - currentEntry.setAmount((BigDecimal) value); - currentEntry.setDebit(false); - break; - case 8: - currentEntry.setLetter((Letter)value); - break; + case 2: + currentEntry.setVoucher((String) value); + break; + case 3: + currentEntry.setAccount((Account) value); + break; + case 4: + currentEntry.setDescription((String) value); + break; + case 5: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(true); + break; + case 6: + currentEntry.setAmount((BigDecimal) value); + currentEntry.setDebit(false); + break; + case 8: + currentEntry.setLetter((Letter) value); + break; } try { financialTransactionService.updateEntry(currentEntry); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't update entry", eee); } 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(); fireTableDataChanged(); } } - - public Object getElementAt(int row){ - + + public Object getElementAt(int row) { + Object currentRow = cacheDataList.get(row); return currentRow; } - + /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by model. - * @param Object, int - * @throws LimaException + * + * @param object + * @param row + * @throws LimaException */ public void removeObject(Object object, int row) throws LimaException { Object currentRow = cacheDataList.get(row); if (currentRow instanceof FinancialTransaction) { FinancialTransaction currentTransaction = - (FinancialTransaction)currentRow; + (FinancialTransaction) currentRow; financialTransactionService.removeFinancialTransaction(currentTransaction); - } - else if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + } else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry) currentRow; financialTransactionService.removeEntry(currentEntry); } //on recharge la liste refresh(); } - + @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/FinancialTransactionUnbalancedViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,12 +25,6 @@ package org.chorem.lima.ui.financialtransactionunbalanced; -import static org.nuiton.i18n.I18n._; - - -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; @@ -38,37 +32,42 @@ import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; import org.chorem.lima.util.DialogHelper; +import javax.swing.JOptionPane; +import javax.swing.ListSelectionModel; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with financial transaction view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialTransactionUnbalancedViewHandler { /** log. */ private static final Log log = - LogFactory.getLog(FinancialTransactionUnbalancedViewHandler.class); + LogFactory.getLog(FinancialTransactionUnbalancedViewHandler.class); protected FinancialTransactionUnbalancedView view; - + protected FinancialTransactionUnbalancedTable table; - + protected FinancialTransactionUnbalancedTableModel tableModel; - + protected FiscalPeriodComboBoxModel comboBoxModel; protected FinancialTransactionUnbalancedViewHandler(FinancialTransactionUnbalancedView view) { this.view = view; - } - + } + //implement new transaction button //add a new entry to the selected transaction - public void addEmptyEntry(){ - + public void addEmptyEntry() { + table = view.getFinancialTransactionUnbalancedTable(); tableModel = view.getFinancialTransactionUnbalancedTableModel(); @@ -76,38 +75,38 @@ if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); try { - //copy + paste the description + //copy + paste the description String description = (String) tableModel.getValueAt(indexSelectedRow, 4); int index = tableModel.addEmptyEntry(selectedValue, description, indexSelectedRow); //select the new line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow+1, indexSelectedRow+1); - //focus on second column - table.changeSelection(index, 1, false, false); - table.requestFocusInWindow(); - } catch (LimaException eee){ + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow + 1, indexSelectedRow + 1); + //focus on second column + table.changeSelection(index, 1, false, false); + table.requestFocusInWindow(); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add emptyentry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call addentry selected transaction without selection"); } } } - + /** * Delete selected row in table (could be transaction or entry). - * + * <p/> * Called by tableModel. - * @throws LimaException + * + * @throws LimaException */ - public void deleteSelectedRow(){ + public void deleteSelectedRow() { table = view.getFinancialTransactionUnbalancedTable(); tableModel = view.getFinancialTransactionUnbalancedTableModel(); @@ -116,44 +115,42 @@ if (indexSelectedRow != -1) { Object selectedValue = tableModel.getElementAt(indexSelectedRow); - String message = null; + String message; if (selectedValue instanceof FinancialTransaction) { message = _("lima.charts.financialtransaction.question.removetransaction"); - } - else { + } else { message = _("lima.charts.financialtransaction.question.removeentry"); } int response = JOptionPane.showConfirmDialog(view, message, - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); + _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { - + try { tableModel.removeObject(selectedValue, indexSelectedRow); //select the upper line - ListSelectionModel selectionModel = - table.getSelectionModel(); - selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1); + ListSelectionModel selectionModel = + table.getSelectionModel(); + selectionModel.setSelectionInterval(indexSelectedRow - 1, indexSelectedRow - 1); } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't remove transaction or entry", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Call delete selected row without selection"); } } } - - public void refresh(){ + + public void refresh() { tableModel = view.getFinancialTransactionUnbalancedTableModel(); tableModel.refresh(); - + comboBoxModel = view.getModelFiscalPeriod(); comboBoxModel.refresh(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -70,7 +70,7 @@ ComponentAdapter adapter) { FiscalPeriod fiscalPeriod = (FiscalPeriod) model.getElementAt(adapter.row); // true if locked - return (fiscalPeriod.getLocked()); + return fiscalPeriod.getLocked(); } }; colorTransaction = @@ -84,8 +84,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -113,8 +113,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -76,13 +76,13 @@ fiscalPeriodService = LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); + fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); financialTransactionService = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService.addServiceListener(this); cacheDataList = null; } @@ -199,7 +199,7 @@ } public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException { - FiscalPeriod fiscalPeriod = null; + FiscalPeriod fiscalPeriod; fiscalPeriod = (FiscalPeriod) cacheDataList.get(row); return fiscalPeriod; } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.fiscalperiod; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - - -import javax.swing.JOptionPane; -import org.jdesktop.swingx.JXTable; -import org.nuiton.util.DateUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; @@ -46,10 +36,17 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.fiscalperiod.AddPeriod; -import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; import org.chorem.lima.util.DialogHelper; +import org.jdesktop.swingx.JXTable; +import org.nuiton.util.DateUtil; +import javax.swing.JOptionPane; +import java.math.BigDecimal; +import java.util.Collection; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * TODO add comment here. * @@ -118,7 +115,7 @@ if (log.isErrorEnabled()) { log.error("Can't add fiscal period", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } } @@ -165,19 +162,21 @@ if (log.isErrorEnabled()) { log.error("Can't block fiscalperiod", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } /** * * Sets EntryBook and Date to use + * @param selectedFiscalPeriod + * @param newyear */ public void addRetainedEarnings(FiscalPeriod selectedFiscalPeriod, boolean newyear) { - JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); - int selectedRow = fiscalPeriodeTable.getSelectedRow(); - FiscalPeriodTableModel model = - (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); +// JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); +// int selectedRow = fiscalPeriodeTable.getSelectedRow(); +// FiscalPeriodTableModel model = +// (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); try { boolean found = false; List<FinancialTransaction> financialTransactionsList = @@ -227,7 +226,7 @@ if (log.isErrorEnabled()) { log.error("Can't set net income", eee); } - DialogHelper.showMessageDialog(eee.getMessage()); + DialogHelper.showErrorMessageDialog(view, eee); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -64,9 +64,9 @@ accountService = LimaServiceFactory.getInstance().getService( AccountServiceMonitorable.class); - accountService.addListener(this); + accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); //init setOpaque(true); 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -62,9 +62,9 @@ entryBookService = LimaServiceFactory.getInstance().getService( EntryBookServiceMonitorable.class); - entryBookService.addListener(this); + entryBookService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); //init setOpaque(true); @@ -99,7 +99,7 @@ int ebSize = entryBooks.size(); if (ebSize>0){ setBackground(greenBackground); - String entryBooksString=""; + String entryBooksString; if (ebSize == 1){ entryBooksString = _("lima.home.entrybooks.state.single") + "<br/>" + entryBooks.get(0).getLabel() 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -64,12 +64,12 @@ financialTransactionService = LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService.addServiceListener(this); fiscalPeriodService = LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); + fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); //init setOpaque(true); 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -61,9 +61,9 @@ fiscalPeriodService = LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); - fiscalPeriodService.addListener(this); + fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); //init setOpaque(true); 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,8 +25,26 @@ package org.chorem.lima.ui.importexport; -import static org.nuiton.i18n.I18n._; +import org.apache.commons.io.IOUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.ExportServiceMonitorable; +import org.chorem.lima.business.ImportServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.utils.ImportExportEntityEnum; +import org.chorem.lima.enums.EncodingEnum; +import org.chorem.lima.enums.ImportExportEnum; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.account.AccountViewHandler; +import org.chorem.lima.util.DialogHelper; +import org.jdesktop.swingx.painter.BusyPainter; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; @@ -43,27 +61,8 @@ import java.io.StringWriter; import java.util.concurrent.ExecutionException; -import javax.swing.JComboBox; -import javax.swing.JFileChooser; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.SwingWorker; +import static org.nuiton.i18n.I18n._; -import org.apache.commons.io.IOUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.ExportServiceMonitorable; -import org.chorem.lima.business.ImportServiceMonitorable; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.utils.ImportExportEntityEnum; -import org.chorem.lima.enums.EncodingEnum; -import org.chorem.lima.enums.ImportExportEnum; -import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.account.AccountViewHandler; -import org.chorem.lima.util.DialogHelper; -import org.jdesktop.swingx.painter.BusyPainter; - public class ImportExport { private static ImportExport exchanger; @@ -119,7 +118,7 @@ final Boolean importMode = importExportMethode.getImportMode(); new SwingWorker<String,Void>() { @Override protected String doInBackground() throws LimaException { - String datas = ""; + String datas; String result = ""; switch (importExportMethodeF) { case CSV_ALL_EXPORT: @@ -177,7 +176,7 @@ _("lima.importexport.usevatpdf"), _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); datas = extractFile(filePath, charset.getEncoding()); - result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, (response == JOptionPane.YES_OPTION)); + result = importService.importAsPDF(filePath, ImportExportEntityEnum.VATPDF, response == JOptionPane.YES_OPTION); break; case EBP_ACCOUNTCHARTS_IMPORT: //For windows ebp @@ -309,7 +308,7 @@ StringWriter sw = new StringWriter(); BufferedReader in = null; try { - InputStream is = null; + InputStream is; // FIXME echatellier 20101129 remove this hack and modify resources reading mecanism if (filePath != null && filePath.indexOf(".jar!") > 0) { 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -100,12 +100,12 @@ handler.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -127,8 +127,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -149,8 +149,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -86,7 +86,7 @@ @Override public boolean isHighlighted(Component renderer, ComponentAdapter adapter) { - return (adapter.getValueAt(adapter.row, 0) != null); + return adapter.getValueAt(adapter.row, 0) != null; } }; colorReportsDatas = @@ -100,8 +100,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -129,8 +129,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -38,7 +38,6 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.Letter; /** * Entry book table model. 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -103,7 +103,7 @@ reportService = LimaServiceFactory.getInstance().getService( ReportServiceMonitorable.class); - reportService.addListener(this); + reportService.addServiceListener(this); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); documentService = @@ -113,9 +113,9 @@ LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class).addListener(this); + FinancialTransactionServiceMonitorable.class).addServiceListener(this); } public void setBeginDate(Date date){ @@ -144,7 +144,7 @@ if (balanceTrialCache.getReportsDatas() != null){ for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { results.add(reportsDatas); - List<Entry> entries = (List<Entry>) reportsDatas.getListEntry(); + List<Entry> entries = reportsDatas.getListEntry(); if (entries != null){ Collections.sort(entries, new EntryComparator()); results.addAll(entries); 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -1,27 +1,27 @@ -/* - * #%L - * Lima :: Swing - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2008 - 2011 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% - */ +/* + * #%L + * Lima :: Swing + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2008 - 2011 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.lettering; import java.awt.event.ActionEvent; @@ -100,12 +100,12 @@ handler.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -127,8 +127,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -149,8 +149,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -172,8 +172,8 @@ // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } @@ -195,8 +195,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -99,9 +99,9 @@ financialTransactionService = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService.addServiceListener(this); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); } public void setSelectedBeginDate(Date date) { @@ -379,7 +379,7 @@ boolean editableCell=false; Object currentRow = cacheDataList.get(rowIndex); // cells editable for the entry row, all cells exclude the date - if ((currentRow instanceof Entry) && ((columnIndex==5))) { + if (currentRow instanceof Entry && columnIndex==5) { editableCell=true; } return editableCell; } Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -0,0 +1,31 @@ +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); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/renderers/RendererUtil.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -105,8 +105,8 @@ @Override public void mousePressed(MouseEvent e) { - if (this.rowAtPoint(e.getPoint()) == -1) { - this.clearSelection(); + if (rowAtPoint(e.getPoint()) == -1) { + clearSelection(); } } @@ -134,8 +134,8 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!this.isEditing()) { - this.clearSelection(); + if (!isEditing()) { + clearSelection(); } } } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -170,7 +170,7 @@ @Override public boolean isCellEditable(Object node, int column) { - return ((column == 1) && (isLeaf(node))); + return column == 1 && isLeaf(node); } @Override 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -62,7 +62,7 @@ LimaServiceFactory.getInstance().getService( VatStatementServiceMonitorable.class); LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class).addListener(this); + ImportServiceMonitorable.class).addServiceListener(this); } public void addVatStatementMovement(){ @@ -72,7 +72,7 @@ int selectedRow = view.getTreeTable().getSelectedRow(); // get current selection path - TreePath treePath = null; + TreePath treePath; if (selectedRow == -1) { treePath = null; } else { 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -103,12 +103,12 @@ handler.tableModel.setEndDate(endDatePicker.getDate()); endDatePicker.addActionListener(endDateActionListener); handler.refresh(); - - this.removeAll(); - this.add(beginDateLabel); - this.add(beginDatePicker); - this.add(endDateLabel); - this.add(endDatePicker); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); break; case FISCAL_PERIOD: @@ -130,8 +130,8 @@ }; fiscalPeriod.addActionListener(fiscalPeriodActionListener); - this.removeAll(); - this.add(fiscalPeriod); + removeAll(); + add(fiscalPeriod); break; case FINANCIAL_PERIOD: @@ -152,8 +152,8 @@ } }; financialPeriod.addActionListener(financialPeriodActionListener); - this.removeAll(); - this.add(financialPeriod); + removeAll(); + add(financialPeriod); break; } 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -84,15 +84,15 @@ vatStatementService = LimaServiceFactory.getInstance().getService( VatStatementServiceMonitorable.class); - vatStatementService.addListener(this); + vatStatementService.addServiceListener(this); financialTransactionService = LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class); - financialTransactionService.addListener(this); + financialTransactionService.addServiceListener(this); importService = LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class); - importService.addListener(this); + importService.addServiceListener(this); //sets autocomplete mode to true on start autocomplete = "true"; @@ -102,7 +102,7 @@ List<VatStatementAmounts> list = null; - if ((selectedBeginDate != null ) || (selectedEndDate != null)) { + if (selectedBeginDate != null || selectedEndDate != null) { try { list = vatStatementService.vatStatementReport( getBeginDate(), @@ -195,7 +195,7 @@ result = value.getLabel(); break; case 1: - if ((value.getAmount() != null) && (!value.isHeader())) { + if (value.getAmount() != null && !value.isHeader()) { result = value.getAmount(); } else { result = null; 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -78,7 +78,7 @@ * Edit VAT document */ public void editVat() { - if ((tableModel.getBeginDate() != null) || (tableModel.getEndDate() != null)){ + if (tableModel.getBeginDate() != null || tableModel.getEndDate() != null){ String address = LimaConfig.getInstance().getHostAdress(); try { 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-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -25,43 +25,47 @@ package org.chorem.lima.util; -import static org.nuiton.i18n.I18n._; -import java.awt.Component; +import org.nuiton.util.Resource; + import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JTextArea; -import org.nuiton.util.Resource; +import java.awt.Component; +import static org.nuiton.i18n.I18n._; + /** * @author ore - * @author Rémi Chapelet + * @author Rémi Chapelet */ public class DialogHelper { public static int showConfirmDialog(String message) { String[] response = {_("lima.response.yes"), _("lima.response.no")}; return JOptionPane.showOptionDialog(null, - message, - _("lima.common.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, //do not use a custom Icon - response, //the titles of buttons - response[0]); //default button title + message, + _("lima.common.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, //do not use a custom Icon + response, //the titles of buttons + response[0]); //default button title } - /** @deprecated */ - /* + /** * Use instead: JOptionPane.showMessageDialog (String message,String titre,int type) - * + * <p/> * for e.g: - * JOptionPane.showMessageDialog( - view, - _("lima.importexport.export.terminated"), - _("lima.importexport.export"), - JOptionPane.INFORMATION_MESSAGE); - * + * JOptionPane.showMessageDialog( + * view, + * _("lima.importexport.export.terminated"), + * _("lima.importexport.export"), + * JOptionPane.INFORMATION_MESSAGE); + * + * @param message + * @deprecated since 0.5, prefer use the method {@link #showErrorMessageDialog(Component, Exception)} */ + @Deprecated public static void showMessageDialog(String message) { JFrame f = new JFrame(); f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); @@ -73,13 +77,22 @@ f.dispose(); } + public static void showErrorMessageDialog(Component view, Exception e) { + JOptionPane.showMessageDialog( + view, + e.getMessage(), + _("lima.common.error"), + JOptionPane.ERROR_MESSAGE); + } + /** * Permet d'afficher une boite de dialogue. + * * @param message * @param titre * @param type */ - public static void showMessageDialog (String message,String titre,int type) { + public static void showMessageDialog(String message, String titre, int type) { JFrame f = new JFrame(); f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); JOptionPane.showMessageDialog( @@ -89,23 +102,24 @@ type); f.dispose(); } - + /** * Permet d'afficher une boite de dialogue avec rapport + * * @param message - * @param titre - * @param type + * @param parent + * @param title */ - public static void showReportDialog (String message, String title, Component parent) { + public static void showReportDialog(String message, String title, Component parent) { ReportDialogView reportDialogView = new ReportDialogView(); reportDialogView.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JTextArea textArea = reportDialogView.getTextArea(); + JTextArea textArea = reportDialogView.getTextArea(); textArea.setText(message); - reportDialogView.setSize(600,400); + reportDialogView.setSize(600, 400); reportDialogView.setTitle(title); reportDialogView.setLocationRelativeTo(parent); reportDialogView.setVisible(true); } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2011-09-17 12:59:34 UTC (rev 3291) @@ -72,14 +72,13 @@ /** serialVersionUID. */ private static final long serialVersionUID = -6715271536163434385L; - private boolean layingOut = false; + private boolean layingOut; public JWideComboBox() { - super(); setUI(new ScrollMetalComboUI()); } - public JWideComboBox(final Object items[]) { + public JWideComboBox(Object items[]) { super(items); } Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2011-09-17 12:55:34 UTC (rev 3290) +++ trunk/pom.xml 2011-09-17 12:59:34 UTC (rev 3291) @@ -310,10 +310,10 @@ <projectId>lima</projectId> <!-- customized libs version --> - <nuitonUtilsVersion>2.2</nuitonUtilsVersion> + <nuitonUtilsVersion>2.3</nuitonUtilsVersion> <eugenePluginVersion>2.3.5</eugenePluginVersion> - <topiaVersion>2.5.4</topiaVersion> - <jaxxVersion>2.4.2</jaxxVersion> + <topiaVersion>2.6.2-SNAPSHOT</topiaVersion> + <jaxxVersion>2.5-SNAPSHOT</jaxxVersion> <nuitonI18nVersion>2.4.1</nuitonI18nVersion> <openEjbVersion>3.1.4</openEjbVersion> <slf4jVersion>1.6.1</slf4jVersion> @@ -321,6 +321,8 @@ <!-- 1.4 and 1.4.1 breaks jnlp with corrupt jar <axis.version>1.3</axis.version>--> + <jnlpPluginVersion>1.0-beta-2</jnlpPluginVersion> + <!-- license to use --> <license.licenseName>gpl_v3</license.licenseName> </properties> @@ -362,6 +364,18 @@ </dependencies> </plugin> + <plugin> + <groupId>org.codehaus.mojo.webstart</groupId> + <artifactId>webstart-maven-plugin</artifactId> + <version>${jnlpPluginVersion}</version> + </plugin> + + <plugin> + <groupId>org.bluestemsoftware.open.maven.plugin</groupId> + <artifactId>launch4j-plugin</artifactId> + <version>1.5.0.0</version> + </plugin> + </plugins> </pluginManagement>
participants (1)
-
tchemit@users.chorem.org