r3488 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb 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/lettering
Author: mallon Date: 2012-07-04 18:30:39 +0200 (Wed, 04 Jul 2012) New Revision: 3488 Url: http://chorem.org/repositories/revision/lima/3488 Log: Lettrage : - Delettrage et Lettrage automatiques; - Correction sur les soldes n?\195?\169gatifs; - MultiS?\195?\169lection de lignes; - Affichage boutons lettrer/d?\195?\169lettrer selon la balance et le lettrage; Modified: 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-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.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/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 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-03 14:38:28 UTC (rev 3487) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -25,16 +25,6 @@ package org.chorem.lima.business.ejb; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.ejb.EJB; -import javax.ejb.Remote; -import javax.ejb.Stateless; -import javax.ejb.TransactionAttribute; - import org.chorem.lima.beans.FinancialTransactionSearch; import org.chorem.lima.business.AccountingRules; import org.chorem.lima.business.LimaConfig; @@ -55,6 +45,15 @@ import org.chorem.lima.entity.FiscalPeriod; import org.nuiton.topia.TopiaException; +import javax.ejb.EJB; +import javax.ejb.Remote; +import javax.ejb.Stateless; +import javax.ejb.TransactionAttribute; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + /** * Cette classe permet la création d'une transaction comptable dans l'application. * Toute action sur une transaction entraîne automatiquement une création de log. @@ -123,12 +122,11 @@ * */ @Override public String getNewLetters() throws LimaException { - String lastActualLetters = ""; - List<Entry> entries = new ArrayList<Entry>(); + String lastActualLetters; try { EntryDAO entryDAO = getDaoHelper().getEntryDAO(); - lastActualLetters = entryDAO.findLetters().get(0); + lastActualLetters = entryDAO.findLetters(); } catch (Exception ex) { throw new LimaException("Can't get new letters", ex); } @@ -137,12 +135,14 @@ String nextSecondLetter = "A"; String nextFirstLetter = "A"; - if (lastActualLetters.length() > 2 && lastActualLetters.charAt(2) != 'Z'){ - nextThirdLetter = incrementLetter(2, lastActualLetters); - }else if (lastActualLetters.length() > 1 && lastActualLetters.charAt(1) != 'Z'){ - nextSecondLetter = incrementLetter(1, lastActualLetters); - }else if (lastActualLetters.charAt(0) != 'Z'){ - nextFirstLetter = incrementLetter(0, lastActualLetters); + if (lastActualLetters != null){ + if (lastActualLetters.length() > 2 && lastActualLetters.charAt(2) != 'Z'){ + nextThirdLetter = incrementLetter(2, lastActualLetters); + }else if (lastActualLetters.length() > 1 && lastActualLetters.charAt(1) != 'Z'){ + nextSecondLetter = incrementLetter(1, lastActualLetters); + }else if (lastActualLetters.charAt(0) != 'Z'){ + nextFirstLetter = incrementLetter(0, lastActualLetters); + } } return nextFirstLetter + nextSecondLetter + nextThirdLetter; 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-07-03 14:38:28 UTC (rev 3487) +++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -25,18 +25,17 @@ package org.chorem.lima.entity; +import org.nuiton.topia.TopiaException; + import java.util.Date; import java.util.List; -import org.nuiton.topia.TopiaException; - public class EntryDAOImpl<E extends Entry> extends EntryDAOAbstract<Entry> { /** * Requete generique qui recupere les entrees equilibrées portant entre * deux dates. * - * @param account account * @param beginDate begin date * @param endDate end date */ @@ -118,12 +117,16 @@ return entries; } - public List<String> findLetters() throws TopiaException{ - String query = "Select E.LETTERING FROM " + Entry.class.getName() + " E" + - " order by E.LETTERING desc"; + public String findLetters() throws TopiaException{ + String result = ""; + String query = "Select E.lettering FROM " + Entry.class.getName() + " E" + + " order by E.lettering desc"; List<String> letters = context.findAll(query); - return letters; + if (!letters.isEmpty()) { + result = letters.get(0); + } + return result; } /** Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-07-03 14:38:28 UTC (rev 3487) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -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; @@ -41,6 +36,9 @@ import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; +import javax.swing.*; +import java.util.List; + /** * Opened financial period combo box model. * @@ -93,6 +91,9 @@ } else { datasCache = getDataList(); } + for (FinancialPeriod financialPeriod : datasCache) { + + } } public void setSelectedFiscalPeriod(FiscalPeriod fiscalPeriod) { 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-03 14:38:28 UTC (rev 3487) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -1,14 +1,12 @@ package org.chorem.lima.ui.lettering; +import org.chorem.lima.entity.Entry; + +import javax.swing.*; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.math.BigDecimal; -import javax.swing.DefaultListSelectionModel; - -import org.chorem.lima.entity.Entry; -import org.eclipse.jetty.util.log.Log; - public class LetteringModelUI extends DefaultListSelectionModel{ public static final String SELECTED_ENTRY_PROPERTY = "selectedEntry"; @@ -23,8 +21,6 @@ public static final String DELETTRER_PROPERTY = "delettrer"; - public static final String TEXTENABLE_PROPERTY = "textEnable"; - private static final long serialVersionUID = 1L; protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this); @@ -32,40 +28,12 @@ protected LetteringTableModel model; protected Entry selectedEntry; - protected BigDecimal debit; - protected BigDecimal credit; - protected String solde; + protected BigDecimal debit = BigDecimal.ZERO; + protected BigDecimal credit = BigDecimal.ZERO; + protected BigDecimal solde = BigDecimal.ZERO; protected boolean lettrer; protected boolean delettrer; - protected BigDecimal debitTotal; - protected BigDecimal creditTotal; - - public BigDecimal getDebitTotal() { - return debitTotal; - } - public void setDebitTotal(BigDecimal debitTotal) { - this.debitTotal = debitTotal; - } - - public BigDecimal getCreditTotal() { - return creditTotal; - } - - public void setCreditTotal(BigDecimal creditTotal) { - this.creditTotal = creditTotal; - } - - public String getSoldeTotal() { - return soldeTotal; - } - - public void setSoldeTotal(String soldeTotal) { - this.soldeTotal = soldeTotal; - } - - protected String soldeTotal; - public Entry getSelectedEntry() { return selectedEntry; } @@ -91,50 +59,41 @@ } public void setDelettrer(boolean delettrer) { - boolean oldLettrer = isLettrer(); + boolean oldDelettrer = isDelettrer(); this.delettrer = delettrer; - firePropertyChange(LETTRER_PROPERTY, oldLettrer, delettrer); + firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, delettrer); } public LetteringModelUI(LetteringTableModel model) { this.model = model; } - public String getDebit() { - if (debit == null){ - return "0"; - } - return String.valueOf(debit); + public BigDecimal getDebit() { + return debit; } public void setDebit(BigDecimal debit) { - BigDecimal oldDebit = BigDecimal.valueOf(Double.valueOf(getDebit())); + BigDecimal oldDebit = getDebit(); this.debit = debit; firePropertyChange(DEBIT_PROPERTY, oldDebit, debit); } - public String getCredit() { - if (credit == null){ - return "0"; - } - return String.valueOf(credit); + public BigDecimal getCredit() { + return credit; } public void setCredit(BigDecimal credit) { - BigDecimal oldCredit = BigDecimal.valueOf(Double.valueOf(getCredit())); + BigDecimal oldCredit = getCredit(); this.credit = credit; firePropertyChange(CREDIT_PROPERTY, oldCredit, credit); } - public String getSolde() { - if (solde == null){ - return "0"; - } + public BigDecimal getSolde() { return solde; } - public void setSolde(String solde) { - String oldSolde = getSolde(); + public void setSolde(BigDecimal solde) { + BigDecimal oldSolde = getSolde(); this.solde = solde; firePropertyChange(SOLDE_PROPERTY, oldSolde, solde); } @@ -167,6 +126,8 @@ @Override public int getSelectionMode() { - return SINGLE_SELECTION; + return MULTIPLE_INTERVAL_SELECTION; } + + } 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 2012-07-03 14:38:28 UTC (rev 3487) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -1,7 +1,7 @@ /* * #%L * Lima Swing - * + * * $Id$ * $HeadURL$ * %% @@ -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% @@ -25,15 +25,6 @@ package org.chorem.lima.ui.lettering; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.math.BigDecimal; -import java.util.Date; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.chorem.lima.entity.Account; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.celleditor.AccountTableCellEditor; @@ -43,7 +34,14 @@ import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; import org.jdesktop.swingx.JXTable; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.math.BigDecimal; +import java.util.Date; + /** * Table des transaction qui ajoute des comportement (keys). * @@ -55,9 +53,6 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3133690382049594727L; - /** log. */ - private static final Log log = LogFactory.getLog(LetteringTable.class); - protected LetteringViewHandler handler; /*private Highlighter colorTransaction; @@ -65,7 +60,7 @@ private ColorHighlighter colorBalance;*/ protected LetteringTableModel letteringTableModel; - + public LetteringTable(LetteringTableModel letteringTableModel) { super(letteringTableModel); this.letteringTableModel = letteringTableModel; @@ -85,67 +80,9 @@ //Get new BigDecimal renderer setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer()); - //highlight financial financial transactions - /*addColorTransaction(); - // highlight unbalanced financial transactions - addColorNonBalancedTransaction();*/ } /** - * Cette méthode permet de colorer toutes les transactions dans le tableau - * afin de bien distinguer les transactions et entrées comptables. - * On récupère la première cellule, on vérifie que c'est une date - */ - /*protected void addColorTransaction() { - if (colorTransaction != null) { - removeHighlighter(colorTransaction); - } - HighlightPredicate predicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { - return adapter.getValueAt(adapter.row, 0) instanceof Date; - } - }; - colorTransaction = - new ColorHighlighter(predicate, new Color(222, 222, 222), null); - addHighlighter(colorTransaction); - }*/ - - - /** - * Permet de surligner une transaction dans le tableau lorsque - * cette dernière n'est pas équilibrée. - * On récupère la dernière cellule de la ligne - * et on vérifie si la valeur est différente de 0 - */ - /* protected void addColorNonBalancedTransaction() { - if (colorBalance != null) { - removeHighlighter(colorBalance); - } - HighlightPredicate predicate = new HighlightPredicate() { - @Override - public boolean isHighlighted(Component renderer, - ComponentAdapter adapter) { - boolean isHighlighted = false; - Object value = adapter.getValueAt(adapter.row, 8); - if (value instanceof BigDecimal) { - BigDecimal currentBalance = (BigDecimal) value; - // can compare two BigDecimals with different scales - // e.g: 3.1 == 3.10 - if (currentBalance.compareTo(BigDecimal.ZERO) != 0) { - isHighlighted = true; - } - } - return isHighlighted; - } - }; - colorTransaction = - new ColorHighlighter(predicate, new Color(255, 198, 209), null); - addHighlighter(colorTransaction); - }*/ - - /** * for each action combination key are think * for extend keyboard and laptop keyboard */ 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-03 14:38:28 UTC (rev 3487) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-04 16:30:39 UTC (rev 3488) @@ -149,15 +149,15 @@ <JLabel text="lima.ui.lettering.selectEntry"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit()}" + <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit().toString()}" focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit()}" + <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit().toString()}" focusable="false"/> </cell> <cell fill="horizontal" weightx="0.25"> - <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde()}" + <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde().toString()}" focusable="false"/> </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 2012-07-03 14:38:28 UTC (rev 3487) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-04 16:30:39 UTC (rev 3488) @@ -25,16 +25,6 @@ package org.chorem.lima.ui.lettering; -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; - -import javax.swing.JComboBox; - import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -49,9 +39,16 @@ import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; -import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +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. * @@ -71,11 +68,11 @@ protected LetteringTable table; - protected LetteringTableModel tableModel; + /*protected LetteringTableModel tableModel; protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel; - protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel; + protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel;*/ /** Transaction service. */ protected FiscalPeriodService fiscalPeriodService; @@ -84,8 +81,6 @@ protected FinancialTransactionService financialTransactionService; protected EntryBookService entryBookService; - protected Object clipBoard; - public LetteringViewHandler(LetteringView view) { this.view = view; @@ -102,15 +97,50 @@ public void init() { loadComboAndRows(); LetteringModelUI modelUi = view.getModelUi(); - modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() { + + modelUi.addListSelectionListener(new ListSelectionListener(){ + List<Entry> entries = new ArrayList<Entry>(); @Override + public void valueChanged(ListSelectionEvent evt) { + + LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource(); + if (evt.getValueIsAdjusting()){ + Entry lastEntry = view.getTableModel().getEntryAt(evt.getLastIndex()); + int nbSelectedRowModel = view.getTable().getSelectedRows().length; + int sizeEntries = entries.size(); + + if (log.isInfoEnabled()) { + log.info("Size list entries : " + sizeEntries + "\n" + + "Nb selected row : " + nbSelectedRowModel); + } + if (nbSelectedRowModel > sizeEntries || (nbSelectedRowModel==sizeEntries && nbSelectedRowModel==1)){ + entries.add(lastEntry); + if (log.isInfoEnabled()) { + log.info("Add entry"); + } + }else if (nbSelectedRowModel < sizeEntries){ + entries.remove(entries.size() - 1); + if (log.isInfoEnabled()) { + log.info("Remove entry"); + } + } + + if (log.isInfoEnabled()) { + log.info("Size entries after update : " + entries.size()); + } + loadCurrentSelection(modelUiPropChange, entries); + } + } + }); + + /*modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource(); Entry selectedEntry = (Entry)evt.getNewValue(); loadCurrentSelection(modelUiPropChange, selectedEntry); } - }); - + });*/ } public void loadComboAndRows(){ @@ -140,7 +170,7 @@ int premierJourMoisCourant = calendar.getActualMinimum(Calendar.DATE); if (fiscalPeriod != null){ - defaultDateBegFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod().getBeginDate(); + defaultDateBegFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod().getBeginDate(); }else{ defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), premierJourMoisCourant); } @@ -205,30 +235,80 @@ } } - public void loadCurrentSelection(LetteringModelUI modelUi, Entry selectedEntry){ + /**Managing components when n rows are selected + * */ + public void loadCurrentSelection(LetteringModelUI modelUi, List<Entry> selectedEntries){ financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class); - boolean enableLettring = false; - boolean enableDelettring = false; + if (selectedEntries.size() > 0){ - if (selectedEntry != null){ - modelUi.setDebit(selectedEntry.getDebit() ? selectedEntry.getAmount() : BigDecimal.ZERO); - modelUi.setCredit(selectedEntry.getDebit() ? BigDecimal.ZERO : selectedEntry.getAmount()); + boolean enableLettring = false; + boolean enableDelettring = false; + BigDecimal soldeTotal = BigDecimal.ZERO; + BigDecimal creditTotal = BigDecimal.ZERO; + BigDecimal debitTotal = BigDecimal.ZERO; - if (modelUi.getDebit().equals("0")){ - modelUi.setSolde(modelUi.getCredit()); - }else{ - modelUi.setSolde(modelUi.getDebit()); + for (Entry selectedEntry : selectedEntries) { + //Managing balance, credit and debit + boolean debitSelected = selectedEntry.getDebit(); + BigDecimal amountSelected = selectedEntry.getAmount(); + + + if (log.isInfoEnabled()) { + log.info("amountSelected : " + amountSelected); + } + modelUi.setDebit(debitSelected ? amountSelected : BigDecimal.ZERO); + modelUi.setCredit(debitSelected ? BigDecimal.ZERO : amountSelected); + + BigDecimal debitVal = modelUi.getDebit(); + if (log.isInfoEnabled()) { + log.info("Debit actuel : " + debitVal); + } + if (debitVal == BigDecimal.ZERO){ + BigDecimal creditVal = modelUi.getCredit(); + if (log.isInfoEnabled()) { + log.info("creditVal : " + creditVal); + } + if (creditVal != BigDecimal.ZERO){ + creditTotal = creditTotal.add(creditVal); + creditVal = new BigDecimal("-" + creditVal.toString()); + if (log.isInfoEnabled()) { + log.info("creditVal neg : " + creditVal); + } + soldeTotal = soldeTotal.add(creditVal); + }else{ + creditTotal = creditTotal.add(creditVal); + soldeTotal = soldeTotal.add(creditVal); + } + }else{ + debitTotal = debitTotal.add(debitVal); + soldeTotal = soldeTotal.add(debitVal); + } } - modelUi.setSolde(modelUi.getSolde()); - if (selectedEntry.getLettering() != null && ! selectedEntry.getLettering().isEmpty()){ - enableDelettring = true; - }else{ - enableLettring = true; - } + + modelUi.setSolde(soldeTotal); + modelUi.setCredit(creditTotal); + modelUi.setDebit(debitTotal); + + //Managing lettering buttons + String lettering = null; + + //lettering impossible if one of entries have letter + for (Entry selectedEntry : selectedEntries) { + lettering = selectedEntry.getLettering(); + if (lettering != null && !lettering.isEmpty()){ + enableDelettring= true; + break; + } + } + + if (soldeTotal.intValue() == 0 && !enableDelettring){ + enableLettring = true; + } + + modelUi.setLettrer(enableLettring); + modelUi.setDelettrer(enableDelettring); } - modelUi.setLettrer(enableLettring); - modelUi.setDelettrer(enableDelettring); } /** @@ -269,21 +349,31 @@ /**Add a group of three letters to n entries*/ public void addLetter() { String newLetters = financialTransactionService.getNewLetters(); - int[] entrieSelected = view.getTable().getSelectedRows(); - view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters); + changeLetter(newLetters); } /**Remove a group of three letters to n entries*/ public void removeLetter() { - //TODO - //removeLetters - /*int[] rows = table.getSelectedRows(); - for (int i : rows) { - view.getTableModel().removeLetter(i); + changeLetter(null); + } + + /**Add or remove a group of three letters to n entries*/ + protected void changeLetter(String newLetters) { + int[] entrieSelected = view.getTable().getSelectedRows(); + + view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters); + + for (int indexEntry : entrieSelected){ + financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry)); } - view.getTableModel().updateRows();*/ } + /*public void nonConsecutiveSelection(int[] selectedRows){ + for (int row : selectedRows){ + view.getTable().addRowSelectionInterval(row, row); + } + }*/ + @Override public void notifyMethod(String serviceName, String methodeName) { }
participants (1)
-
mallon@users.chorem.org