r3709 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/lettering resources/i18n resources/icons
Author: Bavencoff Date: 2013-09-27 16:03:11 +0200 (Fri, 27 Sep 2013) New Revision: 3709 Url: http://chorem.org/projects/lima/repository/revisions/3709 Log: lettrage : am?\195?\169lioration des l'ergonomie, ajout de racourcis clavier Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java trunk/lima-swing/src/main/resources/icons/action-choose-account.png trunk/lima-swing/src/main/resources/icons/action-choose-entry.png trunk/lima-swing/src/main/resources/icons/action-un-lettering.png 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/LetteringView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 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 2013-08-09 10:06:55 UTC (rev 3708) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-09-27 14:03:11 UTC (rev 3709) @@ -25,7 +25,6 @@ package org.chorem.lima.ui.lettering; -import org.chorem.lima.LimaConfig; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; @@ -35,11 +34,8 @@ import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; import org.jdesktop.swingx.JXTable; -import javax.swing.DefaultCellEditor; -import javax.swing.InputMap; -import javax.swing.JComponent; -import javax.swing.JTextField; -import javax.swing.KeyStroke; +import javax.swing.*; +import java.awt.event.ActionEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.math.BigDecimal; @@ -56,15 +52,49 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - protected LetteringViewHandler handler; + protected final LetteringViewHandler handler; - public LetteringTable(LetteringTableModel letteringTableModel) { + public LetteringTable(LetteringTableModel letteringTableModel, final LetteringViewHandler handler) { super(letteringTableModel); + this.handler = handler; + //To block reaction of the dual key 'ctrl+a' (Selection of all lines) - InputMap im = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - im.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none"); + InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); + ActionMap actionMap = getActionMap(); + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none"); + // add action on Ctrl + L + String binding = "lettering"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.addLetter(); + } + }); + + // add action on Ctrl + Delete + binding = "un-lettering"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.removeLetter(); + } + }); + + // add action on Ctrl + B + binding = "balance"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.roundAndCreateEntry(); + } + }); + + //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); 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 2013-08-09 10:06:55 UTC (rev 3708) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-09-27 14:03:11 UTC (rev 3709) @@ -28,6 +28,7 @@ <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 @@ -53,136 +54,114 @@ </script> <row> - <cell> - <JPanel layout='{new BorderLayout()}' id="panelAccountComboBox" border='{new TitledBorder(_("lima.ui.lettering.account"))}'> - <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/> - <JComboBox id="accountComboBox" model="{accountComboBoxModel}" - renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" - onActionPerformed="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())" - constraints='BorderLayout.WEST'/> - <JButton id="backCount" text="lima.ui.account.buttonback" - onActionPerformed="handler.back(accountComboBox)" - constraints='BorderLayout.CENTER'/> - <JButton id="nextCount" text="lima.ui.account.buttonnext" - onActionPerformed="handler.next(accountComboBox)" - constraints='BorderLayout.EAST'/> - </JPanel> - </cell> - <cell> - <JPanel id="panelFinancialPeriodComboBox" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.period"))}'> - <Table constraints='BorderLayout.NORTH'> - <row> - <cell> - <JLabel text="lima.ui.lettering.beginFinancialPeriod"/> - </cell> - <cell> - <JXDatePicker id="pickerDebut" - onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/> - </cell> - </row> - <row> - <cell> - <JLabel text="lima.ui.lettering.endFinancialPeriod"/> - </cell> - <cell> - <JXDatePicker id="pickerFin" - onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/> - </cell> - </row> - </Table> - </JPanel> - </cell> - <cell> - <JPanel id="entryPanel" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.entry"))}'> - <Table constraints='BorderLayout.NORTH'> - <row> - <cell> - <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(false)"/> - </cell> - <cell> - <JLabel text="lima.ui.lettering.checkLettredEntry"/> - </cell> - </row> - <row> - <cell> - <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup" - onActionPerformed="filterModel.setDisplayUnlettred(true); filterModel.setDisplayLettered(false)"/> - </cell> - <cell> - <JLabel text="lima.ui.lettering.checkNoLettredEntry"/> - </cell> - </row> - <row> - <cell> - <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="filterModel.setDisplayLettered(false) ; filterModel.setDisplayUnlettred(false)"/> - </cell> - <cell> - <JLabel text="lima.ui.lettering.checkAll"/> - </cell> - </row> - </Table> - </JPanel> - </cell> + <cell fill="horizontal"> + <JToolBar floatable="false"> + + <JButton id="lettered" + toolTipText="{ _("lima.ui.lettering.buttonLettered") + " (Ctrl+L)"}" + enabled="{editModel.isLettred()}" + actionIcon='lettering' + onActionPerformed="handler.addLetter()"/> + + <JButton id="noLettered" + toolTipText="{ _("lima.ui.lettering.buttonNoLettered") + " (Del)"}" + enabled="{editModel.isUnLettred()}" + actionIcon='un-lettering' + onActionPerformed="handler.removeLetter()"/> + + <JButton id="round" + toolTipText="{ _("lima.ui.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.ui.lettering.account" + renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" + onItemStateChanged="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())" /> + <JButton id="back" actionIcon="previous" + toolTipText="lima.ui.account.buttonback" + onActionPerformed="handler.back(accountComboBox)"/> + <JButton id="next" actionIcon="next" + toolTipText="lima.ui.account.buttonnext" + onActionPerformed="handler.next(accountComboBox)"/> + + <JToolBar.Separator/> + + <JLabel text="lima.ui.lettering.beginFinancialPeriod" + labelFor='{pickerDebut}'/> + <JXDatePicker id="pickerDebut" + onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/> + + <JLabel text="lima.ui.lettering.endFinancialPeriod" + labelFor="{pickerFin}"/> + <JXDatePicker id="pickerFin" + onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/> + + <JToolBar.Separator/> + + <JLabel actionIcon='choose-entry' + labelFor='{lettredEntryComboBox}'/> + <EnumEditor id='lettredEntryComboBox' + genericType='TypeEntry' + constructorParams='TypeEntry.class' + toolTipText="lima.ui.lettering.entry" + onItemStateChanged="filterModel.setDisplayLettered(lettredEntryComboBox.getSelectedItem().isLettered()) ; filterModel.setDisplayUnlettred(lettredEntryComboBox.getSelectedItem().isNoLettered()) " /> + + <JToolBar.Separator/> + + <JButton id="refresh" + toolTipText="{ _("lima.ui.lettering.buttonRefresh") + " (F5)"}" + actionIcon='refresh' + onActionPerformed="handler.updateAllEntries()"/> + + </JToolBar> + </cell> </row> <row> - <cell fill="horizontal" columns="4"> - <JPanel id="selectedEntry" layout='{new BorderLayout()}' border='{new TitledBorder(_("lima.ui.lettering.selectEntry"))}'> - <Table constraints='BorderLayout.NORTH'> - <row> - <cell anchor="center" weightx="0.6"> - <JLabel text="lima.ui.lettering.selectDebit" labelFor='{debitTexttField}'/> - </cell> - <cell fill="horizontal" weightx="0.6"> - <JTextField id="debitTexttField" editable="false" text="{editModel.getDebit().toString()}" - focusable="false"/> - </cell> - <cell anchor="center" weightx="0.6"> - <JLabel text="lima.ui.lettering.selectCredit" labelFor='{creditTextField}'/> - </cell> - <cell fill="horizontal" weightx="0.6"> - <JTextField id="creditTextField" editable="false" text="{editModel.getCredit().toString()}" - focusable="false"/> - </cell> - <cell anchor="center" weightx="0.6"> - <JLabel text="lima.ui.lettering.selectSolde" labelFor='{soldeTextField}'/> - </cell> - <cell fill="horizontal" weightx="0.6"> - <JTextField id="soldeTextField" editable="false" text="{editModel.getSolde().toString()}" - focusable="false"/> - </cell> - </row> - </Table> - </JPanel> + <cell fill="horizontal" > + <JToolBar floatable="false"> + <JLabel text="lima.ui.lettering.selectDebit" + labelFor='{debitTexttField}'/> + <JTextField id="debitTexttField" + enabled="false" + text="{editModel.getDebit().toString()}" + focusable="false"/> + + <JToolBar.Separator/> + + <JLabel text="lima.ui.lettering.selectCredit" + labelFor='{creditTextField}'/> + <JTextField id="creditTextField" + enabled="false" + text="{editModel.getCredit().toString()}" + focusable="false"/> + + <JToolBar.Separator/> + + <JLabel text="lima.ui.lettering.selectSolde" + labelFor='{soldeTextField}'/> + <JTextField id="soldeTextField" + enabled="false" + text="{editModel.getSolde().toString()}" + focusable="false"/> + + </JToolBar> </cell> </row> <row> - <cell anchor="center" columns='4'> - <JPanel id="actionsPanel"> - <JButton id="lettered" text="lima.ui.lettering.buttonLettered" - enabled="{editModel.isLettred()}" - onActionPerformed="handler.addLetter()"/> - <JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered" - enabled="{editModel.isUnLettred()}" - onActionPerformed="handler.removeLetter()"/> - <JButton id="refresh" text="lima.ui.lettering.buttonRefresh" - enabled="true" - onActionPerformed="handler.updateAllEntries()"/> - <JButton id="round" text="lima.ui.lettering.buttonEqualize" - enabled="{editModel.isEqualized()}" - onActionPerformed="handler.roundAndCreateEntry()"/> - </JPanel> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1" columns="4"> + <cell fill="both" weightx="1" weighty="1" > <JScrollPane> <LetteringTable id="table" sortable="false" rowHeight="22" - constructorParams="getTableModel()" - selectionModel="{lettringSelectionModel}" - /> + constructorParams="getTableModel(), handler" + selectionModel="{lettringSelectionModel}" /> </JScrollPane> </cell> </row> 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 2013-08-09 10:06:55 UTC (rev 3708) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-09-27 14:03:11 UTC (rev 3709) @@ -336,7 +336,7 @@ LetteringTableModel tableModel = view.getTableModel(); int[] selectedRows = view.getTable().getSelectedRows(); - if (selectedRows.length == 2) { + if (editModel.isEqualized() && selectedRows.length == 2) { /*Treatment only if one of values contains decimals*/ Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]); Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]); @@ -400,15 +400,19 @@ /**Add a group of three letters to n entries*/ public void addLetter() { - String newLetters = financialTransactionService.getNextLetters(); - changeLetter(newLetters); - onButtonModeChanged(ButtonMode.DELETTRED); + if (editModel.isLettred()) { + String newLetters = financialTransactionService.getNextLetters(); + changeLetter(newLetters); + onButtonModeChanged(ButtonMode.DELETTRED); + } } /**Remove a group of three letters to n entries*/ public void removeLetter() { - changeLetter(null); - onButtonModeChanged(ButtonMode.LETTRED); + if (editModel.isUnLettred()) { + changeLetter(null); + onButtonModeChanged(ButtonMode.LETTRED); + } } /**Add or remove a group of three letters to n entries*/ Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java 2013-09-27 14:03:11 UTC (rev 3709) @@ -0,0 +1,54 @@ +package org.chorem.lima.ui.lettering; + +import static org.nuiton.i18n.I18n._; + +/** + * @author Sylvain Bavencoff <bavencoff@codelutin.com> + */ +public enum TypeEntry { + + LETTERED(true, false), + + NO_LETTERED(false, true), + + ALL(true, true); + + private boolean lettered; + + private boolean noLettered; + + private TypeEntry(boolean lettered, boolean noLettered) { + this.lettered = lettered; + this.noLettered = noLettered; + } + + + @Override + public String toString() { + + String result = ""; + + switch (this) { + case LETTERED: + result = _("lima.ui.lettering.checkLettredEntry"); + break; + case NO_LETTERED: + result = _("lima.ui.lettering.checkNoLettredEntry"); + break; + case ALL: + result = _("lima.ui.lettering.checkAll"); + break; + } + + return result; + + } + + public boolean isLettered() { + return lettered; + } + + public boolean isNoLettered() { + return noLettered; + } +} Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-08-09 10:06:55 UTC (rev 3708) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-09-27 14:03:11 UTC (rev 3709) @@ -392,7 +392,9 @@ lima.ui.lettering.buttonRefresh=Refresh lima.ui.lettering.checkAll=All lima.ui.lettering.checkLettredEntry=Lettered +lima.ui.lettering.checkLettredEntrye= lima.ui.lettering.checkNoLettredEntry=Unlettered +lima.ui.lettering.checkNoLettredEntrye= lima.ui.lettering.endFinancialPeriod=To lima.ui.lettering.entry=Entries lima.ui.lettering.period=Periods Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-08-09 10:06:55 UTC (rev 3708) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-09-27 14:03:11 UTC (rev 3709) @@ -382,7 +382,9 @@ lima.ui.lettering.buttonRefresh=Rafraîchir lima.ui.lettering.checkAll=Toutes lima.ui.lettering.checkLettredEntry=Lettrées +lima.ui.lettering.checkLettredEntrye= lima.ui.lettering.checkNoLettredEntry=Non-lettrées +lima.ui.lettering.checkNoLettredEntrye= lima.ui.lettering.endFinancialPeriod=A lima.ui.lettering.entry=Écritures lima.ui.lettering.period=Périodes Copied: trunk/lima-swing/src/main/resources/icons/action-choose-account.png (from rev 3708, trunk/lima-swing/src/main/resources/icons/action-filter-transaction-account.png) =================================================================== (Binary files differ) Added: trunk/lima-swing/src/main/resources/icons/action-choose-entry.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-entry.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-un-lettering.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-un-lettering.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream
participants (1)
-
Bavencoff@users.chorem.org