r3681 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/financialtransaction resources/i18n resources/icons
Author: Bavencoff Date: 2013-06-14 11:26:25 +0200 (Fri, 14 Jun 2013) New Revision: 3681 Url: http://chorem.org/projects/lima/repository/revisions/3681 Log: user experience Added: trunk/lima-swing/src/main/resources/icons/action-add-entry.png trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png trunk/lima-swing/src/main/resources/icons/action-balance.png trunk/lima-swing/src/main/resources/icons/action-choose-book.png trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png trunk/lima-swing/src/main/resources/icons/action-copy.png trunk/lima-swing/src/main/resources/icons/action-delete-entry.png trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png trunk/lima-swing/src/main/resources/icons/action-delete.png trunk/lima-swing/src/main/resources/icons/action-next.png trunk/lima-swing/src/main/resources/icons/action-paste.png trunk/lima-swing/src/main/resources/icons/action-previous.png trunk/lima-swing/src/main/resources/icons/action-refresh.png Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/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/celleditor/EntryTableCellRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-06-14 09:26:25 UTC (rev 3681) @@ -1,6 +1,5 @@ package org.chorem.lima.ui.celleditor; -import com.google.common.base.Preconditions; import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable; import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel; import sun.swing.DefaultLookup; @@ -23,8 +22,6 @@ 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 - Preconditions.checkState(table instanceof FinancialTransactionTable); - JLabel myCell = new JLabel(); myCell.setOpaque(true); myCell.setBorder(new EmptyBorder(1, 1, 1, 1)); @@ -33,28 +30,20 @@ Color background = Color.WHITE; Color foreground = Color.BLACK; - FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel(); - - /*JTable.DropLocation dropLocation = table.getDropLocation(); - if (dropLocation != null - && !dropLocation.isInsertRow() - && !dropLocation.isInsertColumn() - && dropLocation.getRow() == row - && dropLocation.getColumn() == column) { - - background = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellForeground"); - foreground = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.dropCellBackground"); - - isSelected = true; - } */ - if (isSelected) { foreground = table.getSelectionForeground(); background = table.getSelectionBackground(); } else { Color alternateColor = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.alternateRowColor"); - if (alternateColor != null && model.getIndexTransaction(row) % 2 != 0) { - background = alternateColor; + if (alternateColor != null) { + if (table instanceof FinancialTransactionTable) { + FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel(); + if (model.getIndexTransaction(row) % 2 != 0) { + background = alternateColor; + } + } else if (row % 2 == 0) { + background = alternateColor; + } } } @@ -66,13 +55,13 @@ background = new Color(255, 198, 209); } - if (model.getBalanceTransactionInRow(row).signum() != 0) { - foreground = new Color(240, 30, 30); + if (table instanceof FinancialTransactionTable) { + FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel(); + if (model.getBalanceTransactionInRow(row).signum() != 0) { + foreground = new Color(240, 30, 30); + } } - myCell.setBackground(background); - myCell.setForeground(foreground); - if (hasFocus) { Border border = null; if (isSelected) { @@ -91,6 +80,8 @@ myCell.setBorder(border); } + myCell.setBackground(background); + myCell.setForeground(foreground); setValue(value); myCell.setText(text); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/StringTableCellEditor.java 2013-06-14 09:26:25 UTC (rev 3681) @@ -23,8 +23,8 @@ public StringTableCellEditor() { super(new JTextField()); - setClickCountToStart(1);Border border = BorderFactory.createLineBorder(new Color(123, 165, 205), 2); - //Border border = BorderFactory.createLoweredBevelBorder(); + setClickCountToStart(1); + Border border = BorderFactory.createLineBorder(new Color(123, 165, 205), 2); getComponent().setBorder(border); getComponent().addFocusListener(new FocusListener() { Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-06-14 09:26:25 UTC (rev 3681) @@ -120,6 +120,116 @@ binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK)); actionMap.put(binding, new CellRouteVerticalFirstAction(false)); + // add action on Ctrl + Shift + N + binding = "new-transaction"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.addFinancialTransaction(); + } + }); + + // add action on Ctrl + Shift + Delete + binding = "delete-transaction"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.deleteSelectedTransaction(); + } + }); + + // add action on Ctrl + Shift + C + binding = "copy-transaction"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (getSelectedRow() >= 0) { + handler.copyTransaction(getSelectedRow()); + } + } + }); + + // add action on Ctrl + Shift + V + binding = "paste-transaction"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (getSelectedRow() >= 0) { + handler.pasteTransaction(getSelectedRow()); + } + } + }); + + // add action on Ctrl + N + binding = "new-entry"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.addEntry(); + } + }); + + // add action on Ctrl + Delete + binding = "delete-entry"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.deleteSelectedEntry(); + } + }); + + // add action on Ctrl + Alt + C + binding = "copy-entry"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (getSelectedRow() >= 0) { + handler.copyEntry(getSelectedRow()); + } + } + }); + + // add action on Ctrl + Alt + V + binding = "paste-entry"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + if (getSelectedRow() >= 0) { + handler.pasteEntry(getSelectedRow()); + } + } + }); + + // 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) { + if (getSelectedRow() >= 0) { + handler.balanceTransaction(getSelectedRow()); + } + } + }); + + // add action on Ctrl + Alt + A + binding = "assign-all"; + inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK), binding); + actionMap.put(binding, new AbstractAction() { + @Override + public void actionPerformed(ActionEvent e) { + handler.assignAllEntries(); + } + }); + // remove input Ctrl + Del inputMap= stringTableCellEditor.getComponent().getInputMap(JComponent.WHEN_FOCUSED); while (inputMap != null) { @@ -142,6 +252,12 @@ if (log.isDebugEnabled()) { log.debug("Key tab used"); } + + if (isEditing()) { + TableCellEditor editor = getCellEditor(); + editor.stopCellEditing(); + } + int nbColumn = getColumnCount(); int nbRows = getRowCount(); int column = getSelectedColumn(); @@ -151,6 +267,8 @@ boolean end = false; + + FinancialTransaction transaction = tableModel.getTransactionAt(row); do { if (column >= nbColumn - 1) { @@ -179,13 +297,8 @@ column++; } } while (!end && !tableModel.isCellEditable(row,column)); - if (isEditing()) { - TableCellEditor editor = getCellEditor(); - editor.stopCellEditing(); - } - setRowSelectionInterval(row, row); - setColumnSelectionInterval(column, column); - //editCellAt(row, column); + changeSelection(row, column, false, false); + editCellAt(row, column); } } } @@ -248,11 +361,8 @@ TableCellEditor editor = getCellEditor(); editor.stopCellEditing(); } - int row = getRow(); - int column = getColumn(); - setRowSelectionInterval(row, row); - setColumnSelectionInterval(column, column); - //editCellAt(row, column); + changeSelection(getRow(), getColumn(), false, false); + editCellAt(getRow(), getColumn()); } } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-06-14 09:26:25 UTC (rev 3681) @@ -25,6 +25,8 @@ package org.chorem.lima.ui.financialtransaction; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.api.FinancialTransactionService; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; @@ -35,6 +37,8 @@ import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.Date; import java.util.List; @@ -52,6 +56,8 @@ /** serialVersionUID. */ private static final long serialVersionUID = -7495388454688562991L; + private static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class); + /** Service (just to update setValueAt(). */ protected FinancialTransactionService financialTransactionService; @@ -76,6 +82,22 @@ fireTableDataChanged(); } + public void sortEntries() { + Comparator<FinancialTransaction> comparator = new Comparator<FinancialTransaction>() { + @Override + public int compare(FinancialTransaction o1, FinancialTransaction o2) { + return o1.getTransactionDate().compareTo(o2.getTransactionDate()); + } + }; + + Collections.sort(transactions, comparator); + entries.clear(); + for (FinancialTransaction transaction : transactions) { + entries.addAll(transaction.getEntry()); + } + fireTableDataChanged(); + } + @Override public int getColumnCount() { return 6; @@ -194,19 +216,24 @@ Entry entry = entries.get(row); FinancialTransaction transaction = entry.getFinancialTransaction(); - String description; - boolean updateEntries = false; + boolean updateEntry = false; boolean updateTransaction = false; switch (column) { case 0: //update - transaction.setTransactionDate((Date) value); - updateTransaction = true; + updateTransaction = (transaction.getTransactionDate().compareTo((Date) value) != 0); + if (updateTransaction) { + transaction.setTransactionDate((Date) value); + } break; case 1: String voucher = ((String) value).trim(); - int firstEntryRow = indexOf(transaction); + updateEntry = (entry.getVoucher().compareTo(voucher) != 0); + if (updateEntry) { + entry.setVoucher(voucher); + } + /*int firstEntryRow = indexOf(transaction); if (row == firstEntryRow) { // let's update the voucher of all entries of @@ -220,11 +247,21 @@ // not on first row, just update this entry voucher entry.setVoucher(voucher); - } + } */ break; case 2: Account account = (Account) value; - entry.setAccount(account); + + + updateEntry = ((entry.getAccount()) == null != (account == null)) + || (entry.getAccount() != null + && account != null + && !entry.getAccount().getAccountNumber().equals(account.getAccountNumber())); + if (updateEntry) { + entry.setAccount(account); + } + + /*entry.setAccount(account); if (account != null) { // let's copy the account description @@ -242,11 +279,17 @@ // not on first row, just update this entry description entry.setDescription(description); } - } + } */ break; case 3: - description = ((String) value).trim(); - firstEntryRow = indexOf(transaction); + String description = ((String) value).trim(); + + updateEntry = (entry.getDescription().compareTo(description) != 0); + if (updateEntry) { + entry.setDescription(description); + } + + /*firstEntryRow = indexOf(transaction); if (row == firstEntryRow) { // let's update the description of all entries of @@ -260,17 +303,21 @@ // not on first row, just update this entry description entry.setDescription(description); - } + } */ break; case 4: - if (((BigDecimal) value).signum() > 0 ) { - entry.setAmount((BigDecimal) value); + BigDecimal credit= (BigDecimal) value; + updateEntry = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0)); + if (updateEntry) { + entry.setAmount(credit); entry.setDebit(false); } break; case 5: - if (((BigDecimal) value).signum() > 0 ) { - entry.setAmount((BigDecimal) value); + BigDecimal debit = (BigDecimal) value; + updateEntry = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0)); + if (updateEntry) { + entry.setAmount(debit); entry.setDebit(true); } break; @@ -278,28 +325,23 @@ // some modification must update all other // first row modification update following rows - if (updateEntries) { - // FIXME echatellier 20120413 make a single service call - for (Entry entryTmp : transaction.getEntry()) { - financialTransactionService.updateEntry(entryTmp); + if (updateEntry) { + financialTransactionService.updateEntry(entry); + fireTableCellUpdated(row, column); + if (log.isDebugEnabled()) { + log.debug("Update Entry"); } + } else if (updateTransaction) { + financialTransactionService.updateFinancialTransaction(transaction); + fireTableCellUpdated(row, column); + if (log.isDebugEnabled()) { + log.debug("Update transaction"); + } } else { - financialTransactionService.updateEntry(entry); + if (log.isDebugEnabled()) { + log.debug("No Update"); + } } - if (updateTransaction) { - financialTransactionService.updateFinancialTransaction(transaction); - } - /* - // FIXME echatellier 20120413 une modification des dates fait que l'ordre - // devient faux - int trIndex = indexOf(transaction); - int endIndex = trIndex; - if (transaction.getEntry() != null) { - endIndex += transaction.getEntry().size(); - } - fireTableRowsUpdated(trIndex, endIndex); */ - fireTableDataChanged(); - } public Entry getEntryAt(int row) { 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 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-06-14 09:26:25 UTC (rev 3681) @@ -48,6 +48,7 @@ <Boolean id="transactionInClipBoard" javaBean="false"/> <Boolean id="entryInClipBoard" javaBean="false"/> <Boolean id="balance" javaBean="true"/> + <Boolean id="assignableInAllEntries" javaBean="false"/> <script> <![CDATA[ @@ -56,91 +57,84 @@ } ]]> </script> + <row> + <cell fill="horizontal"> + <JToolBar floatable="false"> + <JButton toolTipText="{ _("lima.entries.addTransaction") + " (Ctrl+Shift+N)"}" + actionIcon='add-financial-transaction' + onActionPerformed="handler.addFinancialTransaction()" /> + <JButton toolTipText="{ _("lima.entries.remove.transaction") + " (Ctrl+Shift+Del)"}" + actionIcon='delete-financial-transaction' + enabled="{isSelectedRow()}" + onActionPerformed="handler.deleteSelectedTransaction()" /> + <JButton toolTipText="{ _("lima.entries.copy.transaction") + " (Ctrl+Shift+C)"}" actionIcon='copy' + enabled="{isSelectedRow()}" + onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())" /> + <JButton toolTipText="{ _("lima.entries.paste.transaction") + " (Ctrl+Shift+V)"}" actionIcon='paste' + enabled="{isTransactionInClipBoard()}" + onActionPerformed="handler.pasteTransaction(financialTransactionTable.getSelectedRow())" /> - <row > - <cell fill="horizontal" columns="8"> - <JMenuBar > - <JMenu text="lima.common.transaction" mnemonic="{'T'}"> - <JMenuItem text="lima.common.new" - onActionPerformed="handler.addFinancialTransaction()" - accelerator="{KeyStroke.getKeyStroke('N', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" /> - <JMenuItem text="lima.common.remove" - enabled="{isSelectedRow()}" - onActionPerformed="handler.deleteSelectedTransaction()" - accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE , KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" /> - <JMenuItem text="lima.common.copy" - enabled="{isSelectedRow()}" - onActionPerformed="handler.copyTransaction(financialTransactionTable.getSelectedRow())" - accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" /> - <JMenuItem text="lima.common.paste" - enabled="{isTransactionInClipBoard()}" - onActionPerformed="handler.pasteTransaction(financialTransactionTable.getSelectedRow())" - accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK)}" /> - </JMenu> - <JMenu text="lima.common.entry" mnemonic="{'E'}"> - <JMenuItem text="lima.common.new" - enabled="{isSelectedRow()}" - onActionPerformed="handler.addEntry()" - accelerator="{KeyStroke.getKeyStroke('N', KeyEvent.CTRL_DOWN_MASK)}" /> - <JMenuItem text="lima.common.remove" - enabled="{isSelectedRow()}" - onActionPerformed="handler.deleteSelectedEntry()" - accelerator="{KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK)}" /> - <JMenuItem text="lima.common.copy" - enabled="{isSelectedRow()}" - onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())" - accelerator="{KeyStroke.getKeyStroke('C', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" /> - <JMenuItem text="lima.common.paste" - enabled="{isEntryInClipBoard() && isSelectedRow()}" - onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())" - accelerator="{KeyStroke.getKeyStroke('V', KeyEvent.CTRL_DOWN_MASK + KeyEvent.ALT_DOWN_MASK)}" /> - <JMenuItem text="lima.common.balance" - enabled="{!isBalance()}" - onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())" - accelerator="{KeyStroke.getKeyStroke('B', KeyEvent.CTRL_DOWN_MASK)}" /> - </JMenu> - </JMenuBar> - </cell> - </row> + <JToolBar.Separator/> - <row > - <cell anchor="east"> - <JLabel text="lima.ui.financialtransaction.fiscalyear" labelFor='{fiscalPeriodComboBox}'/> - </cell> - <cell anchor="west"> - <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> - <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}" - renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}" - onItemStateChanged="handler.fiscalPeriodSelected(event)"/> - </cell> - <cell anchor="east"> - <JLabel text="lima.ui.financialtransaction.financialperiod" labelFor='{financialPeriodComboBox}'/> - </cell> - <cell anchor="west"> - <JPanel> + <JButton toolTipText ="{ _("lima.entries.addEntry") + " (Ctrl+N)"}" actionIcon='add-entry' + enabled="{isSelectedRow()}" + onActionPerformed="handler.addEntry()" /> + <JButton toolTipText="{ _("lima.entries.remove.entry") + " (Ctrl+Del)"}" actionIcon='delete-entry' + enabled="{isSelectedRow()}" + onActionPerformed="handler.deleteSelectedEntry()" /> + <JButton toolTipText="{ _("lima.entries.copy.entry") + " (Ctrl+Alt+C)"}" actionIcon='copy' + enabled="{isSelectedRow()}" + onActionPerformed="handler.copyEntry(financialTransactionTable.getSelectedRow())" /> + <JButton toolTipText="{ _("lima.entries.paste.entry") + " (Ctrl+Alt+V)"}" actionIcon='paste' + enabled="{isEntryInClipBoard() && isSelectedRow()}" + onActionPerformed="handler.pasteEntry(financialTransactionTable.getSelectedRow())" /> + <JButton toolTipText="{ _("lima.entries.assign.entries") + " (Ctrl+Alt+A)"}" actionIcon='assign-all-entries-in-transaction' + enabled="{isAssignableInAllEntries() && isSelectedRow()}" + onActionPerformed="handler.assignAllEntries()" /> + <JToolBar.Separator/> + <JButton toolTipText="{ _("lima.entries.balance") + " (Ctrl+B)"}" actionIcon='balance' + enabled="{!isBalance()}" + onActionPerformed="handler.balanceTransaction(financialTransactionTable.getSelectedRow())" /> + + <JToolBar.Separator/> + + <JLabel actionIcon='choose-fiscal-year' + labelFor='{fiscalPeriodComboBox}'/> + <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodComboBoxModel"/> + <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodComboBoxModel}" + toolTipText="lima.ui.financialtransaction.fiscalyear" + renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}" + onItemStateChanged="handler.fiscalPeriodSelected(event)"/> + + <JLabel actionIcon='choose-fiscal-period' + labelFor='{financialPeriodComboBox}'/> <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodComboBoxModel"/> <JComboBox id="financialPeriodComboBox" model="{financialPeriodComboBoxModel}" + toolTipText="lima.ui.financialtransaction.financialperiod" renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}" onItemStateChanged="handler.financialPeriodSelected(event)"/> - <JButton id="back" text="lima.ui.financialtransaction.buttonback" + <JButton id="back" actionIcon="previous" + toolTipText="lima.ui.financialtransaction.previousfinancialperiod" onActionPerformed="handler.back(financialPeriodComboBox)"/> - <JButton id="next" text="lima.ui.financialtransaction.buttonnext" + <JButton id="next" actionIcon="next" + toolTipText="lima.ui.financialtransaction.nextfinancialperiod" onActionPerformed="handler.next(financialPeriodComboBox)"/> - </JPanel> + + <JToolBar.Separator/> + + <JLabel actionIcon="choose-book" + labelFor='{entryBookComboBox}'/> + <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/> + <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}" + toolTipText="lima.ui.financialtransaction.entrybook" + renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}" + onItemStateChanged="handler.entryBookSelected(event)"/> + </JToolBar> </cell> - <cell anchor="east"> - <JLabel text="lima.ui.financialtransaction.entrybook" labelFor='{entryBookComboBox}'/> - </cell> - <cell anchor="west"> - <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookComboBoxModel"/> - <JComboBox id="entryBookComboBox" model="{entryBookComboBoxModel}" - renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}" - onItemStateChanged="handler.entryBookSelected(event)"/> - </cell> </row> <row> - <cell fill="both" weightx="1" weighty="1" columns="8"> + <cell fill="both" weightx="1" weighty="1"> <JScrollPane> <FinancialTransactionTableModel id="financialTransactionTableModel"/> <FinancialTransactionTable Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-06-14 09:26:25 UTC (rev 3681) @@ -44,9 +44,13 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import javax.swing.JComboBox; -import javax.swing.JOptionPane; -import javax.swing.ListSelectionModel; +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.TableColumnModelEvent; +import javax.swing.event.TableColumnModelListener; +import javax.swing.event.TableModelEvent; +import javax.swing.event.TableModelListener; import javax.swing.table.TableCellEditor; import java.awt.event.ItemEvent; import java.math.BigDecimal; @@ -68,7 +72,7 @@ * Last update : $Date$ * By : $Author$ */ -public class FinancialTransactionViewHandler implements ServiceListener { +public class FinancialTransactionViewHandler implements ServiceListener, TableModelListener, TableColumnModelListener { private static final Log log = LogFactory.getLog(FinancialTransactionViewHandler.class); @@ -116,6 +120,12 @@ if (log.isDebugEnabled()) { log.debug(String.format("Loaded %d entry books", allEntryBooks.size())); } + + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + tableModel.addTableModelListener(this); + + FinancialTransactionTable table = view.getFinancialTransactionTable(); + table.getColumnModel().addColumnModelListener(this); } /** @@ -602,6 +612,46 @@ } } + public void assignAllEntries() { + FinancialTransactionTable table = view.getFinancialTransactionTable(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + ListSelectionModel selectionModel = table.getSelectionModel(); + + if (table.isEditing()) { + TableCellEditor editor = table.getCellEditor(); + editor.stopCellEditing(); + } + + int selectedRow = table.getSelectedRow(); + int selectedColumn = table.getSelectedColumn(); + if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) { + Entry entrySource = tableModel.getEntryAt(selectedRow); + FinancialTransaction transaction = entrySource.getFinancialTransaction(); + for (Entry entryTarget : transaction.getEntry()) { + if (entrySource != entryTarget) { + switch (selectedColumn) { + case 1 : + if (entryTarget.getVoucher().compareTo(entrySource.getVoucher()) != 0) { + entryTarget.setVoucher(entrySource.getVoucher()); + financialTransactionService.updateEntry(entryTarget); + } + break; + case 3 : + if (entryTarget.getDescription().compareTo(entrySource.getDescription()) != 0) { + entryTarget.setDescription(entrySource.getDescription()); + financialTransactionService.updateEntry(entryTarget); + } + break; + } + } + } + int firstRow = tableModel.indexOf(transaction); + int lastRow = firstRow + transaction.sizeEntry() - 1; + tableModel.fireTableRowsUpdated(firstRow, lastRow); + table.editCellAt(selectedRow, selectedColumn); + } + } + /** * Select previous value in combo box. * @@ -645,4 +695,57 @@ updateFinancialTransactions(); } } + + @Override + public void tableChanged(TableModelEvent e) { + if (e.getType() == TableModelEvent.UPDATE + && e.getColumn() == 0 + && e.getFirstRow() >= 0) { + if (log.isDebugEnabled()) { + log.debug("Date changed"); + } + + FinancialTransactionTable table = view.getFinancialTransactionTable(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + Entry entry = tableModel.getEntryAt(e.getFirstRow()); + tableModel.sortEntries(); + int newRow = tableModel.indexOf(entry); + table.changeSelection(newRow, 0, false, false); + } + } + + @Override + public void columnAdded(TableColumnModelEvent e) { + //nothing + } + + @Override + public void columnRemoved(TableColumnModelEvent e) { + //nothing + } + + @Override + public void columnMoved(TableColumnModelEvent e) { + //nothing + } + + @Override + public void columnMarginChanged(ChangeEvent e) { + //nothing + } + + @Override + public void columnSelectionChanged(ListSelectionEvent e) { + FinancialTransactionTable table = view.getFinancialTransactionTable(); + FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel(); + + int selectedRow = table.getSelectedRow(); + int selectedColumn = table.getSelectedColumn(); + if (selectedRow >= 0 && selectedRow < tableModel.size()) { + FinancialTransaction transaction = tableModel.getTransactionAt(selectedRow); + view.setAssignableInAllEntries(transaction.sizeEntry() > 1 && (selectedColumn == 1 || selectedColumn == 3)); + } else { + view.setAssignableInAllEntries(false); + } + } } 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-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-06-14 09:26:25 UTC (rev 3681) @@ -52,6 +52,7 @@ lima.common.closed=Closed lima.common.code=Code lima.common.confirmation=Confirmation +lima.common.cop= lima.common.copy=Copy lima.common.enddate=End lima.common.entry=Entry @@ -95,14 +96,22 @@ lima.config.ui.fullscreen.description=FullScreen lima.documents=Documents… lima.entries=Entries -lima.entries.addEntry=Add entry -lima.entries.addTransaction=Add transaction +lima.entries.addEntry=New entry +lima.entries.addTransaction=New transaction +lima.entries.assign.entries=Assign this value in all entries in transaction +lima.entries.balance=Balance transaction with this entry +lima.entries.copy.entry=Copy entry +lima.entries.copy.transaction=Copy transaction lima.entries.lettering=Lettering lima.entries.lettering.add=Add letter lima.entries.lettering.noletterselected=Error \: No selected letter lima.entries.lettering.radiobutton.list=Existing letters lima.entries.lettering.radiobutton.new=New letter lima.entries.lettering.remove=Remove letter +lima.entries.paste.entry=Paste entry +lima.entries.paste.transaction=Paste transaction +lima.entries.remove.entry=Delete entry +lima.entries.remove.transaction=Delete transaction lima.entries.searchtransaction=Search transaction lima.entries.searchunbalancedtransaction=Incorrect transactions lima.entries.writetransaction=Write entries @@ -270,6 +279,8 @@ lima.ui.financialtransaction.letter= lima.ui.financialtransaction.messageremoveentry= lima.ui.financialtransaction.messageremovetransaction= +lima.ui.financialtransaction.nextfinancialperiod=Next period +lima.ui.financialtransaction.previousfinancialperiod=previous period lima.ui.financialtransaction.titleremoveentry= lima.ui.financialtransaction.titleremovetransaction= lima.ui.financialtransaction.voucher= 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-06-12 16:03:34 UTC (rev 3680) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-06-14 09:26:25 UTC (rev 3681) @@ -95,14 +95,22 @@ lima.config.ui.fullscreen.description=Plein écran lima.documents=Documents… lima.entries=Traitement -lima.entries.addEntry=Ajouter entrée -lima.entries.addTransaction=Ajouter transaction +lima.entries.addEntry=Créer une entrée dans la transaction +lima.entries.addTransaction=Créer une transaction +lima.entries.assign.entries=Assigner cette valeur à toutes les entrées de la transaction +lima.entries.balance=Équilibrer la transaction avec cette entrée +lima.entries.copy.entry=Copier l'entrée +lima.entries.copy.transaction=Copier la transaction lima.entries.lettering=Lettrage lima.entries.lettering.add=Ajouter une lettre lima.entries.lettering.noletterselected=Erreur \: Aucune lettre sélectionnée. lima.entries.lettering.radiobutton.list=Lettres existantes lima.entries.lettering.radiobutton.new=Nouvelle lettre lima.entries.lettering.remove=Supprimer une lettre +lima.entries.paste.entry=Coller l'entrée +lima.entries.paste.transaction=Coller la transaction +lima.entries.remove.entry=Supprimer l'entrée +lima.entries.remove.transaction=Supprimer la transaction lima.entries.searchtransaction=Rechercher des écritures lima.entries.searchunbalancedtransaction=Entrées incorrectes lima.entries.writetransaction=Saisir des écritures @@ -269,6 +277,8 @@ lima.ui.financialtransaction.letter=Lettre lima.ui.financialtransaction.messageremoveentry=Voulez-vous supprimer cette ligne de transaction? lima.ui.financialtransaction.messageremovetransaction=Voulez-vous supprimer cette transaction? +lima.ui.financialtransaction.nextfinancialperiod=Période suivante +lima.ui.financialtransaction.previousfinancialperiod=Période précédente lima.ui.financialtransaction.titleremoveentry=Suppression lima.ui.financialtransaction.titleremovetransaction=Suppression lima.ui.financialtransaction.voucher=Pièce comptable Added: trunk/lima-swing/src/main/resources/icons/action-add-entry.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-add-entry.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-add-financial-transaction.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-assign-all-entries-in-transaction.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-balance.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-balance.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-choose-book.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-book.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-period.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-fiscal-year.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-copy.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-copy.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-delete-entry.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete-entry.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete-financial-transaction.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-delete.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-delete.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-next.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-next.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-paste.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-paste.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-previous.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-previous.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/lima-swing/src/main/resources/icons/action-refresh.png =================================================================== (Binary files differ) Property changes on: trunk/lima-swing/src/main/resources/icons/action-refresh.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream
participants (1)
-
Bavencoff@users.chorem.org