Author: tchemit Date: 2011-09-17 16:17:04 +0200 (Sat, 17 Sep 2011) New Revision: 3293 Url: http://chorem.org/repositories/revision/lima/3293 Log: do not use renderer, prefer usage of the RendererUtil instead + reformat code Added: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollBasicComboPopup.java trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollMetalComboUI.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.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/ui/LimaDecoratorProvider.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/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/AccountsReportsTableModel.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/BalanceTableModel.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/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/entrybook/EntryBookViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.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/financialperiod/FinancialPeriodViewHandler.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/FinancialStatementChartTreeTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementImportForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.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/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 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/identity/IdentityForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx 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/LedgerView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/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/lettering/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.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/VatReportTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaConfig.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -57,31 +57,27 @@ * * @author chemit * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class LimaConfig extends ApplicationConfig { - /** - * 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(LimaConfig.class); - + protected static LimaConfig instance; - + private static final String configFile = "lima-config.properties"; - + protected OptionsServiceMonitorable optionsService; - - /** - * La version du logiciel. - */ + + /** La version du logiciel. */ protected Version version; /** * Get copyrighy text (include version). - * + * * @return copyright text */ public String getCopyrightText() { @@ -90,7 +86,7 @@ /** * Version as string. - * + * * @return le nombre global ex: 3.2.0.0 */ public String getVersion() { @@ -99,7 +95,7 @@ /** * Lima config constructor. - * + * <p/> * Define all default options and action alias. */ public LimaConfig() { @@ -123,7 +119,7 @@ // TODO what is it for ? //FileUtil.setCurrentDirectory(getLimaUserDirectory()); //getLimaUserDirectory().mkdirs(); - + } public static LimaConfig getInstance() { @@ -133,9 +129,9 @@ } return instance; } - - protected void loadConfiguration(String configFileName){ + protected void loadConfiguration(String configFileName) { + instance.setConfigFileName(configFileName); try { instance.parse(new String[0]); @@ -146,26 +142,26 @@ } instance.setOption(TopiaContextFactory.CONFIG_PERSISTENCE_CLASSES, LimaCallaoDAOHelper.getImplementationClassesAsString()); -} - + } + @Override public ApplicationConfig parse(String... args) throws ArgumentsParserException { - + // super parse, read config file etc... super.parse(args); - + // on ne peut pas connaitre la version avant la lecture du fichier // on supprime tout ce qui est apres - (-SNAPSHOT, -rc-1 ,...) String sVersion = VersionUtil.removeSnapshot(getOption("application.version")); version = VersionUtil.valueOf(sVersion); - + return this; - + } /** * Get application locale. - * + * * @return configuration application locale */ public Locale getLocale() { @@ -176,7 +172,7 @@ /** * Locale setter for command line parameters. - * + * * @param locale new locale */ public void setLocale(String locale) { @@ -186,7 +182,7 @@ /** * Change locale (not command line version). * Save user file. - * + * * @param newLocale new locale */ public void setLocale(Locale newLocale) { @@ -197,18 +193,18 @@ /** * Get application decimal separator - * + * * @return configuration application decimal separator */ public char getDecimalSeparator() { char decimalSeparator = getOption(Option.DECIMAL_SEPARATOR.key).charAt(0); return decimalSeparator; } - + /** * Change decimal separator * Save user file. - * + * * @param decimalSeparator new DecimalSeparator */ public void setDecimalSeparator(String decimalSeparator) { @@ -219,17 +215,17 @@ /** * Get application scale - * + * * @return configuration application scale */ public int getScale() { return getOptionAsInt(Option.SCALE.key); } - + /** * Change scale * Save user file. - * + * * @param scale new Scale */ public void setScale(String scale) { @@ -241,20 +237,20 @@ } optionsService.setScale(scale); } - + /** * Get application thousand separator - * + * * @return configuration application thousand separator */ public char getThousandSeparator() { return getOption(Option.THOUSAND_SEPARATOR.key).charAt(0); } - + /** * Change the thousand separator * Save user file. - * + * * @param thousandSeparator new thousandSeparator */ public void setThousandSeparator(String thousandSeparator) { @@ -262,19 +258,19 @@ saveForUser(); firePropertyChange("thousandSeparator", null, thousandSeparator); } - + /** * currency configuration boolean - * + * * @return {@code true} if the currency must be displayed */ public boolean getCurrency() { - return getOptionAsBoolean(Option.CURRENCY.key); + return getOptionAsBoolean(Option.CURRENCY.key); } - + /** * Change the currency displaying - * + * * @param currency */ public void setCurrency(String currency) { @@ -285,7 +281,7 @@ /** * Launch ui configuration value. - * + * * @return {@code true} if ui must be displayed */ public boolean isLaunchui() { @@ -295,7 +291,7 @@ /** * Launch ui setter for command line parameters. - * + * * @param launchui new lauch ui value */ public void setLaunchui(String launchui) { @@ -305,7 +301,7 @@ /** * Change full screen mode. * Save user file. - * + * * @param fullscreen new fullscreen mode */ public void setFullscreen(boolean fullscreen) { @@ -322,7 +318,7 @@ /** * Get support email address. - * + * * @return support email */ public String getSupportEmail() { @@ -331,7 +327,7 @@ /** * Return true if ejb mode is configured as remote. - * + * * @return {@code true} if remote mode should be used */ public boolean isEJBRemoteMode() { @@ -348,24 +344,20 @@ File result = getOptionAsFile(Option.RESOURCES_DIRECTORY.key); return result; } - - public File getI18nDirectory() { + + public File getI18nDirectory() { File result = getOptionAsFile(Option.I18N_DIRECTORY.key); return result; } - + public String getHostAdress() { return getOption(Option.LIMA_HOST_ADDRESS.key); - } + } - /** - * Used in ???? - */ - public static final String[] DEFAULT_JAXX_PCS = { "fullScreen", "locale", "decimalSeparator", "scale", "thousandSeparator", "currency" }; + /** Used in ???? */ + public static final String[] DEFAULT_JAXX_PCS = {"fullScreen", "locale", "decimalSeparator", "scale", "thousandSeparator", "currency"}; - /** - * Used in ???? - */ + /** Used in ???? */ public void removeJaxxPropertyChangeListener() { PropertyChangeListener[] toRemove = JAXXUtil.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners()); if (toRemove == null || toRemove.length == 0) { @@ -386,7 +378,7 @@ /** * Lima option definition. - * + * <p/> * Contains all lima configuration key, with defaut value and * information for jaxx configuration frame ({@link #type}, * {@link #_transient}, {@link #_final}...) @@ -407,16 +399,21 @@ SUPPORT_EMAIL("lima.misc.supportemail", _("lima.misc.supportemail.description"), "support@codelutin.com", String.class, false, false), OPENEJB_REMOTEMODE("lima.openejb.remotemode", _("lima.openejb.remotemode.description"), "false", String.class, false, false), LIMA_HOST_ADDRESS("lima.host.address", _("lima.config.host.adress"), "localhost", String.class, false, false); - + public final String key; + public final String description; + public String defaultValue; + public final Class<?> type; + public boolean _transient; + public boolean _final; Option(String key, String description, String defaultValue, - Class<?> type, boolean _transient, boolean _final) { + Class<?> type, boolean _transient, boolean _final) { this.key = key; this.description = description; this.defaultValue = defaultValue; @@ -429,20 +426,20 @@ public boolean isFinal() { return _final; } - + @Override - public void setFinal(boolean _final){ - this._final=_final; + public void setFinal(boolean _final) { + this._final = _final; } - + @Override public boolean isTransient() { return _transient; } - + @Override public void setTransient(boolean _transient) { - this._transient=_transient; + this._transient = _transient; } @Override @@ -452,9 +449,9 @@ @Override public void setDefaultValue(String defaultValue) { - this.defaultValue=defaultValue; + this.defaultValue = defaultValue; } - + @Override public String getDescription() { return description; @@ -471,20 +468,21 @@ } } - /** - * Lima action definition. - */ + /** Lima action definition. */ public enum Action { HELP(_("lima.action.commandline.help"), MiscAction.class.getName() + "#help", "-h", "--help"); /** Before init action step. */ public static final int BEFORE_EXIT_STEP = 0; + /** After init action step. */ public static final int AFTER_INIT_STEP = 1; public String description; + public String action; + public String[] aliases; Action(String description, String action, String... aliases) { @@ -493,7 +491,7 @@ this.aliases = aliases; } } - + /** * Save configuration, in user home directory using the * {@link #getConfigFileName}. Default, env and commande line note saved @@ -501,7 +499,7 @@ * @param excludeKeys optional list of keys to exclude from */ public void saveForUser(String... excludeKeys) { - + File file = getUserConfigFile(); if (log.isDebugEnabled()) { log.debug("will save user configuration in " + file); @@ -515,26 +513,26 @@ } } } - + /** * Save configuration, in specified file. * - * @param file file where config will be writen - * @param forceAll if true save all config option - * (with defaults, classpath, env, command line) + * @param file file where config will be writen + * @param forceAll if true save all config option + * (with defaults, classpath, env, command line) * @param excludeKeys optional list of keys to exclude from * @throws IOException if IO pb */ public void save(File file, boolean forceAll, String... excludeKeys) throws IOException { - + // String[] serverProperties = {"scale"}; // store sorted in file Properties prop = new SortedProperties(); - + // store server properties in file Properties serverProp = new SortedProperties(); @@ -555,7 +553,7 @@ for (String excludeKey : excludeKeys) { prop.remove(excludeKey); } - + for (String serverPropertie : serverProperties) { if (prop.containsKey(serverPropertie)) { serverProp.put(serverPropertie, prop.get(serverPropertie)); @@ -574,11 +572,11 @@ } finally { stream.close(); } - + optionsService = - LimaServiceFactory.getInstance().getService( - OptionsServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + OptionsServiceMonitorable.class); + if (!serverProp.isEmpty()) { if (serverProp.containsKey("scale")) { if (!serverProp.getProperty("scale").isEmpty()) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/LimaSplash.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,30 +25,30 @@ package org.chorem.lima; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import java.awt.AlphaComposite; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.awt.SplashScreen; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - /** * Utility class used to manage information on slash screen. - * + * <p/> * Currently display: * <ul> - * <li>Version - * <li>Loading information + * <li>Version + * <li>Loading information * </ul> - * - * @since 0.3.2 + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ + * @since 0.3.2 */ public class LimaSplash { @@ -69,9 +69,7 @@ } } - /** - * Init splash (add version). - */ + /** Init splash (add version). */ public void initSplash() { if (splashGraphics != null) { splashGraphics.setColor(Color.GRAY); @@ -82,10 +80,9 @@ Font font = new Font("Lucida Sans", Font.BOLD, 14); splashGraphics.setFont(font); splashGraphics.drawString("Lutin Invoice Monitoring and Accounting", 65, 249); - + splash.update(); - } - else { + } else { if (log.isWarnEnabled()) { log.warn("Can't find splash screen"); log.warn("Make sure that lima is launched with -splash:image.png VM argument"); @@ -94,7 +91,7 @@ } } - public void drawVersion(String version){ + public void drawVersion(String version) { if (splashGraphics != null) { splashGraphics.setColor(Color.DARK_GRAY); Font font = new Font("Lucida Sans", Font.PLAIN, 12); @@ -104,19 +101,19 @@ splash.update(); } } - + /** * Update progression. - * + * * @param progress progress (between 0.0 and 1.0) - * @param message message can be {@code null} + * @param message message can be {@code null} */ public void updateProgression(double progress, String message) { if (splashGraphics != null && splash.isVisible()) { - + splashGraphics.setColor(Color.GRAY); splashGraphics.drawRect(65, 253, 300, 10); - splashGraphics.fillRect(65, 253, (int)(300.0 * progress), 10); + splashGraphics.fillRect(65, 253, (int) (300.0 * progress), 10); if (message != null) { splashGraphics.setComposite(AlphaComposite.Clear); @@ -130,10 +127,8 @@ splash.update(); } } - - /** - * Close splash screen (if needed). - */ + + /** Close splash screen (if needed). */ public void closeSplash() { if (splash != null && splash.isVisible()) { splash.close(); 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/actions/MiscAction.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,21 +25,21 @@ package org.chorem.lima.actions; -import static org.nuiton.i18n.I18n._; - import org.chorem.lima.LimaConfig; import org.chorem.lima.LimaMain; import java.util.Arrays; +import static org.nuiton.i18n.I18n._; + /** * Les actions appellables via {@link LimaMain}. * * @author tony * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class MiscAction { 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/AccountsChartEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,18 +28,18 @@ public enum AccountsChartEnum { IMPORT(""), IMPORTEBP(""), SHORTENED("pcg_shortened.csv"), BASE("pcg_base.csv"), DEVELOPED("pcg_developed.csv"); - + private final String filePath; - + AccountsChartEnum(String filePath) { this.filePath = filePath; } - + public String getFilePath() { String result = ""; - if (!filePath.equals("")){ - result=getClass().getResource("/import/"+ filePath).getPath(); + if (!filePath.equals("")) { + result = getClass().getResource("/import/" + filePath).getPath(); } - return result; + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -33,18 +33,18 @@ ALL(_("lima.enum.comboboxaccount.allaccount")), ACCOUNT(_("lima.enum.comboboxaccount.account")), ACCOUNT_LIST(_("lima.enum.comboboxaccount.accountlist")); - + private final String description; - + ComboBoxAccountsEnum(String description) { this.description = description; } - + public String getDescription() { - return description; + return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxAccountsEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxAccountsEnum[] enums = ComboBoxAccountsEnum.values(); @@ -53,12 +53,12 @@ } return descriptions; } - - public static ComboBoxAccountsEnum valueOfDescription(String description){ + + public static ComboBoxAccountsEnum valueOfDescription(String description) { ComboBoxAccountsEnum value = null; - + for (ComboBoxAccountsEnum enums : ComboBoxAccountsEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxDatesEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -33,18 +33,18 @@ FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")), PERIOD(_("lima.enum.comboboxperiod.period")); - + private final String description; - + ComboBoxDatesEnum(String description) { this.description = description; } - + public String getDescription() { - return description; + return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxDatesEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxDatesEnum[] enums = ComboBoxDatesEnum.values(); @@ -53,12 +53,12 @@ } return descriptions; } - - public static ComboBoxDatesEnum valueOfDescription(String description){ + + public static ComboBoxDatesEnum valueOfDescription(String description) { ComboBoxDatesEnum value = null; - + for (ComboBoxDatesEnum enums : ComboBoxDatesEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxEntryBooksEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -32,18 +32,18 @@ ALL(_("lima.enum.comboboxentrybook.all")), SELECT_ONE(_("lima.enum.comboboxentrybook.select_one")); - + private final String description; - + ComboBoxEntryBooksEnum(String description) { this.description = description; } - + public String getDescription() { - return description; + return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxEntryBooksEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxEntryBooksEnum[] enums = ComboBoxEntryBooksEnum.values(); @@ -52,12 +52,12 @@ } return descriptions; } - - public static ComboBoxEntryBooksEnum valueOfDescription(String description){ + + public static ComboBoxEntryBooksEnum valueOfDescription(String description) { ComboBoxEntryBooksEnum value = null; - + for (ComboBoxEntryBooksEnum enums : ComboBoxEntryBooksEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxLetterEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -32,18 +32,18 @@ ALL(_("lima.enum.comboboxletter.all")), SELECT_ONE(_("lima.enum.comboboxletter.selectone")); - + private final String description; - + ComboBoxLetterEnum(String description) { this.description = description; } - + public String getDescription() { - return description; + return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxLetterEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxLetterEnum[] enums = ComboBoxLetterEnum.values(); @@ -52,12 +52,12 @@ } return descriptions; } - - public static ComboBoxLetterEnum valueOfDescription(String description){ + + public static ComboBoxLetterEnum valueOfDescription(String description) { ComboBoxLetterEnum value = null; - + for (ComboBoxLetterEnum enums : ComboBoxLetterEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -36,25 +36,26 @@ SUPERIOR(_("lima.enum.comboboxoperator.superior"), ">"), INFERIOR(_("lima.enum.comboboxoperator.inferior"), "<"), INTERVAL(_("lima.enum.comboboxoperator.interval"), ""), - NOT_EQUAL(_("lima.enum.comboboxoperator.notequal"),"!="); - + NOT_EQUAL(_("lima.enum.comboboxoperator.notequal"), "!="); + private final String description; + private final String symbol; - + ComboBoxOperatorsEnum(String description, String symbol) { this.description = description; this.symbol = symbol; } - + public String getDescription() { return description; } - - public String getSymbol(){ + + public String getSymbol() { return symbol; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxOperatorsEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxOperatorsEnum[] enums = ComboBoxOperatorsEnum.values(); @@ -64,12 +65,12 @@ return descriptions; } - - public static ComboBoxOperatorsEnum valueOfDescription(String description){ + + public static ComboBoxOperatorsEnum valueOfDescription(String description) { ComboBoxOperatorsEnum value = null; - + for (ComboBoxOperatorsEnum enums : ComboBoxOperatorsEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -34,18 +34,18 @@ DATE(_("lima.enum.comboboxperiod.date")), FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")); - + private final String description; - + ComboBoxPeriodEnum(String description) { this.description = description; } - + public String getDescription() { - return description; + return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = ComboBoxPeriodEnum.values().length; String[] descriptions = new String[nbElts]; ComboBoxPeriodEnum[] enums = ComboBoxPeriodEnum.values(); @@ -54,12 +54,12 @@ } return descriptions; } - - public static ComboBoxPeriodEnum valueOfDescription(String description){ + + public static ComboBoxPeriodEnum valueOfDescription(String description) { ComboBoxPeriodEnum value = null; - + for (ComboBoxPeriodEnum enums : ComboBoxPeriodEnum.values()) { - if (description.equals(enums.description)){ + if (description.equals(enums.description)) { value = enums; break; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EncodingEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,24 +29,25 @@ UTF8("UTF-8", "UTF-8 Lima"), ISOLATIN1("ISO-8859-1", "ISO-Latin-1 Excel / Windows"), MACROMAN("MacRoman", "MacRoman Excel / Mac"); - + private final String encoding; + private final String description; - + EncodingEnum(String encoding, String description) { this.encoding = encoding; this.description = description; } - + public String getEncoding() { return encoding; } - - public String getDescription(){ + + public String getDescription() { return description; } - - public static String[] descriptions(){ + + public static String[] descriptions() { int nbElts = EncodingEnum.values().length; String[] descriptions = new String[nbElts]; EncodingEnum[] encodingEnums = EncodingEnum.values(); @@ -55,17 +56,17 @@ } return descriptions; } - - public static EncodingEnum valueOfDescription(String description){ + + public static EncodingEnum valueOfDescription(String description) { EncodingEnum value = null; - + for (EncodingEnum encodingEnum : EncodingEnum.values()) { - if (description.equals(encodingEnum.description)){ + if (description.equals(encodingEnum.description)) { value = encodingEnum; break; } } return value; } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/EntryBooksChartEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,17 +28,18 @@ public enum EntryBooksChartEnum { IMPORT(""), DEFAULT("eb_default.csv"); - + private final String filePath; - + EntryBooksChartEnum(String filePath) { this.filePath = filePath; } - + public String getFilePath() { String result = ""; - if (!filePath.equals("")){ - result=getClass().getResource("/import/"+ filePath).getPath(); + if (!filePath.equals("")) { + result = getClass().getResource("/import/" + filePath).getPath(); } - return result; } + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/FinancialStatementsChartEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,19 +28,19 @@ public enum FinancialStatementsChartEnum { IMPORT(""), SHORTENED("bcr_shortened.csv"), BASE("bcr_base.csv"), DEVELOPED("bcr_developed.csv"); - + private final String filePath; - + FinancialStatementsChartEnum(String filePath) { this.filePath = filePath; - + } - + public String getFilePath() { String result = ""; - if (!filePath.equals("")){ - result=getClass().getResource("/import/"+ 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ImportExportEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -26,10 +26,7 @@ package org.chorem.lima.enums; -/** - * Boolean importMode define if it's a import (true) or an export (false) - * - */ +/** Boolean importMode define if it's a import (true) or an export (false) */ public enum ImportExportEnum { CSV_ALL_EXPORT(false, true), CSV_ALL_IMPORT(true, true), CSV_ACCOUNTCHARTS_EXPORT(false, true), CSV_ACCOUNTCHARTS_IMPORT(true, true), @@ -39,10 +36,11 @@ PDF_VAT_EXPORT(false, true), PDF_VAT_IMPORT(true, true), EBP_ACCOUNTCHARTS_EXPORT(false, false), EBP_ENTRIES_EXPORT(false, false), EBP_ACCOUNTCHARTS_IMPORT(true, false), EBP_ENTRIES_IMPORT(true, false); - + private final Boolean importMode; + private final Boolean encodingOption; - + /** * import mode : * true if import, false if export @@ -51,15 +49,15 @@ this.importMode = importMode; this.encodingOption = encodingOption; } - + /** * encoding choice * true if import or export methode let encoding option */ - public Boolean getEncodingOption(){ + public Boolean getEncodingOption() { return encodingOption; } - + public Boolean getImportMode() { 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/VatStatementsChartEnum.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,19 +28,19 @@ IMPORT(""), SHORTENED("vat_shortened.csv"), BASE("vat_base.csv"), DEVELOPED("vat_developed.csv"), DEFAULT("vat_default.csv"); - + private final String filePath; - + VatStatementsChartEnum(String filePath) { this.filePath = filePath; - + } - + public String getFilePath() { String result = ""; - if (!filePath.equals("")){ - result=getClass().getResource("/import/"+ filePath).getPath(); - } + if (!filePath.equals("")) { + result = getClass().getResource("/import/" + filePath).getPath(); + } return result; } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/LimaDecoratorProvider.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -3,6 +3,7 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.entity.Letter; import org.nuiton.util.decorator.DecoratorProvider; /** @@ -18,6 +19,8 @@ registerJXPathDecorator(EntryBook.class, "${code}$s - ${label}$s"); + registerJXPathDecorator(Letter.class, "${code}$s"); + registerJXPathDecorator( FiscalPeriod.class, "${beginDate}$td/%1$tm/%1$tY - ${endDate}$td/%1$tm/%1$tY"); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -46,7 +46,7 @@ org.chorem.lima.enums.ImportExportEnum org.chorem.lima.service.LimaServiceFactory </import> - + <Desktop id='desktop' javaBean='Desktop.getDesktop()'/> <script><![CDATA[ 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -62,21 +62,19 @@ /** * Handler for main view. - * + * <p/> * Date: 8 nov. 2009 * Time: 09:59:54 - * + * * @author chemit * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class MainViewHandler { - /** - * 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(MainViewHandler.class); /** @@ -167,7 +165,7 @@ ConfigUIHelper helper = new ConfigUIHelper(config); helper.addCategory(_("lima.config.category.directories"), _("lima.config.category.directories.description")); helper.addOption(LimaConfig.Option.CONFIG_FILE); - + helper.addCategory(_("lima.config.category.other"), _("lima.config.category.other.description")); helper.addOption(LimaConfig.Option.FULL_SCREEN); helper.addOption(LimaConfig.Option.LOCALE); @@ -175,7 +173,7 @@ helper.addOption(LimaConfig.Option.SCALE); helper.addOption(LimaConfig.Option.THOUSAND_SEPARATOR); helper.addOption(LimaConfig.Option.CURRENCY); - + helper.buildUI(context, _("lima.config.category.directories")); helper.displayUI(ui, false); } @@ -282,16 +280,17 @@ HomeView homeView = new HomeView(mainView); mainView.showTab(_("lima.tab.home"), homeView, false); } - + public void showIdentity(JAXXContext rootContext) { MainView mainView = getUI(rootContext); IdentityForm identityForm = new IdentityForm(); identityForm.setLocationRelativeTo(mainView); identityForm.setVisible(true); } - + /** * Show account tree table view to create or modify accounts + * * @param rootContext */ public void showAccountView(JAXXContext rootContext) { @@ -299,19 +298,21 @@ AccountView accountView = new AccountView(mainView); mainView.showTab(_("lima.charts.account"), accountView); } - + /** * Show account tree table view to create or modify accounts + * * @param rootContext */ public void showEntryBookView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - EntryBookView entryBookView= new EntryBookView(mainView); + EntryBookView entryBookView = new EntryBookView(mainView); mainView.showTab(_("lima.common.entrybooks"), entryBookView); } /** * Show fiscal period view to create or block a period + * * @param rootContext */ public void showFiscalPeriodView(JAXXContext rootContext) { @@ -319,63 +320,69 @@ FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView); mainView.showTab(_("lima.charts.fiscalyear"), fiscalPeriodView); } - + /** * Show financial period view to create or block a period + * * @param rootContext */ public void showFinancialPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialPeriodView financialPeriodView = - new FinancialPeriodView(mainView); + new FinancialPeriodView(mainView); mainView.showTab(_("lima.charts.financialperiod"), financialPeriodView); } - + /** * Show financial statement view to generate balance sheet and income statement + * * @param rootContext */ public void showFinancialStatementView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialStatementChartView financialStatementView = - new FinancialStatementChartView(mainView); + new FinancialStatementChartView(mainView); mainView.showTab(_("lima.charts.financialstatement"), financialStatementView); } - + /** * Show vat chart to generate vat document + * * @param rootContext */ - public void showVatChartView(JAXXContext rootContext){ - MainView mainView = getUI(rootContext); - VatChartView vatChartView = new VatChartView(mainView); - mainView.showTab(_("lima.charts.vatstatement"), vatChartView); + public void showVatChartView(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + VatChartView vatChartView = new VatChartView(mainView); + mainView.showTab(_("lima.charts.vatstatement"), vatChartView); } - + /** * Show account table report to view an account on a period + * * @param rootContext */ public void showAccountReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); AccountsReportsView accountsReportsView = - new AccountsReportsView(mainView); + new AccountsReportsView(mainView); mainView.showTab(_("lima.reports.accounts"), accountsReportsView); } - + /** * Show entry book table report to view an account on a period + * * @param rootContext */ public void showEntryBookReports(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - EntryBooksReportsView entryBooksReportsView= new EntryBooksReportsView(mainView); + EntryBooksReportsView entryBooksReportsView = new EntryBooksReportsView(mainView); mainView.showTab(_("lima.reports.entrybooks"), entryBooksReportsView); } - - + + /** * Show financial transactions view to create entries + * * @param rootContext */ public void showTransactionView(JAXXContext rootContext) { @@ -383,48 +390,48 @@ FinancialTransactionView transactionView = new FinancialTransactionView(mainView); mainView.showTab(_("lima.entries.writetransaction"), transactionView); } - + public void showTransactionUnbalancedView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialTransactionUnbalancedView searchResultView = new FinancialTransactionUnbalancedView(mainView); mainView.showTab(_("lima.entries.searchunbalancedtransaction"), searchResultView); } - + public void showTransactionSearchView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialTransactionSearchView searchView = new FinancialTransactionSearchView(mainView); mainView.showTab(_("lima.entries.searchtransaction"), searchView); } - - public void showLetteringView(JAXXContext rootContext){ - MainView mainView = getUI(rootContext); - LetteringView letteringView = new LetteringView(mainView); - mainView.showTab(_("lima.entries.lettering"), letteringView); + + public void showLetteringView(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + LetteringView letteringView = new LetteringView(mainView); + mainView.showTab(_("lima.entries.lettering"), letteringView); } - + public void showBalanceView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - BalanceView balanceView = new BalanceView(mainView); - mainView.showTab(_("lima.reports.balance"), balanceView); + BalanceView balanceView = new BalanceView(mainView); + mainView.showTab(_("lima.reports.balance"), balanceView); } - + public void showLedgerView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); - LedgerView ledgerView = new LedgerView(mainView); - mainView.showTab(_("lima.reports.ledger"), ledgerView); + LedgerView ledgerView = new LedgerView(mainView); + mainView.showTab(_("lima.reports.ledger"), ledgerView); } - + public void showFinancialStatementReportsView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FinancialStatementReportView financialStatementReportView = new FinancialStatementReportView(mainView); mainView.showTab(_("lima.reports.financialstatement"), financialStatementReportView); } - + public void showVatReportView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); VatReportView vatReportView = new VatReportView(mainView); mainView.showTab(_("lima.reports.vat"), vatReportView); - + } public void showImportExportView(JAXXContext rootContext, ImportExportEnum type) { 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,34 +24,34 @@ */ package org.chorem.lima.ui.account; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; + import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTreeTable; - public class AccountTreeTable extends JXTreeTable implements KeyListener, MouseListener { - /** serialVersionUID. */ - private static final long serialVersionUID = 1092873442245932784L; + /** serialVersionUID. */ + private static final long serialVersionUID = 1092873442245932784L; - /** log. */ + /** log. */ private static final Log log = LogFactory .getLog(AccountTreeTable.class); - + protected AccountViewHandler handler; - + public AccountTreeTable(AccountViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + } @Override @@ -89,9 +89,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,9 +25,6 @@ package org.chorem.lima.ui.account; -import static org.nuiton.i18n.I18n._; -import java.util.List; -import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.AccountServiceMonitorable; @@ -38,34 +35,37 @@ import org.chorem.lima.service.LimaServiceFactory; import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import javax.swing.tree.TreePath; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Tree table model for account edition. - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class AccountTreeTableModel extends AbstractTreeTableModel { - + /** log. */ private static final Log log = LogFactory.getLog(AccountViewHandler.class); - + /** Account service. */ protected final AccountServiceMonitorable accountService; - /** - * Model constructor. Init account service used here. - */ + /** Model constructor. Init account service used here. */ public AccountTreeTableModel() { // root super(new AccountImpl()); // Gets factory service accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); } @@ -97,8 +97,7 @@ } catch (LimaException eee) { log.debug("Can't count child", eee); } - } - else { + } else { Account parentAccount = (Account) node; try { result = accountService.getChildrenAccounts(parentAccount).size(); @@ -115,19 +114,18 @@ if (parent == getRoot()) { try { List<Account> allAccounts = - accountService.getChildrenAccounts(null); + accountService.getChildrenAccounts(null); result = allAccounts.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); } - } - else { + } else { Account parentAccount = (Account) parent; // FIXME sub account is a collection ? try { List<Account> subaccounts = - accountService.getChildrenAccounts(parentAccount); + accountService.getChildrenAccounts(parentAccount); result = subaccounts.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); @@ -141,21 +139,20 @@ int result = 0; Account parentAccount = (Account) parent; Account childAccount = (Account) child; - + if (parent == getRoot()) { try { List<Account> allAccounts = - accountService.getChildrenAccounts(null); + accountService.getChildrenAccounts(null); result = allAccounts.indexOf(child); } catch (LimaException eee) { log.debug("Can't get index child", eee); } - } - else { + } else { // FIXME sub account is a collection ? try { List<Account> subaccounts = - accountService.getChildrenAccounts(parentAccount); + accountService.getChildrenAccounts(parentAccount); result = subaccounts.indexOf(childAccount); } catch (LimaException eee) { log.debug("Can't get index child", eee); @@ -163,7 +160,7 @@ } return result; } - + @Override public Object getValueAt(Object node, int column) { Object result = "n/a"; @@ -190,15 +187,15 @@ public boolean isLeaf(Object node) { return getChildCount(node) == 0; } - + /** * Add account - * + * * @param parentAccount * @param account * @throws LimaException */ - public void addAccount(Account parentAccount, Account account) throws LimaException{ + public void addAccount(Account parentAccount, Account account) throws LimaException { accountService.createAccount(parentAccount, account); //FIXME 2011.08.09 vsalaun quick tree refresh, it should refresh only the path changed //modelSupport.fireTreeStructureChanged(path); @@ -207,7 +204,7 @@ /** * Add account - * + * * @param parentAccount * @param account * @throws LimaException @@ -218,34 +215,30 @@ //modelSupport.fireTreeStructureChanged(path); modelSupport.fireNewRoot(); } - + /** * Update account. - * + * * @param account * @throws LimaException */ public void updateAccount(Account account) throws LimaException { // Calling account service //FIXME Force fire for no update if error. Where is the cache ? - try{ + try { accountService.updateAccount(account); - } - catch (LimaBusinessException eee) { + } catch (LimaBusinessException eee) { //modelSupport.fireTreeStructureChanged(path); throw new LimaBusinessException("Can't update account : " - + account.getAccountNumber(), eee); + + account.getAccountNumber(), eee); } //FIXME 2011.08.10 vsalaun quick tree refresh, it should only refresh the path where //the account were, and the path where it has been moved //modelSupport.fireTreeStructureChanged(path); modelSupport.fireNewRoot(); } - - /** - * Refresh accountschart. - * - */ + + /** Refresh accountschart. */ public void refreshTree() throws LimaException { modelSupport.fireNewRoot(); @@ -253,7 +246,7 @@ /** * Remove account. - * + * * @param path * @param account * @throws LimaException 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -49,12 +49,12 @@ /** * Handler associated with account view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class AccountViewHandler implements ServiceListener { @@ -62,28 +62,29 @@ private static final Log log = LogFactory.getLog(AccountViewHandler.class); protected AccountView view; - + protected AccountServiceMonitorable accountService; - + protected AccountViewHandler(AccountView view) { this.view = view; // Gets factory service LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); } /** * Add new account with account form. - * @throws LimaException + * + * @throws LimaException */ public void addAccount() { - + JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel) accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); AccountForm accountForm = new AccountForm(view); @@ -91,8 +92,8 @@ // jaxx constructor don't call super() ? accountForm.setLocationRelativeTo(view); accountForm.setVisible(true); - - + + // null == cancel action newAccount = accountForm.getAccount(); Account parentAccount = new AccountImpl(); @@ -103,7 +104,7 @@ //search for the nearest account from the one been created //e.g.: for 41019 search for 4, 41, 410, 4101 //and stop when the account doesn't exist, use last account found instead - for (int i = 1; i<number.length(); i++) { + for (int i = 1; i < number.length(); i++) { try { //get the parent account from the new account subnumber parentAccount = accountService.getAccountByNumber(number.substring(0, i)); @@ -113,14 +114,14 @@ if (parentAccount == null) { try { //if the account is null, get the previous account searched then stop the loop - parentAccount = accountService.getAccountByNumber(number.substring(0, i-1)); + parentAccount = accountService.getAccountByNumber(number.substring(0, i - 1)); break; } catch (LimaException eee) { - log.debug("Can't search account : " + number.substring(0, i-1), eee); + log.debug("Can't search account : " + number.substring(0, i - 1), eee); } } } - + // add it try { accountsTreeTableModel.addAccount(parentAccount, newAccount); @@ -130,39 +131,39 @@ } DialogHelper.showErrorMessageDialog(view, eee); - } - - catch (LimaException ex) { + } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't add account", ex); } ErrorHelper.showErrorDialog(_("lima.account.addaccounterror"), ex); } } - }; - - public void addSubLedger(){ - + } + + ; + + public void addSubLedger() { + JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel) accountsTreeTable.getTreeTableModel(); Account newAccount = new AccountImpl(); SubLedgerForm subledgerForm = new SubLedgerForm(view); subledgerForm.setAccount(newAccount); // jaxx constructor don't call super() ? subledgerForm.setLocationRelativeTo(view); subledgerForm.setVisible(true); - newAccount=subledgerForm.getAccount(); - + newAccount = subledgerForm.getAccount(); + // null == cancel action if (newAccount != null) { Account parentAccount = new AccountImpl(); String number = newAccount.getAccountNumber(); - + //search for the nearest account from the one been created //e.g.: for 41019 search for 4, 41, 410, 4101 //and stop when the account doesn't exist, use last account found instead - for (int i = 1; i<=number.length(); i++) { + for (int i = 1; i <= number.length(); i++) { try { //get the parent account from the new account subnumber parentAccount = accountService.getAccountByNumber(number.substring(0, i)); @@ -172,14 +173,14 @@ if (parentAccount == null) { try { //if the account is null, get the previous account searched then stop the loop - parentAccount = accountService.getAccountByNumber(number.substring(0, i-1)); + parentAccount = accountService.getAccountByNumber(number.substring(0, i - 1)); break; } catch (LimaException eee) { - log.debug("Can't search account : " + number.substring(0, i-1), eee); + log.debug("Can't search account : " + number.substring(0, i - 1), eee); } } } - + // add it try { accountsTreeTableModel.addSubLedger(parentAccount, newAccount); @@ -188,9 +189,7 @@ log.error("Can't add subledger", eee); } DialogHelper.showErrorMessageDialog(view, eee); - } - - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add subledger", eee); } @@ -206,82 +205,80 @@ public void updateAccount() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel) accountsTreeTable.getTreeTableModel(); // get selected account int selectedRow = view.getAccountsTreeTable().getSelectedRow(); TreePath treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // not null - Account selectedObject = (Account)treePath.getLastPathComponent(); - //update Account or update SubLedger + Account selectedObject = (Account) treePath.getLastPathComponent(); + //update Account or update SubLedger + if (selectedObject != null) { + // get current selection path + if (selectedRow != -1) { + treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); + } else { + treePath = new TreePath(accountsTreeTableModel.getRoot()); + } + //test if selectedrow is account or ledger + if (selectedObject.getGeneralLedger() == null) { + UpdateAccountForm accountForm = new UpdateAccountForm(view); + accountForm.setAccount(selectedObject); + // jaxx constructor don't call super() ? + accountForm.setLocationRelativeTo(view); + accountForm.setVisible(true); + // null == cancel action + selectedObject = accountForm.getAccount(); + } + // else is a subledger + else { + UpdateSubLedgerForm subLedgerForm = new UpdateSubLedgerForm(view); + subLedgerForm.setAccount(selectedObject); + // jaxx constructor don't call super() ? + subLedgerForm.setLocationRelativeTo(view); + subLedgerForm.setVisible(true); + // null == cancel action + selectedObject = subLedgerForm.getAccount(); + } + //if action confirmed if (selectedObject != null) { - // get current selection path - if ( selectedRow != -1) { - treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); - } else { - treePath = new TreePath(accountsTreeTableModel.getRoot()); - } - //test if selectedrow is account or ledger - if (selectedObject.getGeneralLedger()==null) { - UpdateAccountForm accountForm = new UpdateAccountForm(view); - accountForm.setAccount(selectedObject); - // jaxx constructor don't call super() ? - accountForm.setLocationRelativeTo(view); - accountForm.setVisible(true); - // null == cancel action - selectedObject = accountForm.getAccount(); - } - // else is a subledger - else { - UpdateSubLedgerForm subLedgerForm = new UpdateSubLedgerForm(view); - subLedgerForm.setAccount(selectedObject); - // jaxx constructor don't call super() ? - subLedgerForm.setLocationRelativeTo(view); - subLedgerForm.setVisible(true); - // null == cancel action - selectedObject = subLedgerForm.getAccount(); - } - //if action confirmed - if (selectedObject != null) { - // update it - try { - accountsTreeTableModel. - updateAccount(selectedObject); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + // update it + try { + accountsTreeTableModel. + updateAccount(selectedObject); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add update", eee); } + DialogHelper.showErrorMessageDialog(view, eee); } } - + } + } - /** - * Ask for user to remove for selected account, and remove it if confirmed. - */ + /** Ask for user to remove for selected account, and remove it if confirmed. */ public void removeAccount() { // maybe this code can be factorised JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); + (AccountTreeTableModel) accountsTreeTable.getTreeTableModel(); // Any row selected int selectedRow = view.getAccountsTreeTable().getSelectedRow(); - if ( selectedRow != -1) { + if (selectedRow != -1) { int n = JOptionPane.showConfirmDialog(view, - _("lima.charts.account.question.remove"), - _("lima.common.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + _("lima.charts.account.question.remove"), + _("lima.common.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (n == JOptionPane.YES_OPTION) { // update view of treetable TreePath treePath = view.getAccountsTreeTable(). - getPathForRow(selectedRow); + getPathForRow(selectedRow); Account account = (Account) treePath.getLastPathComponent(); - try{ + try { accountsTreeTableModel.removeAccount(treePath, account); } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -292,57 +289,57 @@ } } } - - public void refresh(){ + + public void refresh() { JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = - (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); - try { - accountsTreeTableModel.refreshTree(); + (AccountTreeTableModel) accountsTreeTable.getTreeTableModel(); + try { + accountsTreeTableModel.refreshTree(); } catch (LimaException eee) { - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't refresh model", eee); } } //refresh view view.repaint(); - } - - public void importAccountsChart(){ - - AccountImportForm form = new AccountImportForm(); - // - form.setLocationRelativeTo(view); - form.setVisible(true); - - ImportExport importExport = ImportExport.getInstance(view); + } - Object value = form.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - AccountsChartEnum defaultAccountsChartEnum = - (AccountsChartEnum) value; - //Import accounts chart - switch (defaultAccountsChartEnum) { - case IMPORTEBP: - importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; + public void importAccountsChart() { - default: - importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; - } - } + AccountImportForm form = new AccountImportForm(); + // + form.setLocationRelativeTo(view); + form.setVisible(true); + + ImportExport importExport = ImportExport.getInstance(view); + + Object value = form.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null) { + AccountsChartEnum defaultAccountsChartEnum = + (AccountsChartEnum) value; + //Import accounts chart + switch (defaultAccountsChartEnum) { + case IMPORTEBP: + importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + + default: + importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + } + } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - - if (methodeName.contains("importAccounts") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")){ + + if (methodeName.contains("importAccounts") || methodeName.contains("importAll") || methodeName.contains("importAsCSV")) { refresh(); } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountComboBox.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,11 +25,6 @@ package org.chorem.lima.ui.accountsreports; -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; +import javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + public class AccountComboBox extends JComboBox implements KeyListener { private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(AccountComboBox.class); - + LogFactory.getLog(AccountComboBox.class); + protected AccountsReportsViewHandler handler; - + public AccountComboBox(AccountsReportsViewHandler handler) { this.handler = handler; AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); @@ -59,30 +59,30 @@ addActionListener(this); } - public void back(){ + public void back() { int row = getSelectedIndex(); log.debug(row); - if (row > 0){ - getEditor().setItem(getItemAt(row-1)); + if (row > 0) { + getEditor().setItem(getItemAt(row - 1)); handler.setAccount((Account) getSelectedItem()); } } - - public void next(){ + + public void next() { int size = getModel().getSize(); int row = getSelectedIndex(); log.debug(row); - - if (row < size-1){ - getEditor().setItem(getItemAt(row+1)); + + if (row < size - 1) { + getEditor().setItem(getItemAt(row + 1)); handler.setAccount((Account) getSelectedItem()); } } - + @Override public void actionPerformed(ActionEvent e) { Object object = getSelectedItem(); - if (object instanceof Account){ + if (object instanceof Account) { handler.setAccount((Account) getSelectedItem()); } } @@ -90,26 +90,25 @@ @Override public void keyPressed(KeyEvent e) { - + } @Override public void keyReleased(KeyEvent e) { Object object = getSelectedItem(); - if (object instanceof Account){ + if (object instanceof Account) { handler.setAccount((Account) 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/accountsreports/AccountsReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.accountsreports; -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; @@ -40,120 +32,129 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 AccountsReportsPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(AccountsReportsPeriodSearchPanel.class); - + LogFactory.getLog(AccountsReportsPeriodSearchPanel.class); + protected AccountsReportsViewHandler handler; - + public AccountsReportsPeriodSearchPanel(AccountsReportsViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); + // 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(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); + 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(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + 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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + 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/accountsreports/AccountsReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,19 +24,17 @@ */ package org.chorem.lima.ui.accountsreports; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; +import org.jdesktop.swingx.JXTable; + 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 org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.ui.accountsreports.AccountsReportsTable; -import org.chorem.lima.ui.accountsreports.AccountsReportsViewHandler; -import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; -import org.jdesktop.swingx.JXTable; - public class AccountsReportsTable extends JXTable implements KeyListener, MouseListener { @@ -46,16 +44,16 @@ /** log. */ private static final Log log = LogFactory .getLog(AccountsReportsTable.class); - + protected AccountsReportsViewHandler handler; public AccountsReportsTable(AccountsReportsViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); @@ -96,9 +94,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.accountsreports; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.ReportsDatas; @@ -39,29 +32,36 @@ import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.Letter; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static org.nuiton.i18n.I18n._; + /** * Entry book table model. * By : $Author$ */ -public class AccountsReportsTableModel extends AbstractTableModel{ +public class AccountsReportsTableModel extends AbstractTableModel { /** serialVersionUID. */ private static final long serialVersionUID = 1L; /** log. */ private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class); - + /** data cache */ protected ReportsDatas cacheDataList; - + @Override public int getRowCount() { int result = 0; - + // just prevent too much result if (cacheDataList != null) { - if (cacheDataList.getListEntry() != null){ + if (cacheDataList.getListEntry() != null) { result = cacheDataList.getListEntry().size(); } } @@ -73,37 +73,37 @@ public int getColumnCount() { return 8; } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = Account.class; - break; - case 1: - result = Date.class; - break; - case 2: - result = Entry.class; - break; - case 3: - result = String.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 0: + result = Account.class; + break; + case 1: + result = Date.class; + break; + case 2: + result = Entry.class; + break; + case 3: + result = String.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; } return result; @@ -145,11 +145,11 @@ @Override public Object getValueAt(int row, int column) { Object result = null; - if(cacheDataList != null) { + if (cacheDataList != null) { Entry currentRow = cacheDataList.getListEntry().get(row); SimpleDateFormat simpleDateFormat - = new SimpleDateFormat("dd MMMMM yyyy"); - + = new SimpleDateFormat("dd MMMMM yyyy"); + switch (column) { case 0: result = currentRow.getAccount().getAccountNumber(); @@ -159,10 +159,9 @@ format(currentRow.getFinancialTransaction().getTransactionDate()); break; case 2: - if (currentRow.getFinancialTransaction().getEntryBook() != null){ + if (currentRow.getFinancialTransaction().getEntryBook() != null) { result = currentRow.getFinancialTransaction().getEntryBook().getCode(); - } - else { + } else { result = null; } break; @@ -173,10 +172,9 @@ result = currentRow.getDescription(); break; case 5: - if (currentRow.getLetter() != null){ + if (currentRow.getLetter() != null) { result = currentRow.getLetter().getCode(); - } - else { + } else { result = null; } break; @@ -187,8 +185,7 @@ result = currentRow.getDebit() ? BigDecimal.ZERO : currentRow.getAmount(); break; } - } - else { + } else { if (log.isDebugEnabled()) { log.debug("No Account selected skip table model update"); } @@ -203,10 +200,10 @@ // Just read, no write return false; } - - public void refresh(ReportsDatas datasList){ + + public void refresh(ReportsDatas datasList) { cacheDataList = datasList; fireTableDataChanged(); } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,10 +25,6 @@ package org.chorem.lima.ui.accountsreports; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.util.Date; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.ReportsDatas; @@ -42,7 +38,12 @@ import org.chorem.lima.ui.combobox.AccountComboBoxModel; import org.chorem.lima.util.ErrorHelper; +import java.math.BigDecimal; +import java.util.Date; +import static org.nuiton.i18n.I18n._; + + /** * Handler associated with accounts reports view. * By : $Author$ @@ -50,65 +51,64 @@ public class AccountsReportsViewHandler implements ServiceListener { protected AccountsReportsView view; - + protected AccountsReportsTable table; - + protected AccountsReportsTableModel tableModel; - + protected AccountComboBoxModel comboBoxModel; - + /** log. */ private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class); - + /** Account. */ protected Account selectedAccount; - + /** Begin Date. */ protected Date selectedBeginDate; - + /** EndDate. */ protected Date selectedEndDate; - + /** Services. */ protected ReportServiceMonitorable reportService; - + protected AccountsReportsViewHandler(AccountsReportsView view) { this.view = view; - + reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class).addServiceListener(this); } - - public void setBeginDate(Date date){ + + public void setBeginDate(Date date) { selectedBeginDate = date; refresh(); } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { selectedEndDate = date; refresh(); } - + public void setAccount(Account account) { selectedAccount = account; refresh(); } - - public ReportsDatas getDataList(){ + + public ReportsDatas getDataList() { ReportsDatas results = null; //avoid unnecessary call to service - if (selectedAccount != null){ + if (selectedAccount != null) { try { results = reportService.generateAccountsReports(selectedAccount, true, - selectedBeginDate, selectedEndDate); - } - catch (LimaException eee) { + selectedBeginDate, selectedEndDate); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -117,20 +117,20 @@ } return results; } - - public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null && selectedAccount != null){ + + public void refresh() { + + if (selectedBeginDate != null && selectedEndDate != null && selectedAccount != null) { ReportsDatas datasList = getDataList(); - + tableModel = view.getModelAccountsReportsTable(); tableModel.refresh(datasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (datasList != null){ + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (datasList != null) { // set amounts credit and debit and solde view.amountCreditLabel.setText( datasList.getAmountCredit().toString()); @@ -138,29 +138,27 @@ datasList.getAmountDebit().toString()); BigDecimal amountSolde = datasList.getAmountSolde(); view.amountSoldeLabel.setText(amountSolde.toString()); - - - if (amountSolde == BigDecimal.ZERO){ + + + if (amountSolde == BigDecimal.ZERO) { view.soldeLabel.setText(_("lima.common.solde")); - } - else { + } else { // set label solde: credit or debit if (datasList.getSoldeDebit()) { view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { + } else { view.soldeLabel.setText(_("lima.common.soldecredit")); } } } } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) { refresh(); } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.balance; -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; @@ -40,121 +32,132 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 BalancePeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(BalancePeriodSearchPanel.class); - + LogFactory.getLog(BalancePeriodSearchPanel.class); + protected BalanceViewHandler handler; - + public BalancePeriodSearchPanel(BalanceViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + // 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(); - } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + } + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod !=null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); - handler.refresh(); + 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(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + 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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + 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/balance/BalanceTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,35 +24,35 @@ */ package org.chorem.lima.ui.balance; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; +import org.jdesktop.swingx.JXTable; + 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 org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; -import org.chorem.lima.ui.balance.BalanceViewHandler; -import org.jdesktop.swingx.JXTable; -public class BalanceTable extends JXTable implements KeyListener, MouseListener{ +public class BalanceTable extends JXTable implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 6093850347322834480L; - + /** log. */ private static final Log log = LogFactory .getLog(BalanceTable.class); - + protected BalanceViewHandler handler; public BalanceTable(BalanceViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); @@ -93,9 +93,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,18 +25,19 @@ package org.chorem.lima.ui.balance; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -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.beans.BalanceTrial; import org.chorem.lima.beans.ReportsDatas; import org.chorem.lima.entity.Account; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.util.List; +import static org.nuiton.i18n.I18n._; + + /** * Entry book table model. * By : $Author$ @@ -48,15 +49,15 @@ /** log. */ private static final Log log = LogFactory.getLog(BalanceTableModel.class); - + /** data cache */ protected BalanceTrial cacheDataList; @Override public int getRowCount() { int result = 0; - if (cacheDataList != null){ - result = cacheDataList.getReportsDatas().size(); + if (cacheDataList != null) { + result = cacheDataList.getReportsDatas().size(); } return result; } @@ -65,31 +66,31 @@ public int getColumnCount() { return 6; } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = Account.class; - break; - case 1: - result = String.class; - break; - case 2: - result = BigDecimal.class; - break; - case 3: - result = BigDecimal.class; - break; - case 4: - result = BigDecimal.class; - break; - case 5: - result = BigDecimal.class; - break; + case 0: + result = Account.class; + break; + case 1: + result = String.class; + break; + case 2: + result = BigDecimal.class; + break; + case 3: + result = BigDecimal.class; + break; + case 4: + result = BigDecimal.class; + break; + case 5: + result = BigDecimal.class; + break; } return result; @@ -141,27 +142,24 @@ result = currentRow.getAmountCredit(); // total crédit break; case 4: // solde debit - if (currentRow.getSoldeDebit()){ + if (currentRow.getSoldeDebit()) { result = currentRow.getAmountSolde(); - } - else { + } else { result = BigDecimal.ZERO; } break; case 5: // solde credit - if (!currentRow.getSoldeDebit()){ + if (!currentRow.getSoldeDebit()) { result = currentRow.getAmountSolde(); - } - else { + } else { result = BigDecimal.ZERO; } break; } - } - catch (Exception eee) { + } catch (Exception eee) { log.debug("Can't get entries", eee); } - + return result; } @@ -171,11 +169,11 @@ // Just read, no write return false; } - - - public void refresh(BalanceTrial datasList){ + + + public void refresh(BalanceTrial datasList) { cacheDataList = datasList; fireTableDataChanged(); } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,19 +25,6 @@ package org.chorem.lima.ui.balance; -import static org.nuiton.i18n.I18n._; -import java.awt.Desktop; -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; @@ -55,7 +42,20 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; +import javax.swing.JOptionPane; +import java.awt.Desktop; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import static org.nuiton.i18n.I18n._; + + /** * Handler associated with accounts reports view. * By : $Author$ @@ -63,77 +63,79 @@ public class BalanceViewHandler implements ServiceListener { protected BalanceView view; - + /** log. */ private static final Log log = LogFactory.getLog(BalanceViewHandler.class); - + /** Services. */ protected ReportServiceMonitorable reportService; + protected HttpServerServiceMonitorable httpServerServiceMonitorable; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + /** DatePicker Begin Date. */ protected Date selectedBeginDate; - + /** DatePicker EndDate. */ protected Date selectedEndDate; - + /** Text field Accounts */ protected String selectedAccounts; - + protected BalanceTable table; protected BalanceTableModel model; - + private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - + new SimpleDateFormat("yyyy-MM-dd"); + protected int port; - + protected BalanceViewHandler(BalanceView view) { this.view = view; - + reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class).addServiceListener(this); - + } - - public void setBeginDate(Date date){ + + public void setBeginDate(Date date) { selectedBeginDate = date; refresh(); } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { selectedEndDate = date; refresh(); } - + public void setAccountFilter(String accounts) { selectedAccounts = accounts; refresh(); } - + /** * get all account fot the selected period + * * @return */ - public BalanceTrial getDataList(){ + public BalanceTrial getDataList() { BalanceTrial results = null; - + try { results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected()); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -141,72 +143,70 @@ } return results; } - - public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null){ + + public void refresh() { + + if (selectedBeginDate != null && selectedEndDate != null) { model = view.getModelBalanceTable(); BalanceTrial datasList = getDataList(); model.refresh(datasList); - - /** - * update the labels credit, debit, solde on the footer - * get all entries for all accounts on the selected period - */ - - if (datasList != null){ + + /** + * update the labels credit, debit, solde on the footer + * get all entries for all accounts on the selected period + */ + + if (datasList != null) { // set amounts credit, debit and solde view.amountCreditLabel.setText( String.valueOf(datasList.getAmountCredit())); view.amountDebitLabel.setText( - String.valueOf(datasList.getAmountDebit())); + String.valueOf(datasList.getAmountDebit())); BigDecimal amountSolde = datasList.getAmountSolde(); view.amountSoldeLabel.setText( String.valueOf(amountSolde)); - - - if (amountSolde.compareTo(BigDecimal.ZERO) == 0){ + + + if (amountSolde.compareTo(BigDecimal.ZERO) == 0) { view.soldeLabel.setText(_("lima.common.solde")); - } - else { + } else { // set label solde: credit or debit if (datasList.getSoldeDebit()) { view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { + } else { view.soldeLabel.setText(_("lima.common.soldecredit")); } } } } } - + public void createDocument() { - - if (selectedBeginDate != null & selectedEndDate != null){ - + + if (selectedBeginDate != null & selectedEndDate != null) { + //looks for all blocked fiscal periods List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); try { blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods(); - }catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Enable to create document ", eee); } ErrorHelper.showErrorDialog(_("lima.balance.documentcreationerror"), eee); } - + //tells if the fiscaPeriod as been found and is blocked boolean error = true; - + for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate) - && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) - && blockedFiscalPeriod.getLocked()) { + && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) + && blockedFiscalPeriod.getLocked()) { error = false; } } - + //shows error message to user if the fiscalPeriod is unblocked if (error) { JOptionPane.showMessageDialog( @@ -215,18 +215,18 @@ _("lima.common.error"), JOptionPane.ERROR_MESSAGE); } else { - + FormatsEnum selectedEnum = - (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + (FormatsEnum) view.getDocumentEditor().getSelectedItem(); String address = LimaConfig.getInstance().getHostAdress(); - + try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate)+"&format=" - +selectedEnum.getExtension()+"&model=" - + DocumentsEnum.BALANCE.getFileName(); - Desktop.getDesktop().browse(new URI(url)); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(selectedBeginDate) + + "&endDate=" + dateFormat.format(selectedEndDate) + "&format=" + + selectedEnum.getExtension() + "&model=" + + DocumentsEnum.BALANCE.getFileName(); + Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { log.error("Can't open browser", e); } catch (URISyntaxException e) { @@ -235,10 +235,10 @@ } } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -48,15 +48,15 @@ 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 boolean keyPressed; - /** - * constructor - */ + /** constructor */ public AccountTableCellEditor() { comboBox = new JWideComboBox(); SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel(); @@ -69,9 +69,9 @@ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Account){ + if (value instanceof Account) { comboBox.setSelectedItem(value); - } + } return comboBox; } @@ -79,28 +79,28 @@ 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 */ - @Override + @Override public boolean isCellEditable(EventObject evt) { // Si il y a une frappe au clavier 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())); } } @@ -111,37 +111,35 @@ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } - + @Override public void keyPressed(KeyEvent e) { - + } - + @Override public void keyReleased(KeyEvent e) { - + // Vérifie si c'est la première frappe au clavier - if (!keyPressed) - { + 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 edit.select(1, edit.getText().length()); keyPressed = true; } - + // delegate popup list menu - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { fireEditingStopped(); } } - + @Override public void keyTyped(KeyEvent e) { - + } - + // public static AccountTableCellEditor getInstance() { // if (editor == null) { // editor = new AccountTableCellEditor(); 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellEditor.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -49,13 +49,14 @@ implements TableCellEditor, FocusListener, AncestorListener, KeyListener { private static final Log log = LogFactory.getLog(BigDecimalTableCellEditor.class); + private static final long serialVersionUID = 1L; + protected final JTextField textField; + private boolean keyPressed; - /** - * constructor - */ + /** constructor */ public BigDecimalTableCellEditor() { textField = new JTextField(); textField.setEditable(true); @@ -65,10 +66,10 @@ textField.addKeyListener(this); keyPressed = false; } - + @Override public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { + boolean isSelected, int row, int column) { textField.setText(value.toString()); return textField; } @@ -92,39 +93,37 @@ } //round half up the number using the scale given by the configuration bdValue = bdValue.setScale(LimaContext.getContext().getConfig().getScale(), - BigDecimal.ROUND_HALF_UP); + BigDecimal.ROUND_HALF_UP); return bdValue; } } - + @Override public boolean isCellEditable(EventObject evt) { return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } - - /** - * Listeners - */ + + /** Listeners */ @Override public void focusGained(FocusEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { textField.selectAll(); - } + } }); } - + @Override public void focusLost(FocusEvent e) { keyPressed = false; } - + @Override public void ancestorAdded(AncestorEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { textField.requestFocus(); - } + } }); } @@ -143,19 +142,19 @@ @Override public void keyPressed(KeyEvent e) { - } + } @Override public void keyReleased(KeyEvent e) { // replace all the cell content only if all the text has been selected if (!keyPressed - && textField.getSelectionStart() == 0 - && textField.getSelectionEnd() == textField.getText().length()) { + && 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 + // 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -38,14 +38,13 @@ public class BigDecimalTableCellRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = -2499433026151065390L; - + public BigDecimalTableCellRenderer() { // } - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); @@ -53,7 +52,7 @@ setValue(value); return this; } - + public void setValue(Object aValue) { Object result = aValue; if (aValue != null && aValue instanceof BigDecimal) { @@ -72,7 +71,7 @@ formatter.setGroupingUsed(true); formatter.setGroupingSize(3); result = formatter.format(result); - } + } super.setValue(result); } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,35 +29,32 @@ import org.chorem.lima.LimaContext; import org.jdesktop.swingx.JXDatePicker; -import javax.swing.*; +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.SwingUtilities; 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.MouseEvent; - import java.util.Date; import java.util.EventObject; -/** - * @author ore - */ +/** @author ore */ public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor, FocusListener, AncestorListener { private final JXDatePicker datePicker; + private static final long serialVersionUID = 1L; // private static DateTableCellEditor editor; - + //used to tell if the user has pressed a key private Date date; - /** - * constructor - */ + /** constructor */ public DateTableCellEditor() { datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale()); datePicker.getEditor().addFocusListener(this); @@ -88,7 +85,7 @@ } //month if (str.length > 1) { - date = DateUtils.setMonths(date, Integer.valueOf(str[1])-1); + date = DateUtils.setMonths(date, Integer.valueOf(str[1]) - 1); } //year if (str.length > 2) { @@ -110,18 +107,16 @@ // } // return editor; // } - - /** - * Listeners - */ + + /** Listeners */ public void focusGained(FocusEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { datePicker.getEditor().selectAll(); - } + } }); } - + public void focusLost(FocusEvent e) { } @@ -130,7 +125,7 @@ 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EmptyCellRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -37,11 +37,10 @@ @SuppressWarnings("restriction") public class EmptyCellRenderer extends DefaultTableCellRenderer { - private static final long serialVersionUID = -7834417406160620726L; + private static final long serialVersionUID = -7834417406160620726L; - public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) { //Create a new JLabel to avoid colouring only when row is selected JLabel mycell = new JLabel(); mycell.setOpaque(true); @@ -56,7 +55,7 @@ } //Setting default foreGround and backGround colours when hasFocus if (hasFocus) { - Border border = null; + Border border = null; if (isSelected) { border = DefaultLookup.getBorder(this, ui, "Table.focusSelectedCellHighlightBorder"); } @@ -74,11 +73,11 @@ if (String.valueOf(value).isEmpty() || String.valueOf(value) == null) { mycell.setBackground(new Color(255, 198, 209)); } else { - mycell.setText(value.toString()); + mycell.setText(value.toString()); } - } else { - mycell.setBackground(new Color(255, 198, 209)); - } + } else { + mycell.setBackground(new Color(255, 198, 209)); + } } return mycell; } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/LetterTableCellEditor.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,14 +28,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Letter; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; import javax.swing.AbstractCellEditor; import javax.swing.JTable; +import javax.swing.ListCellRenderer; import javax.swing.SwingUtilities; import javax.swing.table.TableCellEditor; import javax.swing.text.JTextComponent; @@ -48,6 +50,7 @@ public class LetterTableCellEditor extends AbstractCellEditor implements TableCellEditor, KeyListener { protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class); + private static final long serialVersionUID = 1L; private final JWideComboBox comboBox; @@ -55,14 +58,13 @@ private static boolean keyPressed; - /** - * constructor - */ + /** constructor */ public LetterTableCellEditor() { comboBox = new JWideComboBox(); LetterComboBoxModel comboBoxModel = new LetterComboBoxModel(); comboBox.setModel(comboBoxModel); - LetterRenderer renderer = new LetterRenderer(); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(Letter.class); comboBox.setRenderer(renderer); AutoCompleteDecorator.decorate(comboBox, LetterToString.getInstance()); comboBox.getEditor().getEditorComponent().addKeyListener(this); @@ -70,9 +72,9 @@ @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (value instanceof Account){ + if (value instanceof Account) { comboBox.setSelectedItem(value); - } + } return comboBox; } @@ -80,28 +82,28 @@ 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 */ - @Override + @Override public boolean isCellEditable(EventObject evt) { // Si il y a une frappe au clavier 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())); } } @@ -112,37 +114,35 @@ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2; } - + @Override public void keyPressed(KeyEvent e) { - + } - + @Override public void keyReleased(KeyEvent e) { - + // Vérifie si c'est la première frappe au clavier - if (!keyPressed) - { + 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 edit.select(1, edit.getText().length()); keyPressed = true; } - + // delegate popup list menu - if ( e.getKeyChar() == KeyEvent.VK_ENTER ) - { + if (e.getKeyChar() == KeyEvent.VK_ENTER) { fireEditingStopped(); } } - + @Override public void keyTyped(KeyEvent e) { - + } - + // public static LetterTableCellEditor getInstance() { // if (editor == null) { // editor = new LetterTableCellEditor(); 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -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.AccountServiceMonitorable; @@ -38,42 +35,44 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; -/** - * Account combo box model. - */ +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.List; +/** Account combo box model. */ + public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); - + LogFactory.getLog(FinancialPeriodTableModel.class); + protected Object selectedAccount; - + protected List<Account> datasCache; - + protected AccountServiceMonitorable accountService; - - public AccountComboBoxModel () { + + public AccountComboBoxModel() { accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } - + @Override public Object getSelectedItem() { - return selectedAccount; + return selectedAccount; } @Override public void setSelectedItem(Object anItem) { selectedAccount = anItem; - fireContentsChanged(this, -1, -1); + fireContentsChanged(this, -1, -1); } @@ -84,34 +83,33 @@ @Override public int getSize() { - return datasCache.size(); + return datasCache.size(); } - public List<Account> getDataList(){ + public List<Account> getDataList() { List<Account> result = null; try { result = accountService.getAllAccounts(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ + } catch (LimaException eee) { + if (log.isDebugEnabled()) { log.debug("Can't get list accounts", eee); } } return result; - + } - - public void refresh(){ + + public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Account") || methodeName.contains("importAll")){ + if (methodeName.contains("Account") || methodeName.contains("importAll")) { refresh(); - } + } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -43,7 +43,7 @@ boolean isSelected, boolean cellHasFocus) { - JLabel label = (JLabel) super.getListCellRendererComponent(list, + JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -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.EntryBookServiceMonitorable; @@ -38,32 +35,36 @@ 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; + /** * Opened financial period combo box model. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class EntryBookComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); - + LogFactory.getLog(FinancialPeriodTableModel.class); + protected Object selectedEntryBook; - + protected EntryBookServiceMonitorable entryBookService; protected List<EntryBook> cacheDatas; - + public EntryBookComboBoxModel() { entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); entryBookService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); @@ -72,12 +73,12 @@ @Override public int getSize() { - return cacheDatas.size(); + return cacheDatas.size(); } @Override public Object getElementAt(int index) { - return cacheDatas.get(index); + return cacheDatas.get(index); } @Override @@ -90,32 +91,29 @@ public Object getSelectedItem() { return selectedEntryBook; } - - /** - * get the accounts list - */ - public List<EntryBook> getDataList(){ - List<EntryBook> result = null; - try { - result = entryBookService.getAllEntryBooks(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't get list accounts", eee); - } - } - return result; + + /** get the accounts list */ + public List<EntryBook> getDataList() { + List<EntryBook> result = null; + try { + result = entryBookService.getAllEntryBooks(); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't get list accounts", eee); + } + } + return result; } - - - public void refresh(){ + + + public void refresh() { cacheDatas = getDataList(); fireContentsChanged(this, 0, cacheDatas.size()); } @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("EntryBook") || methodeName.contains("importAll")){ + if (methodeName.contains("EntryBook") || methodeName.contains("importAll")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -32,6 +32,7 @@ import javax.swing.JList; import java.awt.Component; +@Deprecated public class EntryBookRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -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.FinancialPeriodServiceMonitorable; @@ -40,76 +37,76 @@ 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; + /** * Opened financial period combo box model. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedFinancialPeriod; - + protected List<FinancialPeriod> datasCache; - + protected FinancialPeriodServiceMonitorable financialPeriodService; - + protected FiscalPeriod selectedFiscalPeriod; - + private boolean displayAllPeriods; - /** - * Constructor for locked period list. - */ + /** Constructor for locked period list. */ public FinancialPeriodComboBoxModel() { this(false); } /** * Constructor for period list. - * + * * @param all if {@code true}, display all available period, otherwize - * display only locked ones + * display only locked ones */ public FinancialPeriodComboBoxModel(boolean displayAllPeriods) { - + this.displayAllPeriods = displayAllPeriods; - - financialPeriodService = - LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + + financialPeriodService = + LimaServiceFactory.getInstance().getService( + FinancialPeriodServiceMonitorable.class); financialPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); if (displayAllPeriods) { - datasCache=getAllDataList(); + datasCache = getAllDataList(); + } else { + datasCache = getDataList(); } - else { - datasCache=getDataList(); - } - } + } - public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ - selectedFiscalPeriod=fiscalPeriod; + public void setFiscalPeriod(FiscalPeriod fiscalPeriod) { + selectedFiscalPeriod = fiscalPeriod; if (displayAllPeriods) { - datasCache=getAllDataList(); + datasCache = getAllDataList(); + } else { + datasCache = getDataList(); } - else { - datasCache=getDataList(); - } fireContentsChanged(this, 0, datasCache.size()); } - + @Override public int getSize() { return datasCache.size(); @@ -129,51 +126,47 @@ public Object getSelectedItem() { return selectedFinancialPeriod; } - + //get unblocked financial periods data list - public List<FinancialPeriod> getDataList(){ + public List<FinancialPeriod> getDataList() { List<FinancialPeriod> result = null; try { - if (selectedFiscalPeriod != null){ + if (selectedFiscalPeriod != null) { result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - } - else { + } else { result = financialPeriodService.getUnblockedFinancialPeriods(); } - } - catch (LimaException ex) { - if (log.isDebugEnabled()){ - log.debug("Can't get Financial Period list",ex); + } catch (LimaException ex) { + if (log.isDebugEnabled()) { + log.debug("Can't get Financial Period list", ex); } } - return result; + return result; } - + //get all financial periods data list public List<FinancialPeriod> getAllDataList() { - List<FinancialPeriod> result = null; + List<FinancialPeriod> result = null; try { - if (selectedFiscalPeriod != null){ + if (selectedFiscalPeriod != null) { result = financialPeriodService.getFinancialPeriods(selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); - } - else { + } else { result = financialPeriodService.getAllFinancialPeriods(); } - } - catch (LimaException ex) { - if (log.isDebugEnabled()){ - log.debug("Can't get Financial Period list",ex); + } catch (LimaException ex) { + if (log.isDebugEnabled()) { + log.debug("Can't get Financial Period list", ex); } } - return result; + return result; } - - - public void refresh(){ + + + public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } - + public void refreshAll() { datasCache = getAllDataList(); fireContentsChanged(this, 0, datasCache.size()); @@ -181,13 +174,12 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("Period") || methodeName.contains("importAll")){ + if (serviceName.contains("Period") || methodeName.contains("importAll")) { if (displayAllPeriods) { - datasCache=getAllDataList(); + datasCache = getAllDataList(); + } else { + datasCache = getDataList(); } - else { - datasCache=getDataList(); - } - } + } } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -33,7 +33,7 @@ import java.awt.Component; import java.text.SimpleDateFormat; - +@Deprecated public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -39,40 +39,40 @@ import javax.swing.ComboBoxModel; import java.util.List; -public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener{ +public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); protected Object selectedFiscalPeriod; - + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + protected List<FiscalPeriod> datasCache; //constructor for blocked fiscal period only - public FiscalPeriodComboBoxModel(){ + public FiscalPeriodComboBoxModel() { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } - + //constructor for all fiscal period public FiscalPeriodComboBoxModel(boolean all) { - fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + fiscalPeriodService = + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); datasCache = getAllDataList(); - } - + } + @Override public int getSize() { return datasCache.size(); @@ -93,50 +93,48 @@ public Object getSelectedItem() { return selectedFiscalPeriod; } - + //get unblocked fiscal periods data list - public List<FiscalPeriod> getDataList(){ + public List<FiscalPeriod> getDataList() { List<FiscalPeriod> result = null; try { result = fiscalPeriodService.getAllUnblockedFiscalPeriods(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ + } catch (LimaException eee) { + if (log.isDebugEnabled()) { log.debug("Can't get list accounts", eee); } } return result; - + } - + //get all fiscal periods data list public List<FiscalPeriod> getAllDataList() { - List<FiscalPeriod> result = null; - try { - result = fiscalPeriodService.getAllFiscalPeriods(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()) { - log.debug("Can't get list accounts", eee); - } - } - return result; + List<FiscalPeriod> result = null; + try { + result = fiscalPeriodService.getAllFiscalPeriods(); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't get list accounts", eee); + } + } + return result; } - - public void refresh(){ + + public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } - + public void refreshAll() { - datasCache = getAllDataList(); - fireContentsChanged(this, 0, datasCache.size()); + datasCache = getAllDataList(); + fireContentsChanged(this, 0, datasCache.size()); } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + if (serviceName.contains("FiscalPeriod") || methodeName.contains("importAll")) { refresh(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -33,6 +33,7 @@ import java.awt.Component; import java.text.SimpleDateFormat; +@Deprecated public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -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.FinancialTransactionServiceMonitorable; @@ -38,42 +35,44 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; -/** - * Account combo box model. - */ +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.List; +/** Account combo box model. */ + public class LetterComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - + private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); - + LogFactory.getLog(FinancialPeriodTableModel.class); + protected Object selectedAccount; - + protected List<Letter> datasCache; - + protected FinancialTransactionServiceMonitorable service; - - public LetterComboBoxModel () { + + public LetterComboBoxModel() { service = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); service.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } - + @Override public Object getSelectedItem() { - return selectedAccount; + return selectedAccount; } @Override public void setSelectedItem(Object anItem) { selectedAccount = anItem; - fireContentsChanged(this, -1, -1); + fireContentsChanged(this, -1, -1); } @@ -84,34 +83,33 @@ @Override public int getSize() { - return datasCache.size(); + return datasCache.size(); } - public List<Letter> getDataList(){ + public List<Letter> getDataList() { List<Letter> result = null; try { result = service.getAllLetters(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ + } catch (LimaException eee) { + if (log.isDebugEnabled()) { log.debug("Can't get list letters", eee); } } return result; - + } - - public void refresh(){ + + public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Letter") || methodeName.contains("importAll")){ + if (methodeName.contains("Letter") || methodeName.contains("importAll")) { refresh(); - } + } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -32,6 +32,7 @@ import javax.swing.JList; import java.awt.Component; +@Deprecated public class LetterRenderer extends DefaultListCellRenderer { private static final long serialVersionUID = 1L; 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/SubAccountComboBoxModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,10 +25,6 @@ package org.chorem.lima.ui.combobox; -import java.util.ArrayList; -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.AccountServiceMonitorable; @@ -38,35 +34,38 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; -/** - * Account combo box model. - */ +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.ArrayList; +import java.util.List; +/** Account combo box model. */ + public class SubAccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { - + private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(SubAccountComboBoxModel.class); - + protected Object selectedAccount; - + protected List<Account> datasCache; - + protected AccountServiceMonitorable accountService; - + public SubAccountComboBoxModel() { accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); datasCache = getDataList(); } - + @Override public Object getSelectedItem() { - return selectedAccount; + return selectedAccount; } @Override @@ -77,7 +76,7 @@ @Override public Object getElementAt(int index) { - return datasCache.get(index); + return datasCache.get(index); } @Override @@ -85,31 +84,30 @@ return datasCache.size(); } - public List<Account> getDataList(){ + public List<Account> getDataList() { List<Account> result = new ArrayList<Account>(); try { result = accountService.getAllSubAccounts(); - } - catch (LimaException eee) { - if (log.isDebugEnabled()){ + } catch (LimaException eee) { + if (log.isDebugEnabled()) { log.debug("Can't get list subaccounts", eee); } } return result; - + } - - public void refresh(){ + + public void refresh() { datasCache = getDataList(); fireContentsChanged(this, 0, datasCache.size()); } @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("Account") || methodeName.contains("importAll")){ + if (serviceName.contains("Account") || methodeName.contains("importAll")) { refresh(); - } + } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,34 +24,34 @@ */ package org.chorem.lima.ui.entrybook; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTable; + import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTable; - public class EntryBookTable extends JXTable implements KeyListener, MouseListener { - /** serialVersionUID. */ - private static final long serialVersionUID = 6228396251512013262L; - - /** log. */ + /** serialVersionUID. */ + private static final long serialVersionUID = 6228396251512013262L; + + /** log. */ private static final Log log = LogFactory .getLog(EntryBookTable.class); - + protected EntryBookViewHandler handler; - + public EntryBookTable(EntryBookViewHandler handler) { - + this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + } @Override @@ -89,9 +89,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,8 +25,6 @@ package org.chorem.lima.ui.entrybook; -import static org.nuiton.i18n.I18n._; -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.EntryBookServiceMonitorable; @@ -36,15 +34,19 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.service.LimaServiceFactory; +import javax.swing.table.AbstractTableModel; + +import static org.nuiton.i18n.I18n._; + /** * Entry book table model. - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class EntryBookTableModel extends AbstractTableModel implements ServiceListener { @@ -57,28 +59,26 @@ /** Services. */ protected EntryBookServiceMonitorable entryBookService; - /** - * Constructor. - */ + /** Constructor. */ public EntryBookTableModel() { entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); LimaServiceFactory.getInstance().getService(ImportServiceMonitorable.class).addServiceListener(this); - } + } @Override public int getRowCount() { int result = 0; - + try { result = entryBookService.getAllEntryBooks().size(); } catch (LimaException e) { - if (log.isDebugEnabled()){ - log.debug("Can't get all entrybooks",e); + if (log.isDebugEnabled()) { + log.debug("Can't get all entrybooks", e); } } - + return result; } @@ -104,7 +104,7 @@ public EntryBook getEntryBookAtRow(int row) throws LimaException { EntryBook entryBook; entryBook = entryBookService.getAllEntryBooks().get(row); - + return entryBook; } @@ -124,8 +124,8 @@ break; } } catch (LimaException eee) { - if (log.isDebugEnabled()){ - log.debug("Can't get EntryBook",eee); + if (log.isDebugEnabled()) { + log.debug("Can't get EntryBook", eee); } } @@ -140,7 +140,7 @@ /** * @param entryBook - * @throws LimaException + * @throws LimaException */ public void addEntryBook(EntryBook entryBook) throws LimaException { /* Calling journal service */ @@ -150,7 +150,6 @@ } /** - * * @param entryBook * @throws LimaException */ @@ -162,9 +161,8 @@ } /** - * * @param entryBook - * @throws LimaException + * @throws LimaException */ public void removeEntryBook(EntryBook entryBook) throws LimaException { /* Calling journal service */ @@ -172,14 +170,14 @@ entryBookService.removeEntryBook(entryBook); fireTableRowsDeleted(row, row); } - + @Override public void notifyMethod(String serviceName, String methodeName) { - + //refresh on import datas if (methodeName.contains("importEntryBooks") - || methodeName.contains("importAll") - || methodeName.contains("importAs")){ + || methodeName.contains("importAll") + || methodeName.contains("importAs")) { fireTableDataChanged(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,9 +25,6 @@ package org.chorem.lima.ui.entrybook; -import static org.nuiton.i18n.I18n._; - -import javax.swing.JOptionPane; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.EntryBookServiceMonitorable; @@ -42,35 +39,39 @@ import org.chorem.lima.util.DialogHelper; import org.jdesktop.swingx.JXTable; +import javax.swing.JOptionPane; + +import static org.nuiton.i18n.I18n._; + /** * Handler for entry book view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class EntryBookViewHandler { private static final Log log = LogFactory.getLog(EntryBookViewHandler.class); - + protected EntryBookView view; - + protected EntryBookService entryBookService; - + public EntryBookViewHandler(EntryBookView view) { this.view = view; entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); - } - + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); + } + public void addEntryBook() { JXTable entryBookTable = view.getEntryBooksTable(); EntryBookTableModel entryBookTableModel = - (EntryBookTableModel)entryBookTable.getModel(); + (EntryBookTableModel) entryBookTable.getModel(); EntryBook newEntryBook = new EntryBookImpl(); EntryBookForm entryBookForm = new EntryBookForm(view); @@ -78,7 +79,7 @@ // jaxx constructor don't call super() ? entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); - + // null == cancel action newEntryBook = entryBookForm.getEntryBook(); if (newEntryBook != null) { @@ -100,18 +101,18 @@ JXTable entryBookTable = view.getEntryBooksTable(); int selectedRow = entryBookTable.getSelectedRow(); EntryBookTableModel entryBookTableModel = - (EntryBookTableModel)entryBookTable.getModel(); + (EntryBookTableModel) entryBookTable.getModel(); // add it try { EntryBook selectedEntryBook = - entryBookTableModel.getEntryBookAtRow(selectedRow); + entryBookTableModel.getEntryBookAtRow(selectedRow); EntryBookForm entryBookForm = new EntryBookForm(view); entryBookForm.setEntryBook(selectedEntryBook); // jaxx constructor don't call super() ? entryBookForm.setLocationRelativeTo(view); entryBookForm.setVisible(true); - + // null == cancel action selectedEntryBook = entryBookForm.getEntryBook(); if (selectedEntryBook != null) { @@ -129,19 +130,19 @@ JXTable entryBookTable = view.getEntryBooksTable(); int selectedRow = entryBookTable.getSelectedRow(); EntryBookTableModel entryBookTableModel = - (EntryBookTableModel)entryBookTable.getModel(); + (EntryBookTableModel) entryBookTable.getModel(); // add it try { EntryBook selectedEntryBook = - entryBookTableModel.getEntryBookAtRow(selectedRow); - + entryBookTableModel.getEntryBookAtRow(selectedRow); + int response = JOptionPane.showConfirmDialog(view, - _("lima.charts.entrybook.confirmation", - selectedEntryBook.getLabel()), - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + _("lima.charts.entrybook.confirmation", + selectedEntryBook.getLabel()), + _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { entryBookTableModel.removeEntryBook(selectedEntryBook); @@ -153,25 +154,25 @@ DialogHelper.showMessageDialog(eee.getMessage()); } } - - - public void importEntryBooks(){ - + + + public void importEntryBooks() { + EntryBookImportForm form = - new EntryBookImportForm(); + new EntryBookImportForm(); form.setLocationRelativeTo(view); form.setVisible(true); Object value = form.getRadioButtons().getSelectedValue(); // if action confirmed - if (value != null){ + if (value != null) { EntryBooksChartEnum defaultEntryBooksEnum = - (EntryBooksChartEnum) value; + (EntryBooksChartEnum) value; ImportExport importExport = ImportExport.getInstance(view); importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, - defaultEntryBooksEnum.getFilePath(), true); + defaultEntryBooksEnum.getFilePath(), true); } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -43,10 +43,10 @@ private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(EntryBookComboBox.class); - + LogFactory.getLog(EntryBookComboBox.class); + protected EntryBooksReportsViewHandler handler; - + public EntryBookComboBox(EntryBooksReportsViewHandler handler) { this.handler = handler; EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); @@ -58,30 +58,30 @@ addActionListener(this); } - public void back(){ + public void back() { int row = getSelectedIndex(); log.debug(row); - if (row > 0){ - getEditor().setItem(getItemAt(row-1)); + if (row > 0) { + getEditor().setItem(getItemAt(row - 1)); handler.setEntryBook((EntryBook) getSelectedItem()); } } - - public void next(){ + + public void next() { int size = getModel().getSize(); int row = getSelectedIndex(); log.debug(row); - - if (row < size-1){ - getEditor().setItem(getItemAt(row+1)); + + if (row < size - 1) { + getEditor().setItem(getItemAt(row + 1)); handler.setEntryBook((EntryBook) getSelectedItem()); } } - + @Override public void actionPerformed(ActionEvent e) { Object object = getSelectedItem(); - if (object instanceof EntryBook){ + if (object instanceof EntryBook) { handler.setEntryBook((EntryBook) getSelectedItem()); } } @@ -89,25 +89,24 @@ @Override public void keyPressed(KeyEvent e) { - + } @Override public void keyReleased(KeyEvent e) { Object object = getSelectedItem(); - if (object instanceof EntryBook){ + 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/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.entrybooksreports; -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; @@ -40,120 +32,131 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 EntryBooksReportsPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(EntryBooksReportsPeriodSearchPanel.class); - + LogFactory.getLog(EntryBooksReportsPeriodSearchPanel.class); + protected EntryBooksReportsViewHandler handler; - + public EntryBooksReportsPeriodSearchPanel(EntryBooksReportsViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + // 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(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + 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(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + 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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + 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/entrybooksreports/EntryBooksReportsTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.entrybooksreports; -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 org.chorem.lima.entity.Entry; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; @@ -42,21 +34,29 @@ 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; + public class EntryBooksReportsTable extends JXTable - implements KeyListener, MouseListener { + implements KeyListener, MouseListener { /** serialVersionUID. */ private static final long serialVersionUID = 1L; protected EntryBooksReportsViewHandler handler; - + protected EntryBooksReportsTableModel model; - + private Highlighter colorReportsDatas; - + private FinancialTransaction oldRow; - + private Boolean highlighterReportsDatasBoolean; /** @@ -65,11 +65,11 @@ this.handler = handler; this.model = model; - + addKeyListener(this); addMouseListener(this); - - highlighterReportsDatasBoolean=true; + + highlighterReportsDatasBoolean = true; //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); //highlight financial financial transactions @@ -82,28 +82,28 @@ * afin de bien distinguer les entête de comptes et les entrées comptables. * On récupère la première cellule, on vérifie que c'est pas null */ - protected void addColorReportsDatas() { - if (colorReportsDatas != null) { - removeHighlighter(colorReportsDatas); - } - HighlightPredicate predicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { - Entry entry = model.getElementAt(adapter.row); - FinancialTransaction financialTransaction = entry.getFinancialTransaction(); - if (financialTransaction != oldRow){ - highlighterReportsDatasBoolean = !highlighterReportsDatasBoolean; - } - oldRow = financialTransaction; - if (adapter.row ==0){ - highlighterReportsDatasBoolean=false; - } - return highlighterReportsDatasBoolean; - } - }; - colorReportsDatas = - new ColorHighlighter(predicate, new Color(222,222,222), null); + protected void addColorReportsDatas() { + if (colorReportsDatas != null) { + removeHighlighter(colorReportsDatas); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + Entry entry = model.getElementAt(adapter.row); + FinancialTransaction financialTransaction = entry.getFinancialTransaction(); + if (financialTransaction != oldRow) { + highlighterReportsDatasBoolean = !highlighterReportsDatasBoolean; + } + oldRow = financialTransaction; + if (adapter.row == 0) { + highlighterReportsDatasBoolean = false; + } + return highlighterReportsDatasBoolean; + } + }; + colorReportsDatas = + new ColorHighlighter(predicate, new Color(222, 222, 222), null); addHighlighter(colorReportsDatas); } @@ -142,9 +142,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.entrybooksreports; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.beans.ReportsDatas; @@ -39,7 +32,14 @@ import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.Letter; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import static org.nuiton.i18n.I18n._; + + /** * Entry book table model. * By : $Author$ @@ -51,14 +51,14 @@ /** log. */ private static final Log log = LogFactory.getLog(EntryBooksReportsTableModel.class); - + /** data cache */ protected ReportsDatas cacheDataList; @Override public int getRowCount() { int result = 0; - + // just prevent too much result if (cacheDataList != null && cacheDataList.getListEntry() != null) { result = cacheDataList.getListEntry().size(); @@ -71,34 +71,34 @@ public int getColumnCount() { return 7; } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = Date.class; - break; - case 1: - result = Account.class; - break; - case 2: - result = String.class; - break; - case 3: - result = String.class; - break; - case 4: - result = Letter.class; - break; - case 5: - result = BigDecimal.class; - break; - case 6: - result = BigDecimal.class; - break; + case 0: + result = Date.class; + break; + case 1: + result = Account.class; + break; + case 2: + result = String.class; + break; + case 3: + result = String.class; + break; + case 4: + result = Letter.class; + break; + case 5: + result = BigDecimal.class; + break; + case 6: + result = BigDecimal.class; + break; } return result; @@ -122,7 +122,7 @@ break; case 4: res = _("lima.table.letter"); - break; + break; case 5: res = _("lima.table.debit"); break; @@ -136,21 +136,20 @@ @Override public Object getValueAt(int row, int column) { Object result = null; - if(cacheDataList.getListEntry() != null) { + if (cacheDataList.getListEntry() != null) { Entry currentRow = cacheDataList.getListEntry().get(row); SimpleDateFormat simpleDateFormat = - new SimpleDateFormat("dd MMMMM yyyy"); - + new SimpleDateFormat("dd MMMMM yyyy"); + switch (column) { case 0: result = simpleDateFormat. - format(currentRow.getFinancialTransaction().getTransactionDate()); + format(currentRow.getFinancialTransaction().getTransactionDate()); break; case 1: - if (currentRow.getAccount() != null){ + if (currentRow.getAccount() != null) { result = currentRow.getAccount().getAccountNumber(); - } - else { + } else { result = null; } break; @@ -161,10 +160,9 @@ result = currentRow.getDescription(); break; case 4: - if (currentRow.getLetter() != null){ + if (currentRow.getLetter() != null) { result = currentRow.getLetter().getCode(); - } - else { + } else { result = null; } break; @@ -175,8 +173,7 @@ result = currentRow.getDebit() ? BigDecimal.ZERO : currentRow.getAmount(); break; } - } - else { + } else { if (log.isDebugEnabled()) { log.debug("No EntryBook selected skip table model update"); } @@ -185,20 +182,20 @@ return result; } - public Entry getElementAt(int row){ + public Entry getElementAt(int row) { return cacheDataList.getListEntry().get(row); } - + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { // Just read, no write return false; } - - public void refresh(ReportsDatas datasList){ + + public void refresh(ReportsDatas datasList) { cacheDataList = datasList; fireTableDataChanged(); } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,19 +25,6 @@ package org.chorem.lima.ui.entrybooksreports; -import static org.nuiton.i18n.I18n._; -import java.awt.Desktop; -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; @@ -57,7 +44,20 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; +import javax.swing.JOptionPane; +import java.awt.Desktop; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import static org.nuiton.i18n.I18n._; + + /** * Handler associated with accounts reports view. * By : $Author$ @@ -65,131 +65,129 @@ public class EntryBooksReportsViewHandler implements ServiceListener { protected EntryBooksReportsView view; - + protected EntryBooksReportsTable table; - + protected EntryBooksReportsTableModel tableModel; - + /** log. */ private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class); - + /** Services. */ protected ReportServiceMonitorable reportService; + protected DocumentServiceMonitorable documentService; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + /** Account. */ protected EntryBook selectedEntryBook; - + /** Begin Date. */ protected Date selectedBeginDate; - + /** EndDate. */ protected Date selectedEndDate; - + protected int port; - + private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - + new SimpleDateFormat("yyyy-MM-dd"); + protected EntryBooksReportsViewHandler(EntryBooksReportsView view) { this.view = view; - + reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class).addServiceListener(this); } - - public void setBeginDate(Date date){ + + public void setBeginDate(Date date) { selectedBeginDate = date; refresh(); } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { selectedEndDate = date; refresh(); } - + public void setEntryBook(EntryBook entryBook) { selectedEntryBook = entryBook; refresh(); } - - public ReportsDatas getDataList(){ + + public ReportsDatas getDataList() { ReportsDatas results = null; - if (selectedEntryBook != null){ + if (selectedEntryBook != null) { try { results = - reportService.generateEntryBooksReports( - selectedEntryBook, selectedBeginDate, selectedEndDate); - } - catch (LimaException eee) { + reportService.generateEntryBooksReports( + selectedEntryBook, selectedBeginDate, selectedEndDate); + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.entrybooksreports.listerror"), eee); - } + } } return results; } - - public void refresh(){ - - if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null){ + + public void refresh() { + + if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null) { tableModel = view.getModelTable(); - + ReportsDatas datasList = getDataList(); - - tableModel.refresh(datasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (datasList != null){ + + tableModel.refresh(datasList); + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (datasList != null) { // set amounts credit, debit and solde view.amountCreditLabel.setText( String.valueOf(datasList.getAmountCredit())); view.amountDebitLabel.setText( - String.valueOf(datasList.getAmountDebit())); + String.valueOf(datasList.getAmountDebit())); BigDecimal amountSolde = datasList.getAmountSolde(); view.amountSoldeLabel.setText(String.valueOf(amountSolde)); - - if (amountSolde == BigDecimal.ZERO){ + + if (amountSolde == BigDecimal.ZERO) { view.soldeLabel.setText(_("lima.common.solde")); - } - else { + } else { // set label solde: credit or debit if (datasList.getSoldeDebit()) { view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { + } else { view.soldeLabel.setText(_("lima.common.soldecredit")); } } } } } - - - + + public void createDocument() { - - if (selectedBeginDate != null && selectedEndDate != null){ - + + if (selectedBeginDate != null && selectedEndDate != null) { + //looks for all blocked fiscal periods List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); try { @@ -200,18 +198,18 @@ } ErrorHelper.showErrorDialog(_("lima.entrybooksreports.documentcreationerror"), eee); } - + //tells if the fiscaPeriod as been found and is blocked boolean error = true; - + for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate) - && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) - && blockedFiscalPeriod.getLocked()) { + && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) + && blockedFiscalPeriod.getLocked()) { error = false; } } - + //shows error message to user if the fiscalPeriod is unblocked if (error) { JOptionPane.showMessageDialog( @@ -220,25 +218,25 @@ _("lima.common.error"), JOptionPane.ERROR_MESSAGE); } else { - + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); String address = LimaConfig.getInstance().getHostAdress(); - + try { - String url = "http://"+address+":"+port+"/?beginDate=" - + dateFormat.format(selectedBeginDate) - + "&endDate="+dateFormat.format(selectedEndDate) - + "&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.ENTRYBOOKS.getFileName(); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(selectedBeginDate) + + "&endDate=" + dateFormat.format(selectedEndDate) + + "&format=" + selectedEnum.getExtension() + "&model=" + + DocumentsEnum.ENTRYBOOKS.getFileName(); Desktop.getDesktop().browse(new URI(url)); - - String url2 = "http://"+address+":"+port+"/?beginDate=" - + dateFormat.format(selectedBeginDate) - + "&endDate="+dateFormat.format(selectedEndDate) - + "&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); - Desktop.getDesktop().browse(new URI(url2)); - + + String url2 = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(selectedBeginDate) + + "&endDate=" + dateFormat.format(selectedEndDate) + + "&format=" + selectedEnum.getExtension() + "&model=" + + DocumentsEnum.GENERAL_ENTRYBOOK.getFileName(); + Desktop.getDesktop().browse(new URI(url2)); + } catch (IOException e) { log.error("Can't open browser", e); } catch (URISyntaxException e) { @@ -247,12 +245,12 @@ } } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")) { refresh(); } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.financialperiod; -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.text.SimpleDateFormat; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialPeriodServiceMonitorable; @@ -47,36 +39,44 @@ 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.text.SimpleDateFormat; + public class FinancialPeriodTable extends JXTable implements KeyListener, MouseListener { - + private static final long serialVersionUID = -1960326844433064178L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); - + LogFactory.getLog(FinancialPeriodTableModel.class); + protected FinancialPeriodViewHandler handler; - + protected FinancialPeriodTableModel model; - + protected FinancialPeriodService financialPeriodService; - + private Highlighter colorTransaction; - + /* - * Constructor, call highlighter - */ + * Constructor, call highlighter + */ public FinancialPeriodTable(FinancialPeriodViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + model = this.handler.getView().modelFinancialPeriodTable; financialPeriodService = - LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialPeriodServiceMonitorable.class); //highlight financial financial transactions addMonthColor(); @@ -90,50 +90,50 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { ClosedPeriodicEntryBook closedPeriodicEntryBook - = (ClosedPeriodicEntryBook) model.getElementAt(adapter.row); + = (ClosedPeriodicEntryBook) model.getElementAt(adapter.row); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM"); int month = Integer.parseInt(simpleDateFormat.format( closedPeriodicEntryBook.getFinancialPeriod().getBeginDate())); // true if month is even - return month % 2 ==0; - + return month % 2 == 0; + } }; - colorTransaction = - new ColorHighlighter(predicate, new Color(222,222,222), null); - addHighlighter(colorTransaction); - } - + colorTransaction = + new ColorHighlighter(predicate, new Color(222, 222, 222), null); + addHighlighter(colorTransaction); + } + /* - * Color the font in red if period are closed - */ + * Color the font in red if period are closed + */ protected void addBlockColor() { HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { ClosedPeriodicEntryBook closedPeriodicEntryBook = - new ClosedPeriodicEntryBookImpl(); + new ClosedPeriodicEntryBookImpl(); ClosedPeriodicEntryBook selectedClosedPeriodicEntryBook = - (ClosedPeriodicEntryBook) model.getElementAt(adapter.row); + (ClosedPeriodicEntryBook) model.getElementAt(adapter.row); // true if locked try { closedPeriodicEntryBook = - financialPeriodService.getClosedPeriodicEntryBook( - selectedClosedPeriodicEntryBook.getEntryBook(), - selectedClosedPeriodicEntryBook.getFinancialPeriod()); + financialPeriodService.getClosedPeriodicEntryBook( + selectedClosedPeriodicEntryBook.getEntryBook(), + selectedClosedPeriodicEntryBook.getFinancialPeriod()); } catch (LimaException eee) { - log.debug("Can't get closePeriodicEntryBook",eee); + log.debug("Can't get closePeriodicEntryBook", eee); } return closedPeriodicEntryBook.getLocked(); } }; - colorTransaction = - new ColorHighlighter(predicate, null, new Color(222,0,0)); - addHighlighter(colorTransaction); - } + colorTransaction = + new ColorHighlighter(predicate, null, new Color(222, 0, 0)); + addHighlighter(colorTransaction); + } @Override public void mouseClicked(MouseEvent e) { @@ -170,14 +170,14 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } @Override public void keyReleased(KeyEvent e) { } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,12 +25,6 @@ package org.chorem.lima.ui.financialperiod; -import static org.nuiton.i18n.I18n._; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -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.FinancialPeriodServiceMonitorable; @@ -44,14 +38,22 @@ import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.service.LimaServiceFactory; +import javax.swing.table.AbstractTableModel; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * TODO add comment here. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialPeriodTableModel extends AbstractTableModel implements ServiceListener { @@ -59,29 +61,29 @@ private static final long serialVersionUID = 77027335135838258L; private static final Log log = - LogFactory.getLog(FinancialPeriodTableModel.class); + LogFactory.getLog(FinancialPeriodTableModel.class); /** service */ protected FinancialPeriodServiceMonitorable financialPeriodService; - + /** Datas cache */ protected List<Object> cacheDataList; - + public FinancialPeriodTableModel() { financialPeriodService = - LimaServiceFactory.getInstance().getService( - FinancialPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( FiscalPeriodServiceMonitorable.class).addServiceListener(this); } - - + + @Override public int getRowCount() { int result = 0; - + if (cacheDataList != null) { result = cacheDataList.size(); } @@ -98,32 +100,32 @@ @Override public String getColumnName(int columnIndex) { - + String result = "n/a"; - - switch(columnIndex) { - case 0 : - result = _("lima.table.period"); - break; - case 1: - result = _("lima.table.entrybook"); - break; - case 2: - result = _("lima.table.closure"); - break; + + switch (columnIndex) { + case 0: + result = _("lima.table.period"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.closure"); + break; } return result; } - + @Override public Class<?> getColumnClass(int columnIndex) { // both String return String.class; } - + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; @@ -132,82 +134,81 @@ public ClosedPeriodicEntryBook getFinancialPeriodAtRow(int row) throws LimaException { return (ClosedPeriodicEntryBook) cacheDataList.get(row); } - - - public Object getElementAt(int row){ - + + + public Object getElementAt(int row) { + Object currentRow = cacheDataList.get(row); return currentRow; } - - + + @Override public Object getValueAt(int rowIndex, int columnIndex) { Object result = null; ClosedPeriodicEntryBook closedPeriodicEntryBook = (ClosedPeriodicEntryBook) cacheDataList.get(rowIndex); - - if (closedPeriodicEntryBook != null){ - EntryBook entryBook = closedPeriodicEntryBook.getEntryBook(); - FinancialPeriod financialPeriod = + + if (closedPeriodicEntryBook != null) { + EntryBook entryBook = closedPeriodicEntryBook.getEntryBook(); + FinancialPeriod financialPeriod = closedPeriodicEntryBook.getFinancialPeriod(); - - SimpleDateFormat simpleDateFormat - = new SimpleDateFormat("dd MMM yyyy"); - - switch (columnIndex) { + + SimpleDateFormat simpleDateFormat + = new SimpleDateFormat("dd MMM yyyy"); + + switch (columnIndex) { case 0: result = simpleDateFormat.format(financialPeriod.getBeginDate()) - +" - "+simpleDateFormat.format(financialPeriod.getEndDate()); + + " - " + simpleDateFormat.format(financialPeriod.getEndDate()); break; case 1: - result = entryBook.getCode()+" - "+entryBook.getLabel(); + result = entryBook.getCode() + " - " + entryBook.getLabel(); break; case 2: - if(closedPeriodicEntryBook.getLocked()){ + if (closedPeriodicEntryBook.getLocked()) { result = _("lima.common.closed"); - } - else{ + } else { result = _("lima.common.open"); } break; - } } + } return result; } - - public List<Object> getDataList(){ + + public List<Object> getDataList() { List<Object> results = - new ArrayList<Object>(); + new ArrayList<Object>(); try { List<ClosedPeriodicEntryBook> closedPeriodicEntryBook = financialPeriodService.//getAllClosedPeriodicEntryBooks(); - getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); + getAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod(); Collections.sort(closedPeriodicEntryBook, new FinancialPeriodComparator()); results.addAll(closedPeriodicEntryBook); - } catch (LimaException eee){ - if (log.isDebugEnabled()){ - log.debug("Can't get closedperiodicentrybook list", eee ); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't get closedperiodicentrybook list", eee); } } return results; } - - public void refresh(){ + + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } - + public void blockFinancialPeriod(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException { financialPeriodService. - blockClosedPeriodicEntryBook(closedPeriodicEntryBook); + blockClosedPeriodicEntryBook(closedPeriodicEntryBook); refresh(); } @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll")){ + if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,36 +25,36 @@ package org.chorem.lima.ui.financialperiod; -import static org.nuiton.i18n.I18n._; - -import javax.swing.JOptionPane; - -import org.jdesktop.swingx.JXTable; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.util.DialogHelper; +import org.jdesktop.swingx.JXTable; +import javax.swing.JOptionPane; + +import static org.nuiton.i18n.I18n._; + /** * TODO add comment here. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialPeriodViewHandler { private static final Log log = LogFactory.getLog(FinancialPeriodViewHandler.class); - + protected FinancialPeriodView view; - + protected FinancialPeriodTable table; - + protected FinancialPeriodTableModel tableModel; - + protected FinancialPeriodViewHandler(FinancialPeriodView view) { this.view = view; } @@ -62,13 +62,13 @@ public void blockFinancialPeriod() { JXTable financialPeriodeTable = view.getFinancialPeriodTable(); int selectedRow = financialPeriodeTable.getSelectedRow(); - FinancialPeriodTableModel model = (FinancialPeriodTableModel)view.getFinancialPeriodTable().getModel(); - + FinancialPeriodTableModel model = (FinancialPeriodTableModel) view.getFinancialPeriodTable().getModel(); + // blocked it try { ClosedPeriodicEntryBook closedPeriodicEntryBook = model.getFinancialPeriodAtRow(selectedRow); int response = JOptionPane.showConfirmDialog(view, _("lima.charts.financialperiod.question.blocked"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); + _("lima.common.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { model.blockFinancialPeriod(closedPeriodicEntryBook); @@ -80,13 +80,13 @@ DialogHelper.showMessageDialog(eee.getMessage()); } } - + public FinancialPeriodView getView() { return view; } - + public void refresh() { - tableModel = (FinancialPeriodTableModel)getView().getFinancialPeriodTable().getModel(); + tableModel = (FinancialPeriodTableModel) getView().getFinancialPeriodTable().getModel(); tableModel.refresh(); } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,15 +24,15 @@ */ package org.chorem.lima.ui.financialstatementchart; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.swingx.JXTreeTable; + import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jdesktop.swingx.JXTreeTable; - public class FinancialStatementChartTreeTable extends JXTreeTable implements KeyListener, MouseListener { @@ -42,15 +42,15 @@ /** log. */ private static final Log log = LogFactory .getLog(FinancialStatementChartTreeTable.class); - + protected FinancialStatementChartViewHandler handler; - + public FinancialStatementChartTreeTable(FinancialStatementChartViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + } @Override Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartTreeTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,9 +25,6 @@ package org.chorem.lima.ui.financialstatementchart; -import static org.nuiton.i18n.I18n._; -import java.util.List; -import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialStatementServiceMonitorable; @@ -37,35 +34,38 @@ import org.chorem.lima.service.LimaServiceFactory; import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import javax.swing.tree.TreePath; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Tree table model for account edition. - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialStatementChartTreeTableModel extends AbstractTreeTableModel { - + /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); - + /** Services. */ protected final FinancialStatementServiceMonitorable financialStatementService; - /** - * Model constructor. Init account service used here. - */ + /** Model constructor. Init account service used here. */ public FinancialStatementChartTreeTableModel() { //create root for the tree super(new FinancialStatementImpl()); // Gets factory service financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); - } + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); + } @Override @@ -102,21 +102,20 @@ if (node == getRoot()) { try { result = financialStatementService. - getChildrenFinancialStatement(null).size(); + getChildrenFinancialStatement(null).size(); } catch (LimaException eee) { log.debug("Can't count child", eee); } - } - else { - FinancialStatement parentFinancialStatementHeader = + } else { + FinancialStatement parentFinancialStatementHeader = (FinancialStatement) node; - try { - result = financialStatementService.getChildrenFinancialStatement( - parentFinancialStatementHeader).size(); - } catch (LimaException eee) { - log.debug("Can't count child", eee); - } + try { + result = financialStatementService.getChildrenFinancialStatement( + parentFinancialStatementHeader).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); } + } return result; } @@ -126,18 +125,17 @@ if (parent == getRoot()) { try { List<FinancialStatement> financialStatements = - financialStatementService.getChildrenFinancialStatement(null); + financialStatementService.getChildrenFinancialStatement(null); result = financialStatements.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); } - } - else { + } else { FinancialStatement parentFinancialStatement = - (FinancialStatement) parent; + (FinancialStatement) parent; try { List<FinancialStatement> financialStatements = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatement); + getChildrenFinancialStatement(parentFinancialStatement); result = financialStatements.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); @@ -149,22 +147,21 @@ @Override public int getIndexOfChild(Object parent, Object child) { int result = 0; - + if (parent == getRoot()) { try { List<FinancialStatement> financialStatements = - financialStatementService.getChildrenFinancialStatement(null); + financialStatementService.getChildrenFinancialStatement(null); result = financialStatements.indexOf(child); } catch (LimaException eee) { log.debug("Can't get index child", eee); } - } - else { + } else { FinancialStatement parentFinancialStatement = - (FinancialStatement) parent; + (FinancialStatement) parent; try { List<FinancialStatement> financialStatements = financialStatementService. - getChildrenFinancialStatement(parentFinancialStatement); + getChildrenFinancialStatement(parentFinancialStatement); result = financialStatements.indexOf(child); } catch (LimaException eee) { log.debug("Can't get index child", eee); @@ -172,28 +169,28 @@ } return result; } - + @Override public Object getValueAt(Object node, int column) { Object result = "n/a"; - FinancialStatement financialStatement = (FinancialStatement) node; - switch (column) { - case 0: - result = financialStatement.getLabel(); - break; - case 1: - result = financialStatement.getAccounts(); - break; - case 2: - result = financialStatement.getDebitAccounts(); - break; - case 3: - result = financialStatement.getCreditAccounts(); - break; - case 4: - result = financialStatement.getProvisionDeprecationAccounts(); - break; - } + FinancialStatement financialStatement = (FinancialStatement) node; + switch (column) { + case 0: + result = financialStatement.getLabel(); + break; + case 1: + result = financialStatement.getAccounts(); + break; + case 2: + result = financialStatement.getDebitAccounts(); + break; + case 3: + result = financialStatement.getCreditAccounts(); + break; + case 4: + result = financialStatement.getProvisionDeprecationAccounts(); + break; + } return result; } @@ -207,20 +204,17 @@ return getChildCount(node) == 0; } - - /** - * Refresh FinancialStatementChart. - * - */ + + /** Refresh FinancialStatementChart. */ public void refreshTree() throws LimaException { modelSupport.fireNewRoot(); } - - + + /** * Add FinancialStatement(path can be null). - * + * * @param path * @param account * @throws LimaException @@ -228,7 +222,7 @@ public void addFinancialStatement(TreePath path, FinancialStatement financialStatement) throws LimaException { // Calling account service FinancialStatement parentFinancialStatementHeader = - (FinancialStatement) path.getLastPathComponent(); + (FinancialStatement) path.getLastPathComponent(); if (parentFinancialStatementHeader == getRoot()) { parentFinancialStatementHeader = null; } @@ -237,10 +231,10 @@ modelSupport.fireTreeStructureChanged(path); } - + /** * Update financialStatement - * + * * @param path * @param account * @throws LimaException @@ -250,11 +244,11 @@ financialStatementService.updateFinancialStatement(financialStatement); modelSupport.fireTreeStructureChanged(path); } - - + + /** * Remove financialStatement - * + * * @param path * @param object * @throws LimaException @@ -263,7 +257,7 @@ // Calling account service int index = getIndexOfChild( path.getParentPath().getLastPathComponent(), financialStatement); - financialStatementService.removeFinancialStatement(financialStatement); + financialStatementService.removeFinancialStatement(financialStatement); modelSupport.fireChildRemoved(path.getParentPath(), index, financialStatement); } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementChartViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,10 +25,6 @@ package org.chorem.lima.ui.financialstatementchart; -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.FinancialStatementServiceMonitorable; @@ -46,14 +42,19 @@ 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. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialStatementChartViewHandler implements ServiceListener { @@ -61,37 +62,35 @@ private static final Log log = LogFactory.getLog(FinancialStatementChartViewHandler.class); protected FinancialStatementServiceMonitorable financialStatementService; - + protected FinancialStatementChartView view; - + protected FinancialStatementChartViewHandler(FinancialStatementChartView view) { this.view = view; - + financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); } - /** - * Add new account with account form. - */ + /** Add new account with account form. */ public void addFinancialStatementHeader() { JXTreeTable treeTable = view.getTreeTable(); FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); FinancialStatement newFinancialStatementHeader = - new FinancialStatementImpl(); + new FinancialStatementImpl(); FinancialStatementHeaderForm financialStatementHeaderForm = - new FinancialStatementHeaderForm(view); + new FinancialStatementHeaderForm(view); financialStatementHeaderForm.setFinancialStatement(newFinancialStatementHeader); // jaxx constructor don't call super() ? financialStatementHeaderForm.setLocationRelativeTo(view); financialStatementHeaderForm.setVisible(true); - + // null == cancel action newFinancialStatementHeader = financialStatementHeaderForm.getFinancialStatement(); if (newFinancialStatementHeader != null) { @@ -99,12 +98,12 @@ // get current selection path TreePath treePath; int selectedRow = treeTable.getSelectedRow(); - if ( selectedRow != -1) { + if (selectedRow != -1) { treePath = treeTable.getPathForRow(selectedRow); } else { treePath = new TreePath(treeTableModel.getRoot()); } - + // add it try { treeTableModel.addFinancialStatement(treePath, newFinancialStatementHeader); @@ -114,57 +113,55 @@ } DialogHelper.showMessageDialog(eee.getMessage()); - } - - catch (LimaException ex) { + } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't add financialStatementHeader", ex); } ErrorHelper.showErrorDialog(_("lima.financialstatement.addfinancialStatementHeadererror"), ex); } } - }; - - public void addFinancialStatementMovement(){ + } - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + ; + public void addFinancialStatementMovement() { + + JXTreeTable treeTable = view.getTreeTable(); + FinancialStatementChartTreeTableModel treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + FinancialStatement newFinancialStatementMovement = - new FinancialStatementImpl(); + new FinancialStatementImpl(); FinancialStatementMovementForm financialStatementMovementForm = - new FinancialStatementMovementForm(view); + new FinancialStatementMovementForm(view); financialStatementMovementForm.setFinancialStatement(newFinancialStatementMovement); - // jaxx constructor don't call super() ? + // jaxx constructor don't call super() ? financialStatementMovementForm.setLocationRelativeTo(view); financialStatementMovementForm.setVisible(true); - newFinancialStatementMovement=financialStatementMovementForm.getFinancialStatement(); - - // null == cancel action - if (newFinancialStatementMovement != null) { - // get current selection path - TreePath treePath; - int selectedRow = view.treeTable.getSelectedRow(); - treePath = view.treeTable.getPathForRow(selectedRow); - // add it - try { - treeTableModel. - addFinancialStatement(treePath, newFinancialStatementMovement); - } catch (LimaBusinessException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - - catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add FinancialStatementMovement", eee); - } - DialogHelper.showMessageDialog(eee.getMessage()); - } - } + newFinancialStatementMovement = financialStatementMovementForm.getFinancialStatement(); + + // null == cancel action + if (newFinancialStatementMovement != null) { + // get current selection path + TreePath treePath; + int selectedRow = view.treeTable.getSelectedRow(); + treePath = view.treeTable.getPathForRow(selectedRow); + // add it + try { + treeTableModel. + addFinancialStatement(treePath, newFinancialStatementMovement); + } catch (LimaBusinessException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add FinancialStatementMovement", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add FinancialStatementMovement", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + } } /** @@ -172,50 +169,50 @@ * Verifiy if it's an account or a subledger */ public void updateFinancialStatement() { - - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + JXTreeTable treeTable = view.getTreeTable(); + FinancialStatementChartTreeTableModel treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + // get selected account int selectedRow = view.treeTable.getSelectedRow(); TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null FinancialStatement financialStatement = - (FinancialStatement) treePath.getLastPathComponent(); + (FinancialStatement) treePath.getLastPathComponent(); //update Account or update SubLedger if (financialStatement != null) { // get current selection path - if ( selectedRow != -1) { + if (selectedRow != -1) { treePath = view.treeTable.getPathForRow(selectedRow); } else { treePath = new TreePath(treeTableModel.getRoot()); } //test if selectedrow is account or ledger log.debug(financialStatement.getHeader()); - if (financialStatement.getHeader()){ + if (financialStatement.getHeader()) { FinancialStatementHeaderForm financialStatementHeaderForm = - new FinancialStatementHeaderForm(view); + new FinancialStatementHeaderForm(view); financialStatementHeaderForm.setFinancialStatement(financialStatement); // jaxx constructor don't call super() ? financialStatementHeaderForm.setLocationRelativeTo(view); financialStatementHeaderForm.setVisible(true); // null == cancel action financialStatement = financialStatementHeaderForm.getFinancialStatement(); - } + } // else is a movement - else{ + else { FinancialStatementMovementForm financialStatementMovementForm = - new FinancialStatementMovementForm(view); + new FinancialStatementMovementForm(view); financialStatementMovementForm.setFinancialStatement(financialStatement); // jaxx constructor don't call super() ? financialStatementMovementForm.setLocationRelativeTo(view); financialStatementMovementForm.setVisible(true); // null == cancel action financialStatement = - financialStatementMovementForm.getFinancialStatement(); + financialStatementMovementForm.getFinancialStatement(); } //if action confirmed - if (financialStatement != null){ + if (financialStatement != null) { // update it try { treeTableModel.updateFinancialStatement( @@ -230,29 +227,27 @@ } } - /** - * Ask for user to remove for selected account, and remove it if confirmed. - */ + /** Ask for user to remove for selected account, and remove it if confirmed. */ public void removeFinancialStatement() { - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + JXTreeTable treeTable = view.getTreeTable(); + FinancialStatementChartTreeTableModel treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); // Any row selected int selectedRow = view.treeTable.getSelectedRow(); - if ( selectedRow != -1) { + if (selectedRow != -1) { int n = JOptionPane.showConfirmDialog(view, - _("lima.charts.account.question.remove"), - _("lima.common.confirmation"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + _("lima.charts.account.question.remove"), + _("lima.common.confirmation"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (n == JOptionPane.YES_OPTION) { // update view of treetable TreePath treePath = view.treeTable.getPathForRow(selectedRow); FinancialStatement financialStatement = - (FinancialStatement) treePath.getLastPathComponent(); + (FinancialStatement) treePath.getLastPathComponent(); - try{ + try { treeTableModel.removeFinancialStatementObject( treePath, financialStatement); } catch (LimaException eee) { @@ -264,70 +259,70 @@ } } } - - public void refresh(){ - JXTreeTable treeTable = view.getTreeTable(); - FinancialStatementChartTreeTableModel treeTableModel = - (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); - try { + + public void refresh() { + JXTreeTable treeTable = view.getTreeTable(); + FinancialStatementChartTreeTableModel treeTableModel = + (FinancialStatementChartTreeTableModel) treeTable.getTreeTableModel(); + try { treeTableModel.refreshTree(); } catch (LimaException eee) { - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't refresh model", eee); } } //refresh view view.repaint(); } - - public void importFinancialStatementChart(){ + + public void importFinancialStatementChart() { FinancialStatementImportForm form = - new FinancialStatementImportForm(); + new FinancialStatementImportForm(); form.setLocationRelativeTo(view); form.setVisible(true); Object value = form.getRadioButtons().getSelectedValue(); // if action confirmed - if (value != null){ - if (form.getDeleteFinancialStatementChart().isSelected()){ + if (value != null) { + if (form.getDeleteFinancialStatementChart().isSelected()) { try { financialStatementService.removeAllFinancialStatement(); - + } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't delete financial statement chart", eee); } } } - FinancialStatementsChartEnum defaultFinancialStatementsEnum = - (FinancialStatementsChartEnum) value; + FinancialStatementsChartEnum defaultFinancialStatementsEnum = + (FinancialStatementsChartEnum) value; ImportExport importExport = ImportExport.getInstance(view); importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - defaultFinancialStatementsEnum.getFilePath(), true); + defaultFinancialStatementsEnum.getFilePath(), true); } } - - - public void financialStatementChartCheck(){ + + + public void financialStatementChartCheck() { String result; try { result = financialStatementService.checkFinancialStatementChart(); DialogHelper.showReportDialog(result, _("lima.financialstatement.check"), view); } catch (LimaException e) { - log.error("Can't check financialstatement chart",e); + log.error("Can't check financialstatement chart", e); } } - + @Override public void notifyMethod(String serviceName, String methodName) { - + if (methodName.contains("FinancialStatements") - || methodName.contains("importAll") - || methodName.contains("importAs")){ + || methodName.contains("importAll") + || methodName.contains("importAs")) { refresh(); } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementImportForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementImportForm.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/FinancialStatementImportForm.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -31,7 +31,7 @@ jaxx.runtime.swing.JAXXButtonGroup org.chorem.lima.enums.FinancialStatementsChartEnum </import> - + <JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> <Boolean id="addState" javaBean='true'/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -31,8 +31,7 @@ public class FinancialStatementDocument { private static final Log log = - LogFactory.getLog(FinancialStatementReportTable.class); - - - + LogFactory.getLog(FinancialStatementReportTable.class); + + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.financialstatementreport; -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; @@ -40,120 +32,130 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 FinancialStatementReportPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(FinancialStatementReportPeriodSearchPanel.class); - + LogFactory.getLog(FinancialStatementReportPeriodSearchPanel.class); + protected FinancialStatementReportTableModel model; - + public FinancialStatementReportPeriodSearchPanel(FinancialStatementReportTableModel model) { this.model = model; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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) { - model.setBeginDate(beginDatePicker.getDate()); - model.refresh(); - } - }; - model.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) { - model.setEndDate(endDatePicker.getDate()); - model.refresh(); - } - }; - model.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - model.refresh(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - model.setBeginDate(fPeriod.getBeginDate()); - model.setEndDate(fPeriod.getEndDate()); - model.refresh(); + // 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) { + model.setBeginDate(beginDatePicker.getDate()); + model.refresh(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + model.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod !=null){ - model.setBeginDate(fPeriod.getBeginDate()); - model.setEndDate(fPeriod.getEndDate()); - model.refresh(); + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + model.setEndDate(endDatePicker.getDate()); + model.refresh(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + model.setEndDate(endDatePicker.getDate()); + endDatePicker.addActionListener(endDateActionListener); + model.refresh(); + + removeAll(); + add(beginDateLabel); + add(beginDatePicker); + add(endDateLabel); + add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + model.setBeginDate(fPeriod.getBeginDate()); + model.setEndDate(fPeriod.getEndDate()); + model.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + model.setBeginDate(fPeriod.getBeginDate()); + model.setEndDate(fPeriod.getEndDate()); + model.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,6 +25,13 @@ package org.chorem.lima.ui.financialstatementreport; +import org.chorem.lima.beans.FinancialStatementAmounts; +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; @@ -32,41 +39,34 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import org.chorem.lima.beans.FinancialStatementAmounts; -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; - public class FinancialStatementReportTable extends JXTable implements KeyListener, MouseListener { - + private static final long serialVersionUID = 154211277688304679L; protected FinancialStatementReportViewHandler handler; - + protected FinancialStatementReportTableModel model; - + private Highlighter colorTransaction; - + /* - * Constructor, call highlighter - */ + * Constructor, call highlighter + */ public FinancialStatementReportTable(FinancialStatementReportViewHandler handler) { super(handler.getView().modelTable); this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + model = this.handler.getView().modelTable; //highlight financial financial transactions colorTitle1(); colorTitle2(); - + //Renderer for font FinancialStatementReportTableCellRenderer renderer = new FinancialStatementReportTableCellRenderer(); for (int i = 0; i < getColumnModel().getColumnCount(); i++) { @@ -78,49 +78,49 @@ * Color the background row in grey if the level is 1 */ protected void colorTitle1() { - - - HighlightPredicate predicate = new HighlightPredicate() { + + + HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { Boolean result = false; Object object = model.getElementAt(adapter.row); - if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ + if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts) { FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; result = financialStatementAmounts.getLevel() == 1; } return result; } }; - colorTransaction = - new ColorHighlighter(predicate, new Color(222,222,222), null); - addHighlighter(colorTransaction); - } - + colorTransaction = + new ColorHighlighter(predicate, new Color(222, 222, 222), null); + addHighlighter(colorTransaction); + } + /* - * Color the background in light grey if is a subamount - */ + * Color the background in light grey if is a subamount + */ protected void colorTitle2() { - - + + HighlightPredicate predicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { - Boolean result = false; - Object object = model.getElementAt(adapter.row); - if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts){ - FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; - result = financialStatementAmounts.getSubAmount(); - } - return result; - } - }; - colorTransaction = - new ColorHighlighter(predicate, new Color(244,244,244), null); - addHighlighter(colorTransaction); - } + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + Boolean result = false; + Object object = model.getElementAt(adapter.row); + if (model.getElementAt(adapter.row) instanceof FinancialStatementAmounts) { + FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; + result = financialStatementAmounts.getSubAmount(); + } + return result; + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(244, 244, 244), null); + addHighlighter(colorTransaction); + } @Override public void mouseClicked(MouseEvent e) { @@ -157,9 +157,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableCellRenderer.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,23 +25,23 @@ package org.chorem.lima.ui.financialstatementreport; +import org.chorem.lima.LimaConfig; +import org.chorem.lima.LimaContext; +import org.chorem.lima.beans.FinancialStatementAmounts; + +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 javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.DefaultTableCellRenderer; -import org.chorem.lima.LimaConfig; -import org.chorem.lima.LimaContext; -import org.chorem.lima.beans.FinancialStatementAmounts; - - /** * Permet de modifier l'apparence du tableau pour le bilan à l'actif + * * @author Rémi Chapelet */ @@ -51,37 +51,34 @@ @Override public Component getTableCellRendererComponent(JTable table, Object value, - boolean isSelected, boolean hasFocus, int row, int column) - { + boolean isSelected, boolean hasFocus, int row, int column) { // Get table FinancialStatementReportTableModel financialStatementReportTableModel = (FinancialStatementReportTableModel) table.getModel(); - + // Récupère le bilan de la ligne Object object = financialStatementReportTableModel.getElementAt(row); Component cell = super.getTableCellRendererComponent( table, value, isSelected, hasFocus, row, column); - + // Si le bilan est un soustotal, alors la ligne est en gras - if (object instanceof FinancialStatementAmounts){ + if (object instanceof FinancialStatementAmounts) { FinancialStatementAmounts financialStatementAmounts = (FinancialStatementAmounts) object; - - if (financialStatementAmounts.getLevel() == 1) - { + + if (financialStatementAmounts.getLevel() == 1) { setFont(new Font("Verdana", Font.BOLD, 14)); } - if (financialStatementAmounts.getHeader()) - { + if (financialStatementAmounts.getHeader()) { setFont(new Font("Verdana", Font.BOLD, 12)); } - if (!financialStatementAmounts.getHeader() && !financialStatementAmounts.getSubAmount()){ - if (column == 0){ + if (!financialStatementAmounts.getHeader() && !financialStatementAmounts.getSubAmount()) { + if (column == 0) { cell.setFont(new Font("Verdana", Font.ITALIC, 12)); } } } - + if (object instanceof BigDecimal) { setHorizontalAlignment(SwingConstants.LEFT); setValue(value); @@ -89,7 +86,7 @@ return this; } - + public void setValue(Object aValue) { Object result = aValue; if (aValue != null && aValue instanceof BigDecimal) { @@ -106,7 +103,7 @@ formatter.setGroupingUsed(true); formatter.setGroupingSize(3); result = formatter.format(result); - } + } super.setValue(result); } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,17 +25,6 @@ package org.chorem.lima.ui.financialstatementreport; -import static org.nuiton.i18n.I18n._; - -import java.awt.Desktop; -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; -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.LimaConfig; @@ -52,15 +41,27 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; +import javax.swing.table.AbstractTableModel; +import java.awt.Desktop; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Entry book table model. - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialStatementReportTableModel extends AbstractTableModel implements ServiceListener { @@ -72,30 +73,29 @@ /** Services. */ protected FinancialStatementServiceMonitorable financialStatementService; + protected DocumentServiceMonitorable documentService; - + /** DatePicker Begin Date. */ protected Date selectedBeginDate; - + /** DatePicker EndDate. */ protected Date selectedEndDate; - + protected int port; - + private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - + new SimpleDateFormat("yyyy-MM-dd"); + /** data cache */ protected List<FinancialStatementAmounts> cacheDataList; - - /** - * Constructor. - */ + + /** Constructor. */ public FinancialStatementReportTableModel() { financialStatementService = - LimaServiceFactory.getInstance().getService( - FinancialStatementServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + FinancialStatementServiceMonitorable.class); + financialStatementService.addServiceListener(this); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); @@ -109,8 +109,8 @@ @Override public int getRowCount() { int result = 0; - if (cacheDataList != null){ - result = cacheDataList.size(); + if (cacheDataList != null) { + result = cacheDataList.size(); } return result; } @@ -119,25 +119,25 @@ public int getColumnCount() { return 4; } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = String.class; - break; - case 1: - result = BigDecimal.class; - break; - case 2: - result = BigDecimal.class; - break; - case 3: - result = BigDecimal.class; - break; + case 0: + result = String.class; + break; + case 1: + result = BigDecimal.class; + break; + case 2: + result = BigDecimal.class; + break; + case 3: + result = BigDecimal.class; + break; } return result; @@ -163,12 +163,12 @@ return res; } - public Object getElementAt(int row){ - + public Object getElementAt(int row) { + Object currentRow = cacheDataList.get(row); return currentRow; } - + @Override public Object getValueAt(int row, int column) { Object result = cacheDataList.get(row); @@ -176,50 +176,47 @@ if (result instanceof FinancialStatementAmounts) { FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result; BigDecimal grossAmount = currentRow.getGrossAmount(); - if (grossAmount == null ){ + if (grossAmount == null) { grossAmount = BigDecimal.ZERO; } - + BigDecimal provisionDeprecationAmount = currentRow.getProvisionDeprecationAmount(); - if (provisionDeprecationAmount == null ){ + if (provisionDeprecationAmount == null) { provisionDeprecationAmount = BigDecimal.ZERO; } switch (column) { - case 0: - result = ""; - String label = currentRow.getLabel(); - if ( label != null){ - for (int i = 0; i <= currentRow.getLevel(); i++) { - result = result+"\t"; + case 0: + result = ""; + String label = currentRow.getLabel(); + if (label != null) { + for (int i = 0; i <= currentRow.getLevel(); i++) { + result = result + "\t"; + } + result = result + label; } - result = result+label; - } - break; - case 1: - if (grossAmount.compareTo(BigDecimal.ZERO) == 0){ - result = null; - } - else { - result = grossAmount; - } - break; - case 2: - if (provisionDeprecationAmount.compareTo(BigDecimal.ZERO) == 0){ - result = null; - } - else { - result = provisionDeprecationAmount; - } - break; - case 3: - BigDecimal solde = grossAmount.subtract(provisionDeprecationAmount); - if (solde.compareTo(BigDecimal.ZERO) == 0) { - result = null; - } - else { - result = solde; - } - break; + break; + case 1: + if (grossAmount.compareTo(BigDecimal.ZERO) == 0) { + result = null; + } else { + result = grossAmount; + } + break; + case 2: + if (provisionDeprecationAmount.compareTo(BigDecimal.ZERO) == 0) { + result = null; + } else { + result = provisionDeprecationAmount; + } + break; + case 3: + BigDecimal solde = grossAmount.subtract(provisionDeprecationAmount); + if (solde.compareTo(BigDecimal.ZERO) == 0) { + result = null; + } else { + result = solde; + } + break; } } @@ -232,34 +229,34 @@ // Just read, no write return false; } - + public Date getBeginDate() { return selectedBeginDate; } - public void setBeginDate(Date date){ + public void setBeginDate(Date date) { selectedBeginDate = date; } - + public Date getEndDate() { return selectedEndDate; } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { selectedEndDate = date; } - + /** * get all account fot the selected period + * * @return */ - public List<FinancialStatementAmounts> getDataList(){ + public List<FinancialStatementAmounts> getDataList() { List<FinancialStatementAmounts> results = null; - if (selectedBeginDate != null && selectedEndDate != null){ + if (selectedBeginDate != null && selectedEndDate != null) { try { results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -268,24 +265,24 @@ } return results; } - - public void refresh(){ + + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } - + public void createDocument(FormatsEnum formatsEnum) { - - if (selectedBeginDate != null && selectedEndDate != null){ + + if (selectedBeginDate != null && selectedEndDate != null) { String address = LimaConfig.getInstance().getHostAdress(); try { - String url = "http://"+address+":"+port+"/?beginDate=" - +dateFormat.format(selectedBeginDate) - +"&endDate="+dateFormat.format(selectedEndDate) - +"&format="+formatsEnum.getExtension()+"&model=" - + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); - Desktop.getDesktop().browse(new URI(url)); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(selectedBeginDate) + + "&endDate=" + dateFormat.format(selectedEndDate) + + "&format=" + formatsEnum.getExtension() + "&model=" + + DocumentsEnum.FINANCIALSTATEMENT.getFileName(); + Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { log.error("Can't open browser", e); } catch (URISyntaxException e) { @@ -293,12 +290,12 @@ } } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")) { refresh(); } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.financialstatementreport; -import static org.nuiton.i18n.I18n._; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; @@ -42,48 +34,55 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; +import javax.swing.JOptionPane; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Handler associated with accounts reports view. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FinancialStatementReportViewHandler { - + /** log. */ private static final Log log = LogFactory.getLog(FinancialStatementReportViewHandler.class); protected FinancialStatementReportView view; - + protected FinancialStatementReportTableModel model; - + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + protected FinancialStatementReportViewHandler(FinancialStatementReportView view) { this.view = view; fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); } - - public void refresh(){ + + public void refresh() { model = view.getModelTable(); - model.refresh(); + model.refresh(); } - + public FinancialStatementReportView getView() { return view; } - + public void createDocument() { - + model = view.getModelTable(); Date selectedBeginDate = model.getBeginDate(); Date selectedEndDate = model.getEndDate(); - + if (selectedBeginDate != null && selectedEndDate != null) { //looks for all blocked fiscal periods List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); @@ -95,18 +94,18 @@ } ErrorHelper.showErrorDialog("Enable to create document ", eee); } - + //tells if the fiscaPeriod as been found and is blocked boolean error = true; - + for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate) - && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) - && blockedFiscalPeriod.getLocked()) { + && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) + && blockedFiscalPeriod.getLocked()) { error = false; } } - + //shows error message to user if the fiscalPeriod is unblocked if (error) { JOptionPane.showMessageDialog( @@ -116,7 +115,7 @@ JOptionPane.ERROR_MESSAGE); } else { FormatsEnum selectedEnum = - (FormatsEnum) view.getDocumentEditor().getSelectedItem(); + (FormatsEnum) view.getDocumentEditor().getSelectedItem(); model.createDocument(selectedEnum); } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -69,15 +69,15 @@ </cell> <cell anchor="west"> <JPanel> - <FinancialPeriodComboBox id="financialPeriodComboBox" - constructorParams="getHandler()" - model="{getModelFinancialPeriod()}" - renderer="{RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class)}" - onActionPerformed="financialTransactionTableModel.setFinancialPeriod((FinancialPeriod)financialPeriodComboBox.getSelectedItem())"/> + <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()"/> + onActionPerformed="financialPeriodComboBox.back()"/> <JButton id="next" text="lima.common.buttonnext" - onActionPerformed="financialPeriodComboBox.next()"/> + onActionPerformed="financialPeriodComboBox.next()"/> </JPanel> </cell> <!--cell> 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -32,14 +32,14 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxPeriodEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.ListCellRenderer; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Calendar; @@ -130,9 +130,10 @@ case FISCAL_PERIOD: FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); - FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); final JComboBox fiscalPeriod = new JComboBox(fiscalModel); - fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setRenderer(renderer); fiscalPeriod.setEditable(false); ActionListener fiscalPeriodActionListener = new ActionListener() { @Override @@ -151,9 +152,10 @@ case FINANCIAL_PERIOD: FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); - FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); final JComboBox financialPeriod = new JComboBox(financialModel); - financialPeriod.setRenderer(financialRenderer); + financialPeriod.setRenderer(renderer); financialPeriod.setEditable(false); ActionListener financialPeriodActionListener = new ActionListener() { @Override 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,11 +29,12 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Letter; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; import javax.swing.JComboBox; +import javax.swing.ListCellRenderer; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; @@ -50,9 +51,10 @@ public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { this.handler = handler; LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); - LetterRenderer letterRenderer = new LetterRenderer(); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(Letter.class); setModel(letterComboBoxModel); - setRenderer(letterRenderer); + setRenderer(renderer); setEditable(true); AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); getEditor().getEditorComponent().addKeyListener(this); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -27,8 +27,8 @@ <import> javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod - org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel + org.chorem.lima.ui.renderers.RendererUtil </import> <FinancialTransactionUnbalancedViewHandler id="handler" javaBean="new FinancialTransactionUnbalancedViewHandler(this)"/> @@ -61,7 +61,7 @@ <cell anchor="west"> <JComboBox id="fiscalPeriodComboBox" model="{modelFiscalPeriod}" - renderer="{new FiscalPeriodComboBoxRenderer()}" + renderer="{RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class)}" onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem()); getHandler().refresh()" editable="false"/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,6 +25,13 @@ package org.chorem.lima.ui.fiscalperiod; +import org.chorem.lima.entity.FiscalPeriod; +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; @@ -32,31 +39,24 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; -import org.chorem.lima.entity.FiscalPeriod; -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; - public class FiscalPeriodTable extends JXTable implements KeyListener, MouseListener { private static final long serialVersionUID = -8462838870024505659L; protected FiscalPeriodViewHandler handler; - + protected FiscalPeriodTableModel model; - + private Highlighter colorTransaction; - + public FiscalPeriodTable(FiscalPeriodViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + model = this.handler.getView().getModelFiscalPeriodTable(); //highlight financial financial transactions @@ -67,16 +67,16 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { FiscalPeriod fiscalPeriod = (FiscalPeriod) model.getElementAt(adapter.row); // true if locked return fiscalPeriod.getLocked(); } }; - colorTransaction = - new ColorHighlighter(predicate, null, new Color(222,0,0)); - addHighlighter(colorTransaction); - } + colorTransaction = + new ColorHighlighter(predicate, null, new Color(222, 0, 0)); + addHighlighter(colorTransaction); + } @Override public void mouseClicked(MouseEvent e) { @@ -113,14 +113,14 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } } @Override public void keyReleased(KeyEvent e) { } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.fiscalperiod; -import static org.nuiton.i18n.I18n._; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - - -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; @@ -49,16 +39,26 @@ import org.chorem.lima.util.ErrorHelper; import org.nuiton.util.Resource; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.table.AbstractTableModel; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * TODO add comment here. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ -public class FiscalPeriodTableModel extends AbstractTableModel implements ServiceListener{ +public class FiscalPeriodTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 77027335135838258L; @@ -66,35 +66,34 @@ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class); protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + protected FinancialTransactionServiceMonitorable financialTransactionService; - + /** data cache */ protected List<Object> cacheDataList; public FiscalPeriodTableModel() { fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addServiceListener(this); - LimaServiceFactory.getInstance().getService( + LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); financialTransactionService.addServiceListener(this); cacheDataList = null; - } - + } + protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); try { List<FiscalPeriod> fiscalPeriod = - fiscalPeriodService.getAllFiscalPeriods(); + fiscalPeriodService.getAllFiscalPeriods(); Collections.sort(fiscalPeriod, new FiscalPeriodComparator()); results.addAll(fiscalPeriod); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -103,15 +102,15 @@ return results; } - public void refresh(){ + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } - + @Override public int getRowCount() { int result = 0; - + if (cacheDataList != null) { result = cacheDataList.size(); } @@ -124,30 +123,30 @@ return 2; } - - public Object getElementAt(int row){ - + + public Object getElementAt(int row) { + Object currentRow = null; - + if (cacheDataList != null) { currentRow = cacheDataList.get(row); } - + return currentRow; } - + @Override public String getColumnName(int columnIndex) { - + String result = "n/a"; - - switch(columnIndex) { - case 0 : - result = _("lima.table.fiscalperiod"); - break; - case 1: - result = _("lima.table.closure"); - break; + + switch (columnIndex) { + case 0: + result = _("lima.table.fiscalperiod"); + break; + case 1: + result = _("lima.table.closure"); + break; } return result; @@ -172,43 +171,40 @@ List<Object> periods; periods = cacheDataList; - FiscalPeriod fiscalPeriod = (FiscalPeriod)periods.get(rowIndex); - - if (fiscalPeriod != null){ - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy"); + FiscalPeriod fiscalPeriod = (FiscalPeriod) periods.get(rowIndex); + if (fiscalPeriod != null) { + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy"); + switch (columnIndex) { - case 0: - result = simpleDateFormat. - format(fiscalPeriod.getBeginDate()) - + " - " + simpleDateFormat. + case 0: + result = simpleDateFormat. + format(fiscalPeriod.getBeginDate()) + + " - " + simpleDateFormat. format(fiscalPeriod.getEndDate()); - break; - case 1: - if(fiscalPeriod.getLocked()){ - result = _("lima.common.closed"); - } - else{ - result = _("lima.common.open"); - } - break; + break; + case 1: + if (fiscalPeriod.getLocked()) { + result = _("lima.common.closed"); + } else { + result = _("lima.common.open"); + } + break; } } return result; } - + public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException { FiscalPeriod fiscalPeriod; - fiscalPeriod = (FiscalPeriod) cacheDataList.get(row); + fiscalPeriod = (FiscalPeriod) cacheDataList.get(row); return fiscalPeriod; } - - /** - * @param period - */ + + /** @param period */ public void addFiscalPeriod(FiscalPeriod period) throws LimaException { - + try { // Calling fiscal period service fiscalPeriodService.createFiscalPeriod(period); @@ -216,26 +212,25 @@ cacheDataList = getDataList(); int row = getDataList().indexOf(period); fireTableRowsInserted(row, row); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't create FiscalPeriod", eee); } ErrorHelper.showErrorDialog(_("lima.fiscalperiod.creationerror"), eee); } } - + public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { - List<FinancialTransaction> financialTransactionsUnbal = - financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod); + List<FinancialTransaction> financialTransactionsUnbal = + financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod); if (financialTransactionsUnbal.size() > 0) { JFrame f = new JFrame(); - f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); - JOptionPane.showMessageDialog( - f, - _("lima.fiscalperiod.unbalancedtransactions"), - _("lima.common.error"), - JOptionPane.ERROR_MESSAGE); + f.setIconImage(Resource.getIcon("icons/lima.png").getImage()); + JOptionPane.showMessageDialog( + f, + _("lima.fiscalperiod.unbalancedtransactions"), + _("lima.common.error"), + JOptionPane.ERROR_MESSAGE); f.dispose(); } else { fiscalPeriodService.blockFiscalPeriod(fiscalPeriod); @@ -246,8 +241,8 @@ @Override public void notifyMethod(String serviceName, String methodeName) { //refresh on import datas - if (methodeName.contains("importAll")){ + if (methodeName.contains("importAll")) { refresh(); - } + } } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -49,66 +49,66 @@ /** * TODO add comment here. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class FiscalPeriodViewHandler { private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); - + private FiscalPeriodView view; - + protected FiscalPeriodTable table; - + protected FiscalPeriodTableModel tableModel; - + /** Service. */ protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + protected FinancialTransactionServiceMonitorable financialTransactionService; - + protected FiscalPeriodViewHandler(FiscalPeriodView view) { - this.view=view; - + this.view = view; + fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); + financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); } public void addFiscalPeriod() { - + FiscalPeriodTableModel model = - (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); - + (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); + AddPeriod addPeriodDialog = new AddPeriod(getView()); // jaxx don't call super() ? addPeriodDialog.setLocationRelativeTo(getView()); addPeriodDialog.setVisible(true); - + FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod(); // null = cancel - if (fiscalPeriod!= null) { + if (fiscalPeriod != null) { //check if fiscalperiod have 12 months, ask a confirmation int nbMonth = - DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), - fiscalPeriod.getEndDate()); + DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate()); int n = 0; - if(nbMonth !=12){ + if (nbMonth != 12) { n = JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.morethan12"), - _("lima.common.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + _("lima.charts.fiscalperiod.question.morethan12"), + _("lima.common.question"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); } - if (n == JOptionPane.YES_OPTION || nbMonth ==11){ + if (n == JOptionPane.YES_OPTION || nbMonth == 11) { try { model.addFiscalPeriod(fiscalPeriod); } catch (LimaException eee) { @@ -125,30 +125,30 @@ JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); int selectedRow = fiscalPeriodeTable.getSelectedRow(); FiscalPeriodTableModel model = - (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); + (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); // blocked it try { FiscalPeriod selectedFiscalPeriod = - model.getFiscalPeriodAtRow(selectedRow); + model.getFiscalPeriodAtRow(selectedRow); //check if the user want to block the fiscal year int response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.blocked"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + JOptionPane.showConfirmDialog(getView(), + _("lima.charts.fiscalperiod.question.blocked"), + _("lima.common.question"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { //use to tell if the user wants to create a new fiscal year boolean newyear = false; //check if two fiscal periods are open - if (model.getRowCount()-1 != selectedRow) { + if (model.getRowCount() - 1 != selectedRow) { newyear = true; //two are open } else { //check if the user wants to create a new fiscal year response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.newyear"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + JOptionPane.showConfirmDialog(getView(), + _("lima.charts.fiscalperiod.question.newyear"), + _("lima.common.question"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); //create a new fiscal year if (response == JOptionPane.YES_OPTION) { addFiscalPeriod(); @@ -165,10 +165,10 @@ DialogHelper.showErrorMessageDialog(view, eee); } } - + /** - * * Sets EntryBook and Date to use + * * @param selectedFiscalPeriod * @param newyear */ @@ -179,7 +179,7 @@ // (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); try { boolean found = false; - List<FinancialTransaction> financialTransactionsList = + List<FinancialTransaction> financialTransactionsList = financialTransactionService.getAllFinancialTransactionsFromDateToDate( selectedFiscalPeriod.getBeginDate(), selectedFiscalPeriod.getEndDate()); //check if they are at least one transaction to be report @@ -189,7 +189,7 @@ Collection<Entry> entryList = financialTransactionsList.get(i).getEntry(); for (Entry entry : entryList) { if (Integer.valueOf(entry.getAccount().getAccountNumber().substring(0, 1)) < 6 - && !entry.getAmount().equals(BigDecimal.ZERO)) { + && !entry.getAmount().equals(BigDecimal.ZERO)) { found = true; } } @@ -200,15 +200,15 @@ if (found) { //check if the user wants to report datas int response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.addretainedearnings"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + JOptionPane.showConfirmDialog(getView(), + _("lima.charts.fiscalperiod.question.addretainedearnings"), + _("lima.common.question"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); //ask user for the entrybook to use for retained earnings if (response == JOptionPane.YES_OPTION) { //Sets EntryBook EntryBook newEntryBook = new EntryBookImpl(); - RetainedEarningsEntryBookForm entryBookForm = + RetainedEarningsEntryBookForm entryBookForm = new RetainedEarningsEntryBookForm(view); entryBookForm.setEntryBook(newEntryBook); // jaxx constructor don't call super() ? @@ -227,16 +227,16 @@ log.error("Can't set net income", eee); } DialogHelper.showErrorMessageDialog(view, eee); - + } } public FiscalPeriodView getView() { return view; } - - public void refresh(){ - tableModel = (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); + + public void refresh() { + tableModel = (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); tableModel.refresh(); } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/AccountsPane.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.home; -import static org.nuiton.i18n.I18n._; -import java.awt.Color; -import java.util.List; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.plaf.basic.BasicEditorPaneUI; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -44,30 +36,39 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.plaf.basic.BasicEditorPaneUI; +import java.awt.Color; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class AccountsPane extends JEditorPane implements HyperlinkListener, ServiceListener { - + private static final long serialVersionUID = 1L; - + private static final Log log = LogFactory.getLog(AccountsPane.class); - + protected HomeView view; - + protected AccountServiceMonitorable accountService; - + private static Color redBackground = new Color(0xff, 0xee, 0xee); + private static Color greenBackground = new Color(0xee, 0xff, 0xee); - public AccountsPane(HomeView view) { - this.view=view; + this.view = view; accountService = - LimaServiceFactory.getInstance().getService( - AccountServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + AccountServiceMonitorable.class); accountService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); - + //init setOpaque(true); setContentType("text/html"); @@ -80,7 +81,7 @@ @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + if (e.getDescription().equals("#accountschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); ui.getHandler().showAccountView(ui); @@ -88,29 +89,28 @@ } } - public void refresh(){ - + public void refresh() { + String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; String htmlEnd = "</p></font>"; - + try { - + List<Account> accounts = accountService.getAllAccounts(); - if (accounts.size()>0){ + if (accounts.size() > 0) { setBackground(greenBackground); String accountsString = _("lima.home.chartaccounts.state1_2") + " " - + accounts.size() + " " + _("lima.home.chartaccounts.state2_2") - + "<br/><br/><a href='#accountschart'>" - + _("lima.home.chartaccounts.modify") + "</a>"; + + accounts.size() + " " + _("lima.home.chartaccounts.state2_2") + + "<br/><br/><a href='#accountschart'>" + + _("lima.home.chartaccounts.modify") + "</a>"; //set Text setText(htmlBegin + accountsString + htmlEnd); - } - else { + } else { setBackground(redBackground); String accountsString = _("lima.home.chartaccounts.nothing") - + "<br/><br/><a href='#accountschart'>" - + _("lima.home.chartaccounts.create") + "</a>"; + + "<br/><br/><a href='#accountschart'>" + + _("lima.home.chartaccounts.create") + "</a>"; //set Text setText(htmlBegin + accountsString + htmlEnd); } @@ -121,9 +121,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { - if (methodeName.contains("Account") || methodeName.contains("importAll") || methodeName.contains("importAs")){ + if (methodeName.contains("Account") || methodeName.contains("importAll") || methodeName.contains("importAs")) { refresh(); - } + } } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/EntryBooksPane.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.home; -import static org.nuiton.i18n.I18n._; -import java.awt.Color; -import java.util.List; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.plaf.basic.BasicEditorPaneUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -43,29 +36,39 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.plaf.basic.BasicEditorPaneUI; +import java.awt.Color; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class EntryBooksPane extends JEditorPane implements HyperlinkListener, ServiceListener { private static final long serialVersionUID = 1L; - + private static final Log log = LogFactory.getLog(EntryBooksPane.class); - + protected HomeView view; - + protected EntryBookServiceMonitorable entryBookService; - + private static Color redBackground = new Color(0xff, 0xee, 0xee); + private static Color greenBackground = new Color(0xee, 0xff, 0xee); - + public EntryBooksPane(HomeView view) { - this.view=view; + this.view = view; entryBookService = - LimaServiceFactory.getInstance().getService( - EntryBookServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + EntryBookServiceMonitorable.class); entryBookService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); - + //init setOpaque(true); setContentType("text/html"); @@ -74,12 +77,12 @@ addHyperlinkListener(this); refresh(); } - + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + if (e.getDescription().equals("#entrybookschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); ui.getHandler().showEntryBookView(ui); @@ -87,65 +90,63 @@ } } - public void refresh(){ - + public void refresh() { + String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; String htmlEnd = "</p></font>"; - + try { - + List<EntryBook> entryBooks = entryBookService.getAllEntryBooks(); int ebSize = entryBooks.size(); - if (ebSize>0){ + if (ebSize > 0) { setBackground(greenBackground); String entryBooksString; - if (ebSize == 1){ + if (ebSize == 1) { entryBooksString = _("lima.home.entrybooks.state.single") - + "<br/>" + entryBooks.get(0).getLabel() - + "<br/><br/><a href='#entrybookschart'>" - + _("lima.home.entrybooks.modify") + "</a>"; - - } - else { + + "<br/>" + entryBooks.get(0).getLabel() + + "<br/><br/><a href='#entrybookschart'>" + + _("lima.home.entrybooks.modify") + "</a>"; + + } else { entryBooksString = _("lima.home.entrybooks.state1_2.plural") - + " " + entryBooks.size() + " " - + _("lima.home.entrybooks.state2_2.plural") + "<ul>"; + + " " + entryBooks.size() + " " + + _("lima.home.entrybooks.state2_2.plural") + "<ul>"; for (int i = 0; i < ebSize && i < 3; i++) { // for (EntryBook entryBook : entryBooks) { EntryBook entryBook = entryBooks.get(i); - entryBooksString += "<li>"+entryBook.getCode() + - " - "+entryBook.getLabel()+"</li>"; + entryBooksString += "<li>" + entryBook.getCode() + + " - " + entryBook.getLabel() + "</li>"; } if (ebSize > 3) { entryBooksString += "<li> ... </li>"; } entryBooksString += "</ul></p><p horizontal-align:'center'>" - + "<a href='#entrybookschart'>" - + _("lima.home.entrybooks.modify") + "</a>"; + + "<a href='#entrybookschart'>" + + _("lima.home.entrybooks.modify") + "</a>"; } //set Text setText(htmlBegin + entryBooksString + htmlEnd); - } - else { + } else { setBackground(redBackground); //set Text setText(htmlBegin - + _("lima.home.entrybooks.nothing") - + "<br/><br/><a href='#entrybookschart'>" - + _("lima.home.entrybooks.create") +"</a>" + htmlEnd); + + _("lima.home.entrybooks.nothing") + + "<br/><br/><a href='#entrybookschart'>" + + _("lima.home.entrybooks.create") + "</a>" + htmlEnd); } - + } catch (LimaException eee) { log.debug("Can't get datas account editor pane home", eee); } } - + @Override public void notifyMethod(String serviceName, String methodeName) { if (methodeName.contains("EntryBook") || methodeName.contains("importAll") - || methodeName.contains("importAs") || methodeName.contains("importEntries")){ + || methodeName.contains("importAs") || methodeName.contains("importEntries")) { refresh(); - } + } } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FinancialTransactionsPane.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.home; -import static org.nuiton.i18n.I18n._; -import java.awt.Color; -import java.util.List; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.plaf.basic.BasicEditorPaneUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -45,32 +38,43 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.plaf.basic.BasicEditorPaneUI; +import java.awt.Color; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class FinancialTransactionsPane extends JEditorPane implements HyperlinkListener, ServiceListener { private static final long serialVersionUID = 1L; - + private static final Log log = LogFactory.getLog(FinancialTransactionsPane.class); - + protected HomeView view; - + protected FinancialTransactionServiceMonitorable financialTransactionService; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + private static Color redBackground = new Color(0xff, 0xee, 0xee); + private static Color greenBackground = new Color(0xee, 0xff, 0xee); - + public FinancialTransactionsPane(HomeView view) { this.view = view; - + financialTransactionService = - LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService(FinancialTransactionServiceMonitorable.class); financialTransactionService.addServiceListener(this); fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); - + //init setOpaque(true); setContentType("text/html"); @@ -78,86 +82,82 @@ setUI(new BasicEditorPaneUI()); addHyperlinkListener(this); refresh(); - } - + } + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + if (e.getDescription().equals("#financialtransactionunbalanced")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); ui.getHandler().showTransactionUnbalancedView(ui); - } - else if (e.getDescription().equals("#financialtransactionbalanced")) { + } else if (e.getDescription().equals("#financialtransactionbalanced")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); ui.getHandler().showTransactionView(ui); } - } + } } -public void refresh(){ - + public void refresh() { + String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; String htmlEnd = "</p></font>"; - + try { - + List<FiscalPeriod> unblockedFiscalPeriods = - fiscalPeriodService.getAllUnblockedFiscalPeriods(); - if (unblockedFiscalPeriods.size() != 0){ + fiscalPeriodService.getAllUnblockedFiscalPeriods(); + if (unblockedFiscalPeriods.size() != 0) { List<FinancialTransaction> financialTransactionsUnbal = - financialTransactionService. - getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0)); - if (financialTransactionsUnbal.size()>0){ + financialTransactionService. + getAllInexactFinancialTransactions(unblockedFiscalPeriods.get(0)); + if (financialTransactionsUnbal.size() > 0) { setBackground(redBackground); String transactionsString = financialTransactionsUnbal.size() - + " " + _("lima.home.transaction.unbalanced") - + "<br/><br/><a href='#financialtransactionunbalanced'>" - + _("lima.home.transaction.modifiy.unbalanced") + "</a>"; + + " " + _("lima.home.transaction.unbalanced") + + "<br/><br/><a href='#financialtransactionunbalanced'>" + + _("lima.home.transaction.modifiy.unbalanced") + "</a>"; //set Text setText(htmlBegin + transactionsString + htmlEnd); - } - else { + } else { List<FinancialTransaction> financialTransactionsBal = - financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0)); - - if (financialTransactionsBal.size()>0){ + financialTransactionService.getAllFinancialTransactionsBalanced(unblockedFiscalPeriods.get(0)); + + if (financialTransactionsBal.size() > 0) { setBackground(greenBackground); String transactionsString = financialTransactionsBal.size() - + " " + _("lima.home.transaction.balanced") - + "<br/><br/><a href='#financialtransactionbalanced'>" - + _("lima.home.transaction.modifiy.balanced") + "</a>"; + + " " + _("lima.home.transaction.balanced") + + "<br/><br/><a href='#financialtransactionbalanced'>" + + _("lima.home.transaction.modifiy.balanced") + "</a>"; //set Text setText(htmlBegin + transactionsString + htmlEnd); - } - else { + } else { setBackground(redBackground); String transactionsString = _("lima.home.transaction.nothing") - + "<br/><br/><a href='#financialtransactionbalanced'>" - + _("lima.home.transaction.create") + "</a>"; + + "<br/><br/><a href='#financialtransactionbalanced'>" + + _("lima.home.transaction.create") + "</a>"; //set Text setText(htmlBegin + transactionsString + htmlEnd); } } - } - else { + } else { setBackground(redBackground); } - + } catch (LimaException eee) { log.debug("Can't get datas account editor pane home", eee); } } - + @Override public void notifyMethod(String serviceName, String methodeName) { if (methodeName.contains("FiscalPeriod") || methodeName.contains("FinancialTransaction") - || methodeName.contains("Entry") || methodeName.contains("importEntries") - || methodeName.contains("importAll") || methodeName.contains("importAs")){ + || methodeName.contains("Entry") || methodeName.contains("importEntries") + || methodeName.contains("importAll") || methodeName.contains("importAs")) { refresh(); - } + } } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/home/FiscalPeriodsPane.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.home; -import static org.nuiton.i18n.I18n._; -import java.awt.Color; -import java.util.List; -import javax.swing.JEditorPane; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import javax.swing.plaf.basic.BasicEditorPaneUI; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; @@ -43,82 +36,92 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.MainView; +import javax.swing.JEditorPane; +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; +import javax.swing.plaf.basic.BasicEditorPaneUI; +import java.awt.Color; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class FiscalPeriodsPane extends JEditorPane implements HyperlinkListener, ServiceListener { private static final long serialVersionUID = 1L; - + private static final Log log = LogFactory.getLog(FiscalPeriodsPane.class); - + protected HomeView view; - + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + private static Color redBackground = new Color(0xff, 0xee, 0xee); + private static Color greenBackground = new Color(0xee, 0xff, 0xee); - + public FiscalPeriodsPane(HomeView view) { this.view = view; - + fiscalPeriodService = - LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService(FiscalPeriodServiceMonitorable.class); fiscalPeriodService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); - + //init setOpaque(true); setContentType("text/html"); setEditable(false); setUI(new BasicEditorPaneUI()); addHyperlinkListener(this); - refresh(); } - + refresh(); + } + @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - + if (e.getDescription().equals("#fiscalperiodschart")) { MainView ui = LimaContext.MAIN_UI_ENTRY_DEF.getContextValue(view); ui.getHandler().showFiscalPeriodView(ui); } } } - -public void refresh(){ - + + public void refresh() { + String htmlBegin = "<font face='sans-serif' size=3>" - + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; + + "<p style=vertical-align:'bottom', horizontal-align:'center'>"; String htmlEnd = "</p></font>"; - + try { - + //FISCAL PERIOD List<FiscalPeriod> fiscalPeriods = - fiscalPeriodService.getAllFiscalPeriods(); + fiscalPeriodService.getAllFiscalPeriods(); List<FiscalPeriod> unblockedFiscalPeriods = - fiscalPeriodService.getAllUnblockedFiscalPeriods(); - if (unblockedFiscalPeriods.size()>0){ + fiscalPeriodService.getAllUnblockedFiscalPeriods(); + if (unblockedFiscalPeriods.size() > 0) { setBackground(greenBackground); String fiscalString = unblockedFiscalPeriods.size() + " " - + _("lima.home.fiscalperiod.opened") + "<br/>" - + (fiscalPeriods.size()-unblockedFiscalPeriods.size()) - + " " + _("lima.home.fiscalperiod.closed") - + "<br/><br/><a href='#fiscalperiodschart'>" - + _("lima.home.fiscalperiod.modify") + "</a>"; + + _("lima.home.fiscalperiod.opened") + "<br/>" + + (fiscalPeriods.size() - unblockedFiscalPeriods.size()) + + " " + _("lima.home.fiscalperiod.closed") + + "<br/><br/><a href='#fiscalperiodschart'>" + + _("lima.home.fiscalperiod.modify") + "</a>"; //set Text setText(htmlBegin + fiscalString + htmlEnd); - - - } - else { + + + } else { setBackground(redBackground); String fiscalString = _("lima.home.fiscalperiod.noopen"); - if (fiscalPeriods.size()>0){ + if (fiscalPeriods.size() > 0) { fiscalString += "<br/>" + fiscalPeriods.size() + " " - + _("lima.home.fiscalperiod.closed"); + + _("lima.home.fiscalperiod.closed"); } fiscalString += "<br/><br/><a href='#fiscalperiodschart'>" - + _("lima.home.fiscalperiod.create") + "</a>"; + + _("lima.home.fiscalperiod.create") + "</a>"; //set Text setText(htmlBegin + fiscalString + htmlEnd); @@ -131,9 +134,9 @@ @Override public void notifyMethod(String serviceName, String methodeName) { if (methodeName.contains("FiscalPeriod") || methodeName.contains("importAll") - || methodeName.contains("importAs")){ + || methodeName.contains("importAs")) { refresh(); - } + } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityForm.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityForm.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -27,10 +27,11 @@ defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> - <IdentityHandler id="handler" javaBean="new IdentityHandler()" /> - <org.chorem.lima.entity.Identity id="identity" javaBean='handler.getIdentity()'/> + <IdentityHandler id="handler" javaBean="new IdentityHandler()"/> + <org.chorem.lima.entity.Identity id="identity" + javaBean='handler.getIdentity()'/> - <script> + <script> <![CDATA[ getRootPane().setDefaultButton(ok); protected void performCancel() { @@ -38,138 +39,152 @@ dispose(); } ]]> - </script> + </script> - <Table> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.name"/> - </cell> - <cell fill="horizontal"> - <JTextField id="nameTextField" text="{getIdentity().getName()}"/> - <javax.swing.text.Document javaBean="getNameTextField().getDocument()" - onInsertUpdate='getIdentity().setName(getNameTextField().getText())' - onRemoveUpdate='getIdentity().setName(getNameTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.description"/> - </cell> - <cell fill="horizontal"> - <JTextField id="descriptionTextField" text="{getIdentity().getDescription()}"/> - <javax.swing.text.Document javaBean="getDescriptionTextField().getDocument()" - onInsertUpdate='getIdentity().setDescription(getDescriptionTextField().getText())' - onRemoveUpdate='getIdentity().setDescription(getDescriptionTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.address"/> - </cell> - <cell fill="horizontal"> - <JTextField id="addressTextField" text="{getIdentity().getAddress()}"/> - <javax.swing.text.Document javaBean="getAddressTextField().getDocument()" - onInsertUpdate='getIdentity().setAddress(getAddressTextField().getText())' - onRemoveUpdate='getIdentity().setAddress(getAddressTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.address2"/> - </cell> - <cell fill="horizontal"> - <JTextField id="address2TextField" text="{getIdentity().getAddress2()}"/> - <javax.swing.text.Document javaBean="getAddress2TextField().getDocument()" - onInsertUpdate='getIdentity().setAddress2(getAddress2TextField().getText())' - onRemoveUpdate='getIdentity().setAddress2(getAddress2TextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.zipCode"/> - </cell> - <cell fill="horizontal"> - <JTextField id="zipCodeTextField" text="{getIdentity().getZipCode()}"/> - <javax.swing.text.Document javaBean="getZipCodeTextField().getDocument()" - onInsertUpdate='getIdentity().setZipCode(getZipCodeTextField().getText())' - onRemoveUpdate='getIdentity().setZipCode(getZipCodeTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.city"/> - </cell> - <cell fill="horizontal"> - <JTextField id="cityTextField" text="{getIdentity().getCity()}"/> - <javax.swing.text.Document javaBean="getCityTextField().getDocument()" - onInsertUpdate='getIdentity().setCity(getCityTextField().getText())' - onRemoveUpdate='getIdentity().setCity(getCityTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.businessNumber"/> - </cell> - <cell fill="horizontal"> - <JTextField id="businessNumberTextField" text="{getIdentity().getBusinessNumber()}"/> - <javax.swing.text.Document javaBean="getBusinessNumberTextField().getDocument()" - onInsertUpdate='getIdentity().setBusinessNumber(getBusinessNumberTextField().getText())' - onRemoveUpdate='getIdentity().setBusinessNumber(getBusinessNumberTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.vatNumber"/> - </cell> - <cell fill="horizontal"> - <JTextField id="vatNumberTextField" text="{getIdentity().getVatNumber()}"/> - <javax.swing.text.Document javaBean="getVatNumberTextField().getDocument()" - onInsertUpdate='getIdentity().setVatNumber(getVatNumberTextField().getText())' - onRemoveUpdate='getIdentity().setVatNumber(getVatNumberTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.classificationCode"/> - </cell> - <cell fill="horizontal"> - <JTextField id="classificationCodeTextField" text="{getIdentity().getClassificationCode()}"/> - <javax.swing.text.Document javaBean="getClassificationCodeTextField().getDocument()" - onInsertUpdate='getIdentity().setClassificationCode(getClassificationCodeTextField().getText())' - onRemoveUpdate='getIdentity().setClassificationCode(getClassificationCodeTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.phoneNumber"/> - </cell> - <cell fill="horizontal"> - <JTextField id="phoneNumberTextField" text="{getIdentity().getPhoneNumber()}"/> - <javax.swing.text.Document javaBean="getPhoneNumberTextField().getDocument()" - onInsertUpdate='getIdentity().setPhoneNumber(getPhoneNumberTextField().getText())' - onRemoveUpdate='getIdentity().setPhoneNumber(getPhoneNumberTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="lima.identity.email"/> - </cell> - <cell fill="horizontal"> - <JTextField id="emailTextField" text="{getIdentity().getEmail()}"/> - <javax.swing.text.Document javaBean="getEmailTextField().getDocument()" - onInsertUpdate='getIdentity().setEmail(getEmailTextField().getText())' - onRemoveUpdate='getIdentity().setEmail(getEmailTextField().getText())' /> - </cell> - </row> - <row> - <cell fill="none"> - <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> - </cell> - <cell fill="none"> - <JButton id="ok" text="lima.common.ok" onActionPerformed="handler.updateIdentity(getIdentity()); + <Table> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.name"/> + </cell> + <cell fill="horizontal"> + <JTextField id="nameTextField" text="{getIdentity().getName()}"/> + <javax.swing.text.Document javaBean="getNameTextField().getDocument()" + onInsertUpdate='getIdentity().setName(getNameTextField().getText())' + onRemoveUpdate='getIdentity().setName(getNameTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.description"/> + </cell> + <cell fill="horizontal"> + <JTextField id="descriptionTextField" + text="{getIdentity().getDescription()}"/> + <javax.swing.text.Document + javaBean="getDescriptionTextField().getDocument()" + onInsertUpdate='getIdentity().setDescription(getDescriptionTextField().getText())' + onRemoveUpdate='getIdentity().setDescription(getDescriptionTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.address"/> + </cell> + <cell fill="horizontal"> + <JTextField id="addressTextField" text="{getIdentity().getAddress()}"/> + <javax.swing.text.Document + javaBean="getAddressTextField().getDocument()" + onInsertUpdate='getIdentity().setAddress(getAddressTextField().getText())' + onRemoveUpdate='getIdentity().setAddress(getAddressTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.address2"/> + </cell> + <cell fill="horizontal"> + <JTextField id="address2TextField" + text="{getIdentity().getAddress2()}"/> + <javax.swing.text.Document + javaBean="getAddress2TextField().getDocument()" + onInsertUpdate='getIdentity().setAddress2(getAddress2TextField().getText())' + onRemoveUpdate='getIdentity().setAddress2(getAddress2TextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.zipCode"/> + </cell> + <cell fill="horizontal"> + <JTextField id="zipCodeTextField" text="{getIdentity().getZipCode()}"/> + <javax.swing.text.Document + javaBean="getZipCodeTextField().getDocument()" + onInsertUpdate='getIdentity().setZipCode(getZipCodeTextField().getText())' + onRemoveUpdate='getIdentity().setZipCode(getZipCodeTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.city"/> + </cell> + <cell fill="horizontal"> + <JTextField id="cityTextField" text="{getIdentity().getCity()}"/> + <javax.swing.text.Document javaBean="getCityTextField().getDocument()" + onInsertUpdate='getIdentity().setCity(getCityTextField().getText())' + onRemoveUpdate='getIdentity().setCity(getCityTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.businessNumber"/> + </cell> + <cell fill="horizontal"> + <JTextField id="businessNumberTextField" + text="{getIdentity().getBusinessNumber()}"/> + <javax.swing.text.Document + javaBean="getBusinessNumberTextField().getDocument()" + onInsertUpdate='getIdentity().setBusinessNumber(getBusinessNumberTextField().getText())' + onRemoveUpdate='getIdentity().setBusinessNumber(getBusinessNumberTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.vatNumber"/> + </cell> + <cell fill="horizontal"> + <JTextField id="vatNumberTextField" + text="{getIdentity().getVatNumber()}"/> + <javax.swing.text.Document + javaBean="getVatNumberTextField().getDocument()" + onInsertUpdate='getIdentity().setVatNumber(getVatNumberTextField().getText())' + onRemoveUpdate='getIdentity().setVatNumber(getVatNumberTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.classificationCode"/> + </cell> + <cell fill="horizontal"> + <JTextField id="classificationCodeTextField" + text="{getIdentity().getClassificationCode()}"/> + <javax.swing.text.Document + javaBean="getClassificationCodeTextField().getDocument()" + onInsertUpdate='getIdentity().setClassificationCode(getClassificationCodeTextField().getText())' + onRemoveUpdate='getIdentity().setClassificationCode(getClassificationCodeTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.phoneNumber"/> + </cell> + <cell fill="horizontal"> + <JTextField id="phoneNumberTextField" + text="{getIdentity().getPhoneNumber()}"/> + <javax.swing.text.Document + javaBean="getPhoneNumberTextField().getDocument()" + onInsertUpdate='getIdentity().setPhoneNumber(getPhoneNumberTextField().getText())' + onRemoveUpdate='getIdentity().setPhoneNumber(getPhoneNumberTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="lima.identity.email"/> + </cell> + <cell fill="horizontal"> + <JTextField id="emailTextField" text="{getIdentity().getEmail()}"/> + <javax.swing.text.Document javaBean="getEmailTextField().getDocument()" + onInsertUpdate='getIdentity().setEmail(getEmailTextField().getText())' + onRemoveUpdate='getIdentity().setEmail(getEmailTextField().getText())'/> + </cell> + </row> + <row> + <cell fill="none"> + <JButton text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + <cell fill="none"> + <JButton id="ok" text="lima.common.ok" onActionPerformed="handler.updateIdentity(getIdentity()); dispose()"/> - </cell> - </row> - </Table> + </cell> + </row> + </Table> </JDialog> \ No newline at end of file Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/identity/IdentityHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -40,36 +40,36 @@ private static final Log log = LogFactory.getLog(IdentityHandler.class); - + public IdentityHandler() { identityService = - LimaServiceFactory.getInstance().getService( - IdentityServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + IdentityServiceMonitorable.class); } - public Identity getIdentity(){ + public Identity getIdentity() { Identity identity = null; try { identity = identityService.getIdentity(); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't get Identity", eee); } } - if (identity == null){ + if (identity == null) { identity = new IdentityImpl(); } return identity; } - public void updateIdentity(Identity identity){ - + public void updateIdentity(Identity identity) { + try { identityService.updateIdentity(identity); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't update Identity", eee); } } - } + } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExport.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -64,32 +64,32 @@ import static org.nuiton.i18n.I18n._; public class ImportExport { - + private static ImportExport exchanger; - + private static final Log log = LogFactory.getLog(AccountViewHandler.class); - + protected static Component viewComponent; - + protected EncodingEnum encodingEnum; protected ImportServiceMonitorable importService; - + protected ExportServiceMonitorable exportService; - + private ImportExportWaitView waitView; public ImportExport(Component view) { - viewComponent=view; - + viewComponent = view; + //services importService = - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class); exportService = - LimaServiceFactory.getInstance().getService( - ExportServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + ExportServiceMonitorable.class); + //create the wait dialog panel waitView = new ImportExportWaitView(); waitView.waitDialog.setSize(400, 200); @@ -101,10 +101,10 @@ /** * Call the appropriate methode in business service. - * + * * @param importExportMethode */ - public void importExport(ImportExportEnum importExportMethode, String file, Boolean verbose){ + public void importExport(ImportExportEnum importExportMethode, String file, Boolean verbose) { final ImportExportEnum importExportMethodeF = importExportMethode; encodingEnum = EncodingEnum.UTF8; if (file.equals("")) { @@ -116,8 +116,9 @@ final String filePath = file; final Boolean verboseMode = verbose; final Boolean importMode = importExportMethode.getImportMode(); - new SwingWorker<String,Void>() { - @Override protected String doInBackground() throws LimaException { + new SwingWorker<String, Void>() { + @Override + protected String doInBackground() throws LimaException { String datas; String result = ""; switch (importExportMethodeF) { @@ -173,8 +174,8 @@ break; case PDF_VAT_IMPORT: int response = JOptionPane.showConfirmDialog(waitView, - _("lima.importexport.usevatpdf"), - _("lima.common.confirmation"), JOptionPane.YES_NO_OPTION); + _("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); break; @@ -188,52 +189,52 @@ datas = extractFile(filePath, EncodingEnum.ISOLATIN1.getEncoding()); result = importService.importEntriesFromEbp(datas); break; - } + } return result; } - @Override protected void done() { + + @Override + protected void done() { try { //hidde wait dialog panel waitView.setVisible(false); // display result dialog - if (verboseMode){ + if (verboseMode) { String result = get(); - if (!result.equals("")){ + if (!result.equals("")) { DialogHelper.showReportDialog(result, _("lima.importexport.import"), viewComponent); - } - else { - if (importMode){ - //special message when importing a VAT PDF - if (importExportMethodeF.equals(ImportExportEnum.PDF_VAT_IMPORT)) { - JOptionPane.showMessageDialog( - waitView, - _("lima.importexport.import.vatpdfimport"), - _("lima.importexport.import"), - JOptionPane.INFORMATION_MESSAGE); - } else { + } else { + if (importMode) { + //special message when importing a VAT PDF + if (importExportMethodeF.equals(ImportExportEnum.PDF_VAT_IMPORT)) { JOptionPane.showMessageDialog( + waitView, + _("lima.importexport.import.vatpdfimport"), + _("lima.importexport.import"), + JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog( + waitView, + _("lima.importexport.import.terminated"), + _("lima.importexport.import"), + JOptionPane.INFORMATION_MESSAGE); + } + } else { + JOptionPane.showMessageDialog( waitView, - _("lima.importexport.import.terminated"), - _("lima.importexport.import"), - JOptionPane.INFORMATION_MESSAGE); - } - } - else { - JOptionPane.showMessageDialog( - waitView, _("lima.importexport.export.terminated"), _("lima.importexport.export"), JOptionPane.INFORMATION_MESSAGE); - } - } + } + } } } catch (InterruptedException eee) { - if (log.isErrorEnabled()){ + if (log.isErrorEnabled()) { log.error("Can't get result message", eee); } } catch (ExecutionException eee) { DialogHelper.showMessageDialog(eee.getCause().getMessage()); - if (log.isErrorEnabled()){ + if (log.isErrorEnabled()) { log.error("Error on import", eee); } } @@ -242,68 +243,62 @@ waitView.setVisible(true); } } - - + + /** * open choose file dialog with appropriate file mode view * folders for export or folders+files for import + * * @param importMode * @return */ - public String chooseFile(Boolean importMode, ImportExportEnum importExportMethode){ + public String chooseFile(Boolean importMode, ImportExportEnum importExportMethode) { String filePath = ""; - JFileChooser chooser = new JFileChooser(); - //Encoding option - - JComboBox comboBox = new JComboBox(EncodingEnum.descriptions()); - if (importExportMethode.getEncodingOption()){ - JPanel panel = new JPanel(); - panel.setLayout(new BorderLayout()); - panel.add(new JLabel(_("lima.importexport.choiceencoding")), BorderLayout.WEST); - panel.add(comboBox, BorderLayout.CENTER); - ((Container)chooser.getComponent(2)).add(panel, BorderLayout.SOUTH); - } - - if (importMode){ - chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + JFileChooser chooser = new JFileChooser(); + //Encoding option + + JComboBox comboBox = new JComboBox(EncodingEnum.descriptions()); + if (importExportMethode.getEncodingOption()) { + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(new JLabel(_("lima.importexport.choiceencoding")), BorderLayout.WEST); + panel.add(comboBox, BorderLayout.CENTER); + ((Container) chooser.getComponent(2)).add(panel, BorderLayout.SOUTH); } - else { + + if (importMode) { + chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + } else { chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); } if (chooser.showOpenDialog(viewComponent) == JFileChooser.APPROVE_OPTION) { filePath = chooser.getSelectedFile().getAbsolutePath(); - if (importExportMethode.getEncodingOption()){ + if (importExportMethode.getEncodingOption()) { encodingEnum = EncodingEnum.valueOfDescription((String) comboBox.getSelectedItem()); } } return filePath; } - - - /** - * Get csv datas in string and write file - * - */ - public void createFile(String filePath, String charset, String datas){ + + + /** Get csv datas in string and write file */ + public void createFile(String filePath, String charset, String datas) { try { File file = new File(filePath); BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), charset)); out.write(datas); out.flush(); out.close(); - } - catch (IOException eee) { - if (log.isErrorEnabled()){ + } catch (IOException eee) { + if (log.isErrorEnabled()) { log.error("Can't write file " + filePath, eee); } } } - /** - * Open csv file and get his datas on a string. - */ + /** Open csv file and get his datas on a string. */ public String extractFile(String filePath, String charset) { StringWriter sw = new StringWriter(); BufferedReader in = null; @@ -314,35 +309,31 @@ if (filePath != null && filePath.indexOf(".jar!") > 0) { String resourcesPath = filePath.substring(filePath.indexOf(".jar!") + 5); is = ImportExport.class.getResourceAsStream(resourcesPath); - } - else { + } else { is = new FileInputStream(filePath); } in = new BufferedReader(new InputStreamReader(is, charset)); IOUtils.copy(in, sw); in.close(); - } - catch (IOException eee) { + } catch (IOException eee) { if (log.isErrorEnabled()) { log.error("Can't read file " + filePath, eee); } - } - finally { + } finally { IOUtils.closeQuietly(in); } return sw.toString(); } - + public static ImportExport getInstance(Component view) { if (exchanger == null) { exchanger = new ImportExport(view); + } else { + viewComponent = view; } - else { - viewComponent=view; - } return exchanger; } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/importexport/ImportExportWaitView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,20 +25,20 @@ <JDialog modal="true" id="waitDialog"> - <script> + <script> <![CDATA[ - ]]> - </script> + ]]> + </script> - <Table> - <row> - <cell> - <org.jdesktop.swingx.JXBusyLabel id='busylabel' busy='true'/> - </cell> - <cell> - <JLabel text='lima.importexport.wait'/> - </cell> - </row> - </Table> + <Table> + <row> + <cell> + <org.jdesktop.swingx.JXBusyLabel id='busylabel' busy='true'/> + </cell> + <cell> + <JLabel text='lima.importexport.wait'/> + </cell> + </row> + </Table> </JDialog> \ No newline at end of file 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,14 +25,6 @@ package org.chorem.lima.ui.ledger; -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; @@ -40,120 +32,130 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 LedgerPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(LedgerPeriodSearchPanel.class); - + LogFactory.getLog(LedgerPeriodSearchPanel.class); + protected LedgerViewHandler handler; - + public LedgerPeriodSearchPanel(LedgerViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + // 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(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + 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(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + 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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + 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/ledger/LedgerTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,6 +25,13 @@ package org.chorem.lima.ui.ledger; +import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; +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; @@ -33,17 +40,10 @@ import java.awt.event.MouseListener; import java.math.BigDecimal; -import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; -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; - /** * Table des transaction qui ajoute des comportement (keys). - * + * * @author ore * @author Rémi Chapelet */ @@ -53,7 +53,7 @@ private static final long serialVersionUID = 3133690382049594727L; protected LedgerViewHandler handler; - + private Highlighter colorReportsDatas; /** @@ -61,13 +61,13 @@ public LedgerTable(LedgerViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); - + //highlight financial financial transactions addColorReportsDatas(); @@ -78,19 +78,19 @@ * afin de bien distinguer les entête de comptes et les entrées comptables. * On récupère la première cellule, on vérifie que c'est pas null */ - protected void addColorReportsDatas() { - if (colorReportsDatas != null) { - removeHighlighter(colorReportsDatas); - } - HighlightPredicate predicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { - return adapter.getValueAt(adapter.row, 0) != null; - } - }; - colorReportsDatas = - new ColorHighlighter(predicate, new Color(222,222,222), null); + protected void addColorReportsDatas() { + if (colorReportsDatas != null) { + removeHighlighter(colorReportsDatas); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + return adapter.getValueAt(adapter.row, 0) != null; + } + }; + colorReportsDatas = + new ColorHighlighter(predicate, new Color(222, 222, 222), null); addHighlighter(colorReportsDatas); } @@ -129,9 +129,9 @@ public void keyPressed(KeyEvent e) { // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,13 +25,6 @@ package org.chorem.lima.ui.ledger; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -import java.text.SimpleDateFormat; -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.beans.ReportsDatas; @@ -39,15 +32,23 @@ import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Entry book table model. - * + * * @author ore * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class LedgerTableModel extends AbstractTableModel { @@ -56,14 +57,14 @@ /** log. */ private static final Log log = LogFactory.getLog(LedgerTableModel.class); - + /** data cache */ protected List<Object> cacheDataList; @Override public int getRowCount() { int result = 0; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.size(); @@ -76,44 +77,43 @@ public int getColumnCount() { return 8; } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = Account.class; - break; - case 1: - result = Date.class; - break; - case 2: - result = EntryBook.class; - break; - case 3: - result = String.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 0: + result = Account.class; + break; + case 1: + result = Date.class; + break; + case 2: + result = EntryBook.class; + break; + case 3: + result = String.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; } return result; } - - + @Override public String getColumnName(int column) { String res = "n/a"; @@ -145,114 +145,110 @@ } return res; } - + @Override public Object getValueAt(int row, int column) { Object result = null; - + // just prevent too much result if (cacheDataList != null) { result = cacheDataList.get(row); SimpleDateFormat simpleDateFormat - = new SimpleDateFormat("dd MMMMM yyyy"); - + = new SimpleDateFormat("dd MMMMM yyyy"); + if (result instanceof ReportsDatas) { - ReportsDatas currentRow = (ReportsDatas)result; + ReportsDatas currentRow = (ReportsDatas) result; BigDecimal amountDebit = currentRow.getAmountDebit(); BigDecimal amountCredit = currentRow.getAmountCredit(); - + switch (column) { - case 0: - if (currentRow.getAccount() != null){ - result = currentRow.getAccount().getAccountNumber(); - } - else { - result = null; - } - break; - case 1: - result = null; // date - break; - case 2: - result = null; //entrybook - break; - case 3: - result = null; // voucher - break; - case 4: - result = null; // description - break; - case 5 : - result = amountDebit; // position - break; - case 6: - result = amountCredit; - break; - case 7: - result = amountDebit.subtract(amountCredit); - break; + case 0: + if (currentRow.getAccount() != null) { + result = currentRow.getAccount().getAccountNumber(); + } else { + result = null; + } + break; + case 1: + result = null; // date + break; + case 2: + result = null; //entrybook + break; + case 3: + result = null; // voucher + break; + case 4: + result = null; // description + break; + case 5: + result = amountDebit; // position + break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit.subtract(amountCredit); + break; } - } - else if (result instanceof Entry) { - Entry currentRow = (Entry)result; + } else if (result instanceof Entry) { + Entry currentRow = (Entry) result; BigDecimal amountDebit = BigDecimal.ZERO, - amountCredit = BigDecimal.ZERO; - if (currentRow.getDebit()){ + amountCredit = BigDecimal.ZERO; + if (currentRow.getDebit()) { amountDebit = currentRow.getAmount(); - } - else { + } else { amountCredit = currentRow.getAmount(); } switch (column) { - case 0: - result = null; // account - break; - case 1 : // date - result = simpleDateFormat. - format(currentRow.getFinancialTransaction().getTransactionDate()); - break; - case 2: - if (currentRow.getFinancialTransaction().getEntryBook() != null){ - result = currentRow.getFinancialTransaction().getEntryBook().getCode(); - } - else { //entrybook - result = null; - } - break; - case 3: // description - result = currentRow.getVoucher(); - break; - case 4: - result = currentRow.getDescription(); - break; - case 5 : - result = amountDebit; - break; - case 6: - result = amountCredit; - break; - case 7: - result = amountDebit.subtract(amountCredit); - break; + case 0: + result = null; // account + break; + case 1: // date + result = simpleDateFormat. + format(currentRow.getFinancialTransaction().getTransactionDate()); + break; + case 2: + if (currentRow.getFinancialTransaction().getEntryBook() != null) { + result = currentRow.getFinancialTransaction().getEntryBook().getCode(); + } else { //entrybook + result = null; + } + break; + case 3: // description + result = currentRow.getVoucher(); + break; + case 4: + result = currentRow.getDescription(); + break; + case 5: + result = amountDebit; + break; + case 6: + result = amountCredit; + break; + case 7: + result = amountDebit.subtract(amountCredit); + break; } - + } } return result; } - + @Override public boolean isCellEditable(int rowIndex, int columnIndex) { // Just read, no write return false; } - - - public void refresh(List<Object> datasList){ + + + public void refresh(List<Object> datasList) { cacheDataList = datasList; fireTableDataChanged(); } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,11 +24,11 @@ --> <Table> - <LedgerViewHandler id="handler" javaBean="new LedgerViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> - <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/> - <org.chorem.lima.ui.ledger.LedgerTableModel id="modelTable"/> - <script> + <LedgerViewHandler id="handler" javaBean="new LedgerViewHandler(this)"/> + <Boolean id="selectedRow" javaBean="false"/> + <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/> + <org.chorem.lima.ui.ledger.LedgerTableModel id="modelTable"/> + <script> <![CDATA[ import org.chorem.lima.enums.ComboBoxDatesEnum; LedgerPeriodSearchPanel periodSearchPanel = new LedgerPeriodSearchPanel(handler); @@ -37,71 +37,83 @@ } ]]> - </script> - <row weightx="1" weighty="0" anchor="center"> - <cell fill='both'><Table><row> - <cell anchor="west"><JComboBox id="periodComboBox" javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())" - onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); - validate(); repaint()"/></cell> - <cell><LedgerPeriodSearchPanel javaBean="periodSearchPanel"/></cell> - </row></Table></cell> - <cell anchor="east"> - <JLabel text="lima.common.filter"/> - </cell> - <cell anchor="west"> - <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter" minimumSize='{balanceFilter.getPreferredSize()}'/> - <javax.swing.text.Document javaBean="balanceFilter.getDocument()" - onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())' - onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())' /> - </cell> - <cell anchor="center"> - <JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter' selected='false' - onActionPerformed="getHandler().refresh()"/> - </cell> - <cell> - <EnumEditor id='DocumentEditor' - constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/> - </cell> - <cell> - <JButton text="lima.common.ok" - onActionPerformed="getHandler().createDocument()"/> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" columns="8"> - <JScrollPane> - <org.chorem.lima.ui.ledger.LedgerTable - id="table" sortable="false" rowHeight="24" - constructorParams="getHandler()" model="{getModelTable()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> - <javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()"/> - </JScrollPane> - </cell> - </row> - <row> - <cell fill="horizontal" weightx="1" columns="7"> - <Table> - <row fill="horizontal" weightx="1"> - <cell> - <JLabel text="lima.common.amountdebit" /> - </cell> - <cell> - <JLabel id="amountDebitLabel" /> - </cell> - <cell> - <JLabel text="lima.common.amountcredit"/> - </cell> - <cell> - <JLabel id="amountCreditLabel" /> - </cell> - <cell> - <JLabel id="soldeLabel" text="lima.common.solde"/> - </cell> - <cell> - <JLabel id="amountSoldeLabel"/> - </cell> - </row> - </Table> - </cell> - </row> + </script> + <row weightx="1" weighty="0" anchor="center"> + <cell fill='both'> + <Table> + <row> + <cell anchor="west"> + <JComboBox id="periodComboBox" + javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())" + onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); + validate(); repaint()"/> + </cell> + <cell> + <LedgerPeriodSearchPanel javaBean="periodSearchPanel"/> + </cell> + </row> + </Table> + </cell> + <cell anchor="east"> + <JLabel text="lima.common.filter"/> + </cell> + <cell anchor="west"> + <JTextField id='balanceFilter' toolTipText="lima.tooltip.filter" + minimumSize='{balanceFilter.getPreferredSize()}'/> + <javax.swing.text.Document javaBean="balanceFilter.getDocument()" + onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())' + onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())'/> + </cell> + <cell anchor="center"> + <JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter' + selected='false' + onActionPerformed="getHandler().refresh()"/> + </cell> + <cell> + <EnumEditor id='DocumentEditor' + constructorParams='org.chorem.lima.business.utils.FormatsEnum.class'/> + </cell> + <cell> + <JButton text="lima.common.ok" + onActionPerformed="getHandler().createDocument()"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" columns="8"> + <JScrollPane> + <org.chorem.lima.ui.ledger.LedgerTable + id="table" sortable="false" rowHeight="24" + constructorParams="getHandler()" model="{getModelTable()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + <javax.swing.ListSelectionModel + javaBean="getTable().getSelectionModel()"/> + </JScrollPane> + </cell> + </row> + <row> + <cell fill="horizontal" weightx="1" columns="7"> + <Table> + <row fill="horizontal" weightx="1"> + <cell> + <JLabel text="lima.common.amountdebit"/> + </cell> + <cell> + <JLabel id="amountDebitLabel"/> + </cell> + <cell> + <JLabel text="lima.common.amountcredit"/> + </cell> + <cell> + <JLabel id="amountCreditLabel"/> + </cell> + <cell> + <JLabel id="soldeLabel" text="lima.common.solde"/> + </cell> + <cell> + <JLabel id="amountSoldeLabel"/> + </cell> + </row> + </Table> + </cell> + </row> </Table> \ No newline at end of file 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,20 +25,6 @@ package org.chorem.lima.ui.ledger; -import static org.nuiton.i18n.I18n._; -import java.awt.Desktop; -import java.io.IOException; -import java.math.BigDecimal; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; @@ -60,7 +46,21 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; +import javax.swing.JOptionPane; +import java.awt.Desktop; +import java.io.IOException; +import java.math.BigDecimal; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import static org.nuiton.i18n.I18n._; + + /** * Handler associated with accounts reports view. * By : $Author$ @@ -70,89 +70,91 @@ protected LedgerView view; protected LedgerTableModel model; - + /** log. */ private static final Log log = LogFactory.getLog(LedgerTableModel.class); /** Services. */ protected ReportServiceMonitorable reportService; + protected DocumentServiceMonitorable documentService; + protected FiscalPeriodServiceMonitorable fiscalPeriodService; - + /** Begin Date. */ protected Date selectedBeginDate; - + /** EndDate. */ protected Date selectedEndDate; - + /** Text field Accounts */ protected String selectedAccounts; - + protected BalanceTrial balanceTrialCache; private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - + new SimpleDateFormat("yyyy-MM-dd"); + protected int port; - + protected List<Object> cachedatasList; - + protected LedgerViewHandler(LedgerView view) { this.view = view; - + reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); reportService.addServiceListener(this); port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); fiscalPeriodService = - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); LimaServiceFactory.getInstance().getService( FinancialTransactionServiceMonitorable.class).addServiceListener(this); } - - public void setBeginDate(Date date){ + + public void setBeginDate(Date date) { selectedBeginDate = date; } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { selectedEndDate = date; } - + public void setAccountFilter(String accounts) { selectedAccounts = accounts; refresh(); } - + /** * get all account fot the selected period + * * @return */ - public List<Object> getDataList(){ + public List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); try { balanceTrialCache = reportService.generateLedger(selectedBeginDate, - selectedEndDate, selectedAccounts, - view.getMovmentedFilter().isSelected()); - if (balanceTrialCache.getReportsDatas() != null){ - for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { + selectedEndDate, selectedAccounts, + view.getMovmentedFilter().isSelected()); + if (balanceTrialCache.getReportsDatas() != null) { + for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) { results.add(reportsDatas); List<Entry> entries = reportsDatas.getListEntry(); - if (entries != null){ + if (entries != null) { Collections.sort(entries, new EntryComparator()); - results.addAll(entries); + results.addAll(entries); } } } - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -160,47 +162,45 @@ } return results; } - - public void refresh(){ - if (selectedBeginDate != null && selectedEndDate != null){ + + public void refresh() { + if (selectedBeginDate != null && selectedEndDate != null) { model = view.getModelTable(); cachedatasList = getDataList(); model.refresh(cachedatasList); - - /** - * set text and amounts of labels credit, debit, solde - */ - - if (balanceTrialCache != null){ + + /** + * set text and amounts of labels credit, debit, solde + */ + + if (balanceTrialCache != null) { // set amounts credit, debit and solde view.amountCreditLabel.setText( String.valueOf(balanceTrialCache.getAmountCredit())); view.amountDebitLabel.setText( - String.valueOf(balanceTrialCache.getAmountDebit())); + String.valueOf(balanceTrialCache.getAmountDebit())); BigDecimal amountSolde = balanceTrialCache.getAmountSolde(); view.amountSoldeLabel.setText( String.valueOf(amountSolde)); - - if (amountSolde == BigDecimal.ZERO){ + + if (amountSolde == BigDecimal.ZERO) { view.soldeLabel.setText(_("lima.common.solde")); - } - else { + } else { // set label solde: credit or debit if (balanceTrialCache.getSoldeDebit()) { view.soldeLabel.setText(_("lima.common.soldedebit")); - } - else { + } else { view.soldeLabel.setText(_("lima.common.soldecredit")); } } } } } - + public void createDocument() { - - if (selectedBeginDate != null && selectedEndDate != null){ - + + if (selectedBeginDate != null && selectedEndDate != null) { + //looks for all blocked fiscal periods List<FiscalPeriod> blockedFiscalPeriods = new ArrayList<FiscalPeriod>(); try { @@ -211,18 +211,18 @@ } ErrorHelper.showErrorDialog(_("lima.ledger.documentcreationerror"), eee); } - + //tells if the fiscaPeriod as been found and is blocked boolean error = true; - + for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) { if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate) - && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) - && blockedFiscalPeriod.getLocked()) { + && blockedFiscalPeriod.getEndDate().equals(selectedEndDate) + && blockedFiscalPeriod.getLocked()) { error = false; } } - + //shows error message to user if the fiscalPeriod is unblocked if (error) { JOptionPane.showMessageDialog( @@ -231,17 +231,17 @@ _("lima.common.error"), JOptionPane.ERROR_MESSAGE); } else { - + FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem(); String address = LimaConfig.getInstance().getHostAdress(); - + try { - String url = "http://"+address+":"+port+"/?beginDate=" - + dateFormat.format(selectedBeginDate) - + "&endDate="+dateFormat.format(selectedEndDate) - + "&format="+selectedEnum.getExtension()+"&model=" - + DocumentsEnum.LEDGER.getFileName(); - Desktop.getDesktop().browse(new URI(url)); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(selectedBeginDate) + + "&endDate=" + dateFormat.format(selectedEndDate) + + "&format=" + selectedEnum.getExtension() + "&model=" + + DocumentsEnum.LEDGER.getFileName(); + Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { log.error("Can't open browser", e); } catch (URISyntaxException e) { @@ -250,12 +250,12 @@ } } } - + @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) { refresh(); } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AddLetterForm.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,7 +29,7 @@ <import> jaxx.runtime.swing.JAXXButtonGroup </import> - + <JAXXButtonGroup id="radioButtons" javaBean='new JAXXButtonGroup()'/> <Boolean id="validOk" javaBean='true'/> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterComboBox.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,30 +25,34 @@ package org.chorem.lima.ui.lettering; -import javax.swing.JComboBox; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Letter; import org.chorem.lima.ui.combobox.LetterComboBoxModel; -import org.chorem.lima.ui.combobox.LetterRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.chorem.lima.util.LetterToString; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; +import javax.swing.JComboBox; +import javax.swing.ListCellRenderer; + public class LetterComboBox extends JComboBox { private static final long serialVersionUID = 1L; private static final Log log = - LogFactory.getLog(LetterComboBox.class); - - + LogFactory.getLog(LetterComboBox.class); + + public LetterComboBox() { - + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); - LetterRenderer letterRenderer = new LetterRenderer(); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(Letter.class); setModel(letterComboBoxModel); - setRenderer(letterRenderer); + setRenderer(renderer); setEditable(true); AutoCompleteDecorator.decorate(this, LetterToString.getInstance()); } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,15 +24,6 @@ */ package org.chorem.lima.ui.lettering; -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; @@ -40,120 +31,130 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 LetteringPeriodSearchPanel extends JPanel { - + private static final Log log = - LogFactory.getLog(LetteringPeriodSearchPanel.class); - + LogFactory.getLog(LetteringPeriodSearchPanel.class); + protected LetteringViewHandler handler; - + public LetteringPeriodSearchPanel(LetteringViewHandler handler) { this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - - static final long serialVersionUID = 1L; - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + // 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(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + handler.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.setBeginDate(fPeriod.getBeginDate()); - handler.setEndDate(fPeriod.getEndDate()); + 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(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + 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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.setBeginDate(fPeriod.getBeginDate()); + handler.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + 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/lettering/LetteringTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,15 +25,6 @@ package org.chorem.lima.ui.lettering; -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.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; @@ -51,10 +42,19 @@ 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 jpepin */ public class LetteringTable extends JXTable @@ -62,7 +62,7 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - + /** log. */ private static final Log log = LogFactory .getLog(LetteringTable.class); @@ -72,14 +72,14 @@ private Highlighter colorTransaction; private ColorHighlighter colorBalance; - + public LetteringTable(LetteringViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); //Get new entry book editor @@ -92,38 +92,37 @@ setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); - + //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. @@ -137,7 +136,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) { @@ -151,8 +150,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); } @@ -163,20 +162,20 @@ @Override public void keyPressed(KeyEvent e) { - + // add letter with the key combination : ctrl + L - if (e.getKeyCode() == KeyEvent.VK_L + if (e.getKeyCode() == KeyEvent.VK_L && e.getModifiers() == KeyEvent.CTRL_MASK) { handler.addLetter(); } - + // clear row selection with the key: escape if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { - if (!isEditing()) { + if (!isEditing()) { clearSelection(); - } + } } - + } @@ -189,28 +188,28 @@ public void keyReleased(KeyEvent e) { } - @Override - public void mouseClicked(MouseEvent e) { - } + @Override + public void mouseClicked(MouseEvent e) { + } - @Override - public void mousePressed(MouseEvent e) { + @Override + public void mousePressed(MouseEvent e) { if (rowAtPoint(e.getPoint()) == -1) { clearSelection(); } - } + } - @Override - public void mouseReleased(MouseEvent e) { - } + @Override + public void mouseReleased(MouseEvent e) { + } - @Override - public void mouseEntered(MouseEvent e) { - } + @Override + public void mouseEntered(MouseEvent e) { + } - @Override - public void mouseExited(MouseEvent e) { - } + @Override + public void mouseExited(MouseEvent e) { + } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.lettering; -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.JFrame; -import javax.swing.JOptionPane; -import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; @@ -52,20 +42,31 @@ import org.chorem.lima.util.ErrorHelper; import org.nuiton.util.Resource; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +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 #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 LetteringTableModel extends AbstractTableModel implements ServiceListener{ +public class LetteringTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = 1L; @@ -76,81 +77,80 @@ /** Transaction service. */ protected final FinancialTransactionServiceMonitorable financialTransactionService; - + /** Begin Date. */ protected Date selectedBeginDate; - + /** EndDate. */ protected Date selectedEndDate; - + /** data cache */ protected List<Object> cacheDataList; - - /** collection - /** + * collection + * <p/> + * <p/> + * /** * Model constructor. - * + * <p/> * Just init service proxies. */ public LetteringTableModel() { /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); financialTransactionService.addServiceListener(this); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); } - + public void setSelectedBeginDate(Date date) { selectedBeginDate = date; } - + public void setSelectedEndDate(Date date) { selectedEndDate = date; } /** * Le model est une combinaison de Transaction/Entries. - * - * + * * @return */ protected List<Object> getDataList() { List<Object> results = new ArrayList<Object>(); - if (selectedBeginDate != null && selectedEndDate != null){ + if (selectedBeginDate != null && selectedEndDate != null) { try { List<FinancialTransaction> financialtransactions = - financialTransactionService.getAllFinancialTransactionsFromDateToDate( - selectedBeginDate, selectedEndDate); + financialTransactionService.getAllFinancialTransactionsFromDateToDate( + selectedBeginDate, selectedEndDate); 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.error("Can't update model", eee); } ErrorHelper.showErrorDialog(_("lima.lettering.listerror"), eee); - } + } } return results; } - - public void setLetter(int row, Letter letter){ + + public void setLetter(int row, Letter letter) { Object currentRow = cacheDataList.get(row); - if (currentRow instanceof Entry){ + if (currentRow instanceof Entry) { Entry entry = (Entry) currentRow; entry.setLetter(letter); try { financialTransactionService.updateEntry(entry); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't set letter", eee); } JFrame f = new JFrame(); @@ -164,20 +164,20 @@ } } } - - public void removeLetter(int row){ + + public void removeLetter(int row) { try { Object currentRow = cacheDataList.get(row); - if (currentRow instanceof Entry){ + if (currentRow instanceof Entry) { Entry entry = (Entry) currentRow; - financialTransactionService.removeEntryLetter(entry); + financialTransactionService.removeEntryLetter(entry); } } catch (LimaException eee) { log.error("Can't remove letter", eee); } } - - public void refresh(){ + + public void refresh() { cacheDataList = getDataList(); fireTableDataChanged(); } @@ -193,72 +193,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; @@ -267,7 +266,7 @@ @Override public int getRowCount() { int result = 0; - + if (cacheDataList != null) { result = cacheDataList.size(); } @@ -278,163 +277,157 @@ @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; } - + /** * 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==5) { - editableCell=true; + if (currentRow instanceof Entry && columnIndex == 5) { + editableCell = true; } - return editableCell; } - - - - public Object getElementAt(int row){ + return editableCell; + } + + + public Object getElementAt(int row) { Object result = null; - if (cacheDataList != null){ + if (cacheDataList != null) { result = cacheDataList.get(row); } return result; } - - - /** - * to modifiy letter entry - */ + + + /** to modifiy letter entry */ @Override public void setValueAt(Object value, int row, int column) { int financialTransactionRow = 0; if (cacheDataList != null) { Object currentRow = cacheDataList.get(row); if (currentRow instanceof Entry) { - Entry currentEntry = (Entry)currentRow; + Entry currentEntry = (Entry) currentRow; switch (column) { - case 5 : - currentEntry.setLetter((Letter)value); - break; + case 5: + currentEntry.setLetter((Letter) value); + break; } try { financialTransactionService.updateEntry(currentEntry); } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.error("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); } } @Override public void notifyMethod(String serviceName, String methodeName) { - if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")){ + if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntries") || methodeName.contains("importAll")) { refresh(); } } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,24 +29,12 @@ javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod org.chorem.lima.entity.FinancialPeriod - org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer org.chorem.lima.enums.ComboBoxDatesEnum </import> <LetteringViewHandler id="handler" javaBean="new LetteringViewHandler(this)"/> <Boolean id="selectedRow" javaBean="false"/> - <script> - <![CDATA[ - - LetteringPeriodSearchPanel periodSearchPanel = new LetteringPeriodSearchPanel(handler); - - void $afterCompleteSetup() { - } - - ]]> - </script> - <row weightx="1" weighty="0" anchor="center"> <cell fill='both'> <Table> @@ -58,7 +46,8 @@ validate(); repaint()"/> </cell> <cell> - <LetteringPeriodSearchPanel javaBean="periodSearchPanel"/> + <LetteringPeriodSearchPanel id='periodSearchPanel' + constructorParams='handler'/> </cell> </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,12 +25,6 @@ package org.chorem.lima.ui.lettering; -import static org.nuiton.i18n.I18n._; - -import java.util.Date; - -import javax.swing.JComboBox; -import javax.swing.JTextField; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FinancialTransactionServiceMonitorable; @@ -41,115 +35,120 @@ import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; import org.chorem.lima.util.DialogHelper; +import javax.swing.JComboBox; +import javax.swing.JTextField; +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 LetteringViewHandler { /** log. */ private static final Log log = - LogFactory.getLog(LetteringViewHandler.class); + LogFactory.getLog(LetteringViewHandler.class); protected LetteringView view; - + protected LetteringTable table; - + protected LetteringTableModel tableModel; - + protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; - + protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; - + /** Transaction service. */ protected final FinancialTransactionServiceMonitorable financialTransactionService; - + protected Object clipBoard; protected LetteringViewHandler(LetteringView view) { this.view = view; - + /* Services */ financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); } - - public void setBeginDate(Date date){ + + public void setBeginDate(Date date) { tableModel = view.getTableModel(); tableModel.setSelectedBeginDate(date); } - - public void setEndDate(Date date){ + + public void setEndDate(Date date) { tableModel = view.getTableModel(); tableModel.setSelectedEndDate(date); } - - public void addLetter(){ - Letter letter = null; - Boolean valid = true; - - table = view.getTable(); - tableModel = view.getTableModel(); - - AddLetterForm addLetterForm = new AddLetterForm(); - JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); - try { - letter = financialTransactionService.getNewLetter(); - newLetterTextField.setText(letter.getCode()); - } catch (LimaException eee) { - log.error("Can't get new letter", eee); - } - - addLetterForm.setLocationRelativeTo(view); - addLetterForm.setVisible(true); - - //false = cancel Action - if (addLetterForm.validOk){ - Object object = addLetterForm.getRadioButtons().getSelectedValue(); - if (!(Boolean) object){ - JComboBox comboBox = addLetterForm.getLetterListComboBox(); - Object selectedObject = comboBox.getSelectedItem(); - if (selectedObject instanceof Letter){ - letter = (Letter) selectedObject; - } - else { - DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); - valid = false; - } - } - if (valid){ - //addLetters - int[] rows = table.getSelectedRows(); - for (int i : rows) { - tableModel.setLetter(i, letter); + public void addLetter() { + Letter letter = null; + Boolean valid = true; + + table = view.getTable(); + tableModel = view.getTableModel(); + + AddLetterForm addLetterForm = new AddLetterForm(); + JTextField newLetterTextField = addLetterForm.getNewLetterTextField(); + + try { + letter = financialTransactionService.getNewLetter(); + newLetterTextField.setText(letter.getCode()); + } catch (LimaException eee) { + log.error("Can't get new letter", eee); + } + + addLetterForm.setLocationRelativeTo(view); + addLetterForm.setVisible(true); + + //false = cancel Action + if (addLetterForm.validOk) { + Object object = addLetterForm.getRadioButtons().getSelectedValue(); + if (!(Boolean) object) { + JComboBox comboBox = addLetterForm.getLetterListComboBox(); + Object selectedObject = comboBox.getSelectedItem(); + if (selectedObject instanceof Letter) { + letter = (Letter) selectedObject; + } else { + DialogHelper.showMessageDialog(_("lima.entries.lettering.noletterselected")); + valid = false; } - tableModel.refresh(); - } - } - } - - public void removeLetter(){ + } + if (valid) { + //addLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.setLetter(i, letter); + } + tableModel.refresh(); + } + } + } - table = view.getTable(); - tableModel = view.getTableModel(); - - //removeLetters - int[] rows = table.getSelectedRows(); - for (int i : rows) { - tableModel.removeLetter(i); + public void removeLetter() { + + table = view.getTable(); + tableModel = view.getTableModel(); + + //removeLetters + int[] rows = table.getSelectedRows(); + for (int i : rows) { + tableModel.removeLetter(i); } - tableModel.refresh(); - } - - public void refresh(){ + tableModel.refresh(); + } + + public void refresh() { tableModel = view.getTableModel(); tableModel.refresh(); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,12 +25,6 @@ package org.chorem.lima.ui.opening; -import static org.nuiton.i18n.I18n._; -import java.awt.Color; -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; @@ -46,22 +40,35 @@ import org.chorem.lima.ui.identity.IdentityHandler; import org.chorem.lima.ui.importexport.ImportExport; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; +import java.awt.Color; + +import static org.nuiton.i18n.I18n._; + public class OpeningViewHandler { - + private static final Log log = LogFactory.getLog(OpeningViewHandler.class); - - private static Border noBorder = new EmptyBorder(0,0,0,0); + + private static Border noBorder = new EmptyBorder(0, 0, 0, 0); + private static Color green = new Color(0x66, 0xcc, 0x00); - + protected int step; + protected OpeningView view; - + //Panels private CreateAccountsPanel caPanel; + private CreateIdentityPanel idPanel; + private CreateEntryBookPanel ebPanel; + private CreateFiscalPeriodPanel fsPanel; - + public OpeningViewHandler(OpeningView view) { this.view = view; caPanel = new CreateAccountsPanel(); @@ -70,130 +77,130 @@ fsPanel = new CreateFiscalPeriodPanel(); step = 0; } - - + + public void importSave() { ImportExport importExport = new ImportExport(view); importExport.importExport(ImportExportEnum.CSV_ALL_IMPORT, "", true); view.dispose(); } - + public void next() { ImportExport importExport = ImportExport.getInstance(view); JPanel panel = view.getPanel(); panel.removeAll(); switch (step) { - case 0: - //refresh UI - view.getIdentityIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(idPanel); - panel.validate(); - view.repaint(); - step++; - break; - case 1: - IdentityHandler identityHandler = new IdentityHandler(); - identityHandler.updateIdentity(idPanel.getIdentity()); - //refresh UI - view.getIdentityIcon().setBorder(noBorder); - view.getAccountsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(caPanel); - panel.validate(); - view.repaint(); - step++; - break; - - case 2 : - Object value = caPanel.getRadioButtons().getSelectedValue(); - // if action confirmed - if (value != null){ - AccountsChartEnum defaultAccountsChartEnum = - (AccountsChartEnum) value; - //Import accounts chart - switch (defaultAccountsChartEnum) { - case IMPORTEBP: - importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; + case 0: + //refresh UI + view.getIdentityIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(idPanel); + panel.validate(); + view.repaint(); + step++; + break; + case 1: + IdentityHandler identityHandler = new IdentityHandler(); + identityHandler.updateIdentity(idPanel.getIdentity()); + //refresh UI + view.getIdentityIcon().setBorder(noBorder); + view.getAccountsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(caPanel); + panel.validate(); + view.repaint(); + step++; + break; - default: - importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, - defaultAccountsChartEnum.getFilePath(), false); - break; + case 2: + Object value = caPanel.getRadioButtons().getSelectedValue(); + // if action confirmed + if (value != null) { + AccountsChartEnum defaultAccountsChartEnum = + (AccountsChartEnum) value; + //Import accounts chart + switch (defaultAccountsChartEnum) { + case IMPORTEBP: + importExport.importExport(ImportExportEnum.EBP_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + + default: + importExport.importExport(ImportExportEnum.CSV_ACCOUNTCHARTS_IMPORT, + defaultAccountsChartEnum.getFilePath(), false); + break; + } + //Import financialstatement + switch (defaultAccountsChartEnum) { + case SHORTENED: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.SHORTENED.getFilePath(), false); + break; + case DEVELOPED: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.DEVELOPED.getFilePath(), false); + break; + default: + importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, + FinancialStatementsChartEnum.BASE.getFilePath(), false); + break; + } + //Import vatstatement + switch (defaultAccountsChartEnum) { + case SHORTENED: + importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, + VatStatementsChartEnum.SHORTENED.getFilePath(), false); + break; + case BASE: + importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, + VatStatementsChartEnum.BASE.getFilePath(), false); + break; + case DEVELOPED: + importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, + VatStatementsChartEnum.DEVELOPED.getFilePath(), false); + break; + default: + importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, + VatStatementsChartEnum.DEFAULT.getFilePath(), false); + break; + } + } - //Import financialstatement - switch (defaultAccountsChartEnum) { - case SHORTENED: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.SHORTENED.getFilePath(), false); - break; - case DEVELOPED: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.DEVELOPED.getFilePath(), false); - break; - default: - importExport.importExport(ImportExportEnum.CSV_FINANCIALSTATEMENTS_IMPORT, - FinancialStatementsChartEnum.BASE.getFilePath(), false); - break; + view.getAccountsIcon().setBorder(noBorder); + view.getEntrybooksIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(ebPanel); + panel.validate(); + view.repaint(); + step++; + break; + + case 3: + if (ebPanel.getImportEntryBook().isSelected()) { + importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, + EntryBooksChartEnum.DEFAULT.getFilePath(), false); } - //Import vatstatement - switch(defaultAccountsChartEnum) { - case SHORTENED: - importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, - VatStatementsChartEnum.SHORTENED.getFilePath(), false); - break; - case BASE: - importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, - VatStatementsChartEnum.BASE.getFilePath(), false); - break; - case DEVELOPED: - importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, - VatStatementsChartEnum.DEVELOPED.getFilePath(), false); - break; - default: - importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, - VatStatementsChartEnum.DEFAULT.getFilePath(), false); - break; + view.getEntrybooksIcon().setBorder(noBorder); + view.getFiscalperiodsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); + panel.add(fsPanel); + panel.validate(); + view.getOk().setText(_("lima.common.fin")); + view.repaint(); + step++; + break; + case 4: + try { + FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); + fiscalPeriod.setBeginDate(fsPanel.getBeginDatePicker().getDate()); + fiscalPeriod.setEndDate(fsPanel.getEndDatePicker().getDate()); + + LimaServiceFactory.getInstance().getService( + FiscalPeriodServiceMonitorable.class). + createFiscalPeriod(fiscalPeriod); + + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't create fiscal period", ex); + } } - - } - view.getAccountsIcon().setBorder(noBorder); - view.getEntrybooksIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(ebPanel); - panel.validate(); - view.repaint(); - step++; - break; - - case 3 : - if (ebPanel.getImportEntryBook().isSelected()) { - importExport.importExport(ImportExportEnum.CSV_ENTRYBOOKS_IMPORT, - EntryBooksChartEnum.DEFAULT.getFilePath(), false); - } - view.getEntrybooksIcon().setBorder(noBorder); - view.getFiscalperiodsIcon().setBorder(BorderFactory.createLineBorder(green, 2)); - panel.add(fsPanel); - panel.validate(); - view.getOk().setText(_("lima.common.fin")); - view.repaint(); - step++; - break; - case 4 : - try { - FiscalPeriod fiscalPeriod = new FiscalPeriodImpl(); - fiscalPeriod.setBeginDate(fsPanel.getBeginDatePicker().getDate()); - fiscalPeriod.setEndDate(fsPanel.getEndDatePicker().getDate()); - - LimaServiceFactory.getInstance().getService( - FiscalPeriodServiceMonitorable.class). - createFiscalPeriod(fiscalPeriod); - - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't create fiscal period", ex); - } - } - view.dispose(); + view.dispose(); } } } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,15 +24,6 @@ */ package org.chorem.lima.ui.vatchart; -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 javax.swing.tree.TreePath; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.VatStatement; @@ -43,33 +34,39 @@ import org.jdesktop.swingx.decorator.Highlighter; import org.jdesktop.swingx.treetable.TreeTableModel; +import javax.swing.tree.TreePath; +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; + public class VatChartTreeTable extends JXTreeTable implements KeyListener, MouseListener { /** serialVersionUID. */ - private static final long serialVersionUID = 3960840343197845825L; + private static final long serialVersionUID = 3960840343197845825L; - /** log. */ + /** log. */ private static final Log log = LogFactory .getLog(VatChartTreeTable.class); - + protected VatChartViewHandler handler; - + private Highlighter colorLine; - + public VatChartTreeTable(VatChartViewHandler handler) { this.handler = handler; - + addKeyListener(this); addMouseListener(this); - + //highlight missing box name lines - addMissingBoxNameColor(); + addMissingBoxNameColor(); } - - /** - * Highlights line when line is a leaf and is missing its BoxName parameter - */ + + /** Highlights line when line is a leaf and is missing its BoxName parameter */ private void addMissingBoxNameColor() { if (colorLine != null) { removeHighlighter(colorLine); @@ -77,12 +74,12 @@ HighlightPredicate predicate = new HighlightPredicate() { @Override public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { + ComponentAdapter adapter) { JXTreeTable treeTable = handler.view.getTreeTable(); TreeTableModel treeTableModel = treeTable.getTreeTableModel(); TreePath treePath = treeTable.getPathForRow(adapter.row); VatStatement vatStatement = - (VatStatement) treePath.getLastPathComponent(); + (VatStatement) treePath.getLastPathComponent(); boolean highlighted = false; if (vatStatement.getBoxName() != null) { if (treeTableModel.isLeaf(vatStatement) && vatStatement.getBoxName().isEmpty()) { @@ -96,7 +93,7 @@ }; colorLine = new ColorHighlighter(predicate, new Color(255, 198, 209), null); - addHighlighter(colorLine); + addHighlighter(colorLine); } @Override 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartTreeTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,9 +24,6 @@ */ package org.chorem.lima.ui.vatchart; -import static org.nuiton.i18n.I18n._; -import java.util.List; -import javax.swing.tree.TreePath; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; @@ -36,25 +33,28 @@ import org.chorem.lima.service.LimaServiceFactory; import org.jdesktop.swingx.treetable.AbstractTreeTableModel; +import javax.swing.tree.TreePath; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class VatChartTreeTableModel extends AbstractTreeTableModel { - + /** log. */ private static final Log log = LogFactory.getLog(VatChartViewHandler.class); - + /** Services. */ protected final VatStatementServiceMonitorable vatStatementService; - /** - * Model constructor. Initiate account service used here. - */ + /** Model constructor. Initiate account service used here. */ public VatChartTreeTableModel() { //create root for the tree super(new VatStatementImpl()); // Gets factory service vatStatementService = - LimaServiceFactory.getInstance().getService( - VatStatementServiceMonitorable.class); - } + LimaServiceFactory.getInstance().getService( + VatStatementServiceMonitorable.class); + } @Override @@ -82,21 +82,20 @@ if (node == getRoot()) { try { result = vatStatementService. - getChildrenVatStatement(null).size(); + getChildrenVatStatement(null).size(); } catch (LimaException eee) { log.debug("Can't count child", eee); } - } - else { - VatStatement parentVatStatementHeader = + } else { + VatStatement parentVatStatementHeader = (VatStatement) node; - try { - result = vatStatementService.getChildrenVatStatement( - parentVatStatementHeader).size(); - } catch (LimaException eee) { - log.debug("Can't count child", eee); - } + try { + result = vatStatementService.getChildrenVatStatement( + parentVatStatementHeader).size(); + } catch (LimaException eee) { + log.debug("Can't count child", eee); } + } return result; } @@ -106,18 +105,17 @@ if (parent == getRoot()) { try { List<VatStatement> vatStatements = - vatStatementService.getChildrenVatStatement(null); + vatStatementService.getChildrenVatStatement(null); result = vatStatements.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); } - } - else { + } else { VatStatement parentVatStatement = - (VatStatement) parent; + (VatStatement) parent; try { List<VatStatement> vatStatements = vatStatementService. - getChildrenVatStatement(parentVatStatement); + getChildrenVatStatement(parentVatStatement); result = vatStatements.get(index); } catch (LimaException eee) { log.debug("Can't get child", eee); @@ -129,22 +127,21 @@ @Override public int getIndexOfChild(Object parent, Object child) { int result = 0; - + if (parent == getRoot()) { try { List<VatStatement> vatStatements = - vatStatementService.getChildrenVatStatement(null); + vatStatementService.getChildrenVatStatement(null); result = vatStatements.indexOf(child); } catch (LimaException eee) { log.debug("Can't get index child", eee); } - } - else { + } else { VatStatement parentVatStatement = - (VatStatement) parent; + (VatStatement) parent; try { List<VatStatement> vatStatements = vatStatementService. - getChildrenVatStatement(parentVatStatement); + getChildrenVatStatement(parentVatStatement); result = vatStatements.indexOf(child); } catch (LimaException eee) { log.debug("Can't get index child", eee); @@ -152,19 +149,19 @@ } return result; } - + @Override public Object getValueAt(Object node, int column) { Object result = "n/a"; - VatStatement vatStatement = (VatStatement) node; - switch (column) { - case 0: - result = vatStatement.getLabel(); - break; - case 1: - result = vatStatement.getAccounts(); - break; - } + VatStatement vatStatement = (VatStatement) node; + switch (column) { + case 0: + result = vatStatement.getLabel(); + break; + case 1: + result = vatStatement.getAccounts(); + break; + } return result; } @@ -178,20 +175,17 @@ return getChildCount(node) == 0; } - - /** - * Refresh VatStatementChart. - * - */ + + /** Refresh VatStatementChart. */ public void refreshTree() throws LimaException { modelSupport.fireNewRoot(); } - - + + /** * Add VatStatement(path can be null). - * + * * @param path * @param account * @throws LimaException @@ -202,17 +196,17 @@ VatStatement parentVatStatementHeader = null; if (path != null) { parentVatStatementHeader = - (VatStatement) path.getLastPathComponent(); + (VatStatement) path.getLastPathComponent(); } vatStatementService.createVatStatement( parentVatStatementHeader, vatStatement); modelSupport.fireTreeStructureChanged(path); } - + /** * Update vatStatement - * + * * @param path * @param account * @throws LimaException @@ -222,10 +216,10 @@ vatStatementService.updateVatStatement(vatStatement); modelSupport.fireTreeStructureChanged(path); } - + /** * Remove vatStatement - * + * * @param path * @param object * @throws LimaException @@ -234,7 +228,7 @@ // Calling account service int index = getIndexOfChild( path.getParentPath().getLastPathComponent(), vatStatement); - vatStatementService.removeVatStatement(vatStatement); + vatStatementService.removeVatStatement(vatStatement); modelSupport.fireChildRemoved(path.getParentPath(), index, vatStatement); } @@ -249,6 +243,6 @@ log.debug("Can't update vatStatement", eee); } } - - + + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatchart/VatChartViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,13 +24,6 @@ */ package org.chorem.lima.ui.vatchart; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; - -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.ImportServiceMonitorable; @@ -46,30 +39,36 @@ import org.chorem.lima.ui.importexport.ImportExport; import org.jdesktop.swingx.JXTreeTable; +import javax.swing.JOptionPane; +import javax.swing.tree.TreePath; +import java.math.BigDecimal; + +import static org.nuiton.i18n.I18n._; + public class VatChartViewHandler implements ServiceListener { /** log. */ private static final Log log = LogFactory.getLog(VatChartViewHandler.class); protected VatStatementServiceMonitorable vatStatementService; - + protected VatChartView view; protected VatChartViewHandler(VatChartView view) { this.view = view; - + vatStatementService = - LimaServiceFactory.getInstance().getService( - VatStatementServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + VatStatementServiceMonitorable.class); LimaServiceFactory.getInstance().getService( ImportServiceMonitorable.class).addServiceListener(this); } - - public void addVatStatementMovement(){ + public void addVatStatementMovement() { + VatChartTreeTableModel treeTableModel = - (VatChartTreeTableModel) view.getTreeTable().getTreeTableModel(); - + (VatChartTreeTableModel) view.getTreeTable().getTreeTableModel(); + int selectedRow = view.getTreeTable().getSelectedRow(); // get current selection path TreePath treePath; @@ -81,10 +80,10 @@ VatStatement newVatChartMovement = new VatStatementImpl(); VatChartMovementForm vatChartMovementForm = - new VatChartMovementForm(view); + new VatChartMovementForm(view); VatStatement masterVatStatement = null; if (selectedRow != -1) { - masterVatStatement = (VatStatement)treePath.getLastPathComponent(); + masterVatStatement = (VatStatement) treePath.getLastPathComponent(); } newVatChartMovement.setMasterVatStatement(masterVatStatement); vatChartMovementForm.setVatStatement(newVatChartMovement); @@ -92,13 +91,13 @@ vatChartMovementForm.setLocationRelativeTo(view); vatChartMovementForm.setVisible(true); newVatChartMovement = vatChartMovementForm.getVatStatement(); - - // null == cancel action - if (newVatChartMovement != null) { - newVatChartMovement.setAmount(BigDecimal.ZERO); - // add it - try { - treeTableModel.addVatStatement(treePath, newVatChartMovement); + + // null == cancel action + if (newVatChartMovement != null) { + newVatChartMovement.setAmount(BigDecimal.ZERO); + // add it + try { + treeTableModel.addVatStatement(treePath, newVatChartMovement); } catch (LimaBusinessException eee) { if (log.isErrorEnabled()) { log.error("Can't add Vat chart Movement", eee); @@ -108,8 +107,7 @@ eee.getMessage(), _("lima.common.error"), JOptionPane.ERROR_MESSAGE); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.error("Can't add Vat chart Movement", eee); } @@ -122,108 +120,106 @@ refresh(); } } - + public void updateVatStatement() { - + JXTreeTable treeTable = view.getTreeTable(); VatChartTreeTableModel treeTableModel = - (VatChartTreeTableModel) treeTable.getTreeTableModel(); + (VatChartTreeTableModel) treeTable.getTreeTableModel(); - // get selected account - int selectedRow = view.treeTable.getSelectedRow(); - TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null - VatStatement vatStatement = - (VatStatement) treePath.getLastPathComponent(); - //update Account or update SubLedger - if (vatStatement != null) { - // get current selection path - if ( selectedRow != -1) { - treePath = view.treeTable.getPathForRow(selectedRow); - } else { - treePath = new TreePath(treeTableModel.getRoot()); - } - VatChartMovementForm vatChartMovementForm = - new VatChartMovementForm(view); - if (vatStatement.getMasterVatStatement() == null) { - VatStatement masterVatStatement = new VatStatementImpl(); - vatStatement.setMasterVatStatement(masterVatStatement); - } - vatChartMovementForm.setVatStatement(vatStatement); - // jaxx constructor don't call super() ? - vatChartMovementForm.setLocationRelativeTo(view); - vatChartMovementForm.setVisible(true); - // null == cancel action - vatStatement = vatChartMovementForm.getVatStatement(); - //if action confirmed - if (vatStatement != null){ - // update it - try { - treeTableModel.updateVatStatement( - treePath, vatStatement); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add update", eee); - } - JOptionPane.showMessageDialog( - view, - eee.getMessage(), - _("lima.common.error"), - JOptionPane.ERROR_MESSAGE); - } - } - } + // get selected account + int selectedRow = view.treeTable.getSelectedRow(); + TreePath treePath = view.treeTable.getPathForRow(selectedRow); // not null + VatStatement vatStatement = + (VatStatement) treePath.getLastPathComponent(); + //update Account or update SubLedger + if (vatStatement != null) { + // get current selection path + if (selectedRow != -1) { + treePath = view.treeTable.getPathForRow(selectedRow); + } else { + treePath = new TreePath(treeTableModel.getRoot()); + } + VatChartMovementForm vatChartMovementForm = + new VatChartMovementForm(view); + if (vatStatement.getMasterVatStatement() == null) { + VatStatement masterVatStatement = new VatStatementImpl(); + vatStatement.setMasterVatStatement(masterVatStatement); + } + vatChartMovementForm.setVatStatement(vatStatement); + // jaxx constructor don't call super() ? + vatChartMovementForm.setLocationRelativeTo(view); + vatChartMovementForm.setVisible(true); + // null == cancel action + vatStatement = vatChartMovementForm.getVatStatement(); + //if action confirmed + if (vatStatement != null) { + // update it + try { + treeTableModel.updateVatStatement( + treePath, vatStatement); + } catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.error("Can't add update", eee); + } + JOptionPane.showMessageDialog( + view, + eee.getMessage(), + _("lima.common.error"), + JOptionPane.ERROR_MESSAGE); + } + } + } refresh(); } - - public void importVatStatementChart(){ + + public void importVatStatementChart() { VatChartImportForm form = - new VatChartImportForm(); + new VatChartImportForm(); form.setLocationRelativeTo(view); form.setVisible(true); Object value = form.getRadioButtons().getSelectedValue(); // if action confirmed - if (value != null){ - if (form.getDeleteVatStatementChart().isSelected()){ + if (value != null) { + if (form.getDeleteVatStatementChart().isSelected()) { try { vatStatementService.removeAllVatStatement(); - + } catch (LimaException eee) { - if (log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't delete financial statement chart", eee); } } } - VatStatementsChartEnum defaultVatStatementsEnum = - (VatStatementsChartEnum) value; + VatStatementsChartEnum defaultVatStatementsEnum = + (VatStatementsChartEnum) value; ImportExport importExport = ImportExport.getInstance(view); importExport.importExport(ImportExportEnum.CSV_VAT_IMPORT, - defaultVatStatementsEnum.getFilePath(), true); + defaultVatStatementsEnum.getFilePath(), true); refresh(); } } - - /** - * Ask for user to remove for selected account, and remove it if confirmed. - */ + + /** Ask for user to remove for selected account, and remove it if confirmed. */ public void removeVatStatement() { - JXTreeTable treeTable = view.getTreeTable(); - VatChartTreeTableModel treeTableModel = - (VatChartTreeTableModel) treeTable.getTreeTableModel(); + JXTreeTable treeTable = view.getTreeTable(); + VatChartTreeTableModel treeTableModel = + (VatChartTreeTableModel) treeTable.getTreeTableModel(); // Any row selected int selectedRow = view.treeTable.getSelectedRow(); - if ( selectedRow != -1) { + if (selectedRow != -1) { int n = JOptionPane.showConfirmDialog(view, - _("lima.charts.vatstatement.question.remove"), - _("lima.common.confirmation"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + _("lima.charts.vatstatement.question.remove"), + _("lima.common.confirmation"), + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); if (n == JOptionPane.YES_OPTION) { // update view of treetable TreePath treePath = treeTable.getPathForRow(selectedRow); VatStatement vatStatement = - (VatStatement) treePath.getLastPathComponent(); + (VatStatement) treePath.getLastPathComponent(); if (!treeTableModel.isLeaf(vatStatement)) { JOptionPane.showMessageDialog( view, @@ -231,7 +227,7 @@ _("lima.common.info"), JOptionPane.INFORMATION_MESSAGE); } else { - try{ + try { treeTableModel.removeVatStatementObject( treePath, vatStatement); } catch (LimaException eee) { @@ -249,15 +245,15 @@ refresh(); } } - - public void refresh(){ + + public void refresh() { JXTreeTable treeTable = view.getTreeTable(); VatChartTreeTableModel treeTableModel = - (VatChartTreeTableModel) treeTable.getTreeTableModel(); + (VatChartTreeTableModel) treeTable.getTreeTableModel(); try { treeTableModel.refreshTree(); } catch (LimaException eee) { - if(log.isDebugEnabled()){ + if (log.isDebugEnabled()) { log.debug("Can't refresh model", eee); } } @@ -265,14 +261,14 @@ view.repaint(); } - @Override - public void notifyMethod(String serviceName, String methodeName) { + @Override + public void notifyMethod(String serviceName, String methodeName) { if (methodeName.contains("VatStatements") - || methodeName.contains("importAll") - || methodeName.contains("importAs")){ + || methodeName.contains("importAll") + || methodeName.contains("importAs")) { refresh(); - } - } + } + } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportPeriodSearchPanel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,17 +24,6 @@ */ package org.chorem.lima.ui.vatreports; -import static org.nuiton.i18n.I18n._; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Calendar; -import java.util.Date; - -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; @@ -42,121 +31,133 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.enums.ComboBoxDatesEnum; import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.chorem.lima.ui.renderers.RendererUtil; import org.jdesktop.swingx.JXDatePicker; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; +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 VatReportPeriodSearchPanel extends JPanel { private static final long serialVersionUID = 1L; - + private static final Log log = LogFactory.getLog(VatReportPeriodSearchPanel.class); - + protected VatReportViewHandler handler; - + public VatReportPeriodSearchPanel(VatReportViewHandler handler) { - + this.handler = handler; - + //init date refresh(ComboBoxDatesEnum.FISCAL_PERIOD); } - public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum){ - + public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) { + switch (comboBoxPeriodEnum) { - 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.tableModel.setBeginDate(beginDatePicker.getDate()); - handler.refresh(); - } - }; - handler.tableModel.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.tableModel.setEndDate(endDatePicker.getDate()); - handler.refresh(); - } - }; - handler.tableModel.setEndDate(endDatePicker.getDate()); - endDatePicker.addActionListener(endDateActionListener); - handler.refresh(); + 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); - removeAll(); - add(beginDateLabel); - add(beginDatePicker); - add(endDateLabel); - add(endDatePicker); - break; - - case FISCAL_PERIOD: - FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true); - 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(); - if (fPeriod != null){ - handler.tableModel.setBeginDate(fPeriod.getBeginDate()); - handler.tableModel.setEndDate(fPeriod.getEndDate()); - handler.refresh(); + // 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.tableModel.setBeginDate(beginDatePicker.getDate()); + handler.refresh(); } - } - }; - fiscalPeriod.addActionListener(fiscalPeriodActionListener); + }; + handler.tableModel.setBeginDate(beginDatePicker.getDate()); + beginDatePicker.addActionListener(beginDateActionListener); - removeAll(); - add(fiscalPeriod); - break; - - case FINANCIAL_PERIOD: - FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); - 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(); - if (fPeriod !=null){ - handler.tableModel.setBeginDate(fPeriod.getBeginDate()); - handler.tableModel.setEndDate(fPeriod.getEndDate()); - handler.refresh(); + JLabel endDateLabel = new JLabel(_("lima.common.enddate")); + final JXDatePicker endDatePicker = new JXDatePicker(endDate); + ActionListener endDateActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + handler.tableModel.setEndDate(endDatePicker.getDate()); + handler.refresh(); } - } - }; - financialPeriod.addActionListener(financialPeriodActionListener); - removeAll(); - add(financialPeriod); - break; + }; + handler.tableModel.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(true); + ListCellRenderer renderer = + RendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class); + final JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(renderer); + fiscalPeriod.setEditable(false); + ActionListener fiscalPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.tableModel.setBeginDate(fPeriod.getBeginDate()); + handler.tableModel.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + fiscalPeriod.addActionListener(fiscalPeriodActionListener); + + removeAll(); + add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true); + renderer = + RendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class); + final JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(renderer); + financialPeriod.setEditable(false); + ActionListener financialPeriodActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem(); + if (fPeriod != null) { + handler.tableModel.setBeginDate(fPeriod.getBeginDate()); + handler.tableModel.setEndDate(fPeriod.getEndDate()); + handler.refresh(); + } + } + }; + financialPeriod.addActionListener(financialPeriodActionListener); + removeAll(); + add(financialPeriod); + break; } - + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTable.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,32 +24,32 @@ */ package org.chorem.lima.ui.vatreports; -import java.math.BigDecimal; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.jdesktop.swingx.JXTable; +import java.math.BigDecimal; + public class VatReportTable extends JXTable { /** serialVersionUID. */ private static final long serialVersionUID = 4042515416850867834L; - + /** log. */ private static final Log log = LogFactory.getLog(VatReportTable.class); - + protected VatReportViewHandler handler; - + protected VatReportTableModel model; public VatReportTable(VatReportViewHandler handler) { this.handler = handler; - + model = this.handler.getView().getVatReportTableModel(); - + //Get new BigDecimal editor setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor()); //Get new BigDecimal renderer 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportTableModel.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,14 +24,6 @@ */ package org.chorem.lima.ui.vatreports; -import static org.nuiton.i18n.I18n._; - -import java.math.BigDecimal; -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.beans.VatStatementAmounts; @@ -45,70 +37,80 @@ import org.chorem.lima.util.ErrorHelper; import org.nuiton.topia.TopiaException; +import javax.swing.table.AbstractTableModel; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + public class VatReportTableModel extends AbstractTableModel implements ServiceListener { /** serialVersionUID. */ private static final long serialVersionUID = -6301817853711018389L; - + /** log. */ private static final Log log = LogFactory .getLog(VatReportTableModel.class); - + /** Services. */ protected ReportServiceMonitorable reportService; + protected VatStatementServiceMonitorable vatStatementService; + protected FinancialTransactionServiceMonitorable financialTransactionService; + protected ImportServiceMonitorable importService; - + /** selected financial period */ protected Date selectedBeginDate; + protected Date selectedEndDate; - + /** data cache */ protected List<VatStatementAmounts> cacheDataList; - + /** * variable used for the document edition, * if "true" then the document will be automatically filled in * if "false" the the document will be empty */ protected String autocomplete; - - + + public VatReportTableModel() { reportService = - LimaServiceFactory.getInstance().getService( - ReportServiceMonitorable.class); - + LimaServiceFactory.getInstance().getService( + ReportServiceMonitorable.class); + //add listeners vatStatementService = - LimaServiceFactory.getInstance().getService( - VatStatementServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + VatStatementServiceMonitorable.class); vatStatementService.addServiceListener(this); - financialTransactionService = - LimaServiceFactory.getInstance().getService( - FinancialTransactionServiceMonitorable.class); + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); financialTransactionService.addServiceListener(this); importService = - LimaServiceFactory.getInstance().getService( - ImportServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + ImportServiceMonitorable.class); importService.addServiceListener(this); - + //sets autocomplete mode to true on start autocomplete = "true"; } - + protected List<VatStatementAmounts> getDataList() throws TopiaException { - + List<VatStatementAmounts> list = null; - + if (selectedBeginDate != null || selectedEndDate != null) { try { list = vatStatementService.vatStatementReport( getBeginDate(), getEndDate()); - } - catch (LimaException eee) { + } catch (LimaException eee) { if (log.isErrorEnabled()) { log.debug("Can't update model", eee); } @@ -118,7 +120,7 @@ return list; } - public void refresh(){ + public void refresh() { try { cacheDataList = getDataList(); } catch (TopiaException eee) { @@ -129,35 +131,35 @@ } fireTableDataChanged(); } - + @Override public Class<?> getColumnClass(int column) { Class<?> result = null; switch (column) { - case 0: - result = String.class; //label - break; - case 1: - result = BigDecimal.class; //solde - break; + case 0: + result = String.class; //label + break; + case 1: + result = BigDecimal.class; //solde + break; } return result; } - + @Override public String getColumnName(int column) { String result = "n/a"; switch (column) { - case 0: - result = _("lima.table.label"); //label - break; - case 1: - result = _("lima.table.solde"); //solde - break; + case 0: + result = _("lima.table.label"); //label + break; + case 1: + result = _("lima.table.solde"); //solde + break; } return result; @@ -166,7 +168,7 @@ @Override public int getRowCount() { int result = 0; - + if (cacheDataList != null) { result = cacheDataList.size(); } @@ -178,8 +180,8 @@ public int getColumnCount() { return 2; } - - public VatStatementAmounts getElementAt(int row){ + + public VatStatementAmounts getElementAt(int row) { VatStatementAmounts currentRow = cacheDataList.get(row); return currentRow; } @@ -209,23 +211,23 @@ public void setBeginDate(Date date) { selectedBeginDate = date; } - + public Date getBeginDate() { return selectedBeginDate; } - + public void setEndDate(Date date) { selectedEndDate = date; } - + public Date getEndDate() { return selectedEndDate; } - + public String getAutocomplete() { return autocomplete; } - + public void setAutocomplete() { if (getAutocomplete().equals("true")) { autocomplete = "false"; @@ -233,7 +235,7 @@ autocomplete = "true"; } } - + @Override public boolean isCellEditable(int row, int column) { return false; @@ -242,7 +244,7 @@ @Override public void notifyMethod(String serviceName, String methodeName) { //automatic refresh when FinancialTransaction, VatStatement chart or import for VAT services have been used by the user - if (serviceName.contains("FinancialTransaction") || methodeName.contains("VatStatement") || methodeName.contains("import") ) { + if (serviceName.contains("FinancialTransaction") || methodeName.contains("VatStatement") || methodeName.contains("import")) { refresh(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportView.jaxx 2011-09-17 14:17:04 UTC (rev 3293) @@ -23,10 +23,10 @@ #L% --> <Table> - <VatReportViewHandler id="handler" javaBean="new VatReportViewHandler(this)" /> - <Boolean id="selectedRow" javaBean="false" /> + <VatReportViewHandler id="handler" javaBean="new VatReportViewHandler(this)"/> + <Boolean id="selectedRow" javaBean="false"/> - <script> + <script> <![CDATA[ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FinancialPeriod; @@ -45,40 +45,46 @@ } ]]> - </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="periodComboBox" javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())" - onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); + </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="periodComboBox" + javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())" + onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); validate(); repaint()"/> - </cell> - <cell><VatReportPeriodSearchPanel javaBean="periodSearchPanel"/></cell> - <cell> - <JCheckBox id='autocomplete' text='lima.common.autocomplete' selected='true' - onActionPerformed="getVatReportTableModel().setAutocomplete()"/> - </cell> - <cell> - <JButton id="editVatButton" text="lima.reports.vat" - onActionPerformed="getHandler().editVat()"/> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> - <JScrollPane> - <org.chorem.lima.ui.vatreports.VatReportTableModel - id="vatReportTableModel"/> - <org.chorem.lima.ui.vatreports.VatReportTable - id="vatReportTable" sortable="false" rowHeight="22" - constructorParams="getHandler()" model="{getVatReportTableModel()}" - selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> - <javax.swing.ListSelectionModel javaBean="getVatReportTable().getSelectionModel()" - onValueChanged="setSelectedRow(vatReportTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - </row> + </cell> + <cell> + <VatReportPeriodSearchPanel javaBean="periodSearchPanel"/> + </cell> + <cell> + <JCheckBox id='autocomplete' text='lima.common.autocomplete' + selected='true' + onActionPerformed="getVatReportTableModel().setAutocomplete()"/> + </cell> + <cell> + <JButton id="editVatButton" text="lima.reports.vat" + onActionPerformed="getHandler().editVat()"/> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="11"> + <JScrollPane> + <org.chorem.lima.ui.vatreports.VatReportTableModel + id="vatReportTableModel"/> + <org.chorem.lima.ui.vatreports.VatReportTable + id="vatReportTable" sortable="false" rowHeight="22" + constructorParams="getHandler()" model="{getVatReportTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/> + <javax.swing.ListSelectionModel + javaBean="getVatReportTable().getSelectionModel()" + onValueChanged="setSelectedRow(vatReportTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> </Table> \ No newline at end of file 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/vatreports/VatReportViewHandler.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -24,12 +24,6 @@ */ package org.chorem.lima.ui.vatreports; -import java.awt.Desktop; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.text.SimpleDateFormat; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaConfig; @@ -38,56 +32,58 @@ import org.chorem.lima.business.utils.DocumentsEnum; import org.chorem.lima.service.LimaServiceFactory; +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.text.SimpleDateFormat; + public class VatReportViewHandler { /** log. */ private static final Log log = - LogFactory.getLog(VatReportViewHandler.class); - + LogFactory.getLog(VatReportViewHandler.class); + protected VatReportView view; - + protected VatReportTable table; - + protected VatReportTableModel tableModel; - + protected DocumentServiceMonitorable documentService; - + private static SimpleDateFormat dateFormat = - new SimpleDateFormat("yyyy-MM-dd"); - + new SimpleDateFormat("yyyy-MM-dd"); + protected int port; - + protected VatReportViewHandler(VatReportView view) { this.view = view; - + port = LimaServiceFactory.getInstance().getService( HttpServerServiceMonitorable.class).getHttpPort(); - + documentService = - LimaServiceFactory.getInstance().getService( - DocumentServiceMonitorable.class); + LimaServiceFactory.getInstance().getService( + DocumentServiceMonitorable.class); } - - /** - * @return VatView - */ + + /** @return VatView */ public VatReportView getView() { return view; } - - /** - * Edit VAT document - */ + + /** 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 { - String url = "http://"+address+":"+port+"/?beginDate=" - + dateFormat.format(tableModel.getBeginDate()) - + "&endDate=" + dateFormat.format(tableModel.getEndDate()) - + "&format=.pdf&model=" + DocumentsEnum.VAT.getFileName() - + "&autocomplete=" + tableModel.getAutocomplete(); - Desktop.getDesktop().browse(new URI(url)); + String url = "http://" + address + ":" + port + "/?beginDate=" + + dateFormat.format(tableModel.getBeginDate()) + + "&endDate=" + dateFormat.format(tableModel.getEndDate()) + + "&format=.pdf&model=" + DocumentsEnum.VAT.getFileName() + + "&autocomplete=" + tableModel.getAutocomplete(); + Desktop.getDesktop().browse(new URI(url)); } catch (IOException e) { log.error("Can't open browser", e); } catch (URISyntaxException e) { @@ -95,13 +91,11 @@ } } } - - /** - * Refresh VatTableModel - */ - public void refresh(){ + + /** Refresh VatTableModel */ + public void refresh() { tableModel = view.getVatReportTableModel(); tableModel.refresh(); } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/AccountToString.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -29,16 +29,16 @@ import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; public class AccountToString extends ObjectToStringConverter { - + private static AccountToString converter; - + @Override public String getPreferredStringForItem(Object item) { String result = null; - if (item != null){ - if (item instanceof Account){ + if (item != null) { + if (item instanceof Account) { Account account = (Account) item; - result = account.getAccountNumber()+" - "+account.getLabel(); + result = account.getAccountNumber() + " - " + account.getLabel(); } } return result; @@ -50,5 +50,5 @@ } return converter; } - + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/EntryBookToString.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -28,23 +28,23 @@ import org.chorem.lima.entity.EntryBook; import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; -public class EntryBookToString extends ObjectToStringConverter{ +public class EntryBookToString extends ObjectToStringConverter { private static EntryBookToString converter; - + @Override public String getPreferredStringForItem(Object item) { String result = null; - if (item != null){ - if (item instanceof EntryBook){ + if (item != null) { + if (item instanceof EntryBook) { EntryBook entryBook = (EntryBook) item; - result = entryBook.getCode()+" - "+entryBook.getLabel(); + result = entryBook.getCode() + " - " + entryBook.getLabel(); } } return result; } - - + + public static EntryBookToString getInstance() { if (converter == null) { converter = new EntryBookToString(); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/ErrorHelper.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,18 +25,6 @@ package org.chorem.lima.util; -import static org.nuiton.i18n.I18n._; - -import java.awt.Component; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.swing.JOptionPane; - import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -47,35 +35,46 @@ import org.jdesktop.swingx.error.ErrorInfo; import org.jdesktop.swingx.error.ErrorReporter; +import javax.swing.JOptionPane; +import java.awt.Component; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import static org.nuiton.i18n.I18n._; + /** * Error helper. - * + * <p/> * Used to easily switch real exception interface. Currently used : swingx. - * + * * @author chatellier * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ + * <p/> + * Last update : $Date$ + * By : $Author$ */ public class ErrorHelper implements ErrorReporter { /** Log. */ private static final Log log = LogFactory.getLog(ErrorHelper.class); - + /** * Display a user friendly error frame. - * - * @param parent parent component + * + * @param parent parent component * @param message message for user - * @param cause exception cause + * @param cause exception cause */ public static void showErrorDialog(Component parent, String message, - Throwable cause) { + Throwable cause) { JXErrorPane pane = new JXErrorPane(); ErrorInfo info = new ErrorInfo(_("lima.common.error"), - _("lima.error.errorpane.htmlmessage", message), null, null, - cause, null, null); + _("lima.error.errorpane.htmlmessage", message), null, null, + cause, null, null); pane.setErrorInfo(info); pane.setErrorReporter(new ErrorHelper()); JXErrorPane.showDialog(parent, pane); @@ -83,7 +82,7 @@ /** * Display a user friendly error frame. - * + * * @param message message for user */ public static void showErrorDialog(String message) { @@ -92,9 +91,9 @@ /** * Display a user friendly error frame. - * + * * @param message message for user - * @param cause exception cause + * @param cause exception cause */ public static void showErrorDialog(String message, Throwable cause) { showErrorDialog(null, message, cause); @@ -148,15 +147,15 @@ // send mail email.send(); - + JOptionPane.showMessageDialog(null, "A report message has been sent to " + emailTo); } catch (EmailException ex) { if (log.isErrorEnabled()) { - log.error("Can't send report email" ,ex); + log.error("Can't send report email", ex); } } } - + protected String formatMessage(String category, String content) { String formatted = category + " :\n"; if (StringUtils.isNotEmpty(content)) { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java 2011-09-17 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/util/LetterToString.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,20 +25,31 @@ package org.chorem.lima.util; +import org.chorem.lima.LimaContext; import org.chorem.lima.entity.Letter; import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; +import org.nuiton.util.decorator.Decorator; +import org.nuiton.util.decorator.DecoratorProvider; public class LetterToString extends ObjectToStringConverter { - + private static LetterToString converter; - + + protected Decorator<Letter> decorator; + + public LetterToString() { + + DecoratorProvider provider = LimaContext.get().getDecoratorProvider(); + decorator = provider.getDecoratorByType(Letter.class); + } + @Override public String getPreferredStringForItem(Object item) { String result = null; - if (item != null){ - if (item instanceof Letter){ + if (item != null) { + if (item instanceof Letter) { Letter letter = (Letter) item; - result = letter.getCode(); + result = decorator.toString(letter); } } return result; @@ -50,5 +61,5 @@ } return converter; } - + } 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 13:50:17 UTC (rev 3292) +++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/JWideComboBox.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -25,46 +25,15 @@ package org.chorem.lima.widgets; -import java.awt.Dimension; - import javax.swing.ComboBoxModel; import javax.swing.JComboBox; -import javax.swing.JScrollPane; -import javax.swing.plaf.basic.BasicComboPopup; -import javax.swing.plaf.basic.ComboPopup; -import javax.swing.plaf.metal.MetalComboBoxUI; +import java.awt.Dimension; -// put it at begin, otherwise jaxx complains again !!! -class ScrollMetalComboUI extends MetalComboBoxUI { - - @Override - protected ComboPopup createPopup() { - return new ScrollBasicComboPopup(comboBox); - } -} - -//put it at begin, otherwise jaxx complains again !!! -class ScrollBasicComboPopup extends BasicComboPopup { - - /** serialVersionUID. */ - private static final long serialVersionUID = 2353523521723292218L; - - public ScrollBasicComboPopup(JComboBox combo) { - super(combo); - } - - @Override - protected JScrollPane createScroller() { - return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, - JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); - } -} - /** * Cette combo box surcharge quelques methodes de l'UI par defaut * pour que le composant popup soit plus grand que la combobox * elle même. - * + * * @author ore */ public class JWideComboBox extends JComboBox { Added: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollBasicComboPopup.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollBasicComboPopup.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollBasicComboPopup.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -0,0 +1,27 @@ +package org.chorem.lima.widgets; + +import javax.swing.JComboBox; +import javax.swing.JScrollPane; +import javax.swing.plaf.basic.BasicComboPopup; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since TODO + */ //put it at begin, otherwise jaxx complains again !!! +public class ScrollBasicComboPopup extends BasicComboPopup { + + /** serialVersionUID. */ + private static final long serialVersionUID = 2353523521723292218L; + + public ScrollBasicComboPopup(JComboBox combo) { + super(combo); + } + + @Override + protected JScrollPane createScroller() { + return new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, + JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollBasicComboPopup.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native Added: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollMetalComboUI.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollMetalComboUI.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollMetalComboUI.java 2011-09-17 14:17:04 UTC (rev 3293) @@ -0,0 +1,18 @@ +package org.chorem.lima.widgets; + +import javax.swing.plaf.basic.ComboPopup; +import javax.swing.plaf.metal.MetalComboBoxUI; + +/** + * TODO + * + * @author tchemit <chemit@codelutin.com> + * @since TODO + */ // put it at begin, otherwise jaxx complains again !!! +public class ScrollMetalComboUI extends MetalComboBoxUI { + + @Override + protected ComboPopup createPopup() { + return new ScrollBasicComboPopup(comboBox); + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/widgets/ScrollMetalComboUI.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision Added: svn:eol-style + native