Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
July 2012
- 5 participants
- 74 discussions
Author: echatellier
Date: 2012-07-12 11:32:19 +0200 (Thu, 12 Jul 2012)
New Revision: 3516
Url: http://chorem.org/repositories/revision/lima/3516
Log:
Move log level to info
Modified:
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-07-12 09:32:10 UTC (rev 3515)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-12 09:32:19 UTC (rev 3516)
@@ -38,14 +38,3 @@
# package level
log4j.logger.org.chorem.lima=INFO
-log4j.logger.org.chorem.lima.business.ejb=DEBUG
-log4j.logger.org.chorem.lima.ui.account=DEBUG
-log4j.logger.org.chorem.lima.ui.home=DEBUG
-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
-log4j.logger.org.chorem.lima.ui.lettering.LettringAndUnlettringSelectionModel=DEBUG
-log4j.logger.org.chorem.lima.ui.lettering.LetteringSelectionModel=DEBUG
-log4j.logger.org.chorem.lima.ui.lettering.UnletteringSelectionModel=DEBUG
-log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG
\ No newline at end of file
1
0
r3515 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by mallon@users.chorem.org 12 Jul '12
by mallon@users.chorem.org 12 Jul '12
12 Jul '12
Author: mallon
Date: 2012-07-12 11:32:10 +0200 (Thu, 12 Jul 2012)
New Revision: 3515
Url: http://chorem.org/repositories/revision/lima/3515
Log:
fixes #691 Correction permettant de selectionner les transactions et entrees, ainsi que de rester sur la m?\195?\170me ligne lors de la saisie du debit / credit dans une entr?\195?\169e.
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/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
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 2012-07-11 15:00:25 UTC (rev 3514)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2012-07-12 09:32:10 UTC (rev 3515)
@@ -25,18 +25,6 @@
package org.chorem.lima.ui.financialtransaction;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.math.BigDecimal;
-import java.util.Date;
-import javax.swing.SwingUtilities;
-import javax.swing.SwingWorker;
-import javax.swing.event.CellEditorListener;
-import javax.swing.event.ChangeEvent;
import org.apache.commons.collections.CollectionUtils;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -54,6 +42,15 @@
import org.jdesktop.swingx.decorator.HighlightPredicate;
import org.jdesktop.swingx.decorator.Highlighter;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.math.BigDecimal;
+import java.util.Date;
+
/**
* Table des transaction qui ajoute des comportement (keys).
*
@@ -94,31 +91,8 @@
setDefaultEditor(Account.class, new AccountTableCellEditor());
//Get new amount editor
- BigDecimalTableCellEditor editor = new BigDecimalTableCellEditor();
+ setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
- // FIXME sletellier 27/06/12 : hack to fix selection of first row on stopEditing cell in last row
- editor.addCellEditorListener(new CellEditorListener() {
-
- @Override
- public void editingStopped(ChangeEvent e) {
- BigDecimalTableCellEditor editor = (BigDecimalTableCellEditor)e.getSource();
- final int row = editor.getRow();
- SwingUtilities.invokeLater(new Runnable() {
-
- @Override
- public void run() {
- getSelectionModel().setSelectionInterval(row, row);
- }
- });
- }
-
- @Override
- public void editingCanceled(ChangeEvent e) {
- // do nothing
- }
- });
- setDefaultEditor(BigDecimal.class, editor);
-
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
@@ -164,19 +138,12 @@
colorTransaction =
new ColorHighlighter(predicate, new Color(255, 198, 209), null);
addHighlighter(colorTransaction);
-
- setTerminateEditOnFocusLost(true);
}
public FinancialTransactionViewHandler getHandler() {
return handler;
}
- @Override
- public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
- super.changeSelection(rowIndex, columnIndex, true, true);
- }
-
private class MyKeyAdapter extends KeyAdapter {
@Override
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 2012-07-11 15:00:25 UTC (rev 3514)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2012-07-12 09:32:10 UTC (rev 3515)
@@ -25,11 +25,6 @@
package org.chorem.lima.ui.financialtransaction;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import javax.swing.table.AbstractTableModel;
-import org.chorem.lima.LimaContext;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -37,6 +32,11 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.table.AbstractTableModel;
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
import static org.nuiton.i18n.I18n._;
/**
@@ -387,13 +387,11 @@
currentEntry.setLettering((String) value);
break;
case 6:
- BigDecimal bigDecimalValue = getBigDecimalValue(value);
- currentEntry.setAmount(bigDecimalValue);
+ currentEntry.setAmount((BigDecimal) value);
currentEntry.setDebit(true);
break;
case 7:
- bigDecimalValue = getBigDecimalValue(value);
- currentEntry.setAmount(bigDecimalValue);
+ currentEntry.setAmount((BigDecimal) value);
currentEntry.setDebit(false);
break;
}
@@ -420,22 +418,6 @@
fireTableRowsUpdated(trIndex, endIndex);
}
- protected BigDecimal getBigDecimalValue(Object value) {
-
- BigDecimal result = (BigDecimal)value;
-
- //set 0 in case the user type in a non number format
- if (result == null) {
- result = BigDecimal.ZERO;
- }
-
- //round half up the number using the scale given by the configuration
- result = result.setScale(LimaContext.getContext().getConfig().getScale(),
- BigDecimal.ROUND_HALF_UP);
-
- return result;
- }
-
public Object getElementAt(int row) {
Object result = transactionAndEntries.get(row);
return result;
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 2012-07-11 15:00:25 UTC (rev 3514)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2012-07-12 09:32:10 UTC (rev 3515)
@@ -25,16 +25,6 @@
package org.chorem.lima.ui.financialtransaction;
-import java.awt.event.ItemEvent;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import javax.swing.JComboBox;
-import javax.swing.JOptionPane;
-import javax.swing.ListSelectionModel;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -54,6 +44,15 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.*;
+import java.awt.event.ItemEvent;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
import static org.nuiton.i18n.I18n._;
/**
1
0
r3514 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 11 Jul '12
by mallon@users.chorem.org 11 Jul '12
11 Jul '12
Author: mallon
Date: 2012-07-11 17:00:25 +0200 (Wed, 11 Jul 2012)
New Revision: 3514
Url: http://chorem.org/repositories/revision/lima/3514
Log:
refs #690 Correction temporaire permettant le rafraichissement de la table, apres ajout d un interval de selection de lignes dans le modele delegue des entrees non-lettrees.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java
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/LetteringSelectionModel.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/LetteringTableModel.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/UnlettringSelectionModel.java
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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -18,9 +18,9 @@
public static final String SOLDE_PROPERTY = "solde";
- public static final String LETTRER_PROPERTY = "lettrer";
+ public static final String LETTRED_PROPERTY = "lettred";
- public static final String DELETTRER_PROPERTY = "delettrer";
+ public static final String UNLETTRED_PROPERTY = "unLettred";
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -49,7 +49,7 @@
log.info("Lettred false");
}
}
- firePropertyChange(LETTRER_PROPERTY, oldLettrer, this.lettred);
+ firePropertyChange(LETTRED_PROPERTY, oldLettrer, this.lettred);
}
public boolean isUnLettred() {
@@ -59,7 +59,7 @@
public void setUnLettred(boolean unLettred) {
boolean oldDelettrer = isUnLettred();
this.unLettred = unLettred;
- firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, this.unLettred);
+ firePropertyChange(UNLETTRED_PROPERTY, oldDelettrer, this.unLettred);
}
public BigDecimal getDebit() {
@@ -115,7 +115,7 @@
}
//Allow to add / subtract credit / debit and balance
- public void balanceCalcultation(BigDecimal amount, boolean debit){
+ public void balanceCalculation(BigDecimal amount, boolean debit){
BigDecimal debitVal = debit ? amount : BigDecimal.ZERO;
BigDecimal creditVal = debit ? BigDecimal.ZERO : amount;
Deleted: 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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -1,332 +0,0 @@
-package org.chorem.lima.ui.lettering;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
-
-import javax.swing.*;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-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";
-
- public static final String DEBIT_PROPERTY = "debit";
-
- public static final String CREDIT_PROPERTY = "credit";
-
- public static final String SOLDE_PROPERTY = "solde";
-
- public static final String LETTRER_PROPERTY = "lettrer";
-
- public static final String DELETTRER_PROPERTY = "delettrer";
-
- private static final long serialVersionUID = 1L;
-
- protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
-
- private static final Log log = LogFactory.getLog(LetteringModelUI.class);
-
- protected LetteringTableModel model;
-
- protected Entry selectedEntry;
- protected BigDecimal debit = BigDecimal.ZERO;
- protected BigDecimal credit = BigDecimal.ZERO;
- protected BigDecimal solde = BigDecimal.ZERO;
- protected BigDecimal debitTotal = BigDecimal.ZERO;
- protected BigDecimal creditTotal = BigDecimal.ZERO;
- protected BigDecimal soldeTotal = BigDecimal.ZERO;
- protected boolean lettrer;
- protected boolean delettrer;
- protected String currentLettring;
- protected List<Entry> precedentEntries;
- protected Entry currentEntry;
-
- public LetteringModelUI(LetteringTableModel model) {
- this.model = model;
- }
-
- public void resetDebitCreditBalance(){
- setDebit(BigDecimal.ZERO);
- setCredit(BigDecimal.ZERO);
- setSolde(BigDecimal.ZERO);
- debitTotal = BigDecimal.ZERO;
- creditTotal = BigDecimal.ZERO;
- soldeTotal = BigDecimal.ZERO;
- }
-
- public Entry getSelectedEntry() {
- return selectedEntry;
- }
-
- public void setSelectedEntry(Entry selectedEntry) {
- Entry oldSelectedEntry = getSelectedEntry();
- this.selectedEntry = selectedEntry;
- firePropertyChange(SELECTED_ENTRY_PROPERTY, oldSelectedEntry, selectedEntry);
- }
-
- public boolean isLettrer() {
- return lettrer;
- }
-
- public void setLettrer(boolean lettrer) {
- boolean oldLettrer = isLettrer();
- this.lettrer = lettrer;
- firePropertyChange(LETTRER_PROPERTY, oldLettrer, lettrer);
- }
-
- public boolean isDelettrer() {
- return delettrer;
- }
-
- public void setDelettrer(boolean delettrer) {
- boolean oldDelettrer = isDelettrer();
- this.delettrer = delettrer;
- firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, delettrer);
- }
-
- public BigDecimal getDebit() {
- return debit;
- }
-
- public void setDebit(BigDecimal debit) {
- BigDecimal oldDebit = getDebit();
- this.debit = debit;
- firePropertyChange(DEBIT_PROPERTY, oldDebit, debit);
- }
-
- public BigDecimal getCredit() {
- return credit;
- }
-
- public void setCredit(BigDecimal credit) {
- BigDecimal oldCredit = getCredit();
- this.credit = credit;
- firePropertyChange(CREDIT_PROPERTY, oldCredit, credit);
- }
-
- public BigDecimal getSolde() {
- return solde;
- }
-
- public void setSolde(BigDecimal solde) {
- BigDecimal oldSolde = getSolde();
- this.solde = solde;
- firePropertyChange(SOLDE_PROPERTY, oldSolde, solde);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
- pcs.firePropertyChange(propertyName, oldValue, newValue);
- }
-
- @Override
- public int getSelectionMode() {
- return MULTIPLE_INTERVAL_SELECTION;
- }
-
- @Override
- public void setSelectionInterval(int row, int column) {
- setLettrer(false);
- setDelettrer(false);
- Entry lastEntrySelected = model.getEntryAt(row);
- List<Entry> modelEntries = model.getEntries();
- setSelectedEntry(lastEntrySelected);
- precedentEntries=new ArrayList<Entry>();
-
- if (lastEntrySelected.getLettering() != null){
-
- // no line selected or line selected different of the current
- if (isSelectionEmpty() || currentEntry != null || !currentLettring.equals(lastEntrySelected.getLettering())){
- if (log.isInfoEnabled()) {
- log.info("First");
- }
- //Test not null for currentEntry cause of selection before of entry without letter
- if (currentEntry != null && currentLettring==null){
- if (log.isInfoEnabled()) {
- log.info("First_A");
- }
- super.clearSelection();
- currentEntry = null;
- debitTotal = BigDecimal.ZERO;
- creditTotal = BigDecimal.ZERO;
- soldeTotal = BigDecimal.ZERO;
- }
-
- currentLettring = lastEntrySelected.getLettering();
- super.setSelectionInterval(row, column);
- //select entries with the same letter of the selected entry
- for(Entry entry : modelEntries){
- if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
- if (entry.getLettering().equals(currentLettring)){
- int entryToSelect = model.getIndexOfEntry(entry);
- //Save current entry before changing it to add
- // debit / credit / solde with current entry later (Case : multiple selection
- //for entries with same letters.)
- precedentEntries.add(entry);
- super.addSelectionInterval(entryToSelect, entryToSelect);
- }
- }
- }
- }
- }else{
- //no line selected or line selected different of the current
- //Test null for currentEntry cause of selection before entry with letter
- if (isSelectionEmpty() || currentEntry == null || !currentEntry.equals(lastEntrySelected)){
- if (log.isInfoEnabled()) {
- log.info("Second");
- }
- if (currentEntry == null && currentLettring != null){
- if (log.isInfoEnabled()) {
- log.info("Second_A");
- }
- super.clearSelection();
- currentLettring = null;
- debitTotal = BigDecimal.ZERO;
- creditTotal = BigDecimal.ZERO;
- soldeTotal = BigDecimal.ZERO;
- }
- currentEntry = lastEntrySelected;
- super.addSelectionInterval(row, column);
-
- //remove entry and get precedent entry for currentEntry
- }else {
- super.removeSelectionInterval(row, column);
- currentEntry = model.getEntryAt(super.getMaxSelectionIndex());
- }
- }
-
- /**Managing components when n rows are selected
- * */
- if (!isSelectionEmpty()){
-
- if (log.isInfoEnabled()) {
- log.info("debit : " + debitTotal + "\n" +
- "credit : " + creditTotal + "\n" +
- "solde : " + soldeTotal);
- }
-
- //Case of selection of entry not lettered
- if (precedentEntries.isEmpty()){
- boolean debitSelected = selectedEntry.getDebit();
- BigDecimal amountSelected = selectedEntry.getAmount();
-
- BigDecimal debitVal = debitSelected ? amountSelected : BigDecimal.ZERO;
- if (debitVal == BigDecimal.ZERO){
- BigDecimal creditVal = debitSelected ? BigDecimal.ZERO : amountSelected;
- if (creditVal != BigDecimal.ZERO){
- if (selectedEntry != currentEntry){
- creditTotal = creditTotal.subtract(creditVal);
- soldeTotal = soldeTotal.add(creditVal);
- }else{
- creditTotal = creditTotal.add(creditVal);
- soldeTotal = soldeTotal.subtract(creditVal);
- }
- }
- }else{
- if (selectedEntry != currentEntry){
- debitTotal = debitTotal.subtract(debitVal);
- soldeTotal = soldeTotal.subtract(debitVal);
- }else{
- debitTotal = debitTotal.add(debitVal);
- soldeTotal = soldeTotal.add(debitVal);
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("AFTER / debit : " + debitTotal + "\n" +
- "credit : " + creditTotal + "\n" +
- "solde : " + soldeTotal);
- }
- }else{
- if (log.isInfoEnabled()) {
- log.info("precedentEntries.size() : " + precedentEntries.size());
- }
- //In case of multiple selection (Entry with same letters)
- //add debit / credit / balance of entries selected
- for (Entry precedentEntry : precedentEntries){
- if (precedentEntry != null){
- if (log.isInfoEnabled()) {
- log.info("precedentEntries not null");
- }
- boolean precedentDebitSelected = precedentEntry.getDebit();
- BigDecimal precedentAmountSelected = precedentEntry.getAmount();
-
- BigDecimal precedentDebitVal = precedentDebitSelected ? precedentAmountSelected : BigDecimal.ZERO;
- BigDecimal precedentCreditVal = precedentDebitSelected ? BigDecimal.ZERO : precedentAmountSelected;
-
- if (log.isInfoEnabled()) {
- log.info("precedentDebitVal : " + precedentDebitVal + "\n" +
- "precedentCreditVal : " + precedentCreditVal);
- }
-
- debitTotal = debitTotal.add(precedentDebitVal);
- soldeTotal = soldeTotal.add(precedentDebitVal);
-
- creditTotal = creditTotal.add(precedentCreditVal);
- soldeTotal = soldeTotal.subtract(precedentCreditVal);
-
- }
- }
- precedentEntries.clear();
- }
-
- setDebit(debitTotal);
- setCredit(creditTotal);
- setSolde(soldeTotal);
-
- //Managing lettering buttons
- String lettering = null;
-
- //lettering impossible if one of entries have letter
- lettering = lastEntrySelected.getLettering();
- if (lettering != null && !lettering.isEmpty()){
- setDelettrer(true);
- }
-
- if (solde.intValue() == 0 && !delettrer){
- setLettrer(true);
- }
- }
- else{
- debitTotal = BigDecimal.ZERO;
- creditTotal = BigDecimal.ZERO;
- soldeTotal = BigDecimal.ZERO;
- setDebit(BigDecimal.ZERO);
- setCredit(BigDecimal.ZERO);
- setSolde(BigDecimal.ZERO);
- }
- }
-
- @Override
- public void addSelectionInterval(int index0, int index1) {
- setSelectionInterval(index0, index1);
- }
-
- @Override
- public void removeSelectionInterval(int index0, int index1) {
- // do nothing
- }
-
-}
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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -14,7 +14,7 @@
*/
public class LetteringSelectionModel extends DefaultListSelectionModel {
- private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
+ private static final Log log = LogFactory.getLog(LetteringSelectionModel.class);
protected LetteringTableModel letteringTableModel;
protected LetteringEditModel editModel;
protected int lineSelected;
@@ -30,26 +30,28 @@
@Override
public void setSelectionInterval(int row, int column){
+ if (log.isInfoEnabled()) {
+ log.info("Selection ligne...");
+ }
selectedRows = new ArrayList<Integer>();
- this.clearSelection();
+ super.clearSelection();
lineSelected = row;
String currentLettring = getCurrentLettring();
- if (log.isInfoEnabled()) {
- log.info("Select line");
- log.info("Entries : " + getEntries().size());
- }
- //FIXME allon 10-07-12 : problème de rafraichissement très long
setValueIsAdjusting(true);
+
try {
//select entries with the same letter of the selected entry
for(Entry entry : getEntries()){
+ if (log.isInfoEnabled()) {
+ log.info("Parcours...");
+ }
if (StringUtils.isNotBlank(entry.getLettering())){
if (entry.getLettering().equals(currentLettring)){
int entryToSelect = letteringTableModel.getIndexOfEntry(entry);
+ selectedRows.add(entryToSelect);
super.addSelectionInterval(entryToSelect, entryToSelect);
- selectedRows.add(entryToSelect);
}
}
}
@@ -60,17 +62,16 @@
}
/**PropertyChange on editModel in the handler, and, there,
- * set values it.
+ * set values on it.
* */
public void updateBalanceAndLetteringButton(boolean lettering){
editModel.resetDebitCreditBalance();
for (int row : selectedRows){
-
Entry entryAt = letteringTableModel.getEntryAt(row);
//Set values for calculation (By LetteringEditModel) of balance
- editModel.balanceCalcultation(entryAt.getAmount(), entryAt.getDebit());
+ editModel.balanceCalculation(entryAt.getAmount(), entryAt.getDebit());
}
//For U.I. buttons (Lettering and unlettering)
@@ -89,4 +90,9 @@
public Entry getCurrentEntrySelected(){
return letteringTableModel.getEntryAt(lineSelected);
}
+
+ @Override
+ public int getSelectionMode() {
+ 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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -34,10 +34,6 @@
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;
@@ -47,23 +43,16 @@
*
* @author jpepin
*/
-public class LetteringTable extends JXTable
- implements KeyListener, MouseListener {
+public class LetteringTable extends JXTable {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
protected LetteringViewHandler handler;
- //protected LetteringTableModel letteringTableModel;
-
public LetteringTable(LetteringTableModel letteringTableModel) {
super(letteringTableModel);
- //this.letteringTableModel = letteringTableModel;
- addKeyListener(this);
- addMouseListener(this);
-
//Get new date editor
setDefaultEditor(Date.class, new DateTableCellEditor());
//Get new entry book editor
@@ -77,62 +66,4 @@
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
}
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
-
-
- // add letter with the key combination : ctrl + L
- if (e.getKeyCode() == KeyEvent.VK_L
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.addLetter();
- }
-
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
-
- }
-
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -25,8 +25,6 @@
package org.chorem.lima.ui.lettering;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
@@ -55,8 +53,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- private static final Log log = LogFactory.getLog(LetteringTableModel.class);
-
/** Begin Date. */
protected Date selectedBeginDate;
@@ -95,14 +91,6 @@
this.entryBooks = entryBooks;
}
- public void setSelectedBeginDate(Date date) {
- selectedBeginDate = date;
- }
-
- public void setSelectedEndDate(Date date) {
- selectedEndDate = date;
- }
-
@Override
public int getColumnCount() {
return 7;
@@ -112,8 +100,8 @@
if (row == -1) {
return null;
}
- Entry result = entries.get(row);
- return result;
+
+ return entries.get(row);
}
@Override
@@ -145,7 +133,6 @@
return result;
}
-
@Override
public String getColumnName(int column) {
String result = "n/a";
@@ -223,11 +210,9 @@
*/
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
-
return false;
}
-
public Object getElementAt(int row) {
return entries.get(row);
}
@@ -239,13 +224,6 @@
fireTableRowsInserted(row, row);
}
- /**add a list of Entry*/
- public void addEntries(List<Entry> entries) {
- for (Entry entry : entries){
- addEntry(entry);
- }
- }
-
/**update selected entries*/
public void updateLettersSelectedEntries(int[] entries, String letters) {
for (int rowEntry : entries){
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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-11 15:00:25 UTC (rev 3514)
@@ -188,9 +188,8 @@
<cell fill="both" weightx="1" weighty="1" columns="4">
<JScrollPane>
<LetteringTable
- id="table" sortable="false" rowHeight="22" editable='true'
+ id="table" sortable="false" rowHeight="22"
constructorParams="getTableModel()"
- selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
selectionModel="{lettringAndUnlettringSelectionModel}"
/>
</JScrollPane>
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-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -122,6 +122,9 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isInfoEnabled()) {
+ log.info("Property change listener sur edit model");
+ }
updateBalanceAndLetteringButton();
}
});
@@ -226,6 +229,9 @@
if (log.isInfoEnabled()) {
log.info("updateBalanceAndLetteringButton");
}
+ //FIXME Allon-11/07/2012 : probleme de rafraichissement de la table, lors
+ //de la delegation de modele ('LetteringSelectionModele')
+ view.getTable().repaint();
}
/**
@@ -255,13 +261,13 @@
}
}
- public void setBeginDate(Date date) {
+ /*public void setBeginDate(Date date) {
view.getTableModel().setSelectedBeginDate(date);
- }
+ }*/
- public void setEndDate(Date date) {
- view.getTableModel().setSelectedEndDate(date);
- }
+ /*public void setEndDate(Date date) {
+ view.getTableModel().setSelectedEndDate(date);
+ }*/
/**Add a group of three letters to n entries*/
public void addLetter() {
Modified: 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 2012-07-11 13:02:26 UTC (rev 3513)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-11 15:00:25 UTC (rev 3514)
@@ -10,7 +10,7 @@
public class UnlettringSelectionModel extends DefaultListSelectionModel {
- private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
+ private static final Log log = LogFactory.getLog(UnlettringSelectionModel.class);
protected LetteringTableModel letteringTableModel;
protected List<Integer> selectedRows;
protected LetteringEditModel editModel;
@@ -81,7 +81,7 @@
Entry entryAt = letteringTableModel.getEntryAt(row);
//Set values for calculation (By LetteringEditModel) of balance
- editModel.balanceCalcultation(entryAt.getAmount(), entryAt.getDebit());
+ editModel.balanceCalculation(entryAt.getAmount(), entryAt.getDebit());
}
//For U.I. buttons (Lettering and unlettering)
editModel.setUnLettred(!lettering);
1
0
r3513 - in trunk: lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/lettering lima-swing/src/main/resources
by mallon@users.chorem.org 11 Jul '12
by mallon@users.chorem.org 11 Jul '12
11 Jul '12
Author: mallon
Date: 2012-07-11 15:02:26 +0200 (Wed, 11 Jul 2012)
New Revision: 3513
Url: http://chorem.org/repositories/revision/lima/3513
Log:
fixes #688 Correction des modeles de s?\195?\169lection, de filtre, du handler et du fichier jaxx, afin de finaliser les fonctionnalit?\195?\169s du panneau de lettrage.
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.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/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/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java
trunk/lima-swing/src/main/resources/log4j.properties
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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -206,7 +206,7 @@
" and E.financialTransaction.transactionDate between :beginDate and :endDate " +
" order by F.transactionDate, F." + FinancialTransaction.TOPIA_CREATE_DATE;
- entries = context.findAll(query, "account", filter.getAccount(), "beginDate", filter.getBeginDate(), "endDate", filter.getEndDate());
+ entries = context.findAll(query, "account", filter.getAccount(), "beginDate", filter.getFiscalDateFilter().getDateStart(), "endDate", filter.getFiscalDateFilter().getDateEnd());
return entries;
}
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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringEditModel.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -1,5 +1,10 @@
package org.chorem.lima.ui.lettering;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
import java.math.BigDecimal;
/**
@@ -7,8 +12,22 @@
*/
public class LetteringEditModel {
+ public static final String DEBIT_PROPERTY = "debit";
+
+ public static final String CREDIT_PROPERTY = "credit";
+
+ public static final String SOLDE_PROPERTY = "solde";
+
+ public static final String LETTRER_PROPERTY = "lettrer";
+
+ public static final String DELETTRER_PROPERTY = "delettrer";
+
+ protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+ private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
+
+ protected LetteringTableModel model;
protected boolean lettred;
- protected boolean unLettred = true; //By default, present unLettred entries
+ protected boolean unLettred;
protected BigDecimal debit = BigDecimal.ZERO;
protected BigDecimal credit = BigDecimal.ZERO;
protected BigDecimal solde = BigDecimal.ZERO;
@@ -18,7 +37,19 @@
}
public void setLettred(boolean lettred) {
- this.lettred = lettred;
+ boolean oldLettrer = isLettred();
+ if(lettred && (solde == BigDecimal.ZERO || solde.intValue() == 0)){
+ this.lettred = lettred;
+ if (log.isInfoEnabled()) {
+ log.info("Lettred true");
+ }
+ }else{
+ this.lettred = false;
+ if (log.isInfoEnabled()) {
+ log.info("Lettred false");
+ }
+ }
+ firePropertyChange(LETTRER_PROPERTY, oldLettrer, this.lettred);
}
public boolean isUnLettred() {
@@ -26,7 +57,9 @@
}
public void setUnLettred(boolean unLettred) {
+ boolean oldDelettrer = isUnLettred();
this.unLettred = unLettred;
+ firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, this.unLettred);
}
public BigDecimal getDebit() {
@@ -34,7 +67,15 @@
}
public void setDebit(BigDecimal debit) {
- this.debit = debit;
+ BigDecimal oldDebit = getDebit();
+
+ if (debit != BigDecimal.ZERO){
+ this.debit = debit.add(oldDebit);
+ }else{
+ this.debit = BigDecimal.ZERO;
+ }
+
+ firePropertyChange(DEBIT_PROPERTY, oldDebit, this.debit);
}
public BigDecimal getCredit() {
@@ -42,20 +83,84 @@
}
public void setCredit(BigDecimal credit) {
- this.credit = credit;
+ BigDecimal oldCredit = getCredit();
+
+ if (credit != BigDecimal.ZERO){
+ this.credit = credit.add(oldCredit);
+ }else{
+ this.credit=BigDecimal.ZERO;
+ }
+
+ firePropertyChange(CREDIT_PROPERTY, oldCredit, this.credit);
}
public BigDecimal getSolde() {
return solde;
}
- public void setSolde(BigDecimal solde) {
- this.solde = solde;
+ public void setSolde(BigDecimal solde, boolean credit) {
+ BigDecimal oldSolde = getSolde();
+
+ if (solde != BigDecimal.ZERO){
+ if (credit){
+ this.solde = oldSolde.subtract(solde);
+ }else{
+ this.solde = oldSolde.add(solde);
+ }
+ }else{
+ this.solde=BigDecimal.ZERO;
+ }
+
+ firePropertyChange(SOLDE_PROPERTY, oldSolde, this.solde);
}
+ //Allow to add / subtract credit / debit and balance
+ public void balanceCalcultation(BigDecimal amount, boolean debit){
+
+ BigDecimal debitVal = debit ? amount : BigDecimal.ZERO;
+ BigDecimal creditVal = debit ? BigDecimal.ZERO : amount;
+
+ if (debitVal == BigDecimal.ZERO){
+
+ if (creditVal != BigDecimal.ZERO){
+ setCredit(creditVal);
+ setSolde(creditVal, true);
+ }
+ }else if (creditVal == BigDecimal.ZERO){
+ setDebit(debitVal);
+ setSolde(debitVal, false);
+ }else{
+ resetDebitCreditBalance();
+ }
+ }
+
public void resetDebitCreditBalance(){
setDebit(BigDecimal.ZERO);
setCredit(BigDecimal.ZERO);
- setSolde(BigDecimal.ZERO);
+ setSolde(BigDecimal.ZERO, false);
}
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(propertyName, oldValue, newValue);
+ }
+
+ protected void firePropertyChange(String propertyName, Object newValue) {
+ firePropertyChange(propertyName, null, newValue);
+ }
}
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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -6,6 +6,7 @@
import org.chorem.lima.entity.Entry;
import javax.swing.*;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -15,16 +16,23 @@
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringTableModel letteringTableModel;
+ protected LetteringEditModel editModel;
protected int lineSelected;
+ protected List<Integer> selectedRows;
//Modele de selection du tableau lors de la selection d une entree lettree
- public LetteringSelectionModel(LetteringTableModel letteringTableModel) {
+ public LetteringSelectionModel(LetteringTableModel letteringTableModel, LetteringEditModel editModel) {
this.letteringTableModel = letteringTableModel;
+ this.editModel = editModel;
+ editModel.resetDebitCreditBalance();
}
@Override
public void setSelectionInterval(int row, int column){
+ selectedRows = new ArrayList<Integer>();
+ this.clearSelection();
+
lineSelected = row;
String currentLettring = getCurrentLettring();
if (log.isInfoEnabled()) {
@@ -34,7 +42,6 @@
//FIXME allon 10-07-12 : problème de rafraichissement très long
setValueIsAdjusting(true);
- super.clearSelection();
try {
//select entries with the same letter of the selected entry
for(Entry entry : getEntries()){
@@ -42,14 +49,35 @@
if (entry.getLettering().equals(currentLettring)){
int entryToSelect = letteringTableModel.getIndexOfEntry(entry);
super.addSelectionInterval(entryToSelect, entryToSelect);
+ selectedRows.add(entryToSelect);
}
}
}
} finally {
setValueIsAdjusting(false);
}
+ updateBalanceAndLetteringButton(false);
}
+ /**PropertyChange on editModel in the handler, and, there,
+ * set values it.
+ * */
+ public void updateBalanceAndLetteringButton(boolean lettering){
+
+ editModel.resetDebitCreditBalance();
+ for (int row : selectedRows){
+
+ Entry entryAt = letteringTableModel.getEntryAt(row);
+
+ //Set values for calculation (By LetteringEditModel) of balance
+ editModel.balanceCalcultation(entryAt.getAmount(), entryAt.getDebit());
+ }
+
+ //For U.I. buttons (Lettering and unlettering)
+ editModel.setUnLettred(!lettering);
+ editModel.setLettred(lettering);
+ }
+
public List<Entry> getEntries(){
return letteringTableModel.getEntries();
}
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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-11 13:02:26 UTC (rev 3513)
@@ -38,13 +38,13 @@
<LetteringViewHandler id="handler" constructorParams="this"/>
<LetteringTableModel id="tableModel"/>
- <LetteringEditModel id='letteringEditModel'/>
+ <LetteringEditModel id='editModel'/>
<LetteringFilter id='filterModel' initializer='new LetteringFilterImpl()'/>
- <LetteringSelectionModel id='letteringSelectionModel' constructorParams='tableModel'/>
- <UnlettringSelectionModel id='unletteringSelectionModel' constructorParams='tableModel'/>
+ <LetteringSelectionModel id='letteringSelectionModel' constructorParams='tableModel, editModel'/>
+ <UnlettringSelectionModel id='unletteringSelectionModel' constructorParams='tableModel, editModel'/>
<LettringAndUnlettringSelectionModel id='lettringAndUnlettringSelectionModel'
- constructorParams='letteringSelectionModel, unletteringSelectionModel, tableModel'/>
+ constructorParams='letteringSelectionModel, unletteringSelectionModel, tableModel, editModel'/>
<script>
<![CDATA[
@@ -87,7 +87,7 @@
</cell>
<cell>
<JXDatePicker id="pickerDebut"
- onActionPerformed="filterModel.setBeginDate(pickerDebut.getDate())"/>
+ onActionPerformed="filterModel.getFiscalDateFilter().setDateStart(pickerDebut.getDate())"/>
</cell>
</row>
<row>
@@ -96,7 +96,7 @@
</cell>
<cell>
<JXDatePicker id="pickerFin"
- onActionPerformed="filterModel.setEndDate(pickerFin.getDate())"/>
+ onActionPerformed="filterModel.getFiscalDateFilter().setDateEnd(pickerFin.getDate())"/>
</cell>
</row>
</Table>
@@ -155,15 +155,15 @@
<JLabel text="lima.ui.lettering.selectEntry"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="debitTexttField" editable="false" text="{getLetteringEditModel().getDebit().toString()}"
+ <JTextField id="debitTexttField" editable="false" text="{editModel.getDebit().toString()}"
focusable="false"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="creditTextField" editable="false" text="{getLetteringEditModel().getCredit().toString()}"
+ <JTextField id="creditTextField" editable="false" text="{editModel.getCredit().toString()}"
focusable="false"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="soldeTextField" editable="false" text="{getLetteringEditModel().getSolde().toString()}"
+ <JTextField id="soldeTextField" editable="false" text="{editModel.getSolde().toString()}"
focusable="false"/>
</cell>
</row>
@@ -176,10 +176,10 @@
<cell anchor="center" columns='4'>
<JPanel id="actionsPanel">
<JButton id="lettered" text="lima.ui.lettering.buttonLettered"
- enabled="{getLetteringEditModel().isLettred()}"
+ enabled="{editModel.isLettred()}"
onActionPerformed="handler.addLetter()"/>
<JButton id="noLettered" text="lima.ui.lettering.buttonNoLettered"
- enabled="{getLetteringEditModel().isUnLettred()}"
+ enabled="{editModel.isUnLettred()}"
onActionPerformed="handler.removeLetter()"/>
</JPanel>
</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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -28,8 +28,8 @@
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.DateFilterImpl;
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;
import org.chorem.lima.business.api.FinancialPeriodService;
@@ -41,11 +41,8 @@
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;
@@ -60,7 +57,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class LetteringViewHandler implements ServiceListener, ListSelectionListener {
+public class LetteringViewHandler{
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -74,6 +71,7 @@
protected FinancialTransactionService financialTransactionService;
protected EntryBookService entryBookService;
protected LetteringFilter filter;
+ protected LetteringEditModel editModel;
public LetteringViewHandler(LetteringView view) {
this.view = view;
@@ -90,6 +88,8 @@
*/
public void init() {
filter = view.getFilterModel();
+ filter.setFiscalDateFilter(new DateFilterImpl());
+ editModel=view.getEditModel();
loadComboAndRows();
filter.addPropertyChangeListener(new PropertyChangeListener() {
@@ -99,9 +99,32 @@
if (log.isInfoEnabled()) {
log.info("Filter changing...");
}
+ editModel.resetDebitCreditBalance();
updateAllEntries();
}
});
+
+ //FIXME Allon-11/07/2012 : mettre simplement deux dates au niveau de 'LetteringFilter'
+ //pour eviter d'avoir a poser un propertyChange supplementaire sur le 'DateFilter'
+ filter.getFiscalDateFilter().addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isInfoEnabled()) {
+ log.info("Filter changing...");
+ }
+ editModel.resetDebitCreditBalance();
+ updateAllEntries();
+ }
+ });
+
+ editModel.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ updateBalanceAndLetteringButton();
+ }
+ });
}
public void loadComboAndRows(){
@@ -148,8 +171,9 @@
log.debug("Val select letter : " + view.getLetteredCheckGroup().getSelectedButton().getName());
- filter.setBeginDate(defaultDateBegFiscalPeriod);
- filter.setEndDate(defaultDateEndCurrent);
+ filter.getFiscalDateFilter().setDateStart(defaultDateBegFiscalPeriod);
+ filter.getFiscalDateFilter().setDateEnd(defaultDateEndCurrent);
+ filter.setDisplayUnlettred(true);
updateAllEntries();
@@ -189,10 +213,21 @@
log.info("Nb entries model : " + view.getTableModel().getNumberOfEntries());
}
}
- view.getLetteringEditModel().resetDebitCreditBalance();
+ view.getEditModel().resetDebitCreditBalance();
view.getLettringAndUnlettringSelectionModel().clearSelection();
}
+ public void updateBalanceAndLetteringButton(){
+ view.creditTextField.setText(editModel.getCredit().toString());
+ view.debitTexttField.setText(editModel.getDebit().toString());
+ view.soldeTextField.setText(editModel.getSolde().toString());
+ view.lettered.setEnabled(editModel.isLettred());
+ view.noLettered.setEnabled(editModel.isUnLettred());
+ if (log.isInfoEnabled()) {
+ log.info("updateBalanceAndLetteringButton");
+ }
+ }
+
/**
* Select previous value in combo box.
*
@@ -232,13 +267,13 @@
public void addLetter() {
String newLetters = financialTransactionService.getNextLetters();
changeLetter(newLetters);
- view.getLetteringEditModel().setLettred(false);
+ view.getEditModel().setLettred(false);
}
/**Remove a group of three letters to n entries*/
public void removeLetter() {
changeLetter(null);
- view.getLetteringEditModel().setUnLettred(false);
+ view.getEditModel().setUnLettred(false);
}
/**Add or remove a group of three letters to n entries*/
@@ -248,40 +283,8 @@
view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters);
for (int indexEntry : entrieSelected){
- financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
+ financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
}
}
- @Override
- 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 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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
import javax.swing.*;
import javax.swing.event.ListSelectionListener;
@@ -15,12 +16,17 @@
protected LetteringSelectionModel letteringSelectionModel;
protected UnlettringSelectionModel unlettringSelectionModel;
protected LetteringTableModel letteringTableModel;
+ protected LetteringEditModel editModel;
protected ListSelectionModel delegate;
+ protected Entry entry;
- public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, UnlettringSelectionModel unlettringSelectionModel, LetteringTableModel letteringTableModel) {
+ public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel,
+ UnlettringSelectionModel unlettringSelectionModel,
+ LetteringTableModel letteringTableModel, LetteringEditModel letteringEditModel){
this.letteringSelectionModel = letteringSelectionModel;
this.unlettringSelectionModel = unlettringSelectionModel;
this.letteringTableModel = letteringTableModel;
+ this.editModel = letteringEditModel;
delegate = unlettringSelectionModel;
}
@@ -28,7 +34,14 @@
@Override
public void setSelectionInterval(int row, int column) {
- delegate=(!letteringNotExist(row)?letteringSelectionModel:unlettringSelectionModel);
+ if (!letteringNotExist(row)) {
+ delegate = letteringSelectionModel;
+ }
+ else {
+ delegate = unlettringSelectionModel;
+ }
+
+ editModel.resetDebitCreditBalance();
delegate.setSelectionInterval(row, column);
}
@@ -36,8 +49,8 @@
/**return true if lettering is null, or not null but empty*/
public boolean letteringNotExist(int row){
boolean emptyOrNull;
-
- String lettering = letteringTableModel.getEntryAt(row).getLettering();
+ entry = letteringTableModel.getEntryAt(row);
+ String lettering = entry.getLettering();
emptyOrNull = (lettering==null||lettering.isEmpty());
return emptyOrNull;
@@ -138,14 +151,4 @@
delegate.removeListSelectionListener(x);
}
- /**clear the selection of the current using model*/
- /*@Override
- public void clearSelection(){
- if (letteringSelectionModel.getSelectedValues().size() == 0) {
- letteringSelectionModel.clearSelection();
- }else{
- unlettringSelectionModel.clearSelection();
- }
- }*/
-
}
Modified: 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 2012-07-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-11 13:02:26 UTC (rev 3513)
@@ -2,6 +2,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
import javax.swing.*;
import java.util.ArrayList;
@@ -12,11 +13,14 @@
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringTableModel letteringTableModel;
protected List<Integer> selectedRows;
+ protected LetteringEditModel editModel;
//Modele de selection du tableau lors de la selection d une entree non lettree
- public UnlettringSelectionModel(LetteringTableModel letteringTableModel) {
+ public UnlettringSelectionModel(LetteringTableModel letteringTableModel, LetteringEditModel editModel) {
this.letteringTableModel = letteringTableModel;
+ this.editModel = editModel;
selectedRows = new ArrayList<Integer>();
+ editModel.resetDebitCreditBalance();
}
@Override
@@ -30,6 +34,7 @@
deleteLine(row);
super.removeSelectionInterval(row, column);
}
+ updateBalanceAndLetteringButton(true);
}
/**
@@ -60,6 +65,36 @@
return false;
}
+ /**PropertyChange on editModel in the handler, and, there,
+ * set values it.
+ * */
+ public void updateBalanceAndLetteringButton(boolean lettering){
+ editModel.resetDebitCreditBalance();
+
+ if (log.isInfoEnabled()) {
+ log.info("size of selectedRows (>?) : " + selectedRows.size());
+ }
+
+ //treatment unuseful if no rows are selected
+ if (selectedRows.size() != 0){
+ for (int row : selectedRows){
+ Entry entryAt = letteringTableModel.getEntryAt(row);
+
+ //Set values for calculation (By LetteringEditModel) of balance
+ editModel.balanceCalcultation(entryAt.getAmount(), entryAt.getDebit());
+ }
+ //For U.I. buttons (Lettering and unlettering)
+ editModel.setUnLettred(!lettering);
+ editModel.setLettred(lettering);
+ }else{
+
+ editModel.setLettred(!lettering);
+ if (log.isInfoEnabled()) {
+ log.info("size of selectedRows : " + selectedRows.size());
+ }
+ }
+ }
+
@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-10 16:18:41 UTC (rev 3512)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-11 13:02:26 UTC (rev 3513)
@@ -46,4 +46,6 @@
log4j.logger.org.chorem.lima.ui.lettering.LetteringTableModel=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LetteringModelUi=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LettringAndUnlettringSelectionModel=DEBUG
-log4j.logger.org.chorem.lima.ui.lettering.LetteringSelectionModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.lettering.LetteringSelectionModel=DEBUG
+log4j.logger.org.chorem.lima.ui.lettering.UnletteringSelectionModel=DEBUG
+log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG
\ No newline at end of file
1
0
r3512 - in trunk: lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 10 Jul '12
by mallon@users.chorem.org 10 Jul '12
10 Jul '12
Author: mallon
Date: 2012-07-10 18:18:41 +0200 (Tue, 10 Jul 2012)
New Revision: 3512
Url: http://chorem.org/repositories/revision/lima/3512
Log:
refs #688 Correction du fichier jaxx, du filtre utilisant les dates et de la requete de selection des entrees, afin de regler le probleme de selection de dates.
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.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/LetteringTableModel.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-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-10 15:17:10 UTC (rev 3511)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-10 16:18:41 UTC (rev 3512)
@@ -201,11 +201,12 @@
}
}
- query += " and :beginDate <= F.transactionDate" +
- " and F.transactionDate <= :endDate"+
- " order by F.transactionDate, F." + FinancialTransaction.TOPIA_CREATE_DATE;
+ query += /*" and :beginDate <= F.transactionDate" +
+ " and F.transactionDate <= :endDate"+*/
+ " and E.financialTransaction.transactionDate between :beginDate and :endDate " +
+ " order by F.transactionDate, F." + FinancialTransaction.TOPIA_CREATE_DATE;
- entries = context.findAll(query, "account", filter.getAccount(), "beginDate", filter.getFiscalDateFilter().getDateStart(), "endDate", filter.getFiscalDateFilter().getDateEnd());
+ entries = context.findAll(query, "account", filter.getAccount(), "beginDate", filter.getBeginDate(), "endDate", filter.getEndDate());
return entries;
}
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-10 15:17:10 UTC (rev 3511)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 16:18:41 UTC (rev 3512)
@@ -29,6 +29,7 @@
String currentLettring = getCurrentLettring();
if (log.isInfoEnabled()) {
log.info("Select line");
+ log.info("Entries : " + getEntries().size());
}
//FIXME allon 10-07-12 : problème de rafraichissement très long
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-10 15:17:10 UTC (rev 3511)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-10 16:18:41 UTC (rev 3512)
@@ -27,12 +27,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.ImportService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.service.LimaServiceFactory;
import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
@@ -54,16 +50,13 @@
* Last update : $Date$
* By : $Author$
*/
-public class LetteringTableModel extends AbstractTableModel implements ServiceListener {
+public class LetteringTableModel extends AbstractTableModel{
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(LetteringTableModel.class);
- /** Transaction service. */
- protected final FinancialTransactionService financialTransactionService;
-
/** Begin Date. */
protected Date selectedBeginDate;
@@ -74,34 +67,11 @@
protected List<Date> datesEntree;
protected List<String> entryBooks;
- /**
- * collection
- * <p/>
- * <p/>
- * /**
- * Model constructor.
- * <p/>
- * Just init service proxies.
- */
- public LetteringTableModel() {
- /* Services */
- financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class,this);
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- }
-
public List<Entry> getEntries(){
return entries;
}
public Integer getIndexOfEntry(Entry entrySearch){
-// Integer index = -1;
-// for (Entry entry : entries){
-// index++;
-// if (entrySearch == entry){
-// return index;
-// }
-// }
return entries.indexOf(entrySearch);
}
@@ -283,14 +253,4 @@
}
fireTableDataChanged();
}
-
- @Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") ||
- methodeName.contains("importEntries") ||
- methodeName.contains("importAll")) {
- fireTableDataChanged();
- }
- }
-
}
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-10 15:17:10 UTC (rev 3511)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 16:18:41 UTC (rev 3512)
@@ -87,7 +87,7 @@
</cell>
<cell>
<JXDatePicker id="pickerDebut"
- onActionPerformed="filterModel.getFiscalDateFilter().setDateStart(pickerDebut.getDate())"/>
+ onActionPerformed="filterModel.setBeginDate(pickerDebut.getDate())"/>
</cell>
</row>
<row>
@@ -96,7 +96,7 @@
</cell>
<cell>
<JXDatePicker id="pickerFin"
- onActionPerformed="filterModel.getFiscalDateFilter().setDateStart(pickerFin.getDate())"/>
+ onActionPerformed="filterModel.setEndDate(pickerFin.getDate())"/>
</cell>
</row>
</Table>
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-10 15:17:10 UTC (rev 3511)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-10 16:18:41 UTC (rev 3512)
@@ -96,6 +96,9 @@
@Override
public void propertyChange(PropertyChangeEvent evt) {
+ if (log.isInfoEnabled()) {
+ log.info("Filter changing...");
+ }
updateAllEntries();
}
});
@@ -145,8 +148,8 @@
log.debug("Val select letter : " + view.getLetteredCheckGroup().getSelectedButton().getName());
- filter.getFiscalDateFilter().setDateStart(defaultDateBegFiscalPeriod);
- filter.getFiscalDateFilter().setDateEnd(defaultDateEndCurrent);
+ filter.setBeginDate(defaultDateBegFiscalPeriod);
+ filter.setEndDate(defaultDateEndCurrent);
updateAllEntries();
@@ -156,7 +159,7 @@
}
protected List<Entry> findAllEntries(LetteringFilter filter){
- if (filter != null && filter.getFiscalDateFilter() != null) {
+ if (filter != null) {
List<Entry> entries =
financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(filter);
return entries;
@@ -170,16 +173,8 @@
log.info("updateAllEntries");
}
- if (filter != null && filter.getFiscalDateFilter() != null) {
+ if (filter != 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>();
@@ -209,8 +204,6 @@
if (row > 0) {
comboBox.setSelectedIndex(row - 1);
}
- /*view.getModelUi().resetDebitCreditBalance();
- view.getModelUi().clearSelection();*/
}
/**
@@ -225,8 +218,6 @@
if (row < size - 1) {
comboBox.setSelectedIndex(row + 1);
}
- view.getLetteringEditModel().resetDebitCreditBalance();
- view.getLettringAndUnlettringSelectionModel().clearSelection();
}
public void setBeginDate(Date date) {
1
0
r3511 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 10 Jul '12
by mallon@users.chorem.org 10 Jul '12
10 Jul '12
Author: mallon
Date: 2012-07-10 17:17:10 +0200 (Tue, 10 Jul 2012)
New Revision: 3511
Url: http://chorem.org/repositories/revision/lima/3511
Log:
refs #688 Correction du fichier jaxx, concernant le probleme de selection de toutes les ecritures.
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/LettringAndUnlettringSelectionModel.java
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-10 15:03:48 UTC (rev 3510)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 15:17:10 UTC (rev 3511)
@@ -126,7 +126,7 @@
<row>
<cell>
<JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup"
- onActionPerformed="filterModel.setDisplayLettered(true) ; filterModel.setDisplayUnlettred(true)"/>
+ onActionPerformed="filterModel.setDisplayLettered(false) ; filterModel.setDisplayUnlettred(false)"/>
</cell>
<cell>
<JLabel text="lima.ui.lettering.checkAll"/>
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-10 15:03:48 UTC (rev 3510)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 15:17:10 UTC (rev 3511)
@@ -38,7 +38,7 @@
boolean emptyOrNull;
String lettering = letteringTableModel.getEntryAt(row).getLettering();
- emptyOrNull = (lettering!=null?lettering.isEmpty():true);
+ emptyOrNull = (lettering==null||lettering.isEmpty());
return emptyOrNull;
}
1
0
r3510 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/lettering resources
by mallon@users.chorem.org 10 Jul '12
by mallon@users.chorem.org 10 Jul '12
10 Jul '12
Author: mallon
Date: 2012-07-10 17:03:48 +0200 (Tue, 10 Jul 2012)
New Revision: 3510
Url: http://chorem.org/repositories/revision/lima/3510
Log:
refs #688 R?\195?\169solution du probl?\195?\168me de choix des mod?\195?\168les ?\195?\160 la s?\195?\169lection d'une entr?\195?\169e lettr?\195?\169e ou non-lettr?\195?\169e.
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/LetteringTableModel.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/LettringAndUnlettringSelectionModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java
trunk/lima-swing/src/main/resources/log4j.properties
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-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 15:03:48 UTC (rev 3510)
@@ -1,15 +1,19 @@
package org.chorem.lima.ui.lettering;
-import jaxx.runtime.swing.model.AbstractGenericListSelectionModel;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Entry;
+import javax.swing.*;
import java.util.List;
/**
* @author sletellier <letellier(a)codelutin.com>
*/
-public class LetteringSelectionModel extends AbstractGenericListSelectionModel<Entry> {
+public class LetteringSelectionModel extends DefaultListSelectionModel {
+ private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringTableModel letteringTableModel;
protected int lineSelected;
@@ -22,42 +26,38 @@
@Override
public void setSelectionInterval(int row, int column){
lineSelected = row;
- super.setSelectionInterval(lineSelected, 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);
+ String currentLettring = getCurrentLettring();
+ if (log.isInfoEnabled()) {
+ log.info("Select line");
+ }
+
+ //FIXME allon 10-07-12 : problème de rafraichissement très long
+ setValueIsAdjusting(true);
+ super.clearSelection();
+ try {
+ //select entries with the same letter of the selected entry
+ for(Entry entry : getEntries()){
+ if (StringUtils.isNotBlank(entry.getLettering())){
+ if (entry.getLettering().equals(currentLettring)){
+ int entryToSelect = letteringTableModel.getIndexOfEntry(entry);
+ super.addSelectionInterval(entryToSelect, entryToSelect);
+ }
}
}
+ } finally {
+ setValueIsAdjusting(false);
}
}
- @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(lineSelected);
- }
-
public String getCurrentLettring(){
return getCurrentEntrySelected().getLettering();
}
- @Override
- public int getSelectionMode() {
- return SINGLE_SELECTION;
+ public Entry getCurrentEntrySelected(){
+ return letteringTableModel.getEntryAt(lineSelected);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-10 15:03:48 UTC (rev 3510)
@@ -95,14 +95,14 @@
}
public Integer getIndexOfEntry(Entry entrySearch){
- Integer index = -1;
- for (Entry entry : entries){
- index++;
- if (entrySearch == entry){
- return index;
- }
- }
- return null;
+// Integer index = -1;
+// for (Entry entry : entries){
+// index++;
+// if (entrySearch == entry){
+// return index;
+// }
+// }
+ return entries.indexOf(entrySearch);
}
public int getNumberOfEntries(){
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-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 15:03:48 UTC (rev 3510)
@@ -191,9 +191,9 @@
id="table" sortable="false" rowHeight="22" editable='true'
constructorParams="getTableModel()"
selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- selectionModel="{lettringAndUnlettringSelectionModel.getSelectedModel()}"
+ selectionModel="{lettringAndUnlettringSelectionModel}"
/>
</JScrollPane>
</cell>
- </row>
+ </row>
</Table>
\ No newline at end of file
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-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 15:03:48 UTC (rev 3510)
@@ -1,84 +1,143 @@
package org.chorem.lima.ui.lettering;
-import jaxx.runtime.swing.model.AbstractGenericListSelectionModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
+import javax.swing.*;
+import javax.swing.event.ListSelectionListener;
+
/**
* @author sletellier <letellier(a)codelutin.com>
*/
-public class LettringAndUnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> {
+public class LettringAndUnlettringSelectionModel implements ListSelectionModel {
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringSelectionModel letteringSelectionModel;
protected UnlettringSelectionModel unlettringSelectionModel;
protected LetteringTableModel letteringTableModel;
- protected boolean modelSelected;
+ protected ListSelectionModel delegate;
public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, UnlettringSelectionModel unlettringSelectionModel, LetteringTableModel letteringTableModel) {
this.letteringSelectionModel = letteringSelectionModel;
this.unlettringSelectionModel = unlettringSelectionModel;
this.letteringTableModel = letteringTableModel;
- modelSelected = false; //By default, unLettred entries
+ delegate = unlettringSelectionModel;
}
/**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)) {
- modelSelected = true;
- letteringSelectionModel.setSelectionInterval(row, column);
- } else {
- if (log.isInfoEnabled()) {
- log.info("Modele de selection utilise : 'unlettringSelectionModel'");
- }
- modelSelected = false;
- unlettringSelectionModel.setSelectionInterval(row, column);
- }
+ delegate=(!letteringNotExist(row)?letteringSelectionModel:unlettringSelectionModel);
+ delegate.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();
+ emptyOrNull = (lettering!=null?lettering.isEmpty():true);
- if (lettering != null){
- emptyOrNull = lettering.isEmpty();
- }else
- emptyOrNull = true;
+ return emptyOrNull;
+ }
- if (log.isInfoEnabled()) {
- log.info("Retour : " + emptyOrNull);
- }
+ @Override
+ public void addSelectionInterval(int index0, int index1) {
+ delegate.addSelectionInterval(index0, index1);
+ }
- return emptyOrNull;
+ @Override
+ public void removeSelectionInterval(int index0, int index1) {
+ delegate.removeSelectionInterval(index0, index1);
}
- /**return number of row in the model*/
@Override
- public int getSize() {
- return letteringTableModel.getRowCount();
+ public int getMinSelectionIndex() {
+ return delegate.getMinSelectionIndex();
}
- /**return the entry at the index indicate*/
@Override
- public Entry getValueAt(int i) {
- return letteringTableModel.getEntryAt(i);
+ public int getMaxSelectionIndex() {
+ return delegate.getMaxSelectionIndex();
}
- public AbstractGenericListSelectionModel<Entry> getSelectedModel(){
- if (modelSelected) {
- return letteringSelectionModel;
- }else{
- return unlettringSelectionModel;
- }
+ @Override
+ public boolean isSelectedIndex(int index) {
+ return delegate.isSelectedIndex(index);
}
+ @Override
+ public int getAnchorSelectionIndex() {
+ return delegate.getAnchorSelectionIndex();
+ }
+
+ @Override
+ public void setAnchorSelectionIndex(int index) {
+ delegate.setAnchorSelectionIndex(index);
+ }
+
+ @Override
+ public int getLeadSelectionIndex() {
+ return delegate.getLeadSelectionIndex();
+ }
+
+ @Override
+ public void setLeadSelectionIndex(int index) {
+ delegate.setLeadSelectionIndex(index);
+ }
+
+ @Override
+ public void clearSelection() {
+ delegate.clearSelection();
+ }
+
+ @Override
+ public boolean isSelectionEmpty() {
+ return delegate.isSelectionEmpty();
+ }
+
+ @Override
+ public void insertIndexInterval(int index, int length, boolean before) {
+ delegate.insertIndexInterval(index, length, before);
+ }
+
+ @Override
+ public void removeIndexInterval(int index0, int index1) {
+ delegate.removeIndexInterval(index0, index1);
+ }
+
+ @Override
+ public void setValueIsAdjusting(boolean valueIsAdjusting) {
+ delegate.setValueIsAdjusting(valueIsAdjusting);
+ }
+
+ @Override
+ public boolean getValueIsAdjusting() {
+ return delegate.getValueIsAdjusting();
+ }
+
+ @Override
+ public void setSelectionMode(int selectionMode) {
+ delegate.setSelectionMode(selectionMode);
+ }
+
+ @Override
+ public int getSelectionMode() {
+ return delegate.getSelectionMode();
+ }
+
+ @Override
+ public void addListSelectionListener(ListSelectionListener x) {
+ delegate.addListSelectionListener(x);
+ }
+
+ @Override
+ public void removeListSelectionListener(ListSelectionListener x) {
+ delegate.removeListSelectionListener(x);
+ }
+
/**clear the selection of the current using model*/
/*@Override
public void clearSelection(){
Modified: 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 2012-07-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-10 15:03:48 UTC (rev 3510)
@@ -1,14 +1,13 @@
package org.chorem.lima.ui.lettering;
-import jaxx.runtime.swing.model.AbstractGenericListSelectionModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
+import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
-public class UnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> {
+public class UnlettringSelectionModel extends DefaultListSelectionModel {
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringTableModel letteringTableModel;
@@ -62,21 +61,6 @@
}
@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-10 11:52:09 UTC (rev 3509)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-10 15:03:48 UTC (rev 3510)
@@ -45,4 +45,5 @@
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
-log4j.logger.org.chorem.lima.ui.lettering.LettringAndUnlettringSelectionModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.lettering.LettringAndUnlettringSelectionModel=DEBUG
+log4j.logger.org.chorem.lima.ui.lettering.LetteringSelectionModel=DEBUG
\ No newline at end of file
1
0
r3509 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 10 Jul '12
by mallon@users.chorem.org 10 Jul '12
10 Jul '12
Author: mallon
Date: 2012-07-10 13:52:09 +0200 (Tue, 10 Jul 2012)
New Revision: 3509
Url: http://chorem.org/repositories/revision/lima/3509
Log:
refs #688 Corrections sur le modele de selection, quand le lettrage n est pas present (null), et sur la selection / deselection de ligne pour les entree non-lettrees
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/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java
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-10 08:26:59 UTC (rev 3508)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509)
@@ -11,6 +11,7 @@
public class LetteringSelectionModel extends AbstractGenericListSelectionModel<Entry> {
protected LetteringTableModel letteringTableModel;
+ protected int lineSelected;
//Modele de selection du tableau lors de la selection d une entree lettree
@@ -20,7 +21,8 @@
@Override
public void setSelectionInterval(int row, int column){
- super.setSelectionInterval(row, column);
+ lineSelected = row;
+ super.setSelectionInterval(lineSelected, column);
//select entries with the same letter of the selected entry
for(Entry entry : getEntries()){
if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
@@ -47,7 +49,7 @@
}
public Entry getCurrentEntrySelected(){
- return letteringTableModel.getEntryAt(super.getMaxSelectionIndex());
+ return letteringTableModel.getEntryAt(lineSelected);
}
public String getCurrentLettring(){
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-10 08:26:59 UTC (rev 3508)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-10 11:52:09 UTC (rev 3509)
@@ -188,10 +188,10 @@
<cell fill="both" weightx="1" weighty="1" columns="4">
<JScrollPane>
<LetteringTable
- id="table" sortable="false" rowHeight="22"
+ id="table" sortable="false" rowHeight="22" editable='true'
constructorParams="getTableModel()"
selectionMode="{ListSelectionModel.MULTIPLE_INTERVAL_SELECTION}"
- selectionModel="{lettringAndUnlettringSelectionModel}"
+ selectionModel="{lettringAndUnlettringSelectionModel.getSelectedModel()}"
/>
</JScrollPane>
</cell>
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-10 08:26:59 UTC (rev 3508)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringAndUnlettringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509)
@@ -14,11 +14,13 @@
protected LetteringSelectionModel letteringSelectionModel;
protected UnlettringSelectionModel unlettringSelectionModel;
protected LetteringTableModel letteringTableModel;
+ protected boolean modelSelected;
public LettringAndUnlettringSelectionModel(LetteringSelectionModel letteringSelectionModel, UnlettringSelectionModel unlettringSelectionModel, LetteringTableModel letteringTableModel) {
this.letteringSelectionModel = letteringSelectionModel;
this.unlettringSelectionModel = unlettringSelectionModel;
this.letteringTableModel = letteringTableModel;
+ modelSelected = false; //By default, unLettred entries
}
/**choice of model : two differents ui reactions, if lettering is present or not*/
@@ -27,12 +29,15 @@
if (log.isInfoEnabled()) {
log.info("Selection de ligne : choix du modele");
}
+
if (!letteringNotExist(row)) {
+ modelSelected = true;
letteringSelectionModel.setSelectionInterval(row, column);
} else {
if (log.isInfoEnabled()) {
log.info("Modele de selection utilise : 'unlettringSelectionModel'");
}
+ modelSelected = false;
unlettringSelectionModel.setSelectionInterval(row, column);
}
}
@@ -66,14 +71,22 @@
return letteringTableModel.getEntryAt(i);
}
+ public AbstractGenericListSelectionModel<Entry> getSelectedModel(){
+ if (modelSelected) {
+ return letteringSelectionModel;
+ }else{
+ return unlettringSelectionModel;
+ }
+ }
+
/**clear the selection of the current using model*/
- @Override
+ /*@Override
public void clearSelection(){
if (letteringSelectionModel.getSelectedValues().size() == 0) {
letteringSelectionModel.clearSelection();
}else{
unlettringSelectionModel.clearSelection();
}
- }
+ }*/
}
Modified: 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 2012-07-10 08:26:59 UTC (rev 3508)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/UnlettringSelectionModel.java 2012-07-10 11:52:09 UTC (rev 3509)
@@ -1,23 +1,66 @@
package org.chorem.lima.ui.lettering;
import jaxx.runtime.swing.model.AbstractGenericListSelectionModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Entry;
+import java.util.ArrayList;
+import java.util.List;
+
public class UnlettringSelectionModel extends AbstractGenericListSelectionModel<Entry> {
+ private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringTableModel letteringTableModel;
+ protected List<Integer> selectedRows;
//Modele de selection du tableau lors de la selection d une entree non lettree
-
public UnlettringSelectionModel(LetteringTableModel letteringTableModel) {
this.letteringTableModel = letteringTableModel;
+ selectedRows = new ArrayList<Integer>();
}
@Override
public void setSelectionInterval(int row, int column){
- super.addSelectionInterval(row, column);
+
+ //Case where line is selected a second time (So, must deselect it on second click)
+ if (selectedRows.isEmpty() || !searchRowSelected(row)){
+ selectedRows.add(row);
+ super.addSelectionInterval(row, column);
+ }else {
+ deleteLine(row);
+ super.removeSelectionInterval(row, column);
+ }
}
+ /**
+ * search the line in a list of selected rows
+ * and delete it
+ * @param row line to delete
+ * */
+ public void deleteLine(int row){
+ for (Integer rowSearching : selectedRows){
+ if (rowSearching == row){
+ selectedRows.remove(rowSearching);
+ break;
+ }
+ }
+ }
+
+ /**search if the selected row is in the list
+ * (List of precedent selected rows)
+ * @param row line searched in the list
+ * @return true if line find
+ * */
+ public boolean searchRowSelected(int row){
+ for (Integer rowSearching : selectedRows){
+ if (rowSearching == row){
+ return true;
+ }
+ }
+ return false;
+ }
+
@Override
public int getSize() {
return letteringTableModel.getRowCount();
1
0
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
by mallon@users.chorem.org 10 Jul '12
by mallon@users.chorem.org 10 Jul '12
10 Jul '12
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(a)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(a)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>
1
0
r3507 - trunk/lima-callao/src/main/java/org/chorem/lima/entity
by mallon@users.chorem.org 09 Jul '12
by mallon@users.chorem.org 09 Jul '12
09 Jul '12
Author: mallon
Date: 2012-07-09 18:36:10 +0200 (Mon, 09 Jul 2012)
New Revision: 3507
Url: http://chorem.org/repositories/revision/lima/3507
Log:
refs #688 Mise en place des mod?\195?\168les de s?\195?\169lection et de filtres : filtre selon les comptes fonctionnel; filtre selon le lettrage quasi-fonctionnel (Pour lettr?\195?\169es et non-lettr?\195?\169es.)
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
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-09 10:23:21 UTC (rev 3506)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-09 16:36:10 UTC (rev 3507)
@@ -25,6 +25,9 @@
package org.chorem.lima.entity;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.LetteringFilter;
import org.nuiton.topia.TopiaException;
import java.util.Date;
@@ -32,6 +35,8 @@
public class EntryDAOImpl<E extends Entry> extends EntryDAOAbstract<Entry> {
+ private static final Log log = LogFactory.getLog(EntryDAOImpl.class);
+
/**
* Requete generique qui recupere les entrees equilibrées portant entre
* deux dates.
@@ -177,22 +182,19 @@
/**
* Retourne toutes les entrées d'une transaction
- * pour un compte et un lettrage
- * @param beginDate debut de la période
- * @param endDate fin de la période
- * @param account compte sur lequel les entrées sont filtrées
- * @param filtreLettre toutes (all), non-lettrées ("null") ou lettrées ("notNull")
+ * 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 TopiaException
* */
- public List<Entry> findAllEntryByAccountAndLettering(Date beginDate, Date endDate, Account account, Boolean filtreLettre) throws TopiaException {
+ public List<Entry> findAllEntryByAccountAndLettering(LetteringFilter filter) throws TopiaException {
List<Entry> entries;
String query = "Select E from " + Entry.class.getName() + " E, " + FinancialTransaction.class.getName() + " F" +
" where E.financialTransaction = F" +
" and E.account = :account ";
- if (filtreLettre != null){
- if (filtreLettre){
+ if (filter.getDisplayLettered() || filter.getDisplayUnlettred()){
+ if (filter.getDisplayUnlettred()){
query += " and E.lettering is null";
}else {
query += " and E.lettering is not null";
@@ -203,7 +205,7 @@
" and F.transactionDate <= :endDate"+
" order by F.transactionDate, F." + FinancialTransaction.TOPIA_CREATE_DATE;
- entries = context.findAll(query, "account", account, "beginDate", beginDate, "endDate", endDate);
+ entries = context.findAll(query, "account", filter.getAccount(), "beginDate", filter.getFiscalDateFilter().getDateStart(), "endDate", filter.getFiscalDateFilter().getDateEnd());
return entries;
}
1
0