r3603 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/combobox lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch
Author: mallon Date: 2012-08-13 16:42:17 +0200 (Mon, 13 Aug 2012) New Revision: 3603 Url: http://chorem.org/repositories/revision/lima/3603 Log: fixes #761 Correction permettant d afficher une liste deroulante avec toutes les lettres utilisees pour les entrees. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.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/LetterSearchPanel.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -194,6 +194,21 @@ } @Override + public List<String> getAllLetters() throws LimaException { + List<String> letters; + try { + EntryDAO entryDAO = getDaoHelper().getEntryDAO(); + + letters = new ArrayList<String>(entryDAO.findLetters()); + + } catch (Exception ex) { + throw new LimaException("Can't get all letters", ex); + } + + return letters; + } + + @Override public Entry[] getEntriesFromEqualizing(Entry FirstEntrySelected, Entry SecondEntrySelected) throws LimaException{ Entry newSameAccountEntry = null; Modified: trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java =================================================================== --- trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -76,8 +76,17 @@ void removeEntry(Entry entry) throws LimaException; + /** Find the last letter used + * and increment them + * @return a string representing the last letter + * */ String getNextLetters() throws LimaException; + /** Find all the letters used + * @return a list of string containing all the letters + * */ + List<String> getAllLetters() throws LimaException; + /** * From to selected entries, create one with same account and * difference between the amounts, and another one with Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -129,6 +129,11 @@ " order by E.lettering desc"; List<String> result = new ArrayList<String>(context.findAll(query)); + + if (log.isDebugEnabled()) { + log.debug("Size of result : " + result.size()); + } + return result; } Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java =================================================================== --- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -327,7 +327,10 @@ if (lettering != null) { query += " AND E.lettering = :lettering"; args.add("lettering"); - args.add("%" + lettering + "%"); + args.add(lettering); + if (log.isDebugEnabled()) { + log.debug("Lettering filter : -" + lettering + "-"); + } } // accounts Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -97,7 +97,7 @@ result = entryBookService.getAllEntryBooks(); } catch (LimaException eee) { if (log.isDebugEnabled()) { - log.debug("Can't get list accounts", eee); + log.debug("Can't get list entry books", eee); } } return result; Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/LetterComboBoxModel.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -0,0 +1,91 @@ +package org.chorem.lima.ui.combobox; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.api.AccountService; +import org.chorem.lima.business.api.FinancialTransactionService; +import org.chorem.lima.business.api.ImportService; +import org.chorem.lima.entity.Account; +import org.chorem.lima.service.LimaServiceFactory; + +import javax.swing.AbstractListModel; +import javax.swing.ComboBoxModel; +import java.util.List; + +/** + * Date: 13/08/12 + * + * @author mallon <mallon@codelutin.com> + * @since 0.6-alpha-2 + */ +public class LetterComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(AccountComboBoxModel.class); + + protected Object selectedAccount; + + protected List<String> datasCache; + + protected FinancialTransactionService financialTransactionService; + + public LetterComboBoxModel() { + financialTransactionService = + LimaServiceFactory.getService(FinancialTransactionService.class); + LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this); + datasCache = getDataList(); + } + + @Override + public Object getSelectedItem() { + return selectedAccount; + } + + @Override + public void setSelectedItem(Object anItem) { + selectedAccount = anItem; + fireContentsChanged(this, -1, -1); + } + + + @Override + public Object getElementAt(int index) { + return datasCache.get(index); + } + + @Override + public int getSize() { + return datasCache.size(); + } + + public List<String> getDataList() { + List<String> result = null; + try { + result = financialTransactionService.getAllLetters(); + } catch (LimaException eee) { + if (log.isDebugEnabled()) { + log.debug("Can't get list letters", eee); + } + } + return result; + + } + + public void refresh() { + datasCache = getDataList(); + fireContentsChanged(this, 0, datasCache.size()); + } + + @Override + public void notifyMethod(String serviceName, String methodeName) { + if (methodeName.contains("Letter") || + methodeName.contains("importAll")) { + refresh(); + } + } + +} 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-13 12:58:13 UTC (rev 3602) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -43,7 +43,6 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; /** * Handler associated with financial transaction view. @@ -120,6 +119,10 @@ financialTransactionSearch.setLettering(lettering); } + public String getLetter() { + return financialTransactionSearch.getLettering(); + } + public String getAccountsList() { return financialTransactionSearch.getAccountList(); } Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchComboBox.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -0,0 +1,68 @@ +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 javax.swing.JComboBox; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; + +/** + * Date: 13/08/12 + * + * @author mallon <mallon@codelutin.com> + * @since 0.6-alpha-2 + */ +public class LetterSearchComboBox extends JComboBox implements KeyListener { + + private static final long serialVersionUID = 1L; + + protected FinancialTransactionSearchViewHandler handler; + + public LetterSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + LetterComboBoxModel letterComboBoxModel = new LetterComboBoxModel(); + setModel(letterComboBoxModel); + setEditable(true); + getEditor().getEditorComponent().addKeyListener(this); + addActionListener(this); + } + + @Override + public void actionPerformed(ActionEvent e) { + Object object = getSelectedItem(); + if (object instanceof String) { + handler.setLetter((String) getSelectedItem()); + } + } + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + Object object = getSelectedItem(); + if (object instanceof String) { + String letter = (String) getSelectedItem(); + //to prevent useless call to service + if (!letter.equals(handler.getLetter())) { + handler.setLetter(letter); + } + + } + + // delegate popup list menu + if (e.getKeyChar() == KeyEvent.VK_ENTER) { + firePopupMenuCanceled(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2012-08-13 12:58:13 UTC (rev 3602) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/LetterSearchPanel.java 2012-08-13 14:42:17 UTC (rev 3603) @@ -50,9 +50,9 @@ break; case SELECT_ONE: - /*LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); + LetterSearchComboBox comboBox = new LetterSearchComboBox(handler); removeAll(); - add(comboBox);*/ + add(comboBox); break; }
participants (1)
-
mallon@users.chorem.org