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
June 2012
- 3 participants
- 48 discussions
Author: echatellier
Date: 2012-06-05 16:51:55 +0200 (Tue, 05 Jun 2012)
New Revision: 3442
Url: http://chorem.org/repositories/revision/lima/3442
Log:
Correction diverses pour la saisie de la comptabilit?\195?\169
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
trunk/lima-callao/src/main/xmi/accounting.properties
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -227,11 +227,15 @@
}
// Check if all financial transactions have EntryBooks
- result = financialTransactionDAO.getAllTransactionWithoutEntryBook();
+ // FIXME echatellier 20120605 only check in interval defined
+ // by period to block (not all database)
+ result = financialTransactionDAO.getAllTransactionWithoutEntryBook(period.getBeginDate(),
+ period.getEndDate());
// FIMXE echatellier 20120504 unutile de recuperer une liste
// entiere juste pour tester l'existence
if (result.size() > 0) {
- throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingentrybook"));
+ FinancialTransaction transaction = result.get(0);
+ throw new LimaBusinessException(_("lima-business.defaultaccountingrules.missingentrybook", transaction.getTransactionDate()));
}
} catch (TopiaException ex) {
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-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -240,19 +240,13 @@
@Override
public void removeFinancialTransaction(FinancialTransaction financialtransaction) throws LimaException {
+ // check if the financial period is blocked
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
+ accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(financialtransaction);
try {
-
- //check if the financial period is blocked
- accountingRules.checkFinancialPeriodBlockedWithFinancialTransaction(
- financialtransaction);
-
FinancialTransactionDAO transactionDAO = getDaoHelper().getFinancialTransactionDAO();
- FinancialTransaction financialTransaction2 =
- //patch : conflict object already instanciate
- transactionDAO.findByTopiaId(financialtransaction.getTopiaId());
-
+ transactionDAO.delete(financialtransaction);
} catch (Exception ex) {
throw new LimaException("Can't remove financial transaction", ex);
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -70,7 +70,7 @@
/**
* Gestion des exercices.
- * Un exercice ne peut être supprimée et débloquée après cloture.
+ * Un exercice ne peut être supprimé et débloqué après cloture.
*
* @author Rémi Chapelet
*/
@@ -255,19 +255,27 @@
public void addRetainedEarnings(FiscalPeriod fiscalPeriod, boolean newyear,
EntryBook entryBook) throws LimaException {
+ // re-attach entities to current session
+ FiscalPeriod localFiscalPeriod = null;
+ try {
+ FiscalPeriodDAO fiscalPeriodDAO = getDaoHelper().getFiscalPeriodDAO();
+ localFiscalPeriod = fiscalPeriodDAO.findByTopiaId(fiscalPeriod.getTopiaId());
+ } catch (TopiaException ex) {
+ throw new LimaException("Can't find fiscal period", ex);
+ }
+
//sets dates
// - endRetainedEarnings: last day of the closing year
// - beginRetainedEarnings: first open day of the following year
-// Date endRetainedEarnings = fiscalPeriod.getBeginDate();
-// Date beginRetainedEarnings = null;
+ // Date endRetainedEarnings = fiscalPeriod.getBeginDate();
+ // Date beginRetainedEarnings = null;
//Sets entryBook
//search for the entryBook to use using param
boolean found = false;
List<EntryBook> entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())
- && entry.getLabel().equals(entryBook.getLabel())) {
+ if (!found && entry.getCode().equals(entryBook.getCode())) {
entryBook = entry;
found = true;
}
@@ -278,8 +286,7 @@
entryBookService.createEntryBook(entryBook);
entryBooksList = entryBookService.getAllEntryBooks();
for (EntryBook entry : entryBooksList) {
- if (!found && entry.getCode().equals(entryBook.getCode())
- && entry.getLabel().equals(entryBook.getLabel())) {
+ if (!found && entry.getCode().equals(entryBook.getCode())) {
entryBook = entry;
found = true;
}
@@ -323,7 +330,7 @@
}
//look for the last financial period from the previous fiscal year
- Collection<FinancialPeriod> fperiod = fiscalPeriod.getFinancialPeriod();
+ Collection<FinancialPeriod> fperiod = localFiscalPeriod.getFinancialPeriod();
Iterator<FinancialPeriod> itr = fperiod.iterator();
FinancialPeriod lastFPeriod = null;
@@ -352,7 +359,7 @@
// - unlocked entrybook
// - right code and label
if (!found && !cPeriodicEntryBook.getFinancialPeriod().getLocked()
- && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(fiscalPeriod.getEndDate())
+ && cPeriodicEntryBook.getFinancialPeriod().getBeginDate().after(localFiscalPeriod.getEndDate())
&& !cPeriodicEntryBook.getLocked()
&& cPeriodicEntryBook.getEntryBook().getCode().equals(entryBook.getCode())
&& cPeriodicEntryBook.getEntryBook().getLabel().equals(entryBook.getLabel())) {
@@ -370,7 +377,7 @@
if (lastFPeriod != null) {
//Sets the endfinancialTransaction
endfinancialTransaction.setEntryBook(entryBook);
- endfinancialTransaction.setTransactionDate(fiscalPeriod.getEndDate());
+ endfinancialTransaction.setTransactionDate(localFiscalPeriod.getEndDate());
financialTransactionService.createFinancialTransaction(endfinancialTransaction);
}
@@ -393,18 +400,15 @@
Entry beginEntry;
- BalanceTrial results = reportService.generateBalanceTrial(fiscalPeriod.getBeginDate(), fiscalPeriod.getEndDate(), null, false, false);
+ BalanceTrial results = reportService.generateBalanceTrial(localFiscalPeriod.getBeginDate(),
+ localFiscalPeriod.getEndDate(), null, false, false);
List<ReportsDatas> reportsDatasList = (List<ReportsDatas>) results.getReportsDatas();
- //check if at least one transaction has been reported
- boolean transaction = false;
-
for (ReportsDatas report : reportsDatasList) {
//Account class from 1 to 5 and only non zero amount
if (Integer.valueOf(report.getAccount().getAccountNumber().substring(0, 1)) < 6
&& !report.getAmountSolde().equals(BigDecimal.ZERO)) {
- transaction = true;
//close accounts by removing amounts from all class 1 to 5 accounts
beginEntry = new EntryImpl();
beginEntry.setDescription(_("lima-business.financialtransaction.retainedearnings.description") + " (" + calendar.get(Calendar.YEAR) + ")");
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/FinancialPeriodComparator.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -35,13 +35,12 @@
private static final long serialVersionUID = 1L;
- private static final Log log =
- LogFactory.getLog(FinancialPeriodComparator.class);
+ private static final Log log = LogFactory.getLog(FinancialPeriodComparator.class);
@Override
public int compare(ClosedPeriodicEntryBook o1, ClosedPeriodicEntryBook o2) {
if (o1.getFinancialPeriod().getBeginDate().compareTo(o2.getFinancialPeriod().getBeginDate()) == 0) {
- if (o1.getEntryBook().getLabel().compareToIgnoreCase(o2.getEntryBook().getLabel()) == 0) {
+ if (o1.getEntryBook().getCode().compareToIgnoreCase(o2.getEntryBook().getCode()) == 0) {
return o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
} else {
return o1.getEntryBook().getCode().compareToIgnoreCase(o2.getEntryBook().getCode());
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2012-06-05 14:51:55 UTC (rev 3442)
@@ -16,7 +16,7 @@
lima-business.defaultaccountingrules.financialtransactionblocked=La période financière de cette transaction est bloquée
lima-business.defaultaccountingrules.invalidaccountnumber=Numéro de compte invalide \: %d
lima-business.defaultaccountingrules.missingelements=Impossible de bloquer la période financière / il manque des éléments dans des transactions
-lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il mmanque un journal dans une transaction
+lima-business.defaultaccountingrules.missingentrybook=Impossible de bloquer la période financière / il manque un journal dans une transaction (%1$te/%1$tm/%1$tY)
lima-business.document.accountnumber=N° Compte
lima-business.document.amounts=Totaux
lima-business.document.balance=Balance
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/ClosedPeriodicEntryBookDAOImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -132,7 +132,7 @@
Date beginDate, Date endDate) throws TopiaException {
String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
+ " WHERE :beginDate <= financialPeriod.beginDate " +
" AND financialPeriod.beginDate <= :endDate" +
" AND entryBook = :entryBook";
return context.find(query, "beginDate", beginDate, "endDate", endDate, "entryBook", entryBook);
@@ -152,7 +152,7 @@
Date beginDate, Date endDate) throws TopiaException {
String query = "FROM " + ClosedPeriodicEntryBook.class.getName() +
- " WHERE :begindate <= financialPeriod.beginDate " +
+ " WHERE :beginDate <= financialPeriod.beginDate " +
" AND financialPeriod.beginDate <= :endDate" +
" AND entryBook = :entryBook" +
" AND locked = true";
@@ -160,16 +160,17 @@
}
/**
- * Retourne les ClosedPeriodicEntryBook clos de toutes les exercive encore ouvert.
+ * Retourne les ClosedPeriodicEntryBook de toutes les exercices encore ouverts.
*
* @return les ClosedPeriodicEntryBook
* @throws TopiaException
*/
public List<ClosedPeriodicEntryBook> findAllClosedPeriodicEntryBooksFromUnblockedFiscalPeriod() throws TopiaException {
- String query = "FROM " + ClosedPeriodicEntryBook.class.getName() + " C" +
+ String query = "SELECT C FROM " + ClosedPeriodicEntryBook.class.getName() + " C" +
", " + FiscalPeriod.class.getName() + " F" +
- " WHERE E.financialPeriod IN ELEMENTS (F.financialPeriod)" +
- " ORDER BY E.financialPeriod.beginDate";
+ " WHERE C.financialPeriod IN ELEMENTS (F.financialPeriod)" +
+ " AND F.locked = false" +
+ " ORDER BY C.financialPeriod.beginDate";
List<ClosedPeriodicEntryBook> result = context.find(query);
return result;
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/FinancialTransactionDAOImpl.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -223,12 +223,13 @@
/**
* Find all transaction without entry book.
*
- * TODO echatellier 20120425 same method as getAllUnfilledTransaction ?
- *
- * @return
+ * @param beginDate begin date
+ * @param endDate end date
+ * @return transaction without entry books
* @throws TopiaException
*/
- public List<FinancialTransaction> getAllTransactionWithoutEntryBook() throws TopiaException {
+ public List<FinancialTransaction> getAllTransactionWithoutEntryBook(Date beginDate,
+ Date endDate) throws TopiaException {
String query = "SELECT T FROM " + FinancialTransaction.class.getName() + " T"+
" LEFT JOIN T.entry AS E" +
@@ -237,9 +238,11 @@
" (SELECT sum(amount) FROM " + Entry.class.getName() +
" WHERE debit = false AND financialTransaction = T) OR E.account = null" +
" OR E.voucher = null OR E.voucher = '' OR E.description = null OR E.description = '')" +
- " AND entryBook = null";
- // FIXME echatellier 20120504 doesn't concern a period ? all database ?
- List<FinancialTransaction> result = context.find(query);
+ " AND entryBook = null" +
+ " AND :beginDate <= T.transactionDate" +
+ " AND T.transactionDate <= :endDate";
+ List<FinancialTransaction> result = context.find(query, "beginDate",
+ beginDate, "endDate", endDate);
return result;
}
Modified: trunk/lima-callao/src/main/xmi/accounting.properties
===================================================================
--- trunk/lima-callao/src/main/xmi/accounting.properties 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-callao/src/main/xmi/accounting.properties 2012-06-05 14:51:55 UTC (rev 3442)
@@ -47,6 +47,8 @@
org.chorem.lima.entity.FiscalPeriod.attribute.endDate.tagvalue.notNull=true
# lazy
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.entryBook.tagvalue.lazy=false
+org.chorem.lima.entity.ClosedPeriodicEntryBook.attribute.financialPeriod.tagvalue.lazy=false
org.chorem.lima.entity.Entry.attribute.account.tagvalue.lazy=false
org.chorem.lima.entity.Entry.attribute.financialTransaction.tagvalue.lazy=false
org.chorem.lima.entity.FinancialTransaction.attribute.entry.tagvalue.lazy=false
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTable.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -24,27 +24,21 @@
*/
package org.chorem.lima.ui.accountsreports;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-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 org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.jdesktop.swingx.JXTable;
+
public class AccountsReportsTable extends JXTable
implements KeyListener, MouseListener {
/** serialVersionUID. */
private static final long serialVersionUID = 6093850347322834480L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(AccountsReportsTable.class);
-
public AccountsReportsTable() {
addKeyListener(this);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -42,11 +42,8 @@
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.enums.ComboBoxDatesEnum;
@@ -71,9 +68,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 5973427750255668999L;
- /** log. */
- private static final Log log = LogFactory.getLog(IntervalPanel.class);
-
protected List<IntervalListener> listeners;
protected JComboBox typeComboBox;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -34,7 +34,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FiscalPeriodService;
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Structure - Plan BCR.
+ */
+package org.chorem.lima.ui.financialstatementchart;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementchart/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-06-05 13:47:53 UTC (rev 3441)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2012-06-05 14:51:55 UTC (rev 3442)
@@ -35,8 +35,6 @@
import javax.swing.table.AbstractTableModel;
-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.utils.EntryComparator;
@@ -65,10 +63,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3914954536809622358L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(FinancialTransactionUnbalancedTableModel.class);
-
/** Transaction service. */
protected final FinancialTransactionService financialTransactionService;
1
0
r3441 - trunk/lima-business/src/main/java/org/chorem/lima/business/ejb
by echatellier@users.chorem.org 05 Jun '12
by echatellier@users.chorem.org 05 Jun '12
05 Jun '12
Author: echatellier
Date: 2012-06-05 15:47:53 +0200 (Tue, 05 Jun 2012)
New Revision: 3441
Url: http://chorem.org/repositories/revision/lima/3441
Log:
fix : ObjectDeletedException: deleted object would be re-saved by cascade
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-06-05 09:04:14 UTC (rev 3440)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2012-06-05 13:47:53 UTC (rev 3441)
@@ -140,27 +140,35 @@
@Override
public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ // check rule
AccountingRules accountingRules = LimaConfig.getInstance().getAccountingRules();
-
- // check rule
accountingRules.removeEntryBookRules(entryBook);
try {
-
+ // re-attach to current transaction
+ EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
+ EntryBook localEntryBook = entryBookDAO.findByTopiaId(entryBook.getTopiaId());
// delete all ClosedPeriodicEntryBook from this EntryBook
ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO =
getDaoHelper().getClosedPeriodicEntryBookDAO();
List<ClosedPeriodicEntryBook> closedPeriodicEntryBooks =
- closedPeriodicEntryBookDAO.findAllByEntryBook(entryBook);
+ closedPeriodicEntryBookDAO.findAllByEntryBook(localEntryBook);
for (ClosedPeriodicEntryBook closedPeriodicEntryBook : closedPeriodicEntryBooks) {
+ if (log.isDebugEnabled()) {
+ log.debug("Deleting closed " + closedPeriodicEntryBook.getTopiaId());
+ }
+
+ // fix : ObjectDeletedException: deleted object would be re-saved by cascade
+ closedPeriodicEntryBook.getEntryBook().removeFinancialPeriodClosedPeriodicEntryBook(closedPeriodicEntryBook);
+ closedPeriodicEntryBook.getFinancialPeriod().removeEntryBookClosedPeriodicEntryBook(closedPeriodicEntryBook);
+
closedPeriodicEntryBookDAO.delete(closedPeriodicEntryBook);
}
// delete entry book
- EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
- entryBookDAO.delete(entryBook);
+ entryBookDAO.delete(localEntryBook);
} catch (Exception ex) {
throw new LimaException("Can't remove entry book", ex);
1
0
r3440 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/common
by echatellier@users.chorem.org 05 Jun '12
by echatellier@users.chorem.org 05 Jun '12
05 Jun '12
Author: echatellier
Date: 2012-06-05 11:04:14 +0200 (Tue, 05 Jun 2012)
New Revision: 3440
Url: http://chorem.org/repositories/revision/lima/3440
Log:
Correction probl?\195?\168me de commit
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java 2012-06-04 16:07:10 UTC (rev 3439)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java 2012-06-05 09:04:14 UTC (rev 3440)
@@ -0,0 +1,31 @@
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 CodeLutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package org.chorem.lima.ui.common;
+
+import java.util.EventListener;
+import java.util.EventObject;
+
+public interface IntervalListener extends EventListener {
+ public void intervalChanged(EventObject e);
+}
1
0
r3439 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: accountsreports balance common entrybooksreports financialstatementreport ledger
by echatellier@users.chorem.org 04 Jun '12
by echatellier@users.chorem.org 04 Jun '12
04 Jun '12
Author: echatellier
Date: 2012-06-04 18:07:10 +0200 (Mon, 04 Jun 2012)
New Revision: 3439
Url: http://chorem.org/repositories/revision/lima/3439
Log:
Refactoring report - balance, ledger, financialstatement
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,13 +27,10 @@
<import>
javax.swing.ListSelectionModel
- org.jdesktop.swingx.JXDatePicker
org.jdesktop.swingx.decorator.HighlighterFactory
- org.chorem.lima.enums.ComboBoxDatesEnum
org.chorem.lima.ui.accountsreports.AccountComboBox
org.chorem.lima.ui.common.AccountComboBoxModel
- org.chorem.lima.ui.common.FiscalPeriodComboBoxModel
- org.chorem.lima.ui.common.FinancialPeriodComboBoxModel
+ org.chorem.lima.ui.common.IntervalPanel
</import>
<AccountsReportsViewHandler id="handler" constructorParams="this"/>
@@ -47,29 +44,8 @@
</script>
<row weightx="1" weighty="0" anchor="center">
<cell fill='horizontal'>
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="handler.periodTypeChanged()"/>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
- <cell fill='horizontal'>
- <CardLayout id="periodTypeLayout" />
- <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
- <FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
- <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
- <FinancialPeriodComboBoxModel id="financialPeriodModel" />
- <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
- <JPanel constraints='"PERIOD"'>
- <JLabel text="lima.common.begindate" />
- <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- <JLabel text="lima.common.enddate" />
- <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- </JPanel>
- </JPanel>
- </cell>
<cell fill='horizontal' anchor="east">
<JLabel id="accountSelectorLabel" text="lima.common.account"/>
</cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -29,15 +29,9 @@
import java.awt.event.ItemEvent;
import java.math.BigDecimal;
-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;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.AccountService;
@@ -49,7 +43,6 @@
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -60,9 +53,6 @@
protected AccountsReportsView view;
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsViewHandler.class);
-
/** Services. */
protected ReportService reportService;
protected AccountService accountService;
@@ -89,49 +79,17 @@
List<Account> account = accountService.getAllAccounts();
view.getAccountComboboxModel().setObjects(account);
List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- view.getFiscalPeriodModel().setObjects(fiscalPeriod);
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getFinancialPeriodModel().setObjects(financialPeriod);
-
- // init date periods
- initDatePeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- /**
- * Init date pickers objects with contextual dates.
- */
- private void initDatePeriods() {
-
- // get begin date
- Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
- view.getPeriodBeginDatePicker().setDate(beginDate);
-
- // get end date
- Date endDate = new Date();
- view.getPeriodEndDatePicker().setDate(endDate);
- }
-
- public void periodTypeChanged() {
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
-
- // show corresponding component in layout
- view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
- }
-
- protected void periodsChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
protected void accountChanged(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
refreshData();
}
}
- protected void periodDatesChanged() {
+ public void intervalChanged() {
refreshData();
}
@@ -140,34 +98,9 @@
*/
protected void refreshData() {
- Date beginDate = null;
- Date endDate = null;
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- }
-
Account account = (Account)view.getAccountComboBox().getModel().getSelectedItem();
if (beginDate != null && endDate != null && account != null) {
@@ -176,6 +109,8 @@
AccountsReportsTableModel dataModel = view.getAccountsReportsTableModel();
dataModel.setReportDatas(results);
+
+ updateFooter(results);
}
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalancePeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,163 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.balance;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class BalancePeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(BalancePeriodSearchPanel.class);
-
- protected BalanceViewHandler handler;
-
- public BalancePeriodSearchPanel(BalanceViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
-
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
-
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2011 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -24,38 +24,27 @@
*/
package org.chorem.lima.ui.balance;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-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 org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.jdesktop.swingx.JXTable;
+
public class BalanceTable extends JXTable implements KeyListener, MouseListener {
/** serialVersionUID. */
private static final long serialVersionUID = 6093850347322834480L;
- /** log. */
- private static final Log log = LogFactory
- .getLog(BalanceTable.class);
+ public BalanceTable() {
- protected BalanceViewHandler handler;
-
- public BalanceTable(BalanceViewHandler handler) {
-
- this.handler = handler;
-
addKeyListener(this);
addMouseListener(this);
//Get new BigDecimal renderer
setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
-
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -25,18 +25,16 @@
package org.chorem.lima.ui.balance;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.BalanceTrial;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
+import static org.nuiton.i18n.I18n._;
-import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
+import javax.swing.table.AbstractTableModel;
+import org.chorem.lima.beans.BalanceTrial;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.entity.Account;
/**
* Entry book table model.
@@ -47,17 +45,14 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(BalanceTableModel.class);
-
/** data cache */
- protected BalanceTrial cacheDataList;
+ protected BalanceTrial balanceTrial;
@Override
public int getRowCount() {
int result = 0;
- if (cacheDataList != null) {
- result = cacheDataList.getReportsDatas().size();
+ if (balanceTrial != null) {
+ result = balanceTrial.getReportsDatas().size();
}
return result;
}
@@ -125,54 +120,42 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- ReportsDatas currentRow = ((List<ReportsDatas>) cacheDataList.getReportsDatas()).get(row);
+ ReportsDatas currentRow = ((List<ReportsDatas>) balanceTrial.getReportsDatas()).get(row);
//get entries for the period for the current row
- try {
- switch (column) {
- case 0:
- result = currentRow.getAccount().getAccountNumber(); //account number
- break;
- case 1:
- result = currentRow.getAccount().getLabel(); //account label
- break;
- case 2:
- result = currentRow.getAmountDebit(); // total debit
- break;
- case 3:
- result = currentRow.getAmountCredit(); // total crédit
- break;
- case 4: // solde debit
- if (currentRow.getSoldeDebit()) {
- result = currentRow.getAmountSolde();
- } else {
- result = BigDecimal.ZERO;
- }
- break;
- case 5: // solde credit
- if (!currentRow.getSoldeDebit()) {
- result = currentRow.getAmountSolde();
- } else {
- result = BigDecimal.ZERO;
- }
- break;
- }
- } catch (Exception eee) {
- log.debug("Can't get entries", eee);
+ switch (column) {
+ case 0:
+ result = currentRow.getAccount().getAccountNumber(); //account number
+ break;
+ case 1:
+ result = currentRow.getAccount().getLabel(); //account label
+ break;
+ case 2:
+ result = currentRow.getAmountDebit(); // total debit
+ break;
+ case 3:
+ result = currentRow.getAmountCredit(); // total crédit
+ break;
+ case 4: // solde debit
+ if (currentRow.getSoldeDebit()) {
+ result = currentRow.getAmountSolde();
+ } else {
+ result = BigDecimal.ZERO;
+ }
+ break;
+ case 5: // solde credit
+ if (!currentRow.getSoldeDebit()) {
+ result = currentRow.getAmountSolde();
+ } else {
+ result = BigDecimal.ZERO;
+ }
+ break;
}
return result;
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
-
- public void refresh(BalanceTrial datasList) {
- cacheDataList = datasList;
+ public void setBalanceTrial(BalanceTrial balanceTrial) {
+ this.balanceTrial = balanceTrial;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -31,37 +31,22 @@
org.jdesktop.swingx.decorator.HighlighterFactory
org.chorem.lima.business.utils.FormatsEnum
org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
</import>
- <BalanceViewHandler id="handler" javaBean="new BalanceViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <BalanceTableModel id="modelBalanceTable"/>
+ <BalanceViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
-
- BalancePeriodSearchPanel periodSearchPanel = new BalancePeriodSearchPanel(handler);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
]]>
</script>
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <BalancePeriodSearchPanel javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel text="lima.common.filter"/>
@@ -70,17 +55,16 @@
<JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
minimumSize='{balanceFilter.getPreferredSize()}'/>
<Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())'
- onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())'/>
+ onInsertUpdate='handler.accountFilterChanged()'
+ onRemoveUpdate='handler.accountFilterChanged()'/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
selected='false'
- onActionPerformed="getHandler().refresh()"/>
+ onActionPerformed="getHandler().movmentedFilterChanged()"/>
</cell>
<cell>
- <EnumEditor id='DocumentEditor'
- constructorParams='FormatsEnum.class'/>
+ <EnumEditor id='DocumentEditor' constructorParams='FormatsEnum.class'/>
</cell>
<cell>
<JButton text="lima.common.ok"
@@ -90,15 +74,13 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
<JScrollPane>
+ <BalanceTableModel id="balanceTableModel" />
<BalanceTable id="balanceTable"
rowHeight="24"
- constructorParams="getHandler()"
- model="{getModelBalanceTable()}"
+ model="{balanceTableModel}"
highlighters="{HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
columnControlVisible="true"/>
- <ListSelectionModel
- javaBean="getBalanceTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
@@ -119,7 +101,7 @@
<JLabel id="amountCreditLabel"/>
</cell>
<cell>
- <JLabel id="soldeLabel" text="lima.common.solde"/>
+ <JLabel text="lima.common.solde"/>
</cell>
<cell>
<JLabel id="amountSoldeLabel"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -43,6 +43,7 @@
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -50,6 +51,7 @@
import org.chorem.lima.business.api.ReportService;
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -66,107 +68,101 @@
/** Services. */
protected ReportService reportService;
-
protected HttpServerService httpServerServiceMonitorable;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** DatePicker Begin Date. */
- protected Date selectedBeginDate;
-
- /** DatePicker EndDate. */
- protected Date selectedEndDate;
-
- /** Text field Accounts */
- protected String selectedAccounts;
-
- protected BalanceTable table;
-
- protected BalanceTableModel model;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected int port;
-
protected BalanceViewHandler(BalanceView view) {
this.view = view;
reportService = LimaServiceFactory.getService(ReportService.class);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
- fiscalPeriodService =
- LimaServiceFactory.getService(FiscalPeriodService.class);
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
-
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public void setEndDate(Date date) {
- selectedEndDate = date;
- refresh();
+ public void intervalChanged() {
+ refreshData();
}
- public void setAccountFilter(String accounts) {
- selectedAccounts = accounts;
- refresh();
+ public void accountFilterChanged() {
+ refreshData();
}
+
+ public void movmentedFilterChanged() {
+ refreshData();
+ }
/**
- * get all account fot the selected period
- *
- * @return
+ * Refresh table data depending on item selected on combo boxes.
*/
- public BalanceTrial getDataList() {
- BalanceTrial results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, selectedAccounts, false, view.getMovmentedFilter().isSelected());
- return results;
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ String account = view.getBalanceFilter().getText().trim();
+
+ if (beginDate != null && endDate != null) {
+ BalanceTrial balanceTrial = reportService.generateBalanceTrial(beginDate,
+ endDate, account, false, view.getMovmentedFilter().isSelected());
+
+ BalanceTableModel dataModel = view.getBalanceTableModel();
+ dataModel.setBalanceTrial(balanceTrial);
+
+ updateFooter(balanceTrial);
+ }
}
- public void refresh() {
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(BalanceTrial balanceTrial) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ balanceTrial.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ balanceTrial.getAmountDebit().toString());
+ BigDecimal amountSolde = balanceTrial.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- if (selectedBeginDate != null && selectedEndDate != null) {
- model = view.getModelBalanceTable();
- BalanceTrial datasList = getDataList();
- model.refresh(datasList);
- /**
- * update the labels credit, debit, solde on the footer
- * get all entries for all accounts on the selected period
- */
-
- if (datasList != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(datasList.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(datasList.getAmountDebit()));
- BigDecimal amountSolde = datasList.getAmountSolde();
- view.amountSoldeLabel.setText(
- String.valueOf(amountSolde));
-
-
- if (amountSolde.compareTo(BigDecimal.ZERO) == 0) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (datasList.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
- }
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.amountSoldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (balanceTrial.getSoldeDebit()) {
+ view.amountSoldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.amountSoldeLabel.setText(_("lima.common.soldecredit"));
}
}
}
public void createDocument() {
- if (selectedBeginDate != null & selectedEndDate != null) {
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+ if (beginDate != null & endDate != null) {
+
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -174,8 +170,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -195,9 +191,10 @@
String address = LimaConfig.getInstance().getHostAdress();
try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate) + "&format="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate) + "&format="
+ selectedEnum.getExtension() + "&model="
+ DocumentsEnum.BALANCE.getFileName();
Desktop.getDesktop().browse(new URI(url));
@@ -211,9 +208,9 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("importAccount") || methodeName.contains("importAll")) {
- refresh();
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") || methodName.contains("importAccount") || methodName.contains("importAll")) {
+ refreshData();
}
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Balance.
+ */
+package org.chorem.lima.ui.balance;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalListener.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,260 @@
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 CodeLutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+package org.chorem.lima.ui.common;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.awt.BorderLayout;
+import java.awt.CardLayout;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Insets;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.JComboBox;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.lang3.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.enums.ComboBoxDatesEnum;
+import org.jdesktop.swingx.JXDatePicker;
+
+/**
+ * Panel permettant de selectionner un interval de date suivant plusieurs type
+ * possible:
+ * <ul>
+ * <li>date d'un exercice
+ * <li>date d'une perdiode comptable
+ * <li>deux dates
+ * </ul>
+ *
+ * Il supporte les listeners, donc on peut être notifié d'un changement
+ * d'interval.
+ *
+ * @author echatellier
+ */
+public class IntervalPanel extends JPanel implements ActionListener, ItemListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 5973427750255668999L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(IntervalPanel.class);
+
+ protected List<IntervalListener> listeners;
+
+ protected JComboBox typeComboBox;
+
+ protected CardLayout typeLayout;
+
+ protected JPanel specificTypePanel;
+
+ protected FiscalPeriodComboBoxModel fiscalPeriodComoboBoxModel;
+
+ protected FinancialPeriodComboBoxModel financialPeriodComoboBoxModel;
+
+ protected JXDatePicker beginDatePicker;
+
+ protected JXDatePicker endDatePicker;
+
+ public IntervalPanel() {
+ super(new BorderLayout());
+ listeners = new ArrayList<IntervalListener>();
+ initUI();
+ }
+
+ public void addIntervalListener(IntervalListener listener) {
+ listeners.add(listener);
+ }
+
+ public void removeIntervalListener(IntervalListener listener) {
+ listeners.remove(listener);
+ }
+
+ private void initUI() {
+
+ // type combo box
+ typeComboBox = new JComboBox(ComboBoxDatesEnum.descriptions());
+ add(typeComboBox, BorderLayout.WEST);
+ typeComboBox.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ // show corresponding component in layout
+ typeLayout.show(specificTypePanel, type.name());
+ }
+ });
+
+ typeLayout = new CardLayout();
+ specificTypePanel = new JPanel(typeLayout);
+
+ fiscalPeriodComoboBoxModel = new FiscalPeriodComboBoxModel();
+ JComboBox fiscalPeriodComboBox = new JComboBox(fiscalPeriodComoboBoxModel);
+ fiscalPeriodComboBox.setRenderer(new FiscalPeriodListRenderer());
+ fiscalPeriodComboBox.addItemListener(this);
+ specificTypePanel.add(fiscalPeriodComboBox, ComboBoxDatesEnum.FISCAL_PERIOD.name());
+
+ financialPeriodComoboBoxModel = new FinancialPeriodComboBoxModel();
+ JComboBox financialPeriodComboBox = new JComboBox(financialPeriodComoboBoxModel);
+ financialPeriodComboBox.setRenderer(new FinancialPeriodListRenderer());
+ financialPeriodComboBox.addItemListener(this);
+ specificTypePanel.add(financialPeriodComboBox, ComboBoxDatesEnum.FINANCIAL_PERIOD.name());
+
+ JPanel periodPanel = new JPanel(new GridBagLayout());
+ JLabel beginLabel = new JLabel(_("lima.common.begindate"));
+ periodPanel.add(beginLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ beginDatePicker = new JXDatePicker();
+ beginDatePicker.addActionListener(this);
+ periodPanel.add(beginDatePicker, new GridBagConstraints(1, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ JLabel endLabel = new JLabel(_("lima.common.begindate"));
+ periodPanel.add(endLabel, new GridBagConstraints(2, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+
+ endDatePicker = new JXDatePicker();
+ endDatePicker.addActionListener(this);
+ periodPanel.add(endDatePicker, new GridBagConstraints(3, 0, 1, 1, 0, 0,
+ GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
+ new Insets(1, 1, 1, 1), 0, 0));
+ specificTypePanel.add(periodPanel, ComboBoxDatesEnum.PERIOD.name());
+
+ // get begin date
+ Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
+ beginDatePicker.setDate(beginDate);
+ endDatePicker.setDate(new Date());
+
+ add(specificTypePanel, BorderLayout.CENTER);
+ }
+
+ /**
+ * Init component combo models.
+ *
+ * @param fiscalPeriods fiscal periods
+ * @param financialPeriods financial periods
+ */
+ public void init(List<FiscalPeriod> fiscalPeriods, List<FinancialPeriod> financialPeriods) {
+ fiscalPeriodComoboBoxModel.setObjects(fiscalPeriods);
+ financialPeriodComoboBoxModel.setObjects(financialPeriods);
+ }
+
+ /**
+ * Return selected begin date.
+ *
+ * @return begin date, or {@code null} with no valid selection.
+ */
+ public Date getBeginDate() {
+ Date beginDate = null;
+
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = beginDatePicker.getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)financialPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)fiscalPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ }
+ break;
+ }
+ }
+
+ return beginDate;
+ }
+
+ /**
+ * Return selected end date.
+ *
+ * @return end date, or {@code null} with no valid selection.
+ */
+ public Date getEndDate() {
+ Date endDate = null;
+
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) typeComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ endDate = endDatePicker.getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)financialPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)fiscalPeriodComoboBoxModel.getSelectedItem();
+ if (period != null) {
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ }
+
+ return endDate;
+ }
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ fireEvent();
+ }
+ }
+
+ protected void fireEvent() {
+ for (IntervalListener l : listeners) {
+ l.intervalChanged(null);
+ }
+ }
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ fireEvent();
+ }
+}
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/IntervalPanel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -26,8 +26,7 @@
<Table>
<import>
javax.swing.ListSelectionModel
- org.chorem.lima.enums.ComboBoxDatesEnum
- org.jdesktop.swingx.JXDatePicker
+ org.chorem.lima.ui.common.IntervalPanel
</import>
<EntryBooksReportsViewHandler id="handler" constructorParams="this"/>
@@ -40,34 +39,7 @@
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="handler.periodTypeChanged()"/>
- </cell>
- <cell>
- <CardLayout id="periodTypeLayout" />
- <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
- <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
- <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
- <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodModel" />
- <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
- renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
- onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
- <JPanel constraints='"PERIOD"'>
- <JLabel text="lima.common.begindate" />
- <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- <JLabel text="lima.common.enddate" />
- <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
- </JPanel>
- </JPanel>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -30,17 +30,15 @@
import java.awt.Desktop;
import java.awt.event.ItemEvent;
import java.io.IOException;
+import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import javax.swing.JComboBox;
import javax.swing.JOptionPane;
-import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
@@ -59,7 +57,6 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
@@ -106,93 +103,27 @@
List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
view.getEntryBookModel().setObjects(entryBooks);
List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
- view.getFiscalPeriodModel().setObjects(fiscalPeriod);
List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
- view.getFinancialPeriodModel().setObjects(financialPeriod);
-
- // init date periods
- initDatePeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- /**
- * Init date pickers objects with contextual dates.
- */
- private void initDatePeriods() {
-
- // get begin date
- Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
- view.getPeriodBeginDatePicker().setDate(beginDate);
-
- // get end date
- Date endDate = new Date();
- view.getPeriodEndDatePicker().setDate(endDate);
+ public void intervalChanged() {
+ refreshData();
}
- public void periodTypeChanged() {
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
-
- // show corresponding component in layout
- view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
- }
-
- protected void periodsChanged(ItemEvent event) {
- if (event.getStateChange() == ItemEvent.SELECTED) {
- refreshData();
- }
- }
-
protected void entryBookChanged(ItemEvent event) {
if (event.getStateChange() == ItemEvent.SELECTED) {
refreshData();
}
}
-
- protected void periodDatesChanged() {
- refreshData();
- }
- /*public ReportsDatas getDataList() {
- ReportsDatas results = null;
- if (selectedEntryBook != null) {
- results = reportService.generateEntryBooksReports(
- selectedEntryBook, selectedBeginDate, selectedEndDate);
- }
- return results;
- }*/
-
/**
* Refresh table data depending on item selected on combo boxes.
*/
protected void refreshData() {
- Date beginDate = null;
- Date endDate = null;
-
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
- }
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
EntryBook entryBook = (EntryBook)view.getEntryBookCombo().getModel().getSelectedItem();
@@ -202,39 +133,42 @@
EntryBooksReportsTableModel dataModel = view.getEntryBookReportsTableModel();
dataModel.setReportDatas(results);
+
+ updateFooter(results);
}
}
- public void createDocument() {
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(ReportsDatas reportsDatas) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ reportsDatas.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ reportsDatas.getAmountDebit().toString());
+ BigDecimal amountSolde = reportsDatas.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- // FIXME echatellier 20120601 duplicated code
- Date beginDate = null;
- Date endDate = null;
- JComboBox periodComboBox = view.getPeriodComboBox();
- ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- switch (type) {
- case PERIOD:
- beginDate = view.getPeriodBeginDatePicker().getDate();
- endDate = view.getPeriodEndDatePicker().getDate();
- break;
- case FINANCIAL_PERIOD: {
- FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.soldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (reportsDatas.getSoldeDebit()) {
+ view.soldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.soldeLabel.setText(_("lima.common.soldecredit"));
}
- case FISCAL_PERIOD: {
- FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
- if (period != null) {
- beginDate = period.getBeginDate();
- endDate = period.getEndDate();
- }
- break;
- }
}
+ }
+
+ public void createDocument() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
if (beginDate != null && endDate != null) {
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementDocument.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,37 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.financialstatementreport;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-public class FinancialStatementDocument {
-
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportTable.class);
-
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportPeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,161 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.financialstatementreport;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class FinancialStatementReportPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(FinancialStatementReportPeriodSearchPanel.class);
-
- protected FinancialStatementReportTableModel model;
-
- public FinancialStatementReportPeriodSearchPanel(FinancialStatementReportTableModel model) {
- this.model = model;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- model.setBeginDate(beginDatePicker.getDate());
- model.refresh();
- }
- };
- model.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- model.setEndDate(endDatePicker.getDate());
- model.refresh();
- }
- };
- model.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- model.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- model.setBeginDate(fPeriod.getBeginDate());
- model.setEndDate(fPeriod.getEndDate());
- model.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- model.setBeginDate(fPeriod.getBeginDate());
- model.setEndDate(fPeriod.getEndDate());
- model.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -39,14 +39,11 @@
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-
public class FinancialStatementReportTable extends JXTable
implements KeyListener, MouseListener {
private static final long serialVersionUID = 154211277688304679L;
- protected FinancialStatementReportViewHandler handler;
-
protected FinancialStatementReportTableModel model;
private Highlighter colorTransaction;
@@ -54,14 +51,13 @@
/*
* Constructor, call highlighter
*/
- public FinancialStatementReportTable(FinancialStatementReportViewHandler handler) {
- super(handler.getView().modelTable);
- this.handler = handler;
+ public FinancialStatementReportTable(FinancialStatementReportTableModel model) {
+ super(model);
addKeyListener(this);
addMouseListener(this);
- model = this.handler.getView().modelTable;
+ this.model = model;
//highlight financial financial transactions
colorTitle1();
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,30 +27,12 @@
import static org.nuiton.i18n.I18n._;
-import java.awt.Desktop;
-import java.io.IOException;
import java.math.BigDecimal;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.SimpleDateFormat;
-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.LimaConfig;
import org.chorem.lima.beans.FinancialStatementAmounts;
-import org.chorem.lima.business.ServiceListener;
-import org.chorem.lima.business.api.DocumentService;
-import org.chorem.lima.business.api.FinancialStatementService;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.api.HttpServerService;
-import org.chorem.lima.business.api.ImportService;
-import org.chorem.lima.business.utils.DocumentsEnum;
-import org.chorem.lima.business.utils.FormatsEnum;
-import org.chorem.lima.service.LimaServiceFactory;
/**
* Entry book table model.
@@ -62,52 +44,19 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialStatementReportTableModel extends AbstractTableModel implements ServiceListener {
+public class FinancialStatementReportTableModel extends AbstractTableModel {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialStatementReportTableModel.class);
-
- /** Services. */
- protected FinancialStatementService financialStatementService;
-
- protected DocumentService documentService;
-
- /** DatePicker Begin Date. */
- protected Date selectedBeginDate;
-
- /** DatePicker EndDate. */
- protected Date selectedEndDate;
-
- protected int port;
-
- private static SimpleDateFormat dateFormat =
- new SimpleDateFormat("yyyy-MM-dd");
-
/** data cache */
- protected List<FinancialStatementAmounts> cacheDataList;
+ protected List<FinancialStatementAmounts> financialStatementAmounts;
- /** Constructor. */
- public FinancialStatementReportTableModel() {
- financialStatementService =
- LimaServiceFactory.getService(
- FinancialStatementService.class);
-
- LimaServiceFactory.addServiceListener(FinancialStatementService.class, this);
- port = LimaServiceFactory.getService(
- HttpServerService.class).getHttpPort();
- LimaServiceFactory.addServiceListener(ImportService.class, this);
- LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
- documentService = LimaServiceFactory.getService(DocumentService.class);
- }
-
@Override
public int getRowCount() {
int result = 0;
- if (cacheDataList != null) {
- result = cacheDataList.size();
+ if (financialStatementAmounts != null) {
+ result = financialStatementAmounts.size();
}
return result;
}
@@ -162,13 +111,13 @@
public Object getElementAt(int row) {
- Object currentRow = cacheDataList.get(row);
+ Object currentRow = financialStatementAmounts.get(row);
return currentRow;
}
@Override
public Object getValueAt(int row, int column) {
- Object result = cacheDataList.get(row);
+ Object result = financialStatementAmounts.get(row);
//get entries for the period for the current row
if (result instanceof FinancialStatementAmounts) {
FinancialStatementAmounts currentRow = (FinancialStatementAmounts) result;
@@ -220,72 +169,8 @@
return result;
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
- public Date getBeginDate() {
- return selectedBeginDate;
- }
-
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- }
-
- public Date getEndDate() {
- return selectedEndDate;
- }
-
- public void setEndDate(Date date) {
- selectedEndDate = date;
- }
-
- /**
- * get all account for the selected period
- *
- * @return
- */
- public List<FinancialStatementAmounts> getDataList() {
- List<FinancialStatementAmounts> results = null;
- if (selectedBeginDate != null && selectedEndDate != null) {
- results = financialStatementService.financialStatementReport(selectedBeginDate, selectedEndDate);
- }
- return results;
- }
-
- public void refresh() {
- cacheDataList = getDataList();
+ public void setFinancialStatementAmounts(List<FinancialStatementAmounts> financialStatementAmounts) {
+ this.financialStatementAmounts = financialStatementAmounts;
fireTableDataChanged();
}
-
-
- public void createDocument(FormatsEnum formatsEnum) {
-
- if (selectedBeginDate != null && selectedEndDate != null) {
- String address = LimaConfig.getInstance().getHostAdress();
- try {
- String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
- + "&format=" + formatsEnum.getExtension() + "&model="
- + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
- Desktop.getDesktop().browse(new URI(url));
- } catch (IOException e) {
- log.error("Can't open browser", e);
- } catch (URISyntaxException e) {
- log.error("Can't create news URI", e);
- }
- }
- }
-
- @Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("FinancialStatement") || methodeName.contains("importAll")) {
- refresh();
- }
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -26,42 +26,22 @@
<Table>
<import>
javax.swing.ListSelectionModel
- org.chorem.lima.enums.ComboBoxDatesEnum
- org.chorem.lima.ui.financialstatementreport.FinancialStatementReportTableModel
+ org.chorem.lima.ui.common.IntervalPanel
</import>
- <FinancialStatementReportViewHandler
- id="handler"
- javaBean="new FinancialStatementReportViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <FinancialStatementReportTableModel id="modelTable"/>
+
+ <FinancialStatementReportViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
-
- FinancialStatementReportPeriodSearchPanel periodSearchPanel =
- new FinancialStatementReportPeriodSearchPanel(modelTable);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
-
]]>
</script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <FinancialStatementReportPeriodSearchPanel
- javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -75,9 +55,9 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
+ <FinancialStatementReportTableModel id="financialStatementReportTableModel"/>
<FinancialStatementReportTable id="table" rowHeight="24"
- constructorParams="getHandler()"
- model="{getModelTable()}"
+ constructorParams="financialStatementReportTableModel"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
<ListSelectionModel javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/FinancialStatementReportViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -27,6 +27,11 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Desktop;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@@ -34,8 +39,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.LimaConfig;
+import org.chorem.lima.beans.FinancialStatementAmounts;
+import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
+import org.chorem.lima.business.api.FinancialStatementService;
+import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
+import org.chorem.lima.business.api.HttpServerService;
+import org.chorem.lima.business.api.ImportService;
+import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -48,40 +63,70 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialStatementReportViewHandler {
+public class FinancialStatementReportViewHandler implements ServiceListener {
/** log. */
private static final Log log = LogFactory.getLog(FinancialStatementReportViewHandler.class);
protected FinancialStatementReportView view;
- protected FinancialStatementReportTableModel model;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
+ protected FinancialStatementService financialStatementService;
+ private static SimpleDateFormat dateFormat =
+ new SimpleDateFormat("yyyy-MM-dd");
+
protected FinancialStatementReportViewHandler(FinancialStatementReportView view) {
this.view = view;
- fiscalPeriodService =
- LimaServiceFactory.getService(
- FiscalPeriodService.class);
+
+ fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
+ financialStatementService = LimaServiceFactory.getService(FinancialStatementService.class);
+
+ LimaServiceFactory.addServiceListener(FinancialStatementService.class, this);
+ LimaServiceFactory.addServiceListener(ImportService.class, this);
+ LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void refresh() {
- model = view.getModelTable();
- model.refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public FinancialStatementReportView getView() {
- return view;
+ public void intervalChanged() {
+ refreshData();
}
+ /**
+ * Refresh table data depending on item selected on combo boxes.
+ */
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null && endDate != null) {
+ List<FinancialStatementAmounts> results =
+ financialStatementService.financialStatementReport(beginDate, endDate);
+
+ FinancialStatementReportTableModel dataModel = view.getFinancialStatementReportTableModel();
+ dataModel.setFinancialStatementAmounts(results);
+ }
+ }
+
public void createDocument() {
- model = view.getModelTable();
- Date selectedBeginDate = model.getBeginDate();
- Date selectedEndDate = model.getEndDate();
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
- if (selectedBeginDate != null && selectedEndDate != null) {
+ if (beginDate != null && endDate != null) {
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -89,8 +134,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -106,8 +151,30 @@
} else {
FormatsEnum selectedEnum =
(FormatsEnum) view.getDocumentEditor().getSelectedItem();
- model.createDocument(selectedEnum);
+
+ String address = LimaConfig.getInstance().getHostAdress();
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
+ String url = "http://" + address + ":" + port + "/?beginDate="
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ + "&format=" + selectedEnum.getExtension() + "&model="
+ + DocumentsEnum.FINANCIALSTATEMENT.getFileName();
+ try {
+ Desktop.getDesktop().browse(new URI(url));
+ } catch (IOException e) {
+ log.error("Can't open browser", e);
+ } catch (URISyntaxException e) {
+ log.error("Can't create news URI", e);
+ }
}
}
}
+
+ @Override
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") ||
+ methodName.contains("FinancialStatement") || methodName.contains("importAll")) {
+ refreshData();
+ }
+ }
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Bilan/Compte de resultats.
+ */
+package org.chorem.lima.ui.financialstatementreport;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialstatementreport/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerPeriodSearchPanel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -1,161 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.ledger;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class LedgerPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(LedgerPeriodSearchPanel.class);
-
- protected LedgerViewHandler handler;
-
- public LedgerPeriodSearchPanel(LedgerViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -40,7 +40,6 @@
import java.awt.event.MouseListener;
import java.math.BigDecimal;
-
/**
* Table des transaction qui ajoute des comportement (keys).
*
@@ -52,16 +51,12 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected LedgerViewHandler handler;
-
private Highlighter colorReportsDatas;
/**
*/
- public LedgerTable(LedgerViewHandler handler) {
+ public LedgerTable() {
- this.handler = handler;
-
addKeyListener(this);
addMouseListener(this);
@@ -70,7 +65,6 @@
//highlight financial financial transactions
addColorReportsDatas();
-
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,21 +25,20 @@
package org.chorem.lima.ui.ledger;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
+import static org.nuiton.i18n.I18n._;
-import javax.swing.table.AbstractTableModel;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
-import static org.nuiton.i18n.I18n._;
+import javax.swing.table.AbstractTableModel;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+
/**
* Entry book table model.
*
@@ -55,19 +54,16 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** log. */
- private static final Log log = LogFactory.getLog(LedgerTableModel.class);
-
/** data cache */
- protected List<Object> cacheDataList;
+ protected List<Object> objects;
@Override
public int getRowCount() {
int result = 0;
// just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.size();
+ if (objects != null) {
+ result = objects.size();
}
return result;
@@ -151,8 +147,8 @@
Object result = null;
// just prevent too much result
- if (cacheDataList != null) {
- result = cacheDataList.get(row);
+ if (objects != null) {
+ result = objects.get(row);
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("dd MMMMM yyyy");
@@ -246,8 +242,8 @@
}
- public void refresh(List<Object> datasList) {
- cacheDataList = datasList;
+ public void setObjects(List<Object> datasList) {
+ objects = datasList;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2012-06-04 16:07:10 UTC (rev 3439)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -24,35 +24,25 @@
-->
<Table>
- <LedgerViewHandler id="handler" javaBean="new LedgerViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/>
- <org.chorem.lima.ui.ledger.LedgerTableModel id="modelTable"/>
+ <import>
+ javax.swing.ListSelectionModel
+ org.chorem.lima.enums.ComboBoxDatesEnum
+ org.chorem.lima.ui.common.IntervalPanel
+ </import>
+
+ <LedgerViewHandler id="handler" constructorParams="this"/>
+
<script>
<![CDATA[
- import org.chorem.lima.enums.ComboBoxDatesEnum;
- LedgerPeriodSearchPanel periodSearchPanel = new LedgerPeriodSearchPanel(handler);
-
void $afterCompleteSetup() {
+ handler.init();
}
-
]]>
</script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
- <Table>
- <row>
- <cell anchor="west">
- <JComboBox id="periodComboBox"
- javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
- </cell>
- <cell>
- <LedgerPeriodSearchPanel javaBean="periodSearchPanel"/>
- </cell>
- </row>
- </Table>
+ <IntervalPanel id="intervalPanel" onIntervalChanged="handler.intervalChanged()" />
</cell>
<cell anchor="east">
<JLabel text="lima.common.filter"/>
@@ -61,13 +51,13 @@
<JTextField id='balanceFilter' toolTipText="lima.tooltip.filter"
minimumSize='{balanceFilter.getPreferredSize()}'/>
<javax.swing.text.Document javaBean="balanceFilter.getDocument()"
- onInsertUpdate='handler.setAccountFilter(balanceFilter.getText())'
- onRemoveUpdate='handler.setAccountFilter(balanceFilter.getText())'/>
+ onInsertUpdate='handler.accountFilterChanged()'
+ onRemoveUpdate='handler.accountFilterChanged()'/>
</cell>
<cell anchor="center">
<JCheckBox id='movmentedFilter' text='lima.common.movmentedfilter'
selected='false'
- onActionPerformed="getHandler().refresh()"/>
+ onActionPerformed="getHandler().movmentedFilterChanged()"/>
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -81,12 +71,9 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="8">
<JScrollPane>
- <org.chorem.lima.ui.ledger.LedgerTable
- id="table" sortable="false" rowHeight="24"
- constructorParams="getHandler()" model="{getModelTable()}"
+ <org.chorem.lima.ui.ledger.LedgerTableModel id="ledgerTableModel"/>
+ <org.chorem.lima.ui.ledger.LedgerTable sortable="false" rowHeight="24" model="{ledgerTableModel}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <javax.swing.ListSelectionModel
- javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-06-04 14:34:55 UTC (rev 3438)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -46,6 +46,7 @@
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -55,10 +56,10 @@
import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-
/**
* Handler associated with accounts reports view.
* By : $Author$
@@ -70,70 +71,69 @@
protected LedgerTableModel model;
/** log. */
- private static final Log log = LogFactory.getLog(LedgerTableModel.class);
+ private static final Log log = LogFactory.getLog(LedgerViewHandler.class);
/** Services. */
protected ReportService reportService;
-
-// protected DocumentService documentService;
-
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** Begin Date. */
- protected Date selectedBeginDate;
-
- /** EndDate. */
- protected Date selectedEndDate;
-
- /** Text field Accounts */
- protected String selectedAccounts;
-
- protected BalanceTrial balanceTrialCache;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected int port;
-
- protected List<Object> cachedatasList;
-
protected LedgerViewHandler(LedgerView view) {
this.view = view;
reportService =
LimaServiceFactory.getService(ReportService.class);
LimaServiceFactory.addServiceListener(ReportService.class, this);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getIntervalPanel().init(fiscalPeriod, financialPeriod);
}
- public void setEndDate(Date date) {
- selectedEndDate = date;
+ public void intervalChanged() {
+ refreshData();
}
- public void setAccountFilter(String accounts) {
- selectedAccounts = accounts;
- refresh();
+ public void accountFilterChanged() {
+ refreshData();
}
+
+ public void movmentedFilterChanged() {
+ refreshData();
+ }
/**
- * get all account fot the selected period
- *
- * @return
+ * Refresh table data depending on item selected on combo boxes.
*/
- public List<Object> getDataList() {
- List<Object> results = new ArrayList<Object>();
- balanceTrialCache = reportService.generateLedger(selectedBeginDate,
- selectedEndDate, selectedAccounts,
- view.getMovmentedFilter().isSelected());
- if (balanceTrialCache.getReportsDatas() != null) {
- for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) {
+ protected void refreshData() {
+
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ String account = view.getBalanceFilter().getText().trim();
+
+ if (beginDate != null && endDate != null) {
+ BalanceTrial balanceTrial = reportService.generateLedger(beginDate,
+ endDate, account, view.getMovmentedFilter().isSelected());
+
+ LedgerTableModel dataModel = view.getLedgerTableModel();
+
+ List<Object> results = new ArrayList<Object>();
+ for (ReportsDatas reportsDatas : balanceTrial.getReportsDatas()) {
results.add(reportsDatas);
List<Entry> entries = reportsDatas.getListEntry();
if (entries != null) {
@@ -141,48 +141,45 @@
results.addAll(entries);
}
}
+ dataModel.setObjects(results);
+
+ updateFooter(balanceTrial);
}
-
- return results;
}
- public void refresh() {
- if (selectedBeginDate != null && selectedEndDate != null) {
- model = view.getModelTable();
- cachedatasList = getDataList();
- model.refresh(cachedatasList);
+ /**
+ * Update footer labels containing reports total sum fields.
+ *
+ * @param results result to render
+ */
+ protected void updateFooter(BalanceTrial balanceTrial) {
+ // set amounts credit and debit and solde
+ view.amountCreditLabel.setText(
+ balanceTrial.getAmountCredit().toString());
+ view.amountDebitLabel.setText(
+ balanceTrial.getAmountDebit().toString());
+ BigDecimal amountSolde = balanceTrial.getAmountSolde();
+ view.amountSoldeLabel.setText(amountSolde.toString());
- /**
- * set text and amounts of labels credit, debit, solde
- */
- if (balanceTrialCache != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(balanceTrialCache.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(balanceTrialCache.getAmountDebit()));
- BigDecimal amountSolde = balanceTrialCache.getAmountSolde();
- view.amountSoldeLabel.setText(
- String.valueOf(amountSolde));
-
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (balanceTrialCache.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
- }
+ if (BigDecimal.ZERO.equals(amountSolde)) {
+ view.amountSoldeLabel.setText(_("lima.common.solde"));
+ } else {
+ // set label solde: credit or debit
+ if (balanceTrial.getSoldeDebit()) {
+ view.amountSoldeLabel.setText(_("lima.common.soldedebit"));
+ } else {
+ view.amountSoldeLabel.setText(_("lima.common.soldecredit"));
}
}
}
-
+
public void createDocument() {
- if (selectedBeginDate != null && selectedEndDate != null) {
+ Date beginDate = view.getIntervalPanel().getBeginDate();
+ Date endDate = view.getIntervalPanel().getEndDate();
+
+ if (beginDate != null && endDate != null) {
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -191,8 +188,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -211,9 +208,10 @@
String address = LimaConfig.getInstance().getHostAdress();
try {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.LEDGER.getFileName();
Desktop.getDesktop().browse(new URI(url));
@@ -227,11 +225,11 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
+ public void notifyMethod(String serviceName, String methodName) {
if (serviceName.contains("FinancialTransaction") ||
- methodeName.contains("importAccount") ||
- methodeName.contains("importAll")) {
- refresh();
+ methodName.contains("importAccount") ||
+ methodName.contains("importAll")) {
+ refreshData();
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java 2012-06-04 16:07:10 UTC (rev 3439)
@@ -0,0 +1,26 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Codelutin, Chatellier Eric
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+/**
+ * Rapport - Grand livre.
+ */
+package org.chorem.lima.ui.ledger;
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r3438 - trunk/lima-business/src/main/java/org/chorem/lima/service
by echatellier@users.chorem.org 04 Jun '12
by echatellier@users.chorem.org 04 Jun '12
04 Jun '12
Author: echatellier
Date: 2012-06-04 16:34:55 +0200 (Mon, 04 Jun 2012)
New Revision: 3438
Url: http://chorem.org/repositories/revision/lima/3438
Log:
Remove test comment
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:33:59 UTC (rev 3437)
+++ trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:34:55 UTC (rev 3438)
@@ -89,7 +89,6 @@
// see http://openejb.apache.org/embedded-configuration.html
// http://openejb.apache.org/properties-listing.html
// for embedded configuration
- //props.setProperty("openejb.jndiname.format", "ejb/{interfaceClass.simpleName}");
container = EJBContainer.createEJBContainer(props);
}
1
0
r3437 - in trunk/lima-business/src: main/java/org/chorem/lima/service main/resources/META-INF test/resources/META-INF
by echatellier@users.chorem.org 04 Jun '12
by echatellier@users.chorem.org 04 Jun '12
04 Jun '12
Author: echatellier
Date: 2012-06-04 16:33:59 +0200 (Mon, 04 Jun 2012)
New Revision: 3437
Url: http://chorem.org/repositories/revision/lima/3437
Log:
Fix ejb module name to not being generated with application version.
Fix startup from command line.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml
Modified: trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2012-06-04 14:33:59 UTC (rev 3437)
@@ -58,7 +58,7 @@
protected static EJBContainer container;
/** EJB service namespace. */
- protected static final String NAMESPACE = "java:global/lima-business/";
+ protected static final String NAMESPACE = "java:global/lima/";
/**
* Init openejb container.
@@ -89,6 +89,7 @@
// see http://openejb.apache.org/embedded-configuration.html
// http://openejb.apache.org/properties-listing.html
// for embedded configuration
+ //props.setProperty("openejb.jndiname.format", "ejb/{interfaceClass.simpleName}");
container = EJBContainer.createEJBContainer(props);
}
Modified: trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/main/resources/META-INF/ejb-jar.xml 2012-06-04 14:33:59 UTC (rev 3437)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Lima business
@@ -28,7 +29,12 @@
Interceptor based on : http://openejb.apache.org/examples-trunk/alternate-descriptors/
-->
-<ejb-jar>
+<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+ version="3.1">
+ <!-- Le nom est a fixer sinon, il est généré et contient la version -->
+ <module-name>lima</module-name>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
Modified: trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml
===================================================================
--- trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml 2012-06-01 14:01:39 UTC (rev 3436)
+++ trunk/lima-business/src/test/resources/META-INF/ejb-jar.xml 2012-06-04 14:33:59 UTC (rev 3437)
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
<!--
#%L
Lima business
@@ -28,7 +29,12 @@
Interceptor based on : http://openejb.apache.org/examples-trunk/alternate-descriptors/
-->
-<ejb-jar>
+<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="http://java.sun.com/xml/ns/javaee" xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
+ version="3.1">
+ <!-- Le nom est a fixer sinon, il est généré et contient la version -->
+ <module-name>lima</module-name>
<assembly-descriptor>
<interceptor-binding>
<ejb-name>*</ejb-name>
1
0
r3436 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/accountsreports java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/common java/org/chorem/lima/ui/entrybooksreports java/org/chorem/lima/ui/financialtransactionsearch resources/i18n
by echatellier@users.chorem.org 01 Jun '12
by echatellier@users.chorem.org 01 Jun '12
01 Jun '12
Author: echatellier
Date: 2012-06-01 16:01:39 +0200 (Fri, 01 Jun 2012)
New Revision: 3436
Url: http://chorem.org/repositories/revision/lima/3436
Log:
Entry book report refactoring
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2012-06-01 14:01:39 UTC (rev 3436)
@@ -76,7 +76,7 @@
<cell fill='horizontal' anchor="west">
<AccountComboBoxModel id="accountComboboxModel" />
<AccountComboBox id="accountComboBox" model="{accountComboboxModel}"
- renderer="{new org.chorem.lima.ui.common.AccountRenderer()}"
+ renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
onItemStateChanged="handler.accountChanged(event)" />
</cell>
<cell>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.ui.combobox.LeafAccountComboBoxModel;
-import org.chorem.lima.ui.common.AccountRenderer;
+import org.chorem.lima.ui.common.AccountListRenderer;
import org.chorem.lima.util.AccountToString;
import org.chorem.lima.widgets.JWideComboBox;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
@@ -70,7 +70,7 @@
comboBox = new JWideComboBox();
LeafAccountComboBoxModel accountComboBoxModel = new LeafAccountComboBoxModel();
comboBox.setModel(accountComboBoxModel);
- AccountRenderer accountRenderer = new AccountRenderer();
+ AccountListRenderer accountRenderer = new AccountListRenderer();
comboBox.setRenderer(accountRenderer);
AutoCompleteDecorator.decorate(comboBox, AccountToString.getInstance());
comboBox.getEditor().getEditorComponent().addKeyListener(this);
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java (from rev 3429, trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountListRenderer.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -0,0 +1,64 @@
+/*
+ * #%L
+ * Lima Swing
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2008 - 2010 CodeLutin
+ * %%
+ * 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
+ * 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
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package org.chorem.lima.ui.common;
+
+import org.chorem.lima.entity.Account;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import java.awt.Component;
+
+public class AccountListRenderer extends DefaultListCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Component getListCellRendererComponent(JList list,
+ Object value,
+ int index,
+ boolean isSelected,
+ boolean cellHasFocus) {
+
+ JLabel label = (JLabel) super.getListCellRendererComponent(list,
+ value,
+ index,
+ isSelected,
+ cellHasFocus
+ );
+ if (value != null) {
+ Account account = (Account) value;
+ String accountLabel = account.getLabel();
+ int nbChars = 30;
+ if (accountLabel != null && accountLabel.length() > nbChars) {
+ accountLabel = accountLabel.substring(0, nbChars) + "…";
+ }
+ label.setText(account.getAccountNumber() + " - " + accountLabel);
+ }
+ return this;
+ }
+
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AccountRenderer.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -1,64 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.common;
-
-import org.chorem.lima.entity.Account;
-
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import java.awt.Component;
-
-public class AccountRenderer extends DefaultListCellRenderer {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Component getListCellRendererComponent(JList list,
- Object value,
- int index,
- boolean isSelected,
- boolean cellHasFocus) {
-
- JLabel label = (JLabel) super.getListCellRendererComponent(list,
- value,
- index,
- isSelected,
- cellHasFocus
- );
- if (value != null) {
- Account account = (Account) value;
- String accountLabel = account.getLabel();
- int nbChars = 30;
- if (accountLabel != null && accountLabel.length() > nbChars) {
- accountLabel = accountLabel.substring(0, nbChars) + "…";
- }
- label.setText(account.getAccountNumber() + " - " + accountLabel);
- }
- return this;
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBookComboBox.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,69 +25,41 @@
package org.chorem.lima.ui.entrybooksreports;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+
+import javax.swing.JComboBox;
+
import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
import org.chorem.lima.util.EntryBookToString;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-import javax.swing.JComboBox;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-
public class EntryBookComboBox extends JComboBox implements KeyListener {
private static final long serialVersionUID = 1L;
- private static final Log log =
- LogFactory.getLog(EntryBookComboBox.class);
-
- protected EntryBooksReportsViewHandler handler;
-
- public EntryBookComboBox(EntryBooksReportsViewHandler handler) {
- this.handler = handler;
- EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
- setModel(entryBookComboBoxModel);
- setRenderer(LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class));
- setEditable(true);
+ public EntryBookComboBox() {
AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance());
getEditor().getEditorComponent().addKeyListener(this);
- addActionListener(this);
}
public void back() {
int row = getSelectedIndex();
- log.debug(row);
if (row > 0) {
getEditor().setItem(getItemAt(row - 1));
- handler.setEntryBook((EntryBook) getSelectedItem());
}
}
public void next() {
int size = getModel().getSize();
int row = getSelectedIndex();
- log.debug(row);
if (row < size - 1) {
getEditor().setItem(getItemAt(row + 1));
- handler.setEntryBook((EntryBook) getSelectedItem());
}
}
@Override
- public void actionPerformed(ActionEvent e) {
- Object object = getSelectedItem();
- if (object instanceof EntryBook) {
- handler.setEntryBook((EntryBook) getSelectedItem());
- }
- }
-
-
- @Override
public void keyPressed(KeyEvent e) {
}
@@ -96,7 +68,7 @@
public void keyReleased(KeyEvent e) {
Object object = getSelectedItem();
if (object instanceof EntryBook) {
- handler.setEntryBook((EntryBook) getSelectedItem());
+ fireActionEvent();
}
// delegate popup list menu
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
@@ -108,5 +80,4 @@
public void keyTyped(KeyEvent e) {
}
-
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsPeriodSearchPanel.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -1,162 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * 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
- * 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
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package org.chorem.lima.ui.entrybooksreports;
-
-import org.apache.commons.lang3.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.enums.ComboBoxDatesEnum;
-import org.chorem.lima.ui.LimaRendererUtil;
-import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
-import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.JComboBox;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.ListCellRenderer;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.nuiton.i18n.I18n._;
-
-public class EntryBooksReportsPeriodSearchPanel extends JPanel {
-
- private static final Log log =
- LogFactory.getLog(EntryBooksReportsPeriodSearchPanel.class);
-
- protected EntryBooksReportsViewHandler handler;
-
- public EntryBooksReportsPeriodSearchPanel(EntryBooksReportsViewHandler handler) {
- this.handler = handler;
-
- //init date
- refresh(ComboBoxDatesEnum.FISCAL_PERIOD);
- }
-
- public void refresh(ComboBoxDatesEnum comboBoxPeriodEnum) {
-
- switch (comboBoxPeriodEnum) {
- case PERIOD:
- // get begin date
- Calendar calendarBegin = Calendar.getInstance();
- // set begindate to JAN 1 - 0:00.000 of this years
- Date beginDate = calendarBegin.getTime();
- beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- //handler().setBeginDate(beginDate);
-
- // get end date
- Calendar calendarEnd = Calendar.getInstance();
- Date endDate = calendarEnd.getTime();
- //handler().setEndDate(endDate);
- JLabel beginDateLabel = new JLabel(_("lima.common.begindate"));
- final JXDatePicker beginDatePicker = new JXDatePicker(beginDate);
- ActionListener beginDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setBeginDate(beginDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setBeginDate(beginDatePicker.getDate());
- beginDatePicker.addActionListener(beginDateActionListener);
-
- JLabel endDateLabel = new JLabel(_("lima.common.enddate"));
- final JXDatePicker endDatePicker = new JXDatePicker(endDate);
- ActionListener endDateActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.setEndDate(endDatePicker.getDate());
- handler.refresh();
- }
- };
- handler.setEndDate(endDatePicker.getDate());
- endDatePicker.addActionListener(endDateActionListener);
- handler.refresh();
-
- removeAll();
- add(beginDateLabel);
- add(beginDatePicker);
- add(endDateLabel);
- add(endDatePicker);
- break;
-
- case FISCAL_PERIOD:
- FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(true);
- ListCellRenderer renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FiscalPeriod.class);
-
- final JComboBox fiscalPeriod = new JComboBox(fiscalModel);
- fiscalPeriod.setRenderer(renderer);
- fiscalPeriod.setEditable(false);
- ActionListener fiscalPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FiscalPeriod fPeriod = (FiscalPeriod) fiscalPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- fiscalPeriod.addActionListener(fiscalPeriodActionListener);
-
- removeAll();
- add(fiscalPeriod);
- break;
-
- case FINANCIAL_PERIOD:
- FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(true);
- renderer =
- LimaRendererUtil.newDecoratorListCellRenderer(FinancialPeriod.class);
- final JComboBox financialPeriod = new JComboBox(financialModel);
- financialPeriod.setRenderer(renderer);
- financialPeriod.setEditable(false);
- ActionListener financialPeriodActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- FinancialPeriod fPeriod = (FinancialPeriod) financialPeriod.getSelectedItem();
- if (fPeriod != null) {
- handler.setBeginDate(fPeriod.getBeginDate());
- handler.setEndDate(fPeriod.getEndDate());
- handler.refresh();
- }
- }
- };
- financialPeriod.addActionListener(financialPeriodActionListener);
- removeAll();
- add(financialPeriod);
- break;
- }
-
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2008 - 2010 CodeLutin
+ * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -49,8 +49,6 @@
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- protected EntryBooksReportsViewHandler handler;
-
protected EntryBooksReportsTableModel model;
private Highlighter colorReportsDatas;
@@ -61,9 +59,8 @@
/**
*/
- public EntryBooksReportsTable(EntryBooksReportsViewHandler handler, EntryBooksReportsTableModel model) {
+ public EntryBooksReportsTable(EntryBooksReportsTableModel model) {
- this.handler = handler;
this.model = model;
addKeyListener(this);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -38,7 +38,6 @@
import static org.nuiton.i18n.I18n._;
-
/**
* Entry book table model.
* By : $Author$
@@ -52,15 +51,15 @@
private static final Log log = LogFactory.getLog(EntryBooksReportsTableModel.class);
/** data cache */
- protected ReportsDatas cacheDataList;
+ protected ReportsDatas reportData;
@Override
public int getRowCount() {
int result = 0;
// just prevent too much result
- if (cacheDataList != null && cacheDataList.getListEntry() != null) {
- result = cacheDataList.getListEntry().size();
+ if (reportData != null && reportData.getListEntry() != null) {
+ result = reportData.getListEntry().size();
}
return result;
@@ -135,8 +134,8 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- if (cacheDataList.getListEntry() != null) {
- Entry currentRow = cacheDataList.getListEntry().get(row);
+ if (reportData.getListEntry() != null) {
+ Entry currentRow = reportData.getListEntry().get(row);
SimpleDateFormat simpleDateFormat =
new SimpleDateFormat("dd MMMMM yyyy");
@@ -178,18 +177,11 @@
}
public Entry getElementAt(int row) {
- return cacheDataList.getListEntry().get(row);
+ return reportData.getListEntry().get(row);
}
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- // Just read, no write
- return false;
- }
-
- public void refresh(ReportsDatas datasList) {
- cacheDataList = datasList;
+ public void setReportDatas(ReportsDatas datasList) {
+ reportData = datasList;
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2012-06-01 14:01:39 UTC (rev 3436)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2008 - 2010 CodeLutin
+ Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -27,27 +27,17 @@
<import>
javax.swing.ListSelectionModel
org.chorem.lima.enums.ComboBoxDatesEnum
- org.chorem.lima.ui.combobox.EntryBookComboBoxModel
- org.chorem.lima.ui.entrybooksreports.EntryBookComboBox
- org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTable
- org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTableModel
+ org.jdesktop.swingx.JXDatePicker
</import>
- <EntryBooksReportsViewHandler id="handler"
- javaBean="new EntryBooksReportsViewHandler(this)"/>
- <Boolean id="selectedRow" javaBean="false"/>
- <org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/>
- <EntryBooksReportsTableModel id="modelTable"/>
- <script>
- <![CDATA[
- EntryBooksReportsPeriodSearchPanel periodSearchPanel = new EntryBooksReportsPeriodSearchPanel(handler);
- EntryBookComboBox comboBox = new EntryBookComboBox(handler);
-
+ <EntryBooksReportsViewHandler id="handler" constructorParams="this"/>
+
+ <script><![CDATA[
void $afterCompleteSetup() {
+ handler.init();
}
-
- ]]>
- </script>
+ ]]></script>
+
<row weightx="1" weighty="0" anchor="center">
<cell fill='both'>
<Table>
@@ -55,11 +45,26 @@
<cell anchor="west">
<JComboBox id="periodComboBox"
javaBean="new JComboBox(ComboBoxDatesEnum.descriptions())"
- onActionPerformed="periodSearchPanel.refresh(ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem()));
- validate(); repaint()"/>
+ onActionPerformed="handler.periodTypeChanged()"/>
</cell>
<cell>
- <EntryBooksReportsPeriodSearchPanel javaBean="periodSearchPanel"/>
+ <CardLayout id="periodTypeLayout" />
+ <JPanel id="periodTypeContainer" layout="{periodTypeLayout}">
+ <org.chorem.lima.ui.common.FiscalPeriodComboBoxModel id="fiscalPeriodModel" />
+ <JComboBox id="fiscalPeriodComboBox" model="{fiscalPeriodModel}"
+ renderer="{new org.chorem.lima.ui.common.FiscalPeriodListRenderer()}"
+ onItemStateChanged="handler.periodsChanged(event)" constraints='"FISCAL_PERIOD"' />
+ <org.chorem.lima.ui.common.FinancialPeriodComboBoxModel id="financialPeriodModel" />
+ <JComboBox id="financialPeriodComboBox" model="{financialPeriodModel}"
+ renderer="{new org.chorem.lima.ui.common.FinancialPeriodListRenderer()}"
+ onItemStateChanged="handler.periodsChanged(event)" constraints='"FINANCIAL_PERIOD"' />
+ <JPanel constraints='"PERIOD"'>
+ <JLabel text="lima.common.begindate" />
+ <JXDatePicker id="periodBeginDatePicker" onActionPerformed="handler.periodDatesChanged()" />
+ <JLabel text="lima.common.enddate" />
+ <JXDatePicker id="periodEndDatePicker" onActionPerformed="handler.periodDatesChanged()" />
+ </JPanel>
+ </JPanel>
</cell>
</row>
</Table>
@@ -68,15 +73,18 @@
<JLabel id="entryBookSelectorLabel" text="lima.common.entrybook"/>
</cell>
<cell anchor="west">
- <JComboBox javaBean='comboBox'/>
+ <org.chorem.lima.ui.common.EntryBookComboBoxModel id="entryBookModel" />
+ <EntryBookComboBox id="entryBookCombo" model="{entryBookModel}"
+ renderer="{new org.chorem.lima.ui.common.EntryBookListRenderer()}"
+ onItemStateChanged="handler.entryBookChanged(event)"/>
</cell>
<cell>
<JButton id="back" text="lima.common.buttonback"
- onActionPerformed="comboBox.back()"/>
+ onActionPerformed="entryBookCombo.back()"/>
</cell>
<cell>
<JButton id="next" text="lima.common.buttonnext"
- onActionPerformed="comboBox.next()"/>
+ onActionPerformed="entryBookCombo.next()"/>
</cell>
<cell>
<EnumEditor id='DocumentEditor'
@@ -90,13 +98,11 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
- <EntryBooksReportsTable
- id="table" sortable="false" rowHeight="24"
- constructorParams="getHandler(), getModelTable()"
- model="{getModelTable()}"
+ <EntryBooksReportsTableModel id="entryBookReportsTableModel" />
+ <EntryBooksReportsTable id="reportTable" sortable="false" rowHeight="24"
+ constructorParams="entryBookReportsTableModel"
+ model="{entryBookReportsTableModel}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <ListSelectionModel
- javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -28,22 +28,27 @@
import static org.nuiton.i18n.I18n._;
import java.awt.Desktop;
+import java.awt.event.ItemEvent;
import java.io.IOException;
-import java.math.BigDecimal;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.List;
+import javax.swing.JComboBox;
import javax.swing.JOptionPane;
+import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.LimaConfig;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.ServiceListener;
import org.chorem.lima.business.api.DocumentService;
+import org.chorem.lima.business.api.EntryBookService;
+import org.chorem.lima.business.api.FinancialPeriodService;
import org.chorem.lima.business.api.FinancialTransactionService;
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.business.api.HttpServerService;
@@ -52,122 +57,187 @@
import org.chorem.lima.business.utils.DocumentsEnum;
import org.chorem.lima.business.utils.FormatsEnum;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.enums.ComboBoxDatesEnum;
import org.chorem.lima.service.LimaServiceFactory;
/**
* Handler associated with accounts reports view.
+ *
* By : $Author$
*/
public class EntryBooksReportsViewHandler implements ServiceListener {
- protected EntryBooksReportsView view;
-
- protected EntryBooksReportsTable table;
-
- protected EntryBooksReportsTableModel tableModel;
-
/** log. */
private static final Log log = LogFactory.getLog(EntryBooksReportsViewHandler.class);
+ protected EntryBooksReportsView view;
+
/** Services. */
protected ReportService reportService;
-
protected DocumentService documentService;
-
+ protected EntryBookService entryBookService;
protected FiscalPeriodService fiscalPeriodService;
+ protected FinancialPeriodService financialPeriodService;
- /** Account. */
- protected EntryBook selectedEntryBook;
-
- /** Begin Date. */
- protected Date selectedBeginDate;
-
- /** EndDate. */
- protected Date selectedEndDate;
-
- protected int port;
-
private static SimpleDateFormat dateFormat =
new SimpleDateFormat("yyyy-MM-dd");
- protected EntryBooksReportsViewHandler(EntryBooksReportsView view) {
+ public EntryBooksReportsViewHandler(EntryBooksReportsView view) {
this.view = view;
reportService = LimaServiceFactory.getService(ReportService.class);
- port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
documentService = LimaServiceFactory.getService(DocumentService.class);
+ reportService = LimaServiceFactory.getService(ReportService.class);
+ entryBookService = LimaServiceFactory.getService(EntryBookService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
+ financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
LimaServiceFactory.addServiceListener(ImportService.class, this);
LimaServiceFactory.addServiceListener(FinancialTransactionService.class, this);
}
- public void setBeginDate(Date date) {
- selectedBeginDate = date;
- refresh();
+ /**
+ * Init data models and displayed objects.
+ */
+ public void init() {
+
+ // init data models
+ List<EntryBook> entryBooks = entryBookService.getAllEntryBooks();
+ view.getEntryBookModel().setObjects(entryBooks);
+ List<FiscalPeriod> fiscalPeriod = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ view.getFiscalPeriodModel().setObjects(fiscalPeriod);
+ List<FinancialPeriod> financialPeriod = financialPeriodService.getUnblockedFinancialPeriods();
+ view.getFinancialPeriodModel().setObjects(financialPeriod);
+
+ // init date periods
+ initDatePeriods();
}
+
+ /**
+ * Init date pickers objects with contextual dates.
+ */
+ private void initDatePeriods() {
- public void setEndDate(Date date) {
- selectedEndDate = date;
- refresh();
+ // get begin date
+ Date beginDate = DateUtils.truncate(new Date(), Calendar.YEAR);
+ view.getPeriodBeginDatePicker().setDate(beginDate);
+
+ // get end date
+ Date endDate = new Date();
+ view.getPeriodEndDatePicker().setDate(endDate);
}
+ public void periodTypeChanged() {
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
- public void setEntryBook(EntryBook entryBook) {
- selectedEntryBook = entryBook;
- refresh();
+ // show corresponding component in layout
+ view.getPeriodTypeLayout().show(view.getPeriodTypeContainer(), type.name());
}
- public ReportsDatas getDataList() {
+ protected void periodsChanged(ItemEvent event) {
+ if (event.getStateChange() == ItemEvent.SELECTED) {
+ refreshData();
+ }
+ }
+
+ protected void entryBookChanged(ItemEvent event) {
+ if (event.getStateChange() == ItemEvent.SELECTED) {
+ refreshData();
+ }
+ }
+
+ protected void periodDatesChanged() {
+ refreshData();
+ }
+
+ /*public ReportsDatas getDataList() {
ReportsDatas results = null;
if (selectedEntryBook != null) {
results = reportService.generateEntryBooksReports(
selectedEntryBook, selectedBeginDate, selectedEndDate);
}
return results;
- }
+ }*/
- public void refresh() {
+ /**
+ * Refresh table data depending on item selected on combo boxes.
+ */
+ protected void refreshData() {
+
+ Date beginDate = null;
+ Date endDate = null;
- if (selectedBeginDate != null && selectedEndDate != null && selectedEntryBook != null) {
- tableModel = view.getModelTable();
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = view.getPeriodBeginDatePicker().getDate();
+ endDate = view.getPeriodEndDatePicker().getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
+ }
+
+ EntryBook entryBook = (EntryBook)view.getEntryBookCombo().getModel().getSelectedItem();
+
+ if (beginDate != null && endDate != null && entryBook != null) {
+ ReportsDatas results = reportService.generateEntryBooksReports(entryBook,
+ beginDate, endDate);
+
+ EntryBooksReportsTableModel dataModel = view.getEntryBookReportsTableModel();
+ dataModel.setReportDatas(results);
+ }
+ }
- ReportsDatas datasList = getDataList();
+ public void createDocument() {
- tableModel.refresh(datasList);
+ // FIXME echatellier 20120601 duplicated code
+ Date beginDate = null;
+ Date endDate = null;
- /**
- * set text and amounts of labels credit, debit, solde
- */
-
- if (datasList != null) {
- // set amounts credit, debit and solde
- view.amountCreditLabel.setText(
- String.valueOf(datasList.getAmountCredit()));
- view.amountDebitLabel.setText(
- String.valueOf(datasList.getAmountDebit()));
- BigDecimal amountSolde = datasList.getAmountSolde();
- view.amountSoldeLabel.setText(String.valueOf(amountSolde));
-
- if (BigDecimal.ZERO.equals(amountSolde)) {
- view.soldeLabel.setText(_("lima.common.solde"));
- } else {
- // set label solde: credit or debit
- if (datasList.getSoldeDebit()) {
- view.soldeLabel.setText(_("lima.common.soldedebit"));
- } else {
- view.soldeLabel.setText(_("lima.common.soldecredit"));
- }
+ JComboBox periodComboBox = view.getPeriodComboBox();
+ ComboBoxDatesEnum type = ComboBoxDatesEnum.valueOfDescription((String) periodComboBox.getSelectedItem());
+ switch (type) {
+ case PERIOD:
+ beginDate = view.getPeriodBeginDatePicker().getDate();
+ endDate = view.getPeriodEndDatePicker().getDate();
+ break;
+ case FINANCIAL_PERIOD: {
+ FinancialPeriod period = (FinancialPeriod)view.getFinancialPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
}
+ break;
}
+ case FISCAL_PERIOD: {
+ FiscalPeriod period = (FiscalPeriod)view.getFiscalPeriodComboBox().getSelectedItem();
+ if (period != null) {
+ beginDate = period.getBeginDate();
+ endDate = period.getEndDate();
+ }
+ break;
+ }
}
- }
+
+ if (beginDate != null && endDate != null) {
-
- public void createDocument() {
-
- if (selectedBeginDate != null && selectedEndDate != null) {
-
//looks for all blocked fiscal periods
List<FiscalPeriod> blockedFiscalPeriods = fiscalPeriodService.getAllBlockedFiscalPeriods();
@@ -175,8 +245,8 @@
boolean error = true;
for (FiscalPeriod blockedFiscalPeriod : blockedFiscalPeriods) {
- if (blockedFiscalPeriod.getBeginDate().equals(selectedBeginDate)
- && blockedFiscalPeriod.getEndDate().equals(selectedEndDate)
+ if (blockedFiscalPeriod.getBeginDate().equals(beginDate)
+ && blockedFiscalPeriod.getEndDate().equals(endDate)
&& blockedFiscalPeriod.getLocked()) {
error = false;
}
@@ -187,24 +257,25 @@
JOptionPane.showMessageDialog(
view,
_("lima.entrybooksreports.documentcreationfiscalerror"),
- _("lima.common.error"),
+ _("lima.entrybooksreports.documentcreationfiscaltitle"),
JOptionPane.ERROR_MESSAGE);
} else {
+ int port = LimaServiceFactory.getService(HttpServerService.class).getHttpPort();
FormatsEnum selectedEnum = (FormatsEnum) view.getDocumentEditor().getSelectedItem();
String address = LimaConfig.getInstance().getHostAdress();
try {
String url = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.ENTRYBOOKS.getFileName();
Desktop.getDesktop().browse(new URI(url));
String url2 = "http://" + address + ":" + port + "/?beginDate="
- + dateFormat.format(selectedBeginDate)
- + "&endDate=" + dateFormat.format(selectedEndDate)
+ + dateFormat.format(beginDate)
+ + "&endDate=" + dateFormat.format(endDate)
+ "&format=" + selectedEnum.getExtension() + "&model="
+ DocumentsEnum.GENERAL_ENTRYBOOK.getFileName();
Desktop.getDesktop().browse(new URI(url2));
@@ -219,10 +290,9 @@
}
@Override
- public void notifyMethod(String serviceName, String methodeName) {
- if (serviceName.contains("FinancialTransaction") || methodeName.contains("importEntryBook") || methodeName.contains("importAll")) {
- refresh();
+ public void notifyMethod(String serviceName, String methodName) {
+ if (serviceName.contains("FinancialTransaction") || methodName.contains("importEntryBook") || methodName.contains("importAll")) {
+ refreshData();
}
}
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2012-06-01 14:01:39 UTC (rev 3436)
@@ -29,7 +29,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.ui.combobox.AccountComboBoxModel;
-import org.chorem.lima.ui.common.AccountRenderer;
+import org.chorem.lima.ui.common.AccountListRenderer;
import org.chorem.lima.util.AccountToString;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
@@ -50,7 +50,7 @@
public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) {
this.handler = handler;
AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel();
- AccountRenderer accountRenderer = new AccountRenderer();
+ AccountListRenderer accountRenderer = new AccountListRenderer();
setModel(accountComboBoxModel);
setRenderer(accountRenderer);
setEditable(true);
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-06-01 14:01:39 UTC (rev 3436)
@@ -95,6 +95,7 @@
lima.entries.writetransaction=Write entries
lima.entrybooksreports.documentcreationerror=Enable to create document
lima.entrybooksreports.documentcreationfiscalerror=Can't create document on an open fiscal year
+lima.entrybooksreports.documentcreationfiscaltitle=
lima.entrybooksreports.listerror=Can't get entries list
lima.enum.comboboxaccount.account=Account
lima.enum.comboboxaccount.accountlist=Account list
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-01 09:27:45 UTC (rev 3435)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-01 14:01:39 UTC (rev 3436)
@@ -95,6 +95,7 @@
lima.entries.writetransaction=Saisir des écritures
lima.entrybooksreports.documentcreationerror=Erreur lors de la création du document
lima.entrybooksreports.documentcreationfiscalerror=Impossible de créer un document quand la période fiscale est ouverte
+lima.entrybooksreports.documentcreationfiscaltitle=
lima.entrybooksreports.listerror=Erreur lors de la récupération des données de la liste
lima.enum.comboboxaccount.account=Compte
lima.enum.comboboxaccount.accountlist=Liste de comptes
1
0
01 Jun '12
Author: echatellier
Date: 2012-06-01 11:27:45 +0200 (Fri, 01 Jun 2012)
New Revision: 3435
Url: http://chorem.org/repositories/revision/lima/3435
Log:
Fix typo
Modified:
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
===================================================================
--- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-05-30 14:06:48 UTC (rev 3434)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-06-01 09:27:45 UTC (rev 3435)
@@ -94,7 +94,7 @@
lima.entries.searchunbalancedtransaction=Entrées incorrectes
lima.entries.writetransaction=Saisir des écritures
lima.entrybooksreports.documentcreationerror=Erreur lors de la création du document
-lima.entrybooksreports.documentcreationfiscalerror=Impossible de créedr un document quand la période fiscale est ouverte
+lima.entrybooksreports.documentcreationfiscalerror=Impossible de créer un document quand la période fiscale est ouverte
lima.entrybooksreports.listerror=Erreur lors de la récupération des données de la liste
lima.enum.comboboxaccount.account=Compte
lima.enum.comboboxaccount.accountlist=Liste de comptes
1
0