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
r3496 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business-api/src/main/java/org/chorem/lima/business/api lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/common lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 06 Jul '12
by mallon@users.chorem.org 06 Jul '12
06 Jul '12
Author: mallon
Date: 2012-07-06 12:17:38 +0200 (Fri, 06 Jul 2012)
New Revision: 3496
Url: http://chorem.org/repositories/revision/lima/3496
Log:
Correction et optimisation sur le filtrage par comptes, p?\195?\169riode et lettrage : cr?\195?\169ation et utilisation d'une nouvelle requ?\195?\170te de s?\195?\169lection.
fixes #683
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/DocumentServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-07-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/DocumentServiceImpl.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -25,25 +25,21 @@
package org.chorem.lima.business.ejb;
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.Color;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
+import com.lowagie.text.BadElementException;
+import com.lowagie.text.Cell;
+import com.lowagie.text.Chapter;
+import com.lowagie.text.DocWriter;
+import com.lowagie.text.Document;
+import com.lowagie.text.DocumentException;
+import com.lowagie.text.Element;
+import com.lowagie.text.Font;
+import com.lowagie.text.PageSize;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.Phrase;
+import com.lowagie.text.Rectangle;
+import com.lowagie.text.Table;
+import com.lowagie.text.html.HtmlWriter;
+import com.lowagie.text.pdf.PdfWriter;
import org.apache.pdfbox.examples.fdf.SetField;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.chorem.lima.beans.BalanceTrial;
@@ -72,22 +68,24 @@
import org.chorem.lima.entity.Identity;
import org.chorem.lima.entity.VatStatement;
-import com.lowagie.text.BadElementException;
-import com.lowagie.text.Cell;
-import com.lowagie.text.Chapter;
-import com.lowagie.text.DocWriter;
-import com.lowagie.text.Document;
-import com.lowagie.text.DocumentException;
-import com.lowagie.text.Element;
-import com.lowagie.text.Font;
-import com.lowagie.text.PageSize;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.Phrase;
-import com.lowagie.text.Rectangle;
-import com.lowagie.text.Table;
-import com.lowagie.text.html.HtmlWriter;
-import com.lowagie.text.pdf.PdfWriter;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.awt.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import static org.nuiton.i18n.I18n._;
+
@Stateless
@Remote(DocumentService.class)
@TransactionAttribute
@@ -750,7 +748,7 @@
// TODO echatellier 20120509, was not about only
// balanced transaction here, normal ?
- List<Entry> entries = entryDAO.findAllEntryOfTransaction(closedPeriodicEntryBook.getEntryBook(),
+ List<Entry> entries = entryDAO.findAllEntryByDateForEntryBook(closedPeriodicEntryBook.getEntryBook(),
closedPeriodicEntryBook.getFinancialPeriod().getBeginDate(),
closedPeriodicEntryBook.getFinancialPeriod().getEndDate());
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-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -260,6 +260,41 @@
}
/**
+ * Get all entries by dates, account and lettering
+ * @param beginDate begin date
+ * @param endDate end date
+ * @param account acount
+ * @param filtreLettre lettering
+ * */
+ @Override
+ public List<Entry> getAllEntrieByDatesAndAccountAndLettering(Date beginDate, Date endDate, Account account, String filtreLettre) throws LimaException {
+ List<FinancialTransaction> financialTransactions = null;
+ List<Entry> entries = new ArrayList<Entry>();
+
+ try{
+ FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
+ financialTransactions = transactionDAO.findAllByDates(beginDate, endDate);
+ }catch (Exception ex){
+ throw new LimaException("Can't get financial transactions", ex);
+ }
+
+ try {
+ EntryDAO entryDAO = getDaoHelper().getEntryDAO();
+ for (FinancialTransaction financialTransaction : financialTransactions){
+ entries.addAll(entryDAO.findAllEntryByAccountAndLettering(financialTransaction, account, filtreLettre));
+ }
+ } catch (Exception ex) {
+ throw new LimaException("Can't get entries", ex);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Entries size : " + entries.size());
+ }
+
+ return entries;
+ }
+
+ /**
* Method used by update entry and remove entry for update amounts.
*/
@Override
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-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-business-api/src/main/java/org/chorem/lima/business/api/FinancialTransactionService.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -25,17 +25,18 @@
package org.chorem.lima.business.api;
-import java.util.Date;
-import java.util.List;
-
import org.chorem.lima.beans.FinancialTransactionSearch;
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;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
+import java.util.Date;
+import java.util.List;
+
/**
* Transaction service.
*
@@ -76,4 +77,6 @@
void removeEntry(Entry entry) throws LimaException;
String getNewLetters() throws LimaException;
+
+ List<Entry> getAllEntrieByDatesAndAccountAndLettering(Date beginDate, Date endDate, Account account, String filtreLettre) throws LimaException;
}
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-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -161,8 +161,8 @@
* @param endDate end date
* @throws TopiaException
*/
- public List<Entry> findAllEntryOfTransaction(EntryBook entryBook, Date beginDate,
- Date endDate) throws TopiaException {
+ public List<Entry> findAllEntryByDateForEntryBook(EntryBook entryBook, Date beginDate,
+ Date endDate) throws TopiaException {
String query = "FROM " + Entry.class.getName() + " E" +
// entre les 2 dates
" WHERE :beginDate <= E.financialTransaction.transactionDate" +
@@ -176,6 +176,31 @@
}
/**
+ * Retourne toutes les entrées d'une transaction
+ * pour un compte et un lettrage
+ *
+ * @param financialTransaction transaction sur laquelle les entrées sont filtrées
+ * @param account compte sur lequel les entrées sont filtrées
+ * @param filtreLettre toutes (all), non-lettrées ("null") ou lettrées ("notNull")
+ * @throws TopiaException
+ * */
+ public List<Entry> findAllEntryByAccountAndLettering(FinancialTransaction financialTransaction, Account account, String filtreLettre) throws TopiaException {
+ List<Entry> entries = null;
+
+ String query = "from " + Entry.class.getName() + " E " +
+ " where E.financialTransaction = :financialTransaction" +
+ " and E.account = :account ";
+ if (filtreLettre.equals("null")){
+ query += " and E.lettering is null";
+ }else if (filtreLettre.equals("notNull")){
+ query += " and E.lettering is not null";
+ }
+
+ entries = context.findAll(query, "financialTransaction", financialTransaction, "account", account);
+ return entries;
+ }
+
+ /**
* Retourne la somme des entrées des transaction entre
* deux dates pour un journal donné.
*
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-07-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -25,17 +25,17 @@
package org.chorem.lima.entity;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
import org.apache.commons.collections.CollectionUtils;
import org.chorem.lima.FinancialStatementWayEnum;
import org.chorem.lima.beans.FinancialTransactionSearch;
import org.hibernate.HibernateException;
import org.nuiton.topia.TopiaException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Ajout de requetes specifiques aux financial transaction sur le DAO.
*
@@ -261,7 +261,7 @@
return result;
}
-
+
/**
* Search financial transaction.
*
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountComboBoxModel.java 2012-07-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountComboBoxModel.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -40,7 +40,7 @@
/*By default, selection of the account 4*/
@Override
- public Object getElementAt(int index) {
+ public Account getElementAt(int index) {
if (getSelectedItem() == null){
int indexAccountFour = 0;
for (Account compte : objects){
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-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-06 10:17:38 UTC (rev 3496)
@@ -28,8 +28,7 @@
<import>
org.chorem.lima.ui.common.AccountComboBoxModel
org.chorem.lima.ui.common.FinancialPeriodComboBoxModel
- org.chorem.lima.entity.FiscalPeriod
- org.chorem.lima.entity.FinancialPeriod
+ org.chorem.lima.entity.Account
javax.swing.ListSelectionModel
org.jdesktop.swingx.JXDatePicker;
</import>
@@ -65,7 +64,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(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
<JButton id="backCount" text="lima.ui.account.buttonback"
onActionPerformed="handler.back(accountComboBox)"/>
<JButton id="nextCount" text="lima.ui.account.buttonnext"
@@ -81,7 +80,7 @@
</cell>
<cell>
<JXDatePicker id="pickerDebut"
- onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
</cell>
</row>
<row>
@@ -90,7 +89,7 @@
</cell>
<cell>
<JXDatePicker id="pickerFin"
- onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
</cell>
</row>
</Table>
@@ -101,8 +100,8 @@
<Table>
<row>
<cell>
- <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup"
- onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ <JRadioButton id="lettredEntryCheckBox" buttonGroup="letteredCheckGroup" value="notNull"
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
</cell>
<cell>
<JLabel text="lima.ui.lettering.checkLettredEntry"/>
@@ -110,8 +109,8 @@
</row>
<row>
<cell>
- <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup"
- onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ <JRadioButton id="noLettredEntryCheckBox" selected="true" buttonGroup="letteredCheckGroup" value="null"
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
</cell>
<cell>
<JLabel text="lima.ui.lettering.checkNoLettredEntry"/>
@@ -119,8 +118,8 @@
</row>
<row>
<cell>
- <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup"
- onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), accountComboBox.getSelectedItem(), letteredCheckGroup.getSelectedButton().getName())"/>
+ <JRadioButton id="allCheckBox" buttonGroup="letteredCheckGroup" value="all"
+ onActionPerformed="handler.updateAllEntries(pickerDebut.getDate(), pickerFin.getDate(), (Account)accountComboBox.getSelectedItem(), (String)letteredCheckGroup.getSelectedValue())"/>
</cell>
<cell>
<JLabel text="lima.ui.lettering.checkAll"/>
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-06 07:57:01 UTC (rev 3495)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-06 10:17:38 UTC (rev 3496)
@@ -36,7 +36,6 @@
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -132,40 +131,25 @@
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, view.getAccountComboBoxModel().getSelectedItem(), view.getLetteredCheckGroup().getSelectedButton().getName());
+ updateAllEntries(defaultDateBegFiscalPeriod, defaultDateEndCurrent, (Account)view.getAccountComboBoxModel().getSelectedItem(), (String)view.getLetteredCheckGroup().getSelectedValue());
if (log.isInfoEnabled()) {
log.info("Nb entries model (After update all entries) : " + view.getTableModel().getNumberOfEntries());
}
}
- protected List<Entry> findAllEntries(Date selectedBeginDate, Date selectedEndDate, Object compte, String filtreLettre){
-
- List<Entry> entries = new ArrayList<Entry>();
- List<Entry> entriesAccount = new ArrayList<Entry>();
+ protected List<Entry> findAllEntries(Date selectedBeginDate, Date selectedEndDate, Account compte, String filtreLettre){
if (selectedBeginDate != null && selectedEndDate != null) {
- List<FinancialTransaction> financialtransactions =
- financialTransactionService.getAllFinancialTransactions(selectedBeginDate, selectedEndDate);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- entries = (List<Entry>) financialtransaction.getEntry();
+ if (log.isInfoEnabled()) {
+ log.info("FiltreLettre : " + filtreLettre);
}
- if (compte != null){
- for(Entry entry : entries){
- log.debug("entry.getLettering() : " + entry.getLettering());
- log.debug("name radioButton : " + filtreLettre);
- //0 for lettered, 1 for no-lettered and 2 for all entries
- if (compte.equals(entry.getAccount()) && ( (filtreLettre.equals("noLettredEntryCheckBox") & entry.getLettering() == null))
- || (filtreLettre.equals("lettredEntryCheckBox") & entry.getLettering() != null) || filtreLettre.equals("allCheckBox")){
- entriesAccount.add(entry);
- }
- }
- log.debug("entriesAccount size : " + entriesAccount.size());
- return entriesAccount;
- }
+ List<Entry> entries =
+ financialTransactionService.getAllEntrieByDatesAndAccountAndLettering(selectedBeginDate, selectedEndDate, compte, filtreLettre);
+ return entries;
}
- return entries;
+ return null;
}
- public void updateAllEntries(Date selectedBeginDate, Date selectedEndDate, Object compte, String filtreLettre) {
+ public void updateAllEntries(Date selectedBeginDate, Date selectedEndDate, Account compte, String filtreLettre) {
if (selectedBeginDate != null && selectedEndDate != null){
log.debug("updateAllEntries");
1
0
r3495 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 06 Jul '12
by mallon@users.chorem.org 06 Jul '12
06 Jul '12
Author: mallon
Date: 2012-07-06 09:57:01 +0200 (Fri, 06 Jul 2012)
New Revision: 3495
Url: http://chorem.org/repositories/revision/lima/3495
Log:
Correction pour la d?\195?\169s?\195?\169lection de lignes quand :
- une ?\195?\169criture lettr?\195?\169e est s?\195?\169lectionn?\195?\169e, puis une non-lettr?\195?\169e s?\195?\169lectionn?\195?\169e ?\195?\160 son tour.
- un filtre est utilis?\195?\169.
refs #681
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/LetteringViewHandler.java
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-05 16:31:54 UTC (rev 3494)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-06 07:57:01 UTC (rev 3495)
@@ -154,10 +154,16 @@
// no line selected or line selected different of the current
if (isSelectionEmpty() || currentEntry != null || !currentLettring.equals(entryAt.getLettering())){
-
+ if (log.isInfoEnabled()) {
+ log.info("First");
+ }
//Test not null for currentEntry cause of selection before of entry without letter
- if (currentEntry != null){
+ 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;
@@ -179,8 +185,15 @@
//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(entryAt)){
+ 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;
@@ -260,10 +273,4 @@
// do nothing
}
- @Override
- public void clearSelection() {
- // do nothing
- }
-
-
}
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-05 16:31:54 UTC (rev 3494)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-06 07:57:01 UTC (rev 3495)
@@ -184,6 +184,7 @@
}
}
view.getModelUi().resetDebitCreditBalance();
+ view.getModelUi().clearSelection();
}
/**
@@ -198,6 +199,7 @@
comboBox.setSelectedIndex(row - 1);
}
view.getModelUi().resetDebitCreditBalance();
+ view.getModelUi().clearSelection();
}
/**
@@ -213,6 +215,7 @@
comboBox.setSelectedIndex(row + 1);
}
view.getModelUi().resetDebitCreditBalance();
+ view.getModelUi().clearSelection();
}
public void setBeginDate(Date date) {
@@ -245,12 +248,6 @@
}
}
- /*public void nonConsecutiveSelection(int[] selectedRows){
- for (int row : selectedRows){
- view.getTable().addRowSelectionInterval(row, row);
- }
- }*/
-
@Override
public void notifyMethod(String serviceName, String methodeName) {
}
1
0
r3494 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 05 Jul '12
by mallon@users.chorem.org 05 Jul '12
05 Jul '12
Author: mallon
Date: 2012-07-05 18:31:54 +0200 (Thu, 05 Jul 2012)
New Revision: 3494
Url: http://chorem.org/repositories/revision/lima/3494
Log:
Correction du mod?\195?\168le de l'interface de lettrage pour la remise ?\195?\160 z?\195?\169ro des montants de d?\195?\169bit / cr?\195?\169dit / solde, lors de l'utilisation des filtres.
fixes #682
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/LetteringTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
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-05 15:21:06 UTC (rev 3493)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 16:31:54 UTC (rev 3494)
@@ -28,7 +28,6 @@
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
- /** log. */
private static final Log log = LogFactory.getLog(LetteringModelUI.class);
protected LetteringTableModel model;
@@ -49,6 +48,15 @@
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;
}
@@ -108,7 +116,7 @@
this.solde = solde;
firePropertyChange(SOLDE_PROPERTY, oldSolde, solde);
}
-
+
public void addPropertyChangeListener(PropertyChangeListener listener) {
pcs.addPropertyChangeListener(listener);
}
@@ -136,6 +144,8 @@
@Override
public void setSelectionInterval(int row, int column) {
+ setLettrer(false);
+ setDelettrer(false);
Entry entryAt = model.getEntryAt(row);
List<Entry> modelEntries = model.getEntries();
setSelectedEntry(entryAt);
@@ -167,9 +177,9 @@
}
}else{
//no line selected or line selected different of the current
- //Test null for currentEntry cause of selection before of entry with letter
+ //Test null for currentEntry cause of selection before entry with letter
if (isSelectionEmpty() || currentEntry == null || !currentEntry.equals(entryAt)){
- if (currentLettring != null){
+ if (currentEntry == null && currentLettring != null){
super.clearSelection();
debitTotal = BigDecimal.ZERO;
creditTotal = BigDecimal.ZERO;
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-05 15:21:06 UTC (rev 3493)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-05 16:31:54 UTC (rev 3494)
@@ -59,7 +59,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
private static final Log log = LogFactory.getLog(LetteringTableModel.class);
/** Transaction service. */
@@ -106,7 +105,7 @@
return null;
}
- public int getNUmberOfEntries(){
+ public int getNumberOfEntries(){
return entries.size();
}
@@ -134,10 +133,6 @@
selectedEndDate = date;
}
- public void removeLetter(int row) {
- //TODO
- }
-
@Override
public int getColumnCount() {
return 7;
@@ -289,33 +284,6 @@
fireTableDataChanged();
}
- /** to modifiy letter entry */
- /* @Override
- public void setValueAt(Object value, int row, int column) {*/
- //TODO
- /*int financialTransactionRow = 0;
- if (cacheDataList != null) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry) currentRow;
- switch (column) {
- case 4:
- currentEntry.setLettering((String) value);
- break;
- }
-
- financialTransactionService.updateEntry(currentEntry);*/
-
- //update the financial transaction in entire
- /*financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
- getFinancialTransaction());*/
- /* }
- //on recharge la liste
- fireTableRowsUpdated(financialTransactionRow, getRowCount() - 1);
- }*/
- //}
-
@Override
public void notifyMethod(String serviceName, String methodeName) {
if (serviceName.contains("FinancialTransaction") ||
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-05 15:21:06 UTC (rev 3493)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-05 16:31:54 UTC (rev 3494)
@@ -57,19 +57,12 @@
*/
public class LetteringViewHandler implements ServiceListener{
- /** log. */
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringView view;
protected LetteringTable table;
- /*protected LetteringTableModel tableModel;
-
- protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel;
-
- protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel;*/
-
/** Transaction service. */
protected FiscalPeriodService fiscalPeriodService;
protected FinancialPeriodService financialPeriodService;
@@ -92,50 +85,6 @@
*/
public void init() {
loadComboAndRows();
- /*LetteringModelUI modelUi = view.getModelUi();
-
- modelUi.addListSelectionListener(new ListSelectionListener(){
- List<Entry> entries = new ArrayList<Entry>();
-
- @Override
- public void valueChanged(ListSelectionEvent evt) {
-
- LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource();
- if (evt.getValueIsAdjusting()){
- LetteringTableModel tableModel = view.getTableModel();
- LetteringTable table = view.getTable();
- int nbEntriesModel = tableModel.getNUmberOfEntries();
-
- Entry lastEntry = tableModel.getEntryAt(evt.getLastIndex());
- int nbSelectedRowTable = table.getSelectedRows().length;
- int sizeEntries = entries.size();
-
- if (log.isInfoEnabled()) {
- log.info("Size list entries : " + sizeEntries + "\n" +
- "Nb selected row : " + nbSelectedRowTable + "\n"+
- "Nb ligne model : " + nbEntriesModel);
- }
-
- //Managing selection
- if (nbSelectedRowTable > sizeEntries || (nbSelectedRowTable==sizeEntries && nbSelectedRowTable==1)){
- entries.add(lastEntry);
- if (log.isInfoEnabled()) {
- log.info("Add entry");
- }
- }else if (nbSelectedRowTable < sizeEntries){
- entries.remove(entries.size() - 1);
- if (log.isInfoEnabled()) {
- log.info("Remove entry");
- }
- }
-
- if (log.isInfoEnabled()) {
- log.info("Size entries after update : " + entries.size());
- }
- loadCurrentSelection(modelUiPropChange, entries);
- }
- }
- });*/
}
public void loadComboAndRows(){
@@ -185,7 +134,7 @@
//Load entry with the default dates, default account 4 and with no letter
updateAllEntries(defaultDateBegFiscalPeriod, defaultDateEndCurrent, view.getAccountComboBoxModel().getSelectedItem(), view.getLetteredCheckGroup().getSelectedButton().getName());
if (log.isInfoEnabled()) {
- log.info("Nb entries model (After update all entries) : " + view.getTableModel().getNUmberOfEntries());
+ log.info("Nb entries model (After update all entries) : " + view.getTableModel().getNumberOfEntries());
}
}
@@ -231,9 +180,10 @@
view.getTableModel().updateEntries(entries, datesEntree, journalEntrees);
if (log.isInfoEnabled()) {
- log.info("Nb entries model : " + view.getTableModel().getNUmberOfEntries());
+ log.info("Nb entries model : " + view.getTableModel().getNumberOfEntries());
}
}
+ view.getModelUi().resetDebitCreditBalance();
}
/**
@@ -247,6 +197,7 @@
if (row > 0) {
comboBox.setSelectedIndex(row - 1);
}
+ view.getModelUi().resetDebitCreditBalance();
}
/**
@@ -261,6 +212,7 @@
if (row < size - 1) {
comboBox.setSelectedIndex(row + 1);
}
+ view.getModelUi().resetDebitCreditBalance();
}
public void setBeginDate(Date date) {
1
0
r3493 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/lettering resources
by mallon@users.chorem.org 05 Jul '12
by mallon@users.chorem.org 05 Jul '12
05 Jul '12
Author: mallon
Date: 2012-07-05 17:21:06 +0200 (Thu, 05 Jul 2012)
New Revision: 3493
Url: http://chorem.org/repositories/revision/lima/3493
Log:
Correction du mod?\195?\168le de l'interface de lettrage pour les calculs du d?\195?\169bit, cr?\195?\169dit et de la solde, en fonction des ?\195?\169critures s?\195?\169lectionn?\195?\169es.
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/LetteringTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/resources/log4j.properties
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-05 13:10:00 UTC (rev 3492)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 15:21:06 UTC (rev 3493)
@@ -1,5 +1,7 @@
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.*;
@@ -25,16 +27,21 @@
private static final long serialVersionUID = 1L;
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
-
+
+ /** log. */
+ 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 Entry currentEntry;
@@ -130,6 +137,7 @@
@Override
public void setSelectionInterval(int row, int column) {
Entry entryAt = model.getEntryAt(row);
+ List<Entry> modelEntries = model.getEntries();
setSelectedEntry(entryAt);
if (entryAt.getLettering() != null){
@@ -140,12 +148,14 @@
//Test not null for currentEntry cause of selection before of entry without letter
if (currentEntry != null){
super.clearSelection();
+ debitTotal = BigDecimal.ZERO;
+ creditTotal = BigDecimal.ZERO;
+ soldeTotal = BigDecimal.ZERO;
}
currentLettring = entryAt.getLettering();
super.setSelectionInterval(row, column);
//select entries with the same letter of the selected entry
- List<Entry> modelEntries = model.getEntries();
for(Entry entry : modelEntries){
if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
if (entry.getLettering().equals(entryAt.getLettering())){
@@ -155,24 +165,79 @@
}
}
}
-
}else{
-
//no line selected or line selected different of the current
//Test null for currentEntry cause of selection before of entry with letter
if (isSelectionEmpty() || currentEntry == null || !currentEntry.equals(entryAt)){
- if (currentEntry == null){
+ if (currentLettring != null){
super.clearSelection();
+ debitTotal = BigDecimal.ZERO;
+ creditTotal = BigDecimal.ZERO;
+ soldeTotal = BigDecimal.ZERO;
}
currentEntry = entryAt;
super.addSelectionInterval(row, column);
- //remove entry and get precedent entry for currentEntry
+ //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()){
+
+ boolean debitSelected = selectedEntry.getDebit();
+ BigDecimal amountSelected = selectedEntry.getAmount();
+
+ BigDecimal debitVal = debitSelected ? amountSelected : BigDecimal.ZERO;
+
+ if (log.isInfoEnabled()) {
+ log.info("debit : " + debitTotal + "\n" +
+ "credit : " + creditTotal + "\n" +
+ "solde : " + soldeTotal);
+ }
+
+ if (debitVal == BigDecimal.ZERO){
+ BigDecimal creditVal = debitSelected ? BigDecimal.ZERO : amountSelected;
+
+ if (creditVal != BigDecimal.ZERO){
+ creditTotal = creditTotal.add(creditVal);
+ soldeTotal = soldeTotal.subtract(creditVal);
+ }else{
+ creditTotal = creditTotal.add(creditVal);
+ soldeTotal = soldeTotal.add(creditVal);
+ }
+ }else{
+ debitTotal = debitTotal.add(debitVal);
+ soldeTotal = soldeTotal.add(debitVal);
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("AFTER / debit : " + debitTotal + "\n" +
+ "credit : " + creditTotal + "\n" +
+ "solde : " + soldeTotal);
+ }
+
+ setDebit(debitTotal);
+ setCredit(creditTotal);
+ setSolde(soldeTotal);
+
+ //Managing lettering buttons
+ String lettering = null;
+
+ //lettering impossible if one of entries have letter
+ lettering = entryAt.getLettering();
+ if (lettering != null && !lettering.isEmpty()){
+ setDelettrer(true);
+ }
+
+ if (solde.intValue() == 0 && !delettrer){
+ setLettrer(true);
+ }
+ }
}
@Override
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-05 13:10:00 UTC (rev 3492)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-05 15:21:06 UTC (rev 3493)
@@ -116,9 +116,6 @@
setDate(datesEntree);
setJournal(entryBooks);
fireTableDataChanged();
- if (log.isInfoEnabled()) {
- log.info("Nb entries model (In model) : " + getNUmberOfEntries());
- }
}
protected void setDate(List<Date> datesEntree){
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-05 13:10:00 UTC (rev 3492)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-05 15:21:06 UTC (rev 3493)
@@ -41,9 +41,6 @@
import org.chorem.lima.service.LimaServiceFactory;
import javax.swing.*;
-import javax.swing.event.ListSelectionEvent;
-import javax.swing.event.ListSelectionListener;
-import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
@@ -61,8 +58,7 @@
public class LetteringViewHandler implements ServiceListener{
/** log. */
- private static final Log log =
- LogFactory.getLog(LetteringViewHandler.class);
+ private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
protected LetteringView view;
@@ -96,7 +92,7 @@
*/
public void init() {
loadComboAndRows();
- LetteringModelUI modelUi = view.getModelUi();
+ /*LetteringModelUI modelUi = view.getModelUi();
modelUi.addListSelectionListener(new ListSelectionListener(){
List<Entry> entries = new ArrayList<Entry>();
@@ -139,7 +135,7 @@
loadCurrentSelection(modelUiPropChange, entries);
}
}
- });
+ });*/
}
public void loadComboAndRows(){
@@ -240,82 +236,6 @@
}
}
- /**Managing components when n rows are selected
- * */
- public void loadCurrentSelection(LetteringModelUI modelUi, List<Entry> selectedEntries){
- financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
-
- if (selectedEntries.size() > 0){
-
- boolean enableLettring = false;
- boolean enableDelettring = false;
- BigDecimal soldeTotal = BigDecimal.ZERO;
- BigDecimal creditTotal = BigDecimal.ZERO;
- BigDecimal debitTotal = BigDecimal.ZERO;
-
- for (Entry selectedEntry : selectedEntries) {
- //Managing balance, credit and debit
- boolean debitSelected = selectedEntry.getDebit();
- BigDecimal amountSelected = selectedEntry.getAmount();
-
-
- if (log.isInfoEnabled()) {
- log.info("amountSelected : " + amountSelected);
- }
- modelUi.setDebit(debitSelected ? amountSelected : BigDecimal.ZERO);
- modelUi.setCredit(debitSelected ? BigDecimal.ZERO : amountSelected);
-
- BigDecimal debitVal = modelUi.getDebit();
- if (log.isInfoEnabled()) {
- log.info("Debit actuel : " + debitVal);
- }
- if (debitVal == BigDecimal.ZERO){
- BigDecimal creditVal = modelUi.getCredit();
- if (log.isInfoEnabled()) {
- log.info("creditVal : " + creditVal);
- }
- if (creditVal != BigDecimal.ZERO){
- creditTotal = creditTotal.add(creditVal);
- creditVal = new BigDecimal("-" + creditVal.toString());
- if (log.isInfoEnabled()) {
- log.info("creditVal neg : " + creditVal);
- }
- soldeTotal = soldeTotal.add(creditVal);
- }else{
- creditTotal = creditTotal.add(creditVal);
- soldeTotal = soldeTotal.add(creditVal);
- }
- }else{
- debitTotal = debitTotal.add(debitVal);
- soldeTotal = soldeTotal.add(debitVal);
- }
- }
-
- modelUi.setSolde(soldeTotal);
- modelUi.setCredit(creditTotal);
- modelUi.setDebit(debitTotal);
-
- //Managing lettering buttons
- String lettering = null;
-
- //lettering impossible if one of entries have letter
- for (Entry selectedEntry : selectedEntries) {
- lettering = selectedEntry.getLettering();
- if (lettering != null && !lettering.isEmpty()){
- enableDelettring= true;
- break;
- }
- }
-
- if (soldeTotal.intValue() == 0 && !enableDelettring & view.getTable().getSelectedRows().length > 1){
- enableLettring = true;
- }
-
- modelUi.setLettrer(enableLettring);
- modelUi.setDelettrer(enableDelettring);
- }
- }
-
/**
* Select previous value in combo box.
*
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-07-05 13:10:00 UTC (rev 3492)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-05 15:21:06 UTC (rev 3493)
@@ -44,4 +44,4 @@
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.LetteringTableSelectionModel=DEBUG
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.lettering.LetteringModelUi=DEBUG
\ No newline at end of file
1
0
r3492 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 05 Jul '12
by mallon@users.chorem.org 05 Jul '12
05 Jul '12
Author: mallon
Date: 2012-07-05 15:10:00 +0200 (Thu, 05 Jul 2012)
New Revision: 3492
Url: http://chorem.org/repositories/revision/lima/3492
Log:
Correction du mod?\195?\168le de l'interface de lettrage pour la s?\195?\169lection des entr?\195?\169es avec uniquement la souris, lorsque toutes les entr?\195?\169es sont s?\195?\169lectionn?\195?\169es.
Modified:
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/LetteringModelUI.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 12:49:53 UTC (rev 3491)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 13:10:00 UTC (rev 3492)
@@ -133,8 +133,15 @@
setSelectedEntry(entryAt);
if (entryAt.getLettering() != null){
+
// no line selected or line selected different of the current
- if (isSelectionEmpty() || !currentLettring.equals(entryAt.getLettering())){
+ if (isSelectionEmpty() || currentEntry != null || !currentLettring.equals(entryAt.getLettering())){
+
+ //Test not null for currentEntry cause of selection before of entry without letter
+ if (currentEntry != null){
+ super.clearSelection();
+ }
+
currentLettring = entryAt.getLettering();
super.setSelectionInterval(row, column);
//select entries with the same letter of the selected entry
@@ -148,11 +155,18 @@
}
}
}
+
}else{
+
//no line selected or line selected different of the current
- if (isSelectionEmpty() || !currentEntry.equals(entryAt)){
+ //Test null for currentEntry cause of selection before of entry with letter
+ if (isSelectionEmpty() || currentEntry == null || !currentEntry.equals(entryAt)){
+ if (currentEntry == null){
+ super.clearSelection();
+ }
currentEntry = entryAt;
super.addSelectionInterval(row, column);
+
//remove entry and get precedent entry for currentEntry
}else {
super.removeSelectionInterval(row, column);
1
0
r3491 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 05 Jul '12
by mallon@users.chorem.org 05 Jul '12
05 Jul '12
Author: mallon
Date: 2012-07-05 14:49:53 +0200 (Thu, 05 Jul 2012)
New Revision: 3491
Url: http://chorem.org/repositories/revision/lima/3491
Log:
Modification du mod?\195?\168le de l'interface de lettrage pour la s?\195?\169lection des entr?\195?\169es avec uniquement la souris.
Modified:
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/LetteringModelUI.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 11:56:32 UTC (rev 3490)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 12:49:53 UTC (rev 3491)
@@ -36,6 +36,7 @@
protected boolean delettrer;
protected String currentLettring;
+ protected Entry currentEntry;
public LetteringModelUI(LetteringTableModel model) {
this.model = model;
@@ -130,21 +131,33 @@
public void setSelectionInterval(int row, int column) {
Entry entryAt = model.getEntryAt(row);
setSelectedEntry(entryAt);
- //if no line selected or if line selected different of the current
- if (isSelectionEmpty() || !currentLettring.equals(entryAt.getLettering())){
- this.currentLettring = entryAt.getLettering();
- super.setSelectionInterval(row, column);
- //select entries with the same letter of the selected entry
- List<Entry> modelEntries = model.getEntries();
- for(Entry entry : modelEntries){
- if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
- if (entry.getLettering().equals(entryAt.getLettering())){
- int entryToSelect = model.getIndexOfEntry(entry);
- super.addSelectionInterval(entryToSelect, entryToSelect);
+
+ if (entryAt.getLettering() != null){
+ // no line selected or line selected different of the current
+ if (isSelectionEmpty() || !currentLettring.equals(entryAt.getLettering())){
+ currentLettring = entryAt.getLettering();
+ super.setSelectionInterval(row, column);
+ //select entries with the same letter of the selected entry
+ List<Entry> modelEntries = model.getEntries();
+ for(Entry entry : modelEntries){
+ if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
+ if (entry.getLettering().equals(entryAt.getLettering())){
+ int entryToSelect = model.getIndexOfEntry(entry);
+ super.addSelectionInterval(entryToSelect, entryToSelect);
+ }
}
}
}
-
+ }else{
+ //no line selected or line selected different of the current
+ if (isSelectionEmpty() || !currentEntry.equals(entryAt)){
+ currentEntry = entryAt;
+ super.addSelectionInterval(row, column);
+ //remove entry and get precedent entry for currentEntry
+ }else {
+ super.removeSelectionInterval(row, column);
+ currentEntry = model.getEntryAt(super.getMaxSelectionIndex());
+ }
}
}
1
0
r3490 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/lettering resources
by mallon@users.chorem.org 05 Jul '12
by mallon@users.chorem.org 05 Jul '12
05 Jul '12
Author: mallon
Date: 2012-07-05 13:56:32 +0200 (Thu, 05 Jul 2012)
New Revision: 3490
Url: http://chorem.org/repositories/revision/lima/3490
Log:
Modification du mod?\195?\168le de l'interface de lettrage pour la s?\195?\169lection des entr?\195?\169es ayant le m?\195?\170me lettrage que la ligne s?\195?\169lectionn?\195?\169e.
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/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/LetteringViewHandler.java
trunk/lima-swing/src/main/resources/log4j.properties
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-04 16:55:47 UTC (rev 3489)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-05 11:56:32 UTC (rev 3490)
@@ -6,6 +6,7 @@
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.math.BigDecimal;
+import java.util.List;
public class LetteringModelUI extends DefaultListSelectionModel{
@@ -34,6 +35,12 @@
protected boolean lettrer;
protected boolean delettrer;
+ protected String currentLettring;
+
+ public LetteringModelUI(LetteringTableModel model) {
+ this.model = model;
+ }
+
public Entry getSelectedEntry() {
return selectedEntry;
}
@@ -64,10 +71,6 @@
firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, delettrer);
}
- public LetteringModelUI(LetteringTableModel model) {
- this.model = model;
- }
-
public BigDecimal getDebit() {
return debit;
}
@@ -119,15 +122,46 @@
}
@Override
+ public int getSelectionMode() {
+ return MULTIPLE_INTERVAL_SELECTION;
+ }
+
+ @Override
public void setSelectionInterval(int row, int column) {
- super.setSelectionInterval(row, column);
- setSelectedEntry(model.getEntryAt(row));
+ Entry entryAt = model.getEntryAt(row);
+ setSelectedEntry(entryAt);
+ //if no line selected or if line selected different of the current
+ if (isSelectionEmpty() || !currentLettring.equals(entryAt.getLettering())){
+ this.currentLettring = entryAt.getLettering();
+ super.setSelectionInterval(row, column);
+ //select entries with the same letter of the selected entry
+ List<Entry> modelEntries = model.getEntries();
+ for(Entry entry : modelEntries){
+ if (entry.getLettering() != null && !entry.getLettering().isEmpty()){
+ if (entry.getLettering().equals(entryAt.getLettering())){
+ int entryToSelect = model.getIndexOfEntry(entry);
+ super.addSelectionInterval(entryToSelect, entryToSelect);
+ }
+ }
+ }
+
+ }
}
@Override
- public int getSelectionMode() {
- return MULTIPLE_INTERVAL_SELECTION;
+ public void addSelectionInterval(int index0, int index1) {
+ setSelectionInterval(index0, index1);
}
+ @Override
+ public void removeSelectionInterval(int index0, int index1) {
+ // do nothing
+ }
+ @Override
+ public void clearSelection() {
+ // do nothing
+ }
+
+
}
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-04 16:55:47 UTC (rev 3489)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2012-07-05 11:56:32 UTC (rev 3490)
@@ -55,15 +55,11 @@
protected LetteringViewHandler handler;
- /*private Highlighter colorTransaction;
+ //protected LetteringTableModel letteringTableModel;
- private ColorHighlighter colorBalance;*/
-
- protected LetteringTableModel letteringTableModel;
-
public LetteringTable(LetteringTableModel letteringTableModel) {
super(letteringTableModel);
- this.letteringTableModel = letteringTableModel;
+ //this.letteringTableModel = letteringTableModel;
addKeyListener(this);
addMouseListener(this);
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-04 16:55:47 UTC (rev 3489)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2012-07-05 11:56:32 UTC (rev 3490)
@@ -25,14 +25,6 @@
package org.chorem.lima.ui.lettering;
-import static org.nuiton.i18n.I18n._;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ServiceListener;
@@ -42,6 +34,13 @@
import org.chorem.lima.entity.Entry;
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._;
+
/**
* Basic transaction table model.
* <p/>
@@ -96,12 +95,30 @@
return entries;
}
+ public Integer getIndexOfEntry(Entry entrySearch){
+ Integer index = -1;
+ for (Entry entry : entries){
+ index++;
+ if (entrySearch == entry){
+ return index;
+ }
+ }
+ return null;
+ }
+
+ public int getNUmberOfEntries(){
+ return entries.size();
+ }
+
public void updateEntries(List<Entry> entries,List<Date> datesEntree, List<String> entryBooks) {
this.entries = entries;
setDate(datesEntree);
setJournal(entryBooks);
fireTableDataChanged();
+ if (log.isInfoEnabled()) {
+ log.info("Nb entries model (In model) : " + getNUmberOfEntries());
+ }
}
protected void setDate(List<Date> datesEntree){
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-04 16:55:47 UTC (rev 3489)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-05 11:56:32 UTC (rev 3490)
@@ -100,25 +100,33 @@
modelUi.addListSelectionListener(new ListSelectionListener(){
List<Entry> entries = new ArrayList<Entry>();
+
@Override
public void valueChanged(ListSelectionEvent evt) {
LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource();
if (evt.getValueIsAdjusting()){
- Entry lastEntry = view.getTableModel().getEntryAt(evt.getLastIndex());
- int nbSelectedRowModel = view.getTable().getSelectedRows().length;
+ LetteringTableModel tableModel = view.getTableModel();
+ LetteringTable table = view.getTable();
+ int nbEntriesModel = tableModel.getNUmberOfEntries();
+
+ Entry lastEntry = tableModel.getEntryAt(evt.getLastIndex());
+ int nbSelectedRowTable = table.getSelectedRows().length;
int sizeEntries = entries.size();
if (log.isInfoEnabled()) {
log.info("Size list entries : " + sizeEntries + "\n" +
- "Nb selected row : " + nbSelectedRowModel);
+ "Nb selected row : " + nbSelectedRowTable + "\n"+
+ "Nb ligne model : " + nbEntriesModel);
}
- if (nbSelectedRowModel > sizeEntries || (nbSelectedRowModel==sizeEntries && nbSelectedRowModel==1)){
+
+ //Managing selection
+ if (nbSelectedRowTable > sizeEntries || (nbSelectedRowTable==sizeEntries && nbSelectedRowTable==1)){
entries.add(lastEntry);
if (log.isInfoEnabled()) {
log.info("Add entry");
}
- }else if (nbSelectedRowModel < sizeEntries){
+ }else if (nbSelectedRowTable < sizeEntries){
entries.remove(entries.size() - 1);
if (log.isInfoEnabled()) {
log.info("Remove entry");
@@ -132,15 +140,6 @@
}
}
});
-
- /*modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource();
- Entry selectedEntry = (Entry)evt.getNewValue();
- loadCurrentSelection(modelUiPropChange, selectedEntry);
- }
- });*/
}
public void loadComboAndRows(){
@@ -189,6 +188,9 @@
//Load entry with the default dates, default account 4 and with no letter
updateAllEntries(defaultDateBegFiscalPeriod, defaultDateEndCurrent, view.getAccountComboBoxModel().getSelectedItem(), view.getLetteredCheckGroup().getSelectedButton().getName());
+ if (log.isInfoEnabled()) {
+ log.info("Nb entries model (After update all entries) : " + view.getTableModel().getNUmberOfEntries());
+ }
}
protected List<Entry> findAllEntries(Date selectedBeginDate, Date selectedEndDate, Object compte, String filtreLettre){
@@ -232,6 +234,9 @@
}
view.getTableModel().updateEntries(entries, datesEntree, journalEntrees);
+ if (log.isInfoEnabled()) {
+ log.info("Nb entries model : " + view.getTableModel().getNUmberOfEntries());
+ }
}
}
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2012-07-04 16:55:47 UTC (rev 3489)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2012-07-05 11:56:32 UTC (rev 3490)
@@ -43,4 +43,5 @@
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
\ No newline at end of file
+log4j.logger.org.chorem.lima.ui.lettering.LetteringTableModel=DEBUG
+log4j.logger.org.chorem.lima.ui.lettering.LetteringTableSelectionModel=DEBUG
\ No newline at end of file
1
0
r3489 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 04 Jul '12
by mallon@users.chorem.org 04 Jul '12
04 Jul '12
Author: mallon
Date: 2012-07-04 18:55:47 +0200 (Wed, 04 Jul 2012)
New Revision: 3489
Url: http://chorem.org/repositories/revision/lima/3489
Log:
Correction concernant la s?\195?\169lection d'une seule ligne et l'impossibilit?\195?\169 de la lettrer.
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
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-04 16:30:39 UTC (rev 3488)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-04 16:55:47 UTC (rev 3489)
@@ -302,7 +302,7 @@
}
}
- if (soldeTotal.intValue() == 0 && !enableDelettring){
+ if (soldeTotal.intValue() == 0 && !enableDelettring & view.getTable().getSelectedRows().length > 1){
enableLettring = true;
}
1
0
r3488 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/combobox lima-swing/src/main/java/org/chorem/lima/ui/lettering
by mallon@users.chorem.org 04 Jul '12
by mallon@users.chorem.org 04 Jul '12
04 Jul '12
Author: mallon
Date: 2012-07-04 18:30:39 +0200 (Wed, 04 Jul 2012)
New Revision: 3488
Url: http://chorem.org/repositories/revision/lima/3488
Log:
Lettrage :
- Delettrage et Lettrage automatiques;
- Correction sur les soldes n?\195?\169gatifs;
- MultiS?\195?\169lection de lignes;
- Affichage boutons lettrer/d?\195?\169lettrer selon la balance et le lettrage;
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -25,16 +25,6 @@
package org.chorem.lima.business.ejb;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import javax.ejb.EJB;
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-
import org.chorem.lima.beans.FinancialTransactionSearch;
import org.chorem.lima.business.AccountingRules;
import org.chorem.lima.business.LimaConfig;
@@ -55,6 +45,15 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.nuiton.topia.TopiaException;
+import javax.ejb.EJB;
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
/**
* Cette classe permet la création d'une transaction comptable dans l'application.
* Toute action sur une transaction entraîne automatiquement une création de log.
@@ -123,12 +122,11 @@
* */
@Override
public String getNewLetters() throws LimaException {
- String lastActualLetters = "";
- List<Entry> entries = new ArrayList<Entry>();
+ String lastActualLetters;
try {
EntryDAO entryDAO = getDaoHelper().getEntryDAO();
- lastActualLetters = entryDAO.findLetters().get(0);
+ lastActualLetters = entryDAO.findLetters();
} catch (Exception ex) {
throw new LimaException("Can't get new letters", ex);
}
@@ -137,12 +135,14 @@
String nextSecondLetter = "A";
String nextFirstLetter = "A";
- if (lastActualLetters.length() > 2 && lastActualLetters.charAt(2) != 'Z'){
- nextThirdLetter = incrementLetter(2, lastActualLetters);
- }else if (lastActualLetters.length() > 1 && lastActualLetters.charAt(1) != 'Z'){
- nextSecondLetter = incrementLetter(1, lastActualLetters);
- }else if (lastActualLetters.charAt(0) != 'Z'){
- nextFirstLetter = incrementLetter(0, lastActualLetters);
+ if (lastActualLetters != null){
+ if (lastActualLetters.length() > 2 && lastActualLetters.charAt(2) != 'Z'){
+ nextThirdLetter = incrementLetter(2, lastActualLetters);
+ }else if (lastActualLetters.length() > 1 && lastActualLetters.charAt(1) != 'Z'){
+ nextSecondLetter = incrementLetter(1, lastActualLetters);
+ }else if (lastActualLetters.charAt(0) != 'Z'){
+ nextFirstLetter = incrementLetter(0, lastActualLetters);
+ }
}
return nextFirstLetter + nextSecondLetter + nextThirdLetter;
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -25,18 +25,17 @@
package org.chorem.lima.entity;
+import org.nuiton.topia.TopiaException;
+
import java.util.Date;
import java.util.List;
-import org.nuiton.topia.TopiaException;
-
public class EntryDAOImpl<E extends Entry> extends EntryDAOAbstract<Entry> {
/**
* Requete generique qui recupere les entrees equilibrées portant entre
* deux dates.
*
- * @param account account
* @param beginDate begin date
* @param endDate end date
*/
@@ -118,12 +117,16 @@
return entries;
}
- public List<String> findLetters() throws TopiaException{
- String query = "Select E.LETTERING FROM " + Entry.class.getName() + " E" +
- " order by E.LETTERING desc";
+ public String findLetters() throws TopiaException{
+ String result = "";
+ String query = "Select E.lettering FROM " + Entry.class.getName() + " E" +
+ " order by E.lettering desc";
List<String> letters = context.findAll(query);
- return letters;
+ if (!letters.isEmpty()) {
+ result = letters.get(0);
+ }
+ return result;
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -25,11 +25,6 @@
package org.chorem.lima.ui.combobox;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
@@ -41,6 +36,9 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import javax.swing.*;
+import java.util.List;
+
/**
* Opened financial period combo box model.
*
@@ -93,6 +91,9 @@
} else {
datasCache = getDataList();
}
+ for (FinancialPeriod financialPeriod : datasCache) {
+
+ }
}
public void setSelectedFiscalPeriod(FiscalPeriod fiscalPeriod) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringModelUI.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -1,14 +1,12 @@
package org.chorem.lima.ui.lettering;
+import org.chorem.lima.entity.Entry;
+
+import javax.swing.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.math.BigDecimal;
-import javax.swing.DefaultListSelectionModel;
-
-import org.chorem.lima.entity.Entry;
-import org.eclipse.jetty.util.log.Log;
-
public class LetteringModelUI extends DefaultListSelectionModel{
public static final String SELECTED_ENTRY_PROPERTY = "selectedEntry";
@@ -23,8 +21,6 @@
public static final String DELETTRER_PROPERTY = "delettrer";
- public static final String TEXTENABLE_PROPERTY = "textEnable";
-
private static final long serialVersionUID = 1L;
protected final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
@@ -32,40 +28,12 @@
protected LetteringTableModel model;
protected Entry selectedEntry;
- protected BigDecimal debit;
- protected BigDecimal credit;
- protected String solde;
+ protected BigDecimal debit = BigDecimal.ZERO;
+ protected BigDecimal credit = BigDecimal.ZERO;
+ protected BigDecimal solde = BigDecimal.ZERO;
protected boolean lettrer;
protected boolean delettrer;
- protected BigDecimal debitTotal;
- protected BigDecimal creditTotal;
-
- public BigDecimal getDebitTotal() {
- return debitTotal;
- }
- public void setDebitTotal(BigDecimal debitTotal) {
- this.debitTotal = debitTotal;
- }
-
- public BigDecimal getCreditTotal() {
- return creditTotal;
- }
-
- public void setCreditTotal(BigDecimal creditTotal) {
- this.creditTotal = creditTotal;
- }
-
- public String getSoldeTotal() {
- return soldeTotal;
- }
-
- public void setSoldeTotal(String soldeTotal) {
- this.soldeTotal = soldeTotal;
- }
-
- protected String soldeTotal;
-
public Entry getSelectedEntry() {
return selectedEntry;
}
@@ -91,50 +59,41 @@
}
public void setDelettrer(boolean delettrer) {
- boolean oldLettrer = isLettrer();
+ boolean oldDelettrer = isDelettrer();
this.delettrer = delettrer;
- firePropertyChange(LETTRER_PROPERTY, oldLettrer, delettrer);
+ firePropertyChange(DELETTRER_PROPERTY, oldDelettrer, delettrer);
}
public LetteringModelUI(LetteringTableModel model) {
this.model = model;
}
- public String getDebit() {
- if (debit == null){
- return "0";
- }
- return String.valueOf(debit);
+ public BigDecimal getDebit() {
+ return debit;
}
public void setDebit(BigDecimal debit) {
- BigDecimal oldDebit = BigDecimal.valueOf(Double.valueOf(getDebit()));
+ BigDecimal oldDebit = getDebit();
this.debit = debit;
firePropertyChange(DEBIT_PROPERTY, oldDebit, debit);
}
- public String getCredit() {
- if (credit == null){
- return "0";
- }
- return String.valueOf(credit);
+ public BigDecimal getCredit() {
+ return credit;
}
public void setCredit(BigDecimal credit) {
- BigDecimal oldCredit = BigDecimal.valueOf(Double.valueOf(getCredit()));
+ BigDecimal oldCredit = getCredit();
this.credit = credit;
firePropertyChange(CREDIT_PROPERTY, oldCredit, credit);
}
- public String getSolde() {
- if (solde == null){
- return "0";
- }
+ public BigDecimal getSolde() {
return solde;
}
- public void setSolde(String solde) {
- String oldSolde = getSolde();
+ public void setSolde(BigDecimal solde) {
+ BigDecimal oldSolde = getSolde();
this.solde = solde;
firePropertyChange(SOLDE_PROPERTY, oldSolde, solde);
}
@@ -167,6 +126,8 @@
@Override
public int getSelectionMode() {
- return SINGLE_SELECTION;
+ return MULTIPLE_INTERVAL_SELECTION;
}
+
+
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -1,7 +1,7 @@
/*
* #%L
* Lima Swing
- *
+ *
* $Id$
* $HeadURL$
* %%
@@ -9,15 +9,15 @@
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 3 of the
+ * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
+ *
+ * You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
@@ -25,15 +25,6 @@
package org.chorem.lima.ui.lettering;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import java.math.BigDecimal;
-import java.util.Date;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
@@ -43,7 +34,14 @@
import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
import org.jdesktop.swingx.JXTable;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.math.BigDecimal;
+import java.util.Date;
+
/**
* Table des transaction qui ajoute des comportement (keys).
*
@@ -55,9 +53,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- /** log. */
- private static final Log log = LogFactory.getLog(LetteringTable.class);
-
protected LetteringViewHandler handler;
/*private Highlighter colorTransaction;
@@ -65,7 +60,7 @@
private ColorHighlighter colorBalance;*/
protected LetteringTableModel letteringTableModel;
-
+
public LetteringTable(LetteringTableModel letteringTableModel) {
super(letteringTableModel);
this.letteringTableModel = letteringTableModel;
@@ -85,67 +80,9 @@
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
- //highlight financial financial transactions
- /*addColorTransaction();
- // highlight unbalanced financial transactions
- addColorNonBalancedTransaction();*/
}
/**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- * On récupère la première cellule, on vérifie que c'est une date
- */
- /*protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return adapter.getValueAt(adapter.row, 0) instanceof Date;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(222, 222, 222), null);
- addHighlighter(colorTransaction);
- }*/
-
-
- /**
- * Permet de surligner une transaction dans le tableau lorsque
- * cette dernière n'est pas équilibrée.
- * On récupère la dernière cellule de la ligne
- * et on vérifie si la valeur est différente de 0
- */
- /* protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = adapter.getValueAt(adapter.row, 8);
- if (value instanceof BigDecimal) {
- BigDecimal currentBalance = (BigDecimal) value;
- // can compare two BigDecimals with different scales
- // e.g: 3.1 == 3.10
- if (currentBalance.compareTo(BigDecimal.ZERO) != 0) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(255, 198, 209), null);
- addHighlighter(colorTransaction);
- }*/
-
- /**
* for each action combination key are think
* for extend keyboard and laptop keyboard
*/
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2012-07-04 16:30:39 UTC (rev 3488)
@@ -149,15 +149,15 @@
<JLabel text="lima.ui.lettering.selectEntry"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit()}"
+ <JTextField id="debitTexttField" editable="false" text="{getModelUi().getDebit().toString()}"
focusable="false"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit()}"
+ <JTextField id="creditTextField" editable="false" text="{getModelUi().getCredit().toString()}"
focusable="false"/>
</cell>
<cell fill="horizontal" weightx="0.25">
- <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde()}"
+ <JTextField id="soldeTextField" editable="false" text="{getModelUi().getSolde().toString()}"
focusable="false"/>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-03 14:38:28 UTC (rev 3487)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2012-07-04 16:30:39 UTC (rev 3488)
@@ -25,16 +25,6 @@
package org.chorem.lima.ui.lettering;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.JComboBox;
-
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,9 +39,16 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
+import javax.swing.*;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
/**
* Handler associated with financial transaction view.
*
@@ -71,11 +68,11 @@
protected LetteringTable table;
- protected LetteringTableModel tableModel;
+ /*protected LetteringTableModel tableModel;
protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel;
- protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel;
+ protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel;*/
/** Transaction service. */
protected FiscalPeriodService fiscalPeriodService;
@@ -84,8 +81,6 @@
protected FinancialTransactionService financialTransactionService;
protected EntryBookService entryBookService;
- protected Object clipBoard;
-
public LetteringViewHandler(LetteringView view) {
this.view = view;
@@ -102,15 +97,50 @@
public void init() {
loadComboAndRows();
LetteringModelUI modelUi = view.getModelUi();
- modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() {
+
+ modelUi.addListSelectionListener(new ListSelectionListener(){
+ List<Entry> entries = new ArrayList<Entry>();
@Override
+ public void valueChanged(ListSelectionEvent evt) {
+
+ LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource();
+ if (evt.getValueIsAdjusting()){
+ Entry lastEntry = view.getTableModel().getEntryAt(evt.getLastIndex());
+ int nbSelectedRowModel = view.getTable().getSelectedRows().length;
+ int sizeEntries = entries.size();
+
+ if (log.isInfoEnabled()) {
+ log.info("Size list entries : " + sizeEntries + "\n" +
+ "Nb selected row : " + nbSelectedRowModel);
+ }
+ if (nbSelectedRowModel > sizeEntries || (nbSelectedRowModel==sizeEntries && nbSelectedRowModel==1)){
+ entries.add(lastEntry);
+ if (log.isInfoEnabled()) {
+ log.info("Add entry");
+ }
+ }else if (nbSelectedRowModel < sizeEntries){
+ entries.remove(entries.size() - 1);
+ if (log.isInfoEnabled()) {
+ log.info("Remove entry");
+ }
+ }
+
+ if (log.isInfoEnabled()) {
+ log.info("Size entries after update : " + entries.size());
+ }
+ loadCurrentSelection(modelUiPropChange, entries);
+ }
+ }
+ });
+
+ /*modelUi.addPropertyChangeListener(LetteringModelUI.SELECTED_ENTRY_PROPERTY, new PropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
LetteringModelUI modelUiPropChange = (LetteringModelUI)evt.getSource();
Entry selectedEntry = (Entry)evt.getNewValue();
loadCurrentSelection(modelUiPropChange, selectedEntry);
}
- });
-
+ });*/
}
public void loadComboAndRows(){
@@ -140,7 +170,7 @@
int premierJourMoisCourant = calendar.getActualMinimum(Calendar.DATE);
if (fiscalPeriod != null){
- defaultDateBegFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod().getBeginDate();
+ defaultDateBegFiscalPeriod = fiscalPeriodService.getLastFiscalPeriod().getBeginDate();
}else{
defaultDateBegFiscalPeriod = DateUtils.setDays(new Date(), premierJourMoisCourant);
}
@@ -205,30 +235,80 @@
}
}
- public void loadCurrentSelection(LetteringModelUI modelUi, Entry selectedEntry){
+ /**Managing components when n rows are selected
+ * */
+ public void loadCurrentSelection(LetteringModelUI modelUi, List<Entry> selectedEntries){
financialTransactionService = LimaServiceFactory.getService(FinancialTransactionService.class);
- boolean enableLettring = false;
- boolean enableDelettring = false;
+ if (selectedEntries.size() > 0){
- if (selectedEntry != null){
- modelUi.setDebit(selectedEntry.getDebit() ? selectedEntry.getAmount() : BigDecimal.ZERO);
- modelUi.setCredit(selectedEntry.getDebit() ? BigDecimal.ZERO : selectedEntry.getAmount());
+ boolean enableLettring = false;
+ boolean enableDelettring = false;
+ BigDecimal soldeTotal = BigDecimal.ZERO;
+ BigDecimal creditTotal = BigDecimal.ZERO;
+ BigDecimal debitTotal = BigDecimal.ZERO;
- if (modelUi.getDebit().equals("0")){
- modelUi.setSolde(modelUi.getCredit());
- }else{
- modelUi.setSolde(modelUi.getDebit());
+ for (Entry selectedEntry : selectedEntries) {
+ //Managing balance, credit and debit
+ boolean debitSelected = selectedEntry.getDebit();
+ BigDecimal amountSelected = selectedEntry.getAmount();
+
+
+ if (log.isInfoEnabled()) {
+ log.info("amountSelected : " + amountSelected);
+ }
+ modelUi.setDebit(debitSelected ? amountSelected : BigDecimal.ZERO);
+ modelUi.setCredit(debitSelected ? BigDecimal.ZERO : amountSelected);
+
+ BigDecimal debitVal = modelUi.getDebit();
+ if (log.isInfoEnabled()) {
+ log.info("Debit actuel : " + debitVal);
+ }
+ if (debitVal == BigDecimal.ZERO){
+ BigDecimal creditVal = modelUi.getCredit();
+ if (log.isInfoEnabled()) {
+ log.info("creditVal : " + creditVal);
+ }
+ if (creditVal != BigDecimal.ZERO){
+ creditTotal = creditTotal.add(creditVal);
+ creditVal = new BigDecimal("-" + creditVal.toString());
+ if (log.isInfoEnabled()) {
+ log.info("creditVal neg : " + creditVal);
+ }
+ soldeTotal = soldeTotal.add(creditVal);
+ }else{
+ creditTotal = creditTotal.add(creditVal);
+ soldeTotal = soldeTotal.add(creditVal);
+ }
+ }else{
+ debitTotal = debitTotal.add(debitVal);
+ soldeTotal = soldeTotal.add(debitVal);
+ }
}
- modelUi.setSolde(modelUi.getSolde());
- if (selectedEntry.getLettering() != null && ! selectedEntry.getLettering().isEmpty()){
- enableDelettring = true;
- }else{
- enableLettring = true;
- }
+
+ modelUi.setSolde(soldeTotal);
+ modelUi.setCredit(creditTotal);
+ modelUi.setDebit(debitTotal);
+
+ //Managing lettering buttons
+ String lettering = null;
+
+ //lettering impossible if one of entries have letter
+ for (Entry selectedEntry : selectedEntries) {
+ lettering = selectedEntry.getLettering();
+ if (lettering != null && !lettering.isEmpty()){
+ enableDelettring= true;
+ break;
+ }
+ }
+
+ if (soldeTotal.intValue() == 0 && !enableDelettring){
+ enableLettring = true;
+ }
+
+ modelUi.setLettrer(enableLettring);
+ modelUi.setDelettrer(enableDelettring);
}
- modelUi.setLettrer(enableLettring);
- modelUi.setDelettrer(enableDelettring);
}
/**
@@ -269,21 +349,31 @@
/**Add a group of three letters to n entries*/
public void addLetter() {
String newLetters = financialTransactionService.getNewLetters();
- int[] entrieSelected = view.getTable().getSelectedRows();
- view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters);
+ changeLetter(newLetters);
}
/**Remove a group of three letters to n entries*/
public void removeLetter() {
- //TODO
- //removeLetters
- /*int[] rows = table.getSelectedRows();
- for (int i : rows) {
- view.getTableModel().removeLetter(i);
+ changeLetter(null);
+ }
+
+ /**Add or remove a group of three letters to n entries*/
+ protected void changeLetter(String newLetters) {
+ int[] entrieSelected = view.getTable().getSelectedRows();
+
+ view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters);
+
+ for (int indexEntry : entrieSelected){
+ financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
}
- view.getTableModel().updateRows();*/
}
+ /*public void nonConsecutiveSelection(int[] selectedRows){
+ for (int row : selectedRows){
+ view.getTable().addRowSelectionInterval(row, row);
+ }
+ }*/
+
@Override
public void notifyMethod(String serviceName, String methodeName) {
}
1
0
Author: echatellier
Date: 2012-07-03 16:38:28 +0200 (Tue, 03 Jul 2012)
New Revision: 3487
Url: http://chorem.org/repositories/revision/lima/3487
Log:
Use jaxx 2.5
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-07-03 14:36:31 UTC (rev 3486)
+++ trunk/pom.xml 2012-07-03 14:38:28 UTC (rev 3487)
@@ -333,7 +333,7 @@
<nuitonUtilsVersion>2.5</nuitonUtilsVersion>
<eugenePluginVersion>2.4.2</eugenePluginVersion>
<topiaVersion>2.6.11</topiaVersion>
- <jaxxVersion>2.5-SNAPSHOT</jaxxVersion>
+ <jaxxVersion>2.5</jaxxVersion>
<nuitonI18nVersion>2.4.1</nuitonI18nVersion>
<openEjbVersion>4.0.0</openEjbVersion>
<slf4jVersion>1.6.6</slf4jVersion>
1
0