r3508 - in trunk: . lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api lima-swing/src/main/java/org/chorem/lima/ui/combobox lima-swing/src/main/java/org/chorem/lima/ui/lettering lima-swing/src/main/resources
Author: mallon Date: 2012-07-10 10:26:59 +0200 (Tue, 10 Jul 2012) New Revision: 3508 Url: http://chorem.org/repositories/revision/lima/3508 Log: refs#688 Correction sur le modele de selection, quand le lettrage n'est pas pr?\195?\169sent (null). Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.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-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.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/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java trunk/lima-swing/src/main/resources/log4j.properties trunk/pom.xml 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-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -26,6 +26,7 @@ package org.chorem.lima.business.ejb; import org.chorem.lima.beans.FinancialTransactionSearch; +import org.chorem.lima.beans.LetteringFilter; import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaConfig; import org.chorem.lima.business.LimaException; @@ -264,12 +265,12 @@ } @Override - public List<Entry> getAllEntrieByDatesAndAccountAndLettering(Date beginDate, Date endDate, Account account, Boolean letterFilter) throws LimaException { + public List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException { List<Entry> entries; try { EntryDAO entryDAO = getDaoHelper().getEntryDAO(); - entries = entryDAO.findAllEntryByAccountAndLettering(beginDate, endDate, account, letterFilter); + entries = entryDAO.findAllEntryByAccountAndLettering(filter); } catch (Exception ex) { throw new LimaException("Can't get entries", ex); } 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-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -26,8 +26,8 @@ package org.chorem.lima.business.api; import org.chorem.lima.beans.FinancialTransactionSearch; +import org.chorem.lima.beans.LetteringFilter; import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.Account; import org.chorem.lima.entity.Entry; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; @@ -79,11 +79,10 @@ String getNextLetters() throws LimaException; /** - * Get all entries by dates, account and lettering - * @param beginDate begin date - * @param endDate end date - * @param account acount - * @param letterFilter lettering + * Retourne toutes les entrées d'une transaction + * pour un compte et la présence d'un lettrage ou (xor) non + * @param filter filtre sur les entrees, selon le compte, les dates de debut et de fin, et le lettrage + * @throws org.nuiton.topia.TopiaException * */ - List<Entry> getAllEntrieByDatesAndAccountAndLettering(Date beginDate, Date endDate, Account account, Boolean letterFilter) throws LimaException; + List<Entry> getAllEntrieByDatesAndAccountAndLettering(LetteringFilter filter) throws LimaException; } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -25,11 +25,6 @@ package org.chorem.lima.ui.combobox; -import java.util.List; - -import javax.swing.AbstractListModel; -import javax.swing.ComboBoxModel; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; @@ -39,6 +34,9 @@ import org.chorem.lima.entity.Account; import org.chorem.lima.service.LimaServiceFactory; +import javax.swing.*; +import java.util.List; + /** Account combo box model. */ public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel, ServiceListener { @@ -48,7 +46,7 @@ private static final Log log = LogFactory.getLog(AccountComboBoxModel.class); - protected Object selectedAccount; + protected Account selectedAccount; protected List<Account> datasCache; @@ -64,13 +62,13 @@ } @Override - public Object getSelectedItem() { + public Account getSelectedItem() { return selectedAccount; } @Override public void setSelectedItem(Object anItem) { - selectedAccount = anItem; + selectedAccount = (Account)anItem; fireContentsChanged(this, -1, -1); } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -8,10 +8,10 @@ public class LetteringEditModel { protected boolean lettred; - protected boolean unLettred; - protected BigDecimal debit; - protected BigDecimal credit; - protected BigDecimal solde; + protected boolean unLettred = true; //By default, present unLettred entries + protected BigDecimal debit = BigDecimal.ZERO; + protected BigDecimal credit = BigDecimal.ZERO; + protected BigDecimal solde = BigDecimal.ZERO; public boolean isLettred() { return lettred; @@ -52,4 +52,10 @@ public void setSolde(BigDecimal solde) { this.solde = solde; } + + public void resetDebitCreditBalance(){ + setDebit(BigDecimal.ZERO); + setCredit(BigDecimal.ZERO); + setSolde(BigDecimal.ZERO); + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -12,6 +12,8 @@ import java.util.List; public class LetteringModelUI extends DefaultListSelectionModel{ + //TODO Algo a repartir entre les autres modeles. Classe a + //supprimer public static final String SELECTED_ENTRY_PROPERTY = "selectedEntry"; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -1,9 +1,61 @@ package org.chorem.lima.ui.lettering; -import javax.swing.DefaultListSelectionModel; +import jaxx.runtime.swing.model.AbstractGenericListSelectionModel; +import org.chorem.lima.entity.Entry; +import java.util.List; + /** * @author sletellier <letellier@codelutin.com> */ -public class LetteringSelectionModel extends DefaultListSelectionModel { +public class LetteringSelectionModel extends AbstractGenericListSelectionModel<Entry> { + + protected LetteringTableModel letteringTableModel; + + //Modele de selection du tableau lors de la selection d une entree lettree + + public LetteringSelectionModel(LetteringTableModel letteringTableModel) { + this.letteringTableModel = letteringTableModel; + } + + @Override + public void setSelectionInterval(int row, int column){ + super.setSelectionInterval(row, column); + //select entries with the same letter of the selected entry + for(Entry entry : getEntries()){ + if (entry.getLettering() != null && !entry.getLettering().isEmpty()){ + if (entry.getLettering().equals(getCurrentLettring())){ + int entryToSelect = letteringTableModel.getIndexOfEntry(entry); + super.addSelectionInterval(entryToSelect, entryToSelect); + } + } + } + } + + @Override + public int getSize() { + return letteringTableModel.getRowCount(); + } + + @Override + public Entry getValueAt(int i) { + return letteringTableModel.getEntryAt(i); + } + + public List<Entry> getEntries(){ + return letteringTableModel.getEntries(); + } + + public Entry getCurrentEntrySelected(){ + return letteringTableModel.getEntryAt(super.getMaxSelectionIndex()); + } + + public String getCurrentLettring(){ + return getCurrentEntrySelected().getLettering(); + } + + @Override + public int getSelectionMode() { + return SINGLE_SELECTION; + } } 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 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 08:26:59 UTC (rev 3508) @@ -30,22 +30,21 @@ org.chorem.lima.ui.common.FinancialPeriodComboBoxModel org.chorem.lima.entity.Account javax.swing.ListSelectionModel - org.jdesktop.swingx.JXDatePicker; + org.jdesktop.swingx.JXDatePicker + org.chorem.lima.beans.LetteringFilter + org.chorem.lima.beans.LetteringFilterImpl </import> <LetteringViewHandler id="handler" constructorParams="this"/> <LetteringTableModel id="tableModel"/> - <!--LetteringModelUI id='modelUi' constructorParams='tableModel'/--> <LetteringEditModel id='letteringEditModel'/> - <LetteringFilter id='filterModel'/> + <LetteringFilter id='filterModel' initializer='new LetteringFilterImpl()'/> - <LetteringSelectionModel id='letteringSelectionModel'/> - <DefaultListSelectionModel id='defaultListSelectionModel'/> + <LetteringSelectionModel id='letteringSelectionModel' constructorParams='tableModel'/> + <UnlettringSelectionModel id='unletteringSelectionModel' constructorParams='tableModel'/> <LettringAndUnlettringSelectionModel id='lettringAndUnlettringSelectionModel' - constructorParams='letteringSelectionModel, defaultListSelectionModel'/> - - <!-- <Boolean id="selectedRow" javaBean="false"/> --> + constructorParams='letteringSelectionModel, unletteringSelectionModel, tableModel'/> <script> <![CDATA[ @@ -72,7 +71,7 @@ <org.chorem.lima.ui.common.AccountComboBoxModel id="accountComboBoxModel"/> <JComboBox id="accountComboBox" model="{accountComboBoxModel}" renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), ( letteredCheckGroup.isSelected(noLettredEntryCheckBox.getModel()) || letteredCheckGroup.isSelected(lettredEntryCheckBox.getModel())))"/> + onActionPerformed="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())"/> <JButton id="backCount" text="lima.ui.account.buttonback" onActionPerformed="handler.back(accountComboBox)"/> <JButton id="nextCount" text="lima.ui.account.buttonnext" @@ -88,7 +87,7 @@ </cell> <cell> <JXDatePicker id="pickerDebut" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), ( letteredCheckGroup.isSelected(noLettredEntryCheckBox.getModel()) || letteredCheckGroup.isSelected(lettredEntryCheckBox.getModel())))"/> + onActionPerformed="filterModel.getFiscalDateFilter().setDateStart(pickerDebut.getDate())"/> </cell> </row> <row> @@ -97,7 +96,7 @@ </cell> <cell> <JXDatePicker id="pickerFin" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), ( letteredCheckGroup.isSelected(noLettredEntryCheckBox.getModel()) || letteredCheckGroup.isSelected(lettredEntryCheckBox.getModel())))"/> + onActionPerformed="filterModel.getFiscalDateFilter().setDateStart(pickerFin.getDate())"/> </cell> </row> </Table> @@ -109,7 +108,7 @@ <row> <cell> <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), letteredCheckGroup.isSelected(noLettredEntryCheckBox.getModel()))"/> + onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(false)"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkLettredEntry"/> @@ -118,7 +117,7 @@ <row> <cell> <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), letteredCheckGroup.isSelected(noLettredEntryCheckBox.getModel()))"/> + onActionPerformed="filterModel.setDisplayUnlettred(true) ; filterModel.setDisplayLettered(false)"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkNoLettredEntry"/> @@ -127,7 +126,7 @@ <row> <cell> <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup" - onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), null)"/> + onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(true)"/> </cell> <cell> <JLabel text="lima.ui.lettering.checkAll"/> @@ -156,15 +155,15 @@ <JLabel text="lima.ui.lettering.selectEntry"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit().toString()}" + <JTextField id="debitTexttField" editable="false" text="{getLetteringEditModel().getDebit().toString()}" focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit().toString()}" + <JTextField id="creditTextField" editable="false" text="{getLetteringEditModel().getCredit().toString()}" focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde().toString()}" + <JTextField id="soldeTextField" editable="false" text="{getLetteringEditModel().getSolde().toString()}" focusable="false"/> </cell> </row> @@ -177,10 +176,10 @@ <cell anchor="center" columns='4'> <JPanel id="actionsPanel"> <JButton id="lettered" text="lima.ui.lettering.buttonLettered" - enabled="{getModelUi().isLettrer()}" + enabled="{getLetteringEditModel().isLettred()}" onActionPerformed="handler.addLetter()"/> <JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered" - enabled="{getModelUi().isDelettrer()}" + enabled="{getLetteringEditModel().isUnLettred()}" onActionPerformed="handler.removeLetter()"/> </JPanel> </cell> @@ -192,7 +191,7 @@ id="table" sortable="false" rowHeight="22" constructorParams="getTableModel()" selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}" - selectionModel="{modelUi}" + selectionModel="{lettringAndUnlettringSelectionModel}" /> </JScrollPane> </cell> 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-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -25,16 +25,10 @@ package org.chorem.lima.ui.lettering; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; -import java.util.List; -import javax.swing.JComboBox; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.beans.LetteringFilter; import org.chorem.lima.business.ServiceListener; import org.chorem.lima.business.api.AccountService; import org.chorem.lima.business.api.EntryBookService; @@ -46,6 +40,17 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + /** * Handler associated with financial transaction view. * @@ -60,7 +65,6 @@ private static final Log log = LogFactory.getLog(LetteringViewHandler.class); protected LetteringView view; - protected LetteringTable table; /** Transaction service. */ @@ -69,6 +73,7 @@ protected AccountService accountService; protected FinancialTransactionService financialTransactionService; protected EntryBookService entryBookService; + protected LetteringFilter filter; public LetteringViewHandler(LetteringView view) { this.view = view; @@ -84,11 +89,16 @@ * Init all combo box in view. */ public void init() { - loadComboAndRows(); + filter = view.getFilterModel(); + loadComboAndRows(); - letteringSelectionModel; - defaultListSelectionModel; - lettringAndUnlettringSelectionModel.addD + filter.addPropertyChangeListener(new PropertyChangeListener() { + + @Override + public void propertyChange(PropertyChangeEvent evt) { + updateAllEntries(); + } + }); } public void loadComboAndRows(){ @@ -135,30 +145,42 @@ log.debug("Val select letter : " + view.getLetteredCheckGroup().getSelectedButton().getName()); - //Load entry with the default dates, default account 4 and with no letter - updateAllEntries(defaultDateBegFiscalPeriod, defaultDateEndCurrent, (Account)view.getAccountComboBoxModel().getSelectedItem(), view.getLetteredCheckGroup().isSelected(view.getNoLettredEntryCheckBox().getModel())); + filter.getFiscalDateFilter().setDateStart(defaultDateBegFiscalPeriod); + filter.getFiscalDateFilter().setDateEnd(defaultDateEndCurrent); + + updateAllEntries(); + if (log.isInfoEnabled()) { log.info("Nb entries model (After update all entries) : " + view.getTableModel().getNumberOfEntries()); } } - protected List<Entry> findAllEntries(Date selectedBeginDate, Date selectedEndDate, Account compte, Boolean filtreLettre){ - if (selectedBeginDate != null && selectedEndDate != null) { - if (log.isInfoEnabled()) { - log.info("FiltreLettre : " + filtreLettre); - } + protected List<Entry> findAllEntries(LetteringFilter filter){ + if (filter != null && filter.getFiscalDateFilter() != null) { List<Entry> entries = - financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(selectedBeginDate, selectedEndDate, compte, filtreLettre); + financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter); return entries; } return null; } - public void updateAllEntries(Date selectedBeginDate, Date selectedEndDate, Account compte, Boolean filtreLettre) { + public void updateAllEntries() { - if (selectedBeginDate != null && selectedEndDate != null){ - log.debug("updateAllEntries"); - List<Entry> entries = findAllEntries(selectedBeginDate, selectedEndDate, compte, filtreLettre); + if (log.isInfoEnabled()) { + log.info("updateAllEntries"); + } + + if (filter != null && filter.getFiscalDateFilter() != null) { + + if (log.isInfoEnabled()) { + log.info("Date deb : " + filter.getFiscalDateFilter().getDateStart() + "\n" + + "Date fin : " + filter.getFiscalDateFilter().getDateEnd() + "\n" + + "Account : " + filter.getAccount().getLabel() + "\n" + + "Letter display : " + filter.getDisplayLettered() + "\n" + + "Letter undisplay : " + filter.getDisplayUnlettred()); + } + + List<Entry> entries = findAllEntries(filter); List<String> journalEntrees = new ArrayList<String>(); List<Date> datesEntree = new ArrayList<Date>(); @@ -172,8 +194,8 @@ log.info("Nb entries model : " + view.getTableModel().getNumberOfEntries()); } } - view.getModelUi().resetDebitCreditBalance(); - view.getModelUi().clearSelection(); + view.getLetteringEditModel().resetDebitCreditBalance(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); } /** @@ -187,8 +209,8 @@ if (row > 0) { comboBox.setSelectedIndex(row - 1); } - view.getModelUi().resetDebitCreditBalance(); - view.getModelUi().clearSelection(); + /*view.getModelUi().resetDebitCreditBalance(); + view.getModelUi().clearSelection();*/ } /** @@ -203,8 +225,8 @@ if (row < size - 1) { comboBox.setSelectedIndex(row + 1); } - view.getModelUi().resetDebitCreditBalance(); - view.getModelUi().clearSelection(); + view.getLetteringEditModel().resetDebitCreditBalance(); + view.getLettringAndUnlettringSelectionModel().clearSelection(); } public void setBeginDate(Date date) { @@ -219,13 +241,13 @@ public void addLetter() { String newLetters = financialTransactionService.getNextLetters(); changeLetter(newLetters); - view.getModelUi().setLettrer(false); + view.getLetteringEditModel().setLettred(false); } /**Remove a group of three letters to n entries*/ public void removeLetter() { changeLetter(null); - view.getModelUi().setDelettrer(false); + view.getLetteringEditModel().setUnLettred(false); } /**Add or remove a group of three letters to n entries*/ @@ -240,12 +262,35 @@ } @Override - public void notifyMethod(String serviceName, String methodeName) { + public void valueChanged(ListSelectionEvent e) { + // calcul solde et boutons lettrer/delettrer actif/inactif sur changement de ligne selectionnee + + LetteringEditModel editModel = view.getLetteringEditModel(); + + int[] numEntriesSelected = view.getTable().getSelectedRows(); + Entry entry = null; + for(int numEntry : numEntriesSelected){ + entry = view.getTableModel().getEntryAt(numEntry); + boolean debitSelected = entry.getDebit(); + BigDecimal amountSelected = entry.getAmount(); + BigDecimal debit = debitSelected ? amountSelected : BigDecimal.ZERO; + BigDecimal credit = debitSelected ? BigDecimal.ZERO : amountSelected; + editModel.setDebit(editModel.getDebit().add(debit)); + editModel.setCredit(editModel.getCredit().add(credit)); + editModel.setSolde(editModel.getSolde().add(debit.subtract(credit))); + } + + if (entry != null){ + if (!entry.getLettering().isEmpty()){ + editModel.setUnLettred(true); + }else if (editModel.getSolde()==BigDecimal.ZERO){ + editModel.setLettred(true); + } + } } @Override - public void valueChanged(ListSelectionEvent e) { - LetteringEditModel editModel = view.getLetteringEditModel(); - editModel. + public void notifyMethod(String serviceName, String methodeName) { + //To change body of implemented methods use File | Settings | File Templates. } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -1,17 +1,79 @@ package org.chorem.lima.ui.lettering; -import javax.swing.DefaultListSelectionModel; +import jaxx.runtime.swing.model.AbstractGenericListSelectionModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Entry; /** * @author sletellier <letellier@codelutin.com> */ -public class LettringAndUnlettringSelectionModel { +public class LettringAndUnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> { + private static final Log log = LogFactory.getLog(LetteringViewHandler.class); protected LetteringSelectionModel letteringSelectionModel; - protected DefaultListSelectionModel defaultListSelectionModel; + protected UnlettringSelectionModel unlettringSelectionModel; + protected LetteringTableModel letteringTableModel; - public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, DefaultListSelectionModel defaultListSelectionModel) { + public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, UnlettringSelectionModel unlettringSelectionModel, LetteringTableModel letteringTableModel) { this.letteringSelectionModel = letteringSelectionModel; - this.defaultListSelectionModel = defaultListSelectionModel; + this.unlettringSelectionModel = unlettringSelectionModel; + this.letteringTableModel = letteringTableModel; } + + /**choice of model : two differents ui reactions, if lettering is present or not*/ + @Override + public void setSelectionInterval(int row, int column) { + if (log.isInfoEnabled()) { + log.info("Selection de ligne : choix du modele"); + } + if (!letteringNotExist(row)) { + letteringSelectionModel.setSelectionInterval(row, column); + } else { + if (log.isInfoEnabled()) { + log.info("Modele de selection utilise : 'unlettringSelectionModel'"); + } + unlettringSelectionModel.setSelectionInterval(row, column); + } + } + + /**return true if lettering is null, or not null but empty*/ + public boolean letteringNotExist(int row){ + boolean emptyOrNull; + String lettering = letteringTableModel.getEntryAt(row).getLettering(); + + if (lettering != null){ + emptyOrNull = lettering.isEmpty(); + }else + emptyOrNull = true; + + if (log.isInfoEnabled()) { + log.info("Retour : " + emptyOrNull); + } + + return emptyOrNull; + } + + /**return number of row in the model*/ + @Override + public int getSize() { + return letteringTableModel.getRowCount(); + } + + /**return the entry at the index indicate*/ + @Override + public Entry getValueAt(int i) { + return letteringTableModel.getEntryAt(i); + } + + /**clear the selection of the current using model*/ + @Override + public void clearSelection(){ + if (letteringSelectionModel.getSelectedValues().size() == 0) { + letteringSelectionModel.clearSelection(); + }else{ + unlettringSelectionModel.clearSelection(); + } + } + } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-10 08:26:59 UTC (rev 3508) @@ -0,0 +1,41 @@ +package org.chorem.lima.ui.lettering; + +import jaxx.runtime.swing.model.AbstractGenericListSelectionModel; +import org.chorem.lima.entity.Entry; + +public class UnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> { + + protected LetteringTableModel letteringTableModel; + + //Modele de selection du tableau lors de la selection d une entree non lettree + + public UnlettringSelectionModel(LetteringTableModel letteringTableModel) { + this.letteringTableModel = letteringTableModel; + } + + @Override + public void setSelectionInterval(int row, int column){ + super.addSelectionInterval(row, column); + } + + @Override + public int getSize() { + return letteringTableModel.getRowCount(); + } + + @Override + public Entry getValueAt(int i) { + return letteringTableModel.getEntryAt(i); + } + + @Override + public void addSelectionInterval(int index0, int index1) { + setSelectionInterval(index0, index1); + } + + @Override + public int getSelectionMode() { + return MULTIPLE_INTERVAL_SELECTION; + } + +} Modified: trunk/lima-swing/src/main/resources/log4j.properties =================================================================== --- trunk/lima-swing/src/main/resources/log4j.properties 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-10 08:26:59 UTC (rev 3508) @@ -44,4 +44,5 @@ log4j.logger.org.chorem.lima.business.accountingrules.DefaultAccountingRules=DEBUG log4j.logger.org.chorem.lima.ui.lettering.LetteringViewHandler=DEBUG log4j.logger.org.chorem.lima.ui.lettering.LetteringTableModel=DEBUG -log4j.logger.org.chorem.lima.ui.lettering.LetteringModelUi=DEBUG \ No newline at end of file +log4j.logger.org.chorem.lima.ui.lettering.LetteringModelUi=DEBUG +log4j.logger.org.chorem.lima.ui.lettering.LettringAndUnlettringSelectionModel=DEBUG \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-07-09 16:36:10 UTC (rev 3507) +++ trunk/pom.xml 2012-07-10 08:26:59 UTC (rev 3508) @@ -333,7 +333,7 @@ <nuitonUtilsVersion>2.5</nuitonUtilsVersion> <eugenePluginVersion>2.4.2</eugenePluginVersion> <topiaVersion>2.6.11</topiaVersion> - <jaxxVersion>2.5</jaxxVersion> + <jaxxVersion>2.5.1-SNAPSHOT</jaxxVersion> <nuitonI18nVersion>2.4.1</nuitonI18nVersion> <openEjbVersion>4.0.0</openEjbVersion> <slf4jVersion>1.6.6</slf4jVersion>
participants (1)
-
mallon@users.chorem.org