Author: mallon Date: 2012-08-21 12:08:39 +0200 (Tue, 21 Aug 2012) New Revision: 3624 Url: http://chorem.org/repositories/revision/lima/3624 Log: fixes #771 Ajout de l autocompletion dans la liste deroulante des lettres. Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2012-08-20 15:52:18 UTC (rev 3623) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2012-08-21 10:08:39 UTC (rev 3624) @@ -73,7 +73,6 @@ addKeyListener(this); addMouseListener(this); - setEnabled(false); //Get new date editor setDefaultEditor(Date.class, new DateTableCellEditor()); @@ -96,8 +95,12 @@ addColorTransaction(); // highlight unbalanced financial transactions addColorNonBalancedTransaction(); - } + /*TODO : 'setEnabled' a supprimer, lors de la refonte du système de + * recherche et de saisie*/ + setEnabled(false); + } + /** * Cette méthode permet de colorer toutes les transactions dans le tableau * afin de bien distinguer les transactions et entrées comptables. @@ -208,105 +211,6 @@ clearSelection(); } } - - - //FIXME 2011.06.11 - //Needs fixing - //Exception in thread "AWT-EventQueue-0" - //java.lang.IndexOutOfBoundsException: - //valid viewIndex: 0 <= index < 42 but was: 42 - /** - * Touche tab - * Incrémente le curseur de case tant que la case n'est pas editable - * Ajoute une entrée comptable si tab est sur - * la dernière cellule et si la transaction est non équilibré - * sinon rajoute une transaction - */ - - /*if (e.getKeyChar() == KeyEvent.VK_TAB) { - int max_x = this.getColumnCount(); - int max_y = this.getRowCount(); - x_tab = this.getSelectedColumn(); - y_tab = this.getSelectedRow(); - Boolean end = true; - - if (x_tab < max_x - 1){ - x_tab++; - } - //end of row - else { - x_tab=0; - y_tab++; - } - - //skip all cell while not editable or if end of table add entry or transaction or end of table - while (!isCellEditable(y_tab, x_tab) && end ){ - //if end of row - if (x_tab == max_x-1) { - Object object = this.handler.tableModel.getElementAt(y_tab); - - //if transaction, add entry - if (object instanceof FinancialTransaction){ - FinancialTransaction financialTransaction = (FinancialTransaction) object; - if (financialTransaction.getEntry().size() == 0){ - handler.addEntry(); - this.setColumnSelectionInterval(1, 1); - } - } - //if entry - else { - //FIXME set value is doing after key pressed - // so update not terminated before get balanced - //Swing Worker stop the UI 500ms - // found best solution ? - final JXTable table = this; - final int y_t = y_tab; - final int m_t = max_y; - new SwingWorker<Void,Void>() { - @Override protected Void doInBackground() throws InterruptedException { - Thread.sleep(500); - return null; - } - @Override protected void done() { - Object object = handler.tableModel.getElementAt(y_tab-1); - FinancialTransaction financialTransaction = null; - if (object instanceof Entry){ - financialTransaction = ((Entry) object).getFinancialTransaction(); - } - else if (object instanceof FinancialTransaction){ - financialTransaction = (FinancialTransaction) object; - } - BigDecimal amountC = financialTransaction.getAmountCredit(); - BigDecimal amountD = financialTransaction.getAmountDebit(); - if (amountC == amountD){ - if (y_t == m_t-1){ - handler.addFinancialTransaction(); - table.setColumnSelectionInterval(0, 0); - } - } - else { - handler.addEntry(); - table.setColumnSelectionInterval(1, 1); - y_tab++; - // positionne la sélection sur la nouvelle ligne créée - table.setRowSelectionInterval(y_tab, y_tab); - x_tab=0; - } - } - }.execute(); - } - end = false; - } - else { - if (x_tab < max_x){ - this.setRowSelectionInterval(y_tab, y_tab); - this.setColumnSelectionInterval(x_tab, x_tab); - x_tab++; - } - } - } - }*/ - } @Override @@ -335,4 +239,5 @@ @Override public void mouseExited(MouseEvent e) { } + } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-08-20 15:52:18 UTC (rev 3623) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-08-21 10:08:39 UTC (rev 3624) @@ -310,6 +310,7 @@ if (tableModel != null) { tableModel.refresh(financialTransactionSearch); } + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2012-08-20 15:52:18 UTC (rev 3623) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2012-08-21 10:08:39 UTC (rev 3624) @@ -1,8 +1,8 @@ package org.chorem.lima.ui.financialtransactionsearch; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.lima.ui.combobox.LetterComboBoxModel; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; +import org.jdesktop.swingx.autocomplete.ObjectToStringConverter; import javax.swing.JComboBox; import java.awt.event.ActionEvent; @@ -26,6 +26,19 @@ LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); setModel(letterComboBoxModel); setEditable(true); + ObjectToStringConverter objectToStringConverter = new ObjectToStringConverter() { + @Override + public String getPreferredStringForItem(Object item) { + String result = null; + if (item != null) { + if (item instanceof String) { + result = item.toString(); + } + } + return result; + } + }; + AutoCompleteDecorator.decorate(this, objectToStringConverter); getEditor().getEditorComponent().addKeyListener(this); addActionListener(this); } 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 2012-08-20 15:52:18 UTC (rev 3623) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-08-21 10:08:39 UTC (rev 3624) @@ -9,15 +9,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% @@ -108,8 +108,12 @@ } public void balanceAndActions() { + if (log.isDebugEnabled()) { + log.debug("balanceAndActions"); + } if (view.getTable().getSelectedRows().length == 0) { onButtonModeChanged(buttonMode.ALL); + onBalanceChanged(null); } else if (!letteringNotExist(view.getTable().getSelectedRow())) { //lettred entries @@ -232,9 +236,13 @@ BigDecimal debitVal = debit ? amount : BigDecimal.ZERO; BigDecimal creditVal = debit ? BigDecimal.ZERO : amount; + if (log.isDebugEnabled()) { + log.debug("Balance calculation"); + } + if (debitVal.equals(BigDecimal.ZERO)){ - if (creditVal.equals(BigDecimal.ZERO)){ + if (!creditVal.equals(BigDecimal.ZERO)){ editModel.setCredit(creditVal); editModel.setSolde(creditVal, true); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java 2012-08-20 15:52:18 UTC (rev 3623) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java 2012-08-21 10:08:39 UTC (rev 3624) @@ -39,7 +39,6 @@ protected LetteringTableModel letteringTableModel; protected Entry entry; protected int lineSelected; - protected boolean letteringEntrySelected; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); public LettringSelectionModel(LetteringTableModel letteringTableModel){ @@ -89,7 +88,6 @@ super.removeSelectionInterval(row, column); } - letteringEntrySelected = false; } }