This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository lima. See http://git.chorem.org/lima.git commit 04240b794d8982c25c8d4dc2b80eb6c255da485c Author: Sylvain Bavencoff <bavencoff@codelutin.com> Date: Wed Oct 29 17:34:53 2014 +0100 refs #875 #1043 : lettering --- .../ui/celleditor/BigDecimalTableCellRenderer.java | 39 +--- .../FinancialTransactionUnbalancedView.jaxx | 5 +- .../lima/ui/lettering/LetteringEditModel.java | 40 ++-- .../org/chorem/lima/ui/lettering/LetteringView.css | 100 +++++++++ .../chorem/lima/ui/lettering/LetteringView.jaxx | 249 +++++++++------------ .../lima/ui/lettering/LetteringViewHandler.java | 64 ++++-- .../org/chorem/lima/util/BigDecimalToString.java | 40 ++++ .../resources/i18n/lima-swing_en_GB.properties | 11 + .../resources/i18n/lima-swing_fr_FR.properties | 20 +- 9 files changed, 344 insertions(+), 224 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java index 16591aa..5aab64e 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java @@ -21,45 +21,18 @@ */ package org.chorem.lima.ui.celleditor; -import org.chorem.lima.LimaSwingApplicationContext; -import org.chorem.lima.LimaSwingConfig; +import org.chorem.lima.util.BigDecimalToString; -import javax.swing.*; -import java.awt.*; +import javax.swing.JLabel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import java.awt.Component; import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; public class BigDecimalTableCellRenderer extends DefaultLimaTableCellRenderer { private static final long serialVersionUID = -2499433026151065390L; - public static String format(BigDecimal value) { - - LimaSwingConfig config = LimaSwingApplicationContext.getContext().getConfig(); - StringBuilder scale = new StringBuilder(); - for (int i = 0; i < config.getScale(); i++) { - scale.append("0"); - } - String currency = ""; - if (config.getCurrency()) { - currency = " ¤"; - } - DecimalFormat formatter = new DecimalFormat("##0." + scale.toString() + currency); - DecimalFormatSymbols symbol = new DecimalFormatSymbols(); - //set decimalSeparator and thousandSeparator preferences - symbol.setDecimalSeparator(config.getDecimalSeparator()); - symbol.setMonetaryDecimalSeparator(config.getDecimalSeparator()); - symbol.setGroupingSeparator(config.getThousandSeparator()); - formatter.setDecimalFormatSymbols(symbol); - //always set grouping - formatter.setGroupingUsed(true); - formatter.setGroupingSize(3); - String result = formatter.format(value); - return result; - } - - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { @@ -73,7 +46,7 @@ public class BigDecimalTableCellRenderer extends DefaultLimaTableCellRenderer { public void setValue(Object aValue) { Object result = aValue; if (aValue != null && aValue instanceof BigDecimal) { - result = format((BigDecimal)result); + result = BigDecimalToString.format((BigDecimal)result); } super.setValue(result); } diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx index 6c37e76..179d39c 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx @@ -9,6 +9,7 @@ published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + $Id: FinancialTransactionUnbalancedView.jaxx 3921 2014-09-19 15:21:43Z sbavencoff $ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -84,7 +85,7 @@ </JToolBar> - <JScrollPane> + <JScrollPane constraints="BorderLayout.CENTER"> <FinancialTransactionUnbalancedTableModel id="financialTransactionUnbalancedTableModel"/> <FinancialTransactionUnbalancedTable @@ -94,4 +95,4 @@ model="{getFinancialTransactionUnbalancedTableModel()}"/> </JScrollPane> -</JPanel> +</JPanel> \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java index 5e437b6..c400009 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java @@ -31,17 +31,17 @@ import java.math.BigDecimal; */ public class LetteringEditModel implements Serializable { - public static final String DEBIT_PROPERTY = "debit"; + public static final String PROPERTY_DEBIT = "debit"; - public static final String CREDIT_PROPERTY = "credit"; + public static final String PROPERTY_CREDIT = "credit"; - public static final String SOLDE_PROPERTY = "solde"; + public static final String PROPERTY_SOLD = "sold"; - public static final String LETTRED_PROPERTY = "lettred"; + public static final String PROPERTY_LETTRED = "lettred"; - public static final String UNLETTRED_PROPERTY = "unLettred"; + public static final String PROPERTY_UNLETTRED = "unLettred"; - public static final String EQUALIZED_PROPERTY = "equalized"; + public static final String PROPERTY_EQUALIZED = "equalized"; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); @@ -51,7 +51,7 @@ public class LetteringEditModel implements Serializable { protected boolean equalized; protected BigDecimal debit = BigDecimal.ZERO; protected BigDecimal credit = BigDecimal.ZERO; - protected BigDecimal solde = BigDecimal.ZERO; + protected BigDecimal sold = BigDecimal.ZERO; public boolean isEqualized() { return equalized; @@ -60,7 +60,7 @@ public class LetteringEditModel implements Serializable { public void setEqualized(boolean equalized) { boolean oldEqualized = isEqualized(); this.equalized = equalized; - firePropertyChange(EQUALIZED_PROPERTY, oldEqualized, this.equalized); + firePropertyChange(PROPERTY_EQUALIZED, oldEqualized, this.equalized); } public boolean isLettred() { @@ -69,12 +69,12 @@ public class LetteringEditModel implements Serializable { public void setLettred(boolean lettred) { boolean oldLettrer = isLettred(); - if(lettred && (solde == BigDecimal.ZERO || solde.doubleValue() == 0)){ + if(lettred && (sold == BigDecimal.ZERO || sold.doubleValue() == 0)){ this.lettred = lettred; }else{ this.lettred = false; } - firePropertyChange(LETTRED_PROPERTY, oldLettrer, this.lettred); + firePropertyChange(PROPERTY_LETTRED, oldLettrer, this.lettred); } public boolean isUnLettred() { @@ -84,7 +84,7 @@ public class LetteringEditModel implements Serializable { public void setUnLettred(boolean unLettred) { boolean oldDelettrer = isUnLettred(); this.unLettred = unLettred; - firePropertyChange(UNLETTRED_PROPERTY, oldDelettrer, this.unLettred); + firePropertyChange(PROPERTY_UNLETTRED, oldDelettrer, this.unLettred); } public BigDecimal getDebit() { @@ -100,7 +100,7 @@ public class LetteringEditModel implements Serializable { this.debit = BigDecimal.ZERO; } - firePropertyChange(DEBIT_PROPERTY, oldDebit, this.debit); + firePropertyChange(PROPERTY_DEBIT, oldDebit, this.debit); } public BigDecimal getCredit() { @@ -116,27 +116,27 @@ public class LetteringEditModel implements Serializable { this.credit=BigDecimal.ZERO; } - firePropertyChange(CREDIT_PROPERTY, oldCredit, this.credit); + firePropertyChange(PROPERTY_CREDIT, oldCredit, this.credit); } - public BigDecimal getSolde() { - return solde; + public BigDecimal getSold() { + return sold; } public void setSolde(BigDecimal solde, boolean credit) { - BigDecimal oldSolde = getSolde(); + BigDecimal oldSolde = getSold(); if (solde != BigDecimal.ZERO){ if (credit){ - this.solde = oldSolde.subtract(solde); + this.sold = oldSolde.subtract(solde); }else{ - this.solde = oldSolde.add(solde); + this.sold = oldSolde.add(solde); } }else{ - this.solde=BigDecimal.ZERO; + this.sold =BigDecimal.ZERO; } - firePropertyChange(SOLDE_PROPERTY, oldSolde, this.solde); + firePropertyChange(PROPERTY_SOLD, oldSolde, this.sold); } public void resetDebitCreditBalance(){ diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css new file mode 100644 index 0000000..0ad9584 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.css @@ -0,0 +1,100 @@ +.toolbar { + floatable : false; +} + +#lettered { + toolTipText : "lima.lettering.lettered"; + enabled : {editModel.lettred}; + actionIcon : "lettering"; +} + +#noLettered { + toolTipText : "lima.lettering.unLettered"; + enabled : {editModel.unLettred}; + actionIcon : "un-lettering"; +} + +#round { + toolTipText : "lima.lettering.equalize"; + enabled : {editModel.equalized}; + actionIcon : "balance"; +} + +#accountLabel { + actionIcon : "choose-account"; + labelFor : {accountComboBox}; +} + +#accountComboBox { + toolTipText : "lima.lettering.account"; + model : {accountComboBoxModel}; + renderer : {new org.chorem.lima.ui.common.AccountListRenderer()}; +} + +#back { + toolTipText : "lima.lettering.account.back"; + actionIcon : "previous"; +} + +#next { + toolTipText : "lima.lettering.account.next"; + actionIcon : "next"; +} + +#beginPeriodLabel { + text : "lima.lettering.period.begin"; + labelFor : {beginPeriodPicker}; +} + +#endPeriodLabel { + text : "lima.lettering.period.end"; + labelFor : {endPeriodPicker}; +} + +#letteredEntryLabel { + actionIcon : "choose-entry"; + labelFor : {letteredEntryComboBox}; +} + +#letteredEntryComboBox { + toolTipText : "lima.lettering.entry"; +} + +#refresh { + toolTipText : "lima.lettering.refresh"; + actionIcon : "refresh"; +} + +#debitLabel { + text : "lima.lettering.selection.debit"; + labelFor : {debitTextField}; +} + +#debitTextField { + enabled : false; + focusable : false; +} + +#creditLabel { + text : "lima.lettering.selection.credit"; + labelFor : {creditTextField}; +} + +#creditTextField { + enabled : false; + focusable : false; +} + +#soldLabel { + text : "lima.lettering.selection.sold"; + labelFor : {soldTextField}; +} + +#soldTextField { + enabled : false; + focusable : false; +} +#table { + sortable : false; + rowHeight : 22; +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx index d3fafd0..7b7d935 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx @@ -18,149 +18,106 @@ #L% --> -<Table > - - <import> - org.chorem.lima.ui.common.AccountComboBoxModel - org.chorem.lima.ui.common.FinancialPeriodComboBoxModel - org.chorem.lima.ui.lettering.TypeEntry - org.chorem.lima.entity.Account - javax.swing.ListSelectionModel - org.jdesktop.swingx.JXDatePicker - static org.nuiton.i18n.I18n.t - </import> - - <LetteringViewHandler id="handler" constructorParams="this"/> - - - <LetteringEditModel id='editModel'/> - - - - <script> - <![CDATA[ - void $afterCompleteSetup() { - handler.init(); - } - ]]> - </script> - - <row> - <cell fill="horizontal"> - <JToolBar floatable="false"> - - <JButton id="lettered" - toolTipText="{ t("lima.lettering.buttonLettered") + " (Ctrl+L)"}" - enabled="{editModel.isLettred()}" - actionIcon='lettering' - onActionPerformed="handler.addLetter()"/> - - <JButton id="noLettered" - toolTipText="{ t("lima.lettering.buttonNoLettered") + " (Del)"}" - enabled="{editModel.isUnLettred()}" - actionIcon='un-lettering' - onActionPerformed="handler.removeLetter()"/> - - <JButton id="round" - toolTipText="{ t("lima.lettering.buttonEqualize") + " (Ctrl+B)"}" - enabled="{editModel.isEqualized()}" - actionIcon='balance' - onActionPerformed="handler.roundAndCreateEntry()"/> - - <JToolBar.Separator/> - - <JLabel actionIcon='choose-account' - labelFor='{accountComboBox}'/> - <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/> - <JComboBox id="accountComboBox" - model="{accountComboBoxModel}" - toolTipText="lima.lettering.account" - renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" - onItemStateChanged="handler.setAccount((Account)accountComboBoxModel.getSelectedItem())" /> - <JButton id="back" actionIcon="previous" - toolTipText="lima.account.buttonback" - onActionPerformed="handler.back(accountComboBox)"/> - <JButton id="next" actionIcon="next" - toolTipText="lima.account.buttonnext" - onActionPerformed="handler.next(accountComboBox)"/> - - <JToolBar.Separator/> - - <JLabel text="lima.lettering.beginFinancialPeriod" - labelFor='{pickerDebut}'/> - <JXDatePicker id="pickerDebut" - onActionPerformed="handler.setDateStart(pickerDebut.getDate())"/> - - <JLabel text="lima.lettering.endFinancialPeriod" - labelFor="{pickerFin}"/> - <JXDatePicker id="pickerFin" - onActionPerformed="handler.setDateEnd(pickerFin.getDate())"/> - - <JToolBar.Separator/> - - <JLabel actionIcon='choose-entry' - labelFor='{lettredEntryComboBox}'/> - <EnumEditor id='lettredEntryComboBox' - genericType='TypeEntry' - constructorParams='TypeEntry.class' - toolTipText="lima.lettering.entry" - onItemStateChanged="handler.setTypeEntry(lettredEntryComboBox.getSelectedItem())" /> - - <JToolBar.Separator/> - - <JButton id="refresh" - toolTipText="{ t("lima.lettering.buttonRefresh") + " (F5)"}" - actionIcon='refresh' - onActionPerformed="handler.updateAllEntries()"/> - - </JToolBar> - </cell> - </row> - <row> - <cell fill="horizontal" > - <JToolBar floatable="false"> - <JLabel text="lima.lettering.selectDebit" - labelFor='{debitTexttField}'/> - <JTextField id="debitTexttField" - enabled="false" - text="{editModel.getDebit().toString()}" - focusable="false"/> - - <JToolBar.Separator/> - - <JLabel text="lima.lettering.selectCredit" - labelFor='{creditTextField}'/> - <JTextField id="creditTextField" - enabled="false" - text="{editModel.getCredit().toString()}" - focusable="false"/> - - <JToolBar.Separator/> - - <JLabel text="lima.lettering.selectSolde" - labelFor='{soldeTextField}'/> - <JTextField id="soldeTextField" - enabled="false" - text="{editModel.getSolde().toString()}" - focusable="false"/> - - </JToolBar> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" > - <JScrollPane> - <LetteringTableModel id="tableModel"/> - <LettringSelectionModel id='lettringSelectionModel' constructorParams='tableModel' - onValueChanged="handler.balanceAndActions()"/> - - <LetteringTable id="table" - sortable="false" - rowHeight="22" - constructorParams="handler" - model="{tableModel}" - selectionModel="{lettringSelectionModel}" /> - </JScrollPane> - </cell> - </row> -</Table> +<JPanel layout="{new BorderLayout()}"> + + <import> + org.chorem.lima.ui.common.AccountComboBoxModel + org.chorem.lima.ui.common.FinancialPeriodComboBoxModel + org.chorem.lima.util.BigDecimalToString + org.chorem.lima.ui.lettering.TypeEntry + org.chorem.lima.entity.Account + javax.swing.ListSelectionModel + org.jdesktop.swingx.JXDatePicker + static org.nuiton.i18n.I18n.t + </import> + + <LetteringViewHandler id="handler" constructorParams="this"/> + + <LetteringEditModel id='editModel'/> + + <script> + <![CDATA[ + void $afterCompleteSetup() { + handler.init(); + } + ]]> + </script> + + <JToolBar styleClass="toolbar" + constraints="BorderLayout.PAGE_START"> + + <JButton id="lettered" + onActionPerformed="handler.addLetter()"/> + + <JButton id="noLettered" + onActionPerformed="handler.removeLetter()"/> + + <JButton id="round" + onActionPerformed="handler.roundAndCreateEntry()"/> + + <JToolBar.Separator/> + + <JLabel id="accountLabel"/> + <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/> + <JComboBox id="accountComboBox" + onItemStateChanged="handler.setAccount((Account)accountComboBoxModel.getSelectedItem())" /> + <JButton id="back" + onActionPerformed="handler.back(accountComboBox)"/> + <JButton id="next" + onActionPerformed="handler.next(accountComboBox)"/> + + <JToolBar.Separator/> + + <JLabel id="beginPeriodLabel"/> + <JXDatePicker id="beginPeriodPicker" + onActionPerformed="handler.setDateStart(beginPeriodPicker.getDate())"/> + + <JLabel id="endPeriodLabel"/> + <JXDatePicker id="endPeriodPicker" + onActionPerformed="handler.setDateEnd(endPeriodPicker.getDate())"/> + + <JToolBar.Separator/> + + <JLabel id='letteredEntryLabel' actionIcon='choose-entry' + labelFor='{letteredEntryComboBox}'/> + <EnumEditor id='letteredEntryComboBox' + genericType='TypeEntry' + constructorParams='TypeEntry.class' + onItemStateChanged="handler.setTypeEntry(letteredEntryComboBox.getSelectedItem())" /> + + <JToolBar.Separator/> + + <JButton id="refresh" + onActionPerformed="handler.updateAllEntries()"/> + + </JToolBar> + <JPanel constraints="BorderLayout.CENTER" + layout="{new BorderLayout()}"> + <JToolBar styleClass="toolbar" + constraints="BorderLayout.PAGE_START"> + <JLabel id="debitLabel"/> + <JFormattedTextField id="debitTextField"/> + + <JToolBar.Separator/> + + <JLabel id="creditLabel"/> + <JTextField id="creditTextField"/> + + <JToolBar.Separator/> + + <JLabel id="soldLabel"/> + <JTextField id="soldTextField"/> + + </JToolBar> + <JScrollPane constraints="BorderLayout.CENTER"> + <LetteringTableModel id="tableModel"/> + <LettringSelectionModel id='letteringSelectionModel' constructorParams='tableModel' + onValueChanged="handler.balanceAndActions()"/> + + <LetteringTable id="table" + constructorParams="handler" + model="{tableModel}" + selectionModel="{letteringSelectionModel}"/> + </JScrollPane> + </JPanel> +</JPanel> \ No newline at end of file diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java index b68c8c5..a2cec45 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java @@ -6,15 +6,15 @@ * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the + * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public + * + * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. * #L% @@ -43,12 +43,20 @@ import org.chorem.lima.entity.AccountImpl; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.BigDecimalToString; import org.chorem.lima.util.ErrorHelper; -import javax.swing.*; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.InputMap; +import javax.swing.JComboBox; +import javax.swing.JComponent; +import javax.swing.KeyStroke; import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; import java.math.BigDecimal; import java.util.Calendar; import java.util.Date; @@ -108,8 +116,36 @@ public class LetteringViewHandler{ public void init() { filter = new LetteringFilterImpl(); editModel = view.getEditModel(); - lettringSelectionModel = view.getLettringSelectionModel(); + lettringSelectionModel = view.getLetteringSelectionModel(); loadComboAndRows(); + + editModel.addPropertyChangeListener(LetteringEditModel.PROPERTY_DEBIT, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + BigDecimal debit = (BigDecimal) evt.getNewValue(); + String text = BigDecimalToString.format(debit); + view.getDebitTextField().setText(text); + } + }); + + editModel.addPropertyChangeListener(LetteringEditModel.PROPERTY_CREDIT, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + BigDecimal credit = (BigDecimal) evt.getNewValue(); + String text = BigDecimalToString.format(credit); + view.getCreditTextField().setText(text); + } + }); + + editModel.addPropertyChangeListener(LetteringEditModel.PROPERTY_SOLD, new PropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent evt) { + BigDecimal sold = (BigDecimal) evt.getNewValue(); + String text = BigDecimalToString.format(sold); + view.getSoldTextField().setText(text); + } + }); + } protected void initShortCuts() { @@ -218,7 +254,7 @@ public class LetteringViewHandler{ //Unlettred entries onBalanceChanged(null); //treatment unuseful if no rows are selected - if (!view.getLettringSelectionModel().isSelectionEmpty()) { + if (!view.getLetteringSelectionModel().isSelectionEmpty()) { if (log.isDebugEnabled()) { log.debug("Rows selected"); } @@ -272,7 +308,7 @@ public class LetteringViewHandler{ Entry selectedEntry; LetteringTableModel tableModel = view.getTableModel(); for (int i = 0; i < tableModel.getRowCount(); i ++){ - if (view.getLettringSelectionModel().isSelectedIndex(i)){ + if (view.getLetteringSelectionModel().isSelectedIndex(i)){ selectedEntry = tableModel.get(i); //Set values for calculation (By LetteringEditModel) of balance onBalanceChanged(selectedEntry); @@ -351,13 +387,13 @@ public class LetteringViewHandler{ Date defaultDateEndCurrent = DateUtils.setDays(new Date(), dernierJourMoisCourant); - view.getPickerDebut().setDate(defaultDateBegFiscalPeriod); - view.getPickerFin().setDate(defaultDateEndCurrent); + view.getBeginPeriodPicker().setDate(defaultDateBegFiscalPeriod); + view.getEndPeriodPicker().setDate(defaultDateEndCurrent); filter.setDateStart(defaultDateBegFiscalPeriod); filter.setDateEnd(defaultDateEndCurrent); - TypeEntry type = view.getLettredEntryComboBox().getSelectedItem(); + TypeEntry type = view.getLetteredEntryComboBox().getSelectedItem(); setTypeEntry(type); updateAllEntries(); @@ -429,7 +465,7 @@ public class LetteringViewHandler{ /*Re-select the two entries (firstSelectedEntry and secondSelectedEntry) * and the new sameAccountEntry * */ - view.getLettringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry); + view.getLetteringSelectionModel().selectRoundedAndNewEntries(selectedRows[0], selectedRows[1], newSameAccountEntry); } catch (LockedFinancialPeriodException e) { errorHelper.showErrorMessage(t("lima.lettering.roundAndCreateEntry.error.lockedFinancialPeriod", e.getFinancialPeriod().getBeginDate(), @@ -455,7 +491,7 @@ public class LetteringViewHandler{ if (row > 0) { comboBox.setSelectedIndex(row - 1); } - view.getLettringSelectionModel().clearSelection(); + view.getLetteringSelectionModel().clearSelection(); } /** @@ -470,7 +506,7 @@ public class LetteringViewHandler{ if (row < size - 1) { comboBox.setSelectedIndex(row + 1); } - view.getLettringSelectionModel().clearSelection(); + view.getLetteringSelectionModel().clearSelection(); } /**Add a group of three letters to n entries*/ diff --git a/lima-swing/src/main/java/org/chorem/lima/util/BigDecimalToString.java b/lima-swing/src/main/java/org/chorem/lima/util/BigDecimalToString.java new file mode 100644 index 0000000..f04e506 --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/util/BigDecimalToString.java @@ -0,0 +1,40 @@ +package org.chorem.lima.util; + +import org.chorem.lima.LimaSwingApplicationContext; +import org.chorem.lima.LimaSwingConfig; + +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; + +/** + * @author Sylvain Bavencoff - bavencoff@codelutin.com + */ +public class BigDecimalToString { + + public static String format(BigDecimal value) { + + LimaSwingConfig config = LimaSwingApplicationContext.getContext().getConfig(); + StringBuilder scale = new StringBuilder(); + for (int i = 0; i < config.getScale(); i++) { + scale.append("0"); + } + String currency = ""; + if (config.getCurrency()) { + currency = " ¤"; + } + DecimalFormat formatter = new DecimalFormat("##0." + scale.toString() + currency); + DecimalFormatSymbols symbol = new DecimalFormatSymbols(); + //set decimalSeparator and thousandSeparator preferences + symbol.setDecimalSeparator(config.getDecimalSeparator()); + symbol.setMonetaryDecimalSeparator(config.getDecimalSeparator()); + symbol.setGroupingSeparator(config.getThousandSeparator()); + formatter.setDecimalFormatSymbols(symbol); + //always set grouping + formatter.setGroupingUsed(true); + formatter.setGroupingSize(3); + String result = formatter.format(value); + return result; + } + +} diff --git a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 206b059..531f06c 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties @@ -557,6 +557,8 @@ lima.init.errorclosing=Error during Lima close lima.label=Label lima.ledger.documentcreationerror=Enable to create document lima.lettering.account=Accounts +lima.lettering.account.back= +lima.lettering.account.next= lima.lettering.accountRegularization=Lettering regularization lima.lettering.actions=Actions lima.lettering.beginFinancialPeriod=From @@ -572,14 +574,23 @@ lima.lettering.checkNoLettredEntry=Unlettered lima.lettering.checkNoLettredEntrye= lima.lettering.endFinancialPeriod=To lima.lettering.entry=Entries +lima.lettering.equalize= +lima.lettering.lettered= lima.lettering.listerror=Can't get entries list lima.lettering.period=Periods +lima.lettering.period.begin= +lima.lettering.period.end= +lima.lettering.refresh= lima.lettering.roundAndCreateEntry.error.lockedEntryBook= lima.lettering.roundAndCreateEntry.error.lockedFinancialPeriod= lima.lettering.selectCredit= lima.lettering.selectDebit= lima.lettering.selectEntry=Actual selection lima.lettering.selectSolde=Balance +lima.lettering.selection.credit= +lima.lettering.selection.debit= +lima.lettering.selection.sold= +lima.lettering.unLettered= lima.list.seeAll=ALL lima.locale= lima.mainview.title=Lutin Invoice Monitoring and Accounting diff --git a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties index c2a661f..4c60004 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties @@ -478,29 +478,31 @@ lima.init.errorclosing=Erreur lors de la fermeture lima.label=Libellé lima.ledger.documentcreationerror=Erreur lors de la création du document lima.lettering.account=Comptes +lima.lettering.account.back=← +lima.lettering.account.next=→ lima.lettering.accountRegularization=Régularisation lettrage lima.lettering.actions=Actions -lima.lettering.beginFinancialPeriod=De lima.lettering.buttonAuto=Auto -lima.lettering.buttonEqualize=Equilibrer -lima.lettering.buttonLettered=Lettrer -lima.lettering.buttonNoLettered=Délettrer -lima.lettering.buttonRefresh=Rafraîchir lima.lettering.checkAll=Toutes lima.lettering.checkLettredEntry=Lettrées lima.lettering.checkLettredEntrye= lima.lettering.checkNoLettredEntry=Non-lettrées lima.lettering.checkNoLettredEntrye= -lima.lettering.endFinancialPeriod=A lima.lettering.entry=Écritures +lima.lettering.equalize=Equilibrer (Ctrl+B) +lima.lettering.lettered=Lettrer (Ctrl+L) lima.lettering.listerror=Erreur lors de la récupération des données de la liste lima.lettering.period=Périodes +lima.lettering.period.begin=De +lima.lettering.period.end=A +lima.lettering.refresh=Rafraîchir (F5) lima.lettering.roundAndCreateEntry.error.lockedEntryBook=Impossible de modifier le lettrage d'une entré car le jounal %2$s (%1$s) est cloturé pour la période du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY. lima.lettering.roundAndCreateEntry.error.lockedFinancialPeriod=Impossible de modifier le lettrage d'une entré car la période fiscale du %3$te %3$tB %3$tY au %4$te %4$tB %4$tY est cloturée. -lima.lettering.selectCredit=Crédit -lima.lettering.selectDebit=Débit lima.lettering.selectEntry=Sélection courante -lima.lettering.selectSolde=Solde +lima.lettering.selection.credit=Crédit +lima.lettering.selection.debit=Débit +lima.lettering.selection.sold=Solde +lima.lettering.unLettered=Délettrer (Suppr) lima.list.seeAll=TOUS lima.mainview.title=Lutin Invoice Monitoring and Accounting lima.message.help.usage=Options (set with --option <key> <value>\: -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.