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 2010
- 4 participants
- 37 discussions
Author: echatellier
Date: 2010-06-08 12:06:40 +0200 (Tue, 08 Jun 2010)
New Revision: 2935
Url: http://chorem.org/repositories/revision/lima/2935
Log:
Update slf4j and h2.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-08 09:55:04 UTC (rev 2934)
+++ trunk/pom.xml 2010-06-08 10:06:40 UTC (rev 2935)
@@ -35,14 +35,14 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>1.5.11</version>
+ <version>1.6.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.5.11</version>
+ <version>1.6.0</version>
<scope>runtime</scope>
</dependency>
@@ -104,7 +104,7 @@
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
- <version>1.2.134</version>
+ <version>1.2.137</version>
<scope>runtime</scope>
</dependency>
1
0
r2934 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/accountingrules lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account
by jpepin@users.chorem.org 08 Jun '10
by jpepin@users.chorem.org 08 Jun '10
08 Jun '10
Author: jpepin
Date: 2010-06-08 11:55:04 +0200 (Tue, 08 Jun 2010)
New Revision: 2934
Url: http://chorem.org/repositories/revision/lima/2934
Log:
Accounting rules pour modification des comptes. D?\195?\169boguage de l'UI.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -44,7 +44,7 @@
*/
public void createAccountRules(Account masterAccount, Account account) throws LimaException;
public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException;
- public void updateAccountRules(Account account) throws LimaException;
+ public void updateAccountRules(Account masterAccount, Account account) throws LimaException;
public void updateSubLedgerRules(Account account) throws LimaException;
public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException;
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 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -346,7 +346,7 @@
}
@Override
- public void updateAccountRules(Account account) throws LimaException {
+ public void updateAccountRules(Account masterAccount, Account account) throws LimaException {
// Check if the numberaccount is not blank
if (StringUtils.isBlank(account.getAccountNumber())) {
throw new LimaBusinessException("Invalid AccountNumber : "
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -62,8 +62,31 @@
}
- public void updateAccountRules(Account account) throws LimaException {
- super.updateAccountRules(account);
+ public void updateAccountRules(Account masterAccount, Account account) throws LimaException {
+ log.debug("masterAccount"+masterAccount);
+ log.debug("acccount"+account);
+ super.updateAccountRules(masterAccount, account);
+ // Check if the number account is type numeric
+ if (!StringUtils.isNumeric(account.getAccountNumber())){
+ throw new LimaBusinessException("AccountNumber is not numeric : "
+ + account.getAccountNumber());
+ }
+
+ // Check if the number account start with the number of the master account
+ if (masterAccount!=null && !account.getAccountNumber().startsWith(
+ masterAccount.getAccountNumber())){
+
+ throw new LimaBusinessException(
+ "Account Number not begin with the number account master : "
+ + account.getAccountNumber());
+ }
+
+ // Check if master account have a number between 1 to 8
+ if (masterAccount==null && !account.getAccountNumber().matches("[1-8]")){
+ throw new LimaBusinessException(
+ "Master account is not a digit between 1 to 8 :"
+ + account.getAccountNumber());
+ }
}
public void updateSubLedgerRules(Account account) throws LimaException {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -345,19 +345,30 @@
try {
transaction = beginTransaction();
- //TODO if account
+ // DAO
+ AccountDAO accountDAO =
+ LimaCallaoDAOHelper.getAccountDAO(transaction);
+ Account subAccount = accountDAO.findByTopiaId(account.getTopiaId());
//check rules account if ledger or account
if (account.getGeneralLedger()==null){
- accountingRules.updateAccountRules(account);
+ Account master = accountDAO.findContainsSubAccounts(subAccount);
+ log.debug(master);
+ accountingRules.updateAccountRules(master, account);
+ subAccount.setMasterAccount(account.getMasterAccount());
+ subAccount.setSubAccounts(account.getSubAccounts());
}
else {
accountingRules.updateSubLedgerRules(account);
+ subAccount.setGeneralLedger(account.getGeneralLedger());
+ subAccount.setSubLedgers(account.getSubLedgers());
+ subAccount.setThirdParty(account.getThirdParty());
}
// update account
- AccountDAO accountDAO =
- LimaCallaoDAOHelper.getAccountDAO(transaction);
- accountDAO.update(account);
+ subAccount.setAccountNumber(account.getAccountNumber());
+ subAccount.setLabel(account.getLabel());
+
+ accountDAO.update(subAccount);
commitTransaction(transaction);
}
catch (TopiaException ex) {
@@ -366,6 +377,9 @@
}
throw new LimaException("Can't update account", ex);
}
+ finally {
+ doFinally(transaction, log);
+ }
}
protected TopiaContext beginTransaction() throws TopiaException {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -24,6 +24,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
@@ -81,25 +82,19 @@
@Override
public int getChildCount(Object node) {
int result = 0;
- if (node instanceof Account) {
- if (node == getRoot()) {
- try {
- result = accountService.getChildrenAccounts(null).size();
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
+ if (node == getRoot()) {
+ try {
+ result = accountService.getChildrenAccounts(null).size();
+ } catch (LimaException eee) {
+ log.debug("Can't count child", eee);
}
- else {
- Account parentAccount = (Account) node;
- try {
- List<Account> subaccounts =
- accountService.getChildrenAccounts(parentAccount);
- result = subaccounts.size();
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
+ }
+ else {
+ Account parentAccount = (Account) node;
+ try {
+ result = accountService.getChildrenAccounts(parentAccount).size();
+ } catch (LimaException eee) {
+ log.debug("Can't count child", eee);
}
}
return result;
@@ -113,9 +108,8 @@
List<Account> allAccounts =
accountService.getChildrenAccounts(null);
result = allAccounts.get(index);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
+ } catch (LimaException eee) {
+ log.debug("Can't get child", eee);
}
}
else {
@@ -126,9 +120,8 @@
List<Account> subaccounts =
accountService.getChildrenAccounts(parentAccount);
result = subaccounts.get(index);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
+ } catch (LimaException eee) {
+ log.debug("Can't get child", eee);
}
}
return result;
@@ -145,9 +138,8 @@
List<Account> allAccounts =
accountService.getChildrenAccounts(null);
result = allAccounts.indexOf(child);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
+ } catch (LimaException eee) {
+ log.debug("Can't get index child", eee);
}
}
else {
@@ -156,9 +148,8 @@
List<Account> subaccounts =
accountService.getChildrenAccounts(parentAccount);
result = subaccounts.indexOf(childAccount);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
+ } catch (LimaException eee) {
+ log.debug("Can't get index child", eee);
}
}
return result;
@@ -205,9 +196,7 @@
parentAccount = null;
}
accountService.createAccount(parentAccount, account);
- int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireTreeStructureChanged(path);
- modelSupport.fireChildAdded(path, index, account);
}
/**
@@ -224,9 +213,7 @@
parentAccount = null;
}
accountService.createSubLedger(parentAccount, account);
- int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireTreeStructureChanged(path);
- modelSupport.fireChildAdded(path, index, account);
}
/**
@@ -238,9 +225,15 @@
*/
public void updateAccount(TreePath path, Account account) throws LimaException {
// Calling account service
- accountService.updateAccount(account);
- //refresh the tree of the node
- modelSupport.fireTreeStructureChanged(path.getParentPath());
+ //FIXME Force fire for no update if error. Where is the cache ?
+ try{
+ accountService.updateAccount(account);
+ }
+ catch (LimaBusinessException eee) {
+ modelSupport.fireTreeStructureChanged(path);
+ throw eee;
+ }
+ modelSupport.fireTreeStructureChanged(path);
}
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-08 09:55:04 UTC (rev 2934)
@@ -164,10 +164,8 @@
} else {
treePath = new TreePath(accountsTreeTableModel.getRoot());
}
- //test if selectedrow is account or ledger
-
+ //test if selectedrow is account or ledger
if (selectedObject.getGeneralLedger()==null){
- //TODO pepin 20100507
AccountForm accountForm = new AccountForm(view);
accountForm.setAccount(selectedObject);
// jaxx constructor don't call super() ?
@@ -190,7 +188,6 @@
if (selectedObject != null){
// update it
try {
-
accountsTreeTableModel.
updateAccount(treePath, selectedObject);
} catch (LimaException eee) {
1
0
Author: jpepin
Date: 2010-06-07 23:27:59 +0200 (Mon, 07 Jun 2010)
New Revision: 2933
Url: http://chorem.org/repositories/revision/lima/2933
Log:
Ajout d'une fonction de rafraichissement pour les vues. Optimisation du code au passage.
Added:
trunk/.settings/org.eclipse.core.resources.prefs
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
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/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/combobox/AccountComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
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/financialperiod/FinancialPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
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
trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties
trunk/pom.xml
Added: trunk/.settings/org.eclipse.core.resources.prefs
===================================================================
--- trunk/.settings/org.eclipse.core.resources.prefs (rev 0)
+++ trunk/.settings/org.eclipse.core.resources.prefs 2010-06-07 21:27:59 UTC (rev 2933)
@@ -0,0 +1,3 @@
+#Fri Jun 04 14:14:04 CEST 2010
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -315,7 +315,7 @@
log.debug(account);
//commit
- //commitTransaction(transaction);
+ commitTransaction(transaction);
}
catch (TopiaException ex) {
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -106,7 +106,7 @@
double credit = 0, debit = 0, solde = 0;
if (account != null){
// First subaccount
- List<Account> accounts = account.getSubAccounts();
+ List<Account> accounts = (List<Account>) account.getSubAccounts();
accounts.addAll(account.getSubLedgers());
if (accounts.size() == 0){
reportsDatas = generateSubAccountReportsWithTransaction(account,
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountForm.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
-<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+<JDialog modal="true">
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
<Boolean id="addState" javaBean='true'/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,20 +19,15 @@
package org.chorem.lima.ui.account;
import static org.nuiton.i18n.I18n._;
-
import java.util.List;
-
import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.DialogHelper;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
/**
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/SubLedgerForm.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
-<JDialog defaultCloseOperation="dispose_on_close" modal="true">
+<JDialog modal="true">
<org.chorem.lima.entity.Account id="account" javaBean='null'/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -20,13 +20,9 @@
package org.chorem.lima.ui.accountsreports;
import static org.nuiton.i18n.I18n._;
-
import java.text.SimpleDateFormat;
import java.util.Date;
-
import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
@@ -83,8 +79,10 @@
int result = 0;
// just prevent too much result
- if (selectedAccount != null) {
- result = cacheDataList.getListEntry().size();
+ if (cacheDataList != null) {
+ if (cacheDataList.getListEntry() != null){
+ result = cacheDataList.getListEntry().size();
+ }
}
else {
if (log.isDebugEnabled()) {
@@ -129,7 +127,7 @@
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- if(selectedAccount != null) {
+ if(cacheDataList != null) {
Entry currentRow = cacheDataList.getListEntry().get(row);
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("dd MMMMM yyyy");
@@ -179,21 +177,15 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public void setEndDate(Date date){
selectedEndDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public void setAccount(Account account) {
selectedAccount = account;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public ReportsDatas getDataList(){
@@ -211,4 +203,9 @@
return results;
}
+ public void refresh(){
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
+
}
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -41,35 +41,42 @@
getBeginDatePicker().setDate(beginDate);
getEndDatePicker().setDate(endDate);
+
+ void $afterCompleteSetup() {
+ getHandler().refresh();
+ }
]]>
</script>
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
onActionPerformed="getModelAccountsReportsTable().setBeginDate(beginDatePicker.getDate());
- getHandler().updateFooterLabel()" />
+ getHandler().refresh()" />
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
onActionPerformed="getModelAccountsReportsTable().setEndDate(endDatePicker.getDate());
- getHandler().updateFooterLabel()"/>
+ getHandler().refresh()"/>
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="accountSelectorLabel" text="lima.account"/>
</cell>
- <cell>
+ <cell anchor="west">
<JComboBox id="accountSelectorComboBox"
- model="{getModelAccounts()}"
+ model="{modelAccounts}"
renderer="{new org.chorem.lima.ui.combobox.AccountRenderer()}"
- onItemStateChanged="getModelAccountsReportsTable().setAccount((Account) event.getItem());
- getHandler().updateFooterLabel()"
+ onActionPerformed="getModelAccountsReportsTable().setAccount((Account) accountSelectorComboBox.getSelectedItem());
+ getHandler().refresh()"
editable="false"
/>
</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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,11 +19,10 @@
package org.chorem.lima.ui.accountsreports;
import static org.nuiton.i18n.I18n._;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.ui.ReportsHelper;
+import org.chorem.lima.ui.combobox.AccountComboBoxModel;
/**
@@ -42,23 +41,27 @@
LogFactory.getLog(AccountsReportsViewHandler.class);
protected AccountsReportsView view;
-
- /** Helper **/
- protected ReportsHelper helper;
+
+ protected AccountsReportsTableModel tableModel;
+
+ protected AccountComboBoxModel comboBoxModel;
protected AccountsReportsViewHandler(AccountsReportsView view) {
this.view = view;
}
- /*
+ public void refresh(){
+ tableModel = view.getModelAccountsReportsTable();
+ tableModel.refresh();
+
+ comboBoxModel = view.getModelAccounts();
+ comboBoxModel.refresh();
+
+ /**
* set text and amounts of labels credit, debit, solde
*/
- public void updateFooterLabel(){
- AccountsReportsTableModel tablemodel =
- (AccountsReportsTableModel) view.getAccountsReportsTable().getModel();
+ ReportsDatas cacheDataList = tableModel.cacheDataList;
- ReportsDatas cacheDataList = tablemodel.cacheDataList;
-
if (cacheDataList != null){
// set amounts credit and debit and solde
view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit()));
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -71,7 +71,11 @@
@Override
public int getRowCount() {
- return cacheDataList.getReportsDatas().size();
+ int result = 0;
+ if (cacheDataList != null){
+ result = cacheDataList.getReportsDatas().size();
+ }
+ return result;
}
@Override
@@ -158,14 +162,10 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public void setEndDate(Date date){
selectedEndDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
/**
@@ -187,4 +187,9 @@
return results;
}
+ public void refresh(){
+ cacheDataList = getDataList();
+ 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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -42,28 +42,31 @@
getModelBalanceTable().setEndDate(endDate);
void $afterCompleteSetup() {
- getHandler().updateFooterLabel();
+ getHandler().refresh();
}
]]>
</script>
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
onActionPerformed="getModelBalanceTable().setBeginDate(beginDatePicker.getDate());
- getHandler().updateFooterLabel()" />
+ getHandler().refresh()" />
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
onActionPerformed="getModelBalanceTable().setEndDate(endDatePicker.getDate());
- getHandler().updateFooterLabel()"/>
+ getHandler().refresh()"/>
</cell>
</row>
<row>
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,15 +19,11 @@
package org.chorem.lima.ui.balance;
import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.ReportsHelper;
/**
@@ -50,8 +46,7 @@
/** service **/
protected FinancialTransactionService financialTransactionService;
- /** Helper **/
- protected ReportsHelper helper;
+ protected BalanceTableModel model;
protected BalanceViewHandler(BalanceView view) {
this.view = view;
@@ -60,14 +55,15 @@
}
+ public void refresh(){
+ model = view.getModelBalanceTable();
+ model.refresh();
+
/**
* update the labels credit, debit, solde on the footer
* get all entries for all accounts on the selected period
*/
- public void updateFooterLabel(){
- BalanceTableModel tablemodel =
- (BalanceTableModel) view.getBalanceTable().getModel();
- BalanceTrial cacheDataList = tablemodel.cacheDataList;
+ BalanceTrial cacheDataList = model.cacheDataList;
if (cacheDataList != null){
// set amounts credit, debit and solde
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountComboBoxModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -20,9 +20,8 @@
import java.util.List;
+import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
-import javax.swing.event.ListDataListener;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
@@ -35,7 +34,7 @@
* Account combo box model.
*/
-public class AccountComboBoxModel implements ComboBoxModel {
+public class AccountComboBoxModel extends AbstractListModel implements ComboBoxModel {
private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
@@ -58,17 +57,13 @@
@Override
public void setSelectedItem(Object anItem) {
selectedAccount = anItem;
+ fireContentsChanged(this, -1, -1);
}
- @Override
- public void addListDataListener(ListDataListener arg0) {
- // TODO Auto-generated method stub
-
- }
@Override
public Object getElementAt(int index) {
- return datasCache.get(index);
+ return datasCache.get(index);
}
@Override
@@ -76,12 +71,6 @@
return datasCache.size();
}
- @Override
- public void removeListDataListener(ListDataListener arg0) {
- // TODO Auto-generated method stub
-
- }
-
public List<Account> getDataList(){
List<Account> result = null;
try {
@@ -95,6 +84,11 @@
return result;
}
+
+ public void refresh(){
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/AccountRenderer.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -24,7 +24,6 @@
label.setText(account.getAccountNumber()+" - "+account.getLabel());
}
return label;
-
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookComboBoxModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -18,6 +18,8 @@
package org.chorem.lima.ui.combobox;
import java.util.List;
+
+import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
import org.apache.commons.logging.Log;
@@ -37,7 +39,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class EntryBookComboBoxModel implements ComboBoxModel {
+public class EntryBookComboBoxModel extends AbstractListModel implements ComboBoxModel {
private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
@@ -52,55 +54,27 @@
cacheDatas = getDataList();
}
- /*
- * @see javax.swing.ListModel#getSize()
- */
@Override
public int getSize() {
return cacheDatas.size();
}
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
@Override
public Object getElementAt(int index) {
return cacheDatas.get(index);
}
- /*
- * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
- */
@Override
- public void addListDataListener(ListDataListener l) {
-
- }
-
- /*
- * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
- */
- @Override
- public void removeListDataListener(ListDataListener l) {
-
- }
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
public void setSelectedItem(Object anItem) {
selectedEntryBook = anItem;
}
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
@Override
public Object getSelectedItem() {
return selectedEntryBook;
}
- /*
+ /**
* get the accounts list
*/
public List<EntryBook> getDataList(){
@@ -116,4 +90,9 @@
return result;
}
+ public void refresh(){
+ cacheDatas = getDataList();
+ fireContentsChanged(this, 0, cacheDatas.size());
+ }
+
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FinancialPeriodComboBoxModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,6 +19,8 @@
package org.chorem.lima.ui.combobox;
import java.util.List;
+
+import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
import org.apache.commons.logging.Log;
@@ -39,7 +41,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class FinancialPeriodComboBoxModel implements ComboBoxModel {
+public class FinancialPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel {
private static final Log log =
LogFactory.getLog(FinancialPeriodTableModel.class);
@@ -62,49 +64,21 @@
datasCache=getDataList();
}
- /*
- * @see javax.swing.ListModel#getSize()
- */
@Override
public int getSize() {
return datasCache.size();
}
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
@Override
public Object getElementAt(int index) {
return datasCache.get(index);
}
- /*
- * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
- */
@Override
- public void addListDataListener(ListDataListener l) {
-
- }
-
- /*
- * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
- */
- @Override
- public void removeListDataListener(ListDataListener l) {
-
- }
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
public void setSelectedItem(Object anItem) {
selectedFinancialPeriod = anItem;
}
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
@Override
public Object getSelectedItem() {
return selectedFinancialPeriod;
@@ -125,7 +99,11 @@
log.debug("Can't get Financial Period list",ex);
}
}
- return result;
-
+ return result;
}
+
+ public void refresh(){
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/FiscalPeriodComboBoxModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -18,85 +18,75 @@
package org.chorem.lima.ui.combobox;
+import java.util.List;
+
+import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import javax.swing.event.ListDataListener;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
-public class FiscalPeriodComboBoxModel implements ComboBoxModel{
+public class FiscalPeriodComboBoxModel extends AbstractListModel implements ComboBoxModel{
+
+ private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
protected Object selectedFiscalPeriod;
protected FiscalPeriodService fiscalPeriodService;
+ protected List<FiscalPeriod> datasCache;
+
+
public FiscalPeriodComboBoxModel(){
fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ datasCache = getDataList();
}
- /*
- * @see javax.swing.ListModel#getSize()
- */
@Override
public int getSize() {
- int result = 0;
- // TODO add cache
- try {
- result = fiscalPeriodService.getAllUnblockedFiscalPeriods().size();
- }
- catch (LimaException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- return result;
+ return datasCache.size();
}
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
@Override
public Object getElementAt(int index) {
- Object result = null;
- try {
- result = fiscalPeriodService.getAllUnblockedFiscalPeriods().get(index);
- }
- catch (LimaException ex) {
- ex.printStackTrace();
- }
- return result;
+ return datasCache.get(index);
}
- /*
- * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
- */
- @Override
- public void addListDataListener(ListDataListener l) {
-
- }
- /*
- * @see javax.swing.ListModel#removeListDataListener(javax.swing.event.ListDataListener)
- */
@Override
- public void removeListDataListener(ListDataListener l) {
-
- }
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
public void setSelectedItem(Object anItem) {
selectedFiscalPeriod = anItem;
}
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
@Override
public Object getSelectedItem() {
return selectedFiscalPeriod;
}
+ public List<FiscalPeriod> getDataList(){
+ List<FiscalPeriod> result = null;
+ try {
+ result = fiscalPeriodService.getAllUnblockedFiscalPeriods();
+ }
+ catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get list accounts", eee);
+ }
+ }
+ return result;
+
+ }
+
+ public void refresh(){
+ datasCache = getDataList();
+ fireContentsChanged(this, 0, datasCache.size());
+ }
+
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -20,17 +20,13 @@
package org.chorem.lima.ui.entrybook;
import static org.nuiton.i18n.I18n._;
-
import javax.swing.table.AbstractTableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookService;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.DialogHelper;
/**
* Entry book table model.
@@ -60,13 +56,6 @@
entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
}
- /*
- * @return
- *
- public List<JournalDTO> getData() {
- return data;
- }*/
-
@Override
public int getRowCount() {
int result = 0;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -38,6 +38,8 @@
onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
+ </row>
+ <row>
<cell fill="horizontal">
<JButton id="addButton" text="lima.entrybook.add"
onActionPerformed="getHandler().addEntryBook()"/>
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -20,12 +20,9 @@
package org.chorem.lima.ui.entrybooksreports;
import static org.nuiton.i18n.I18n._;
-
import java.text.SimpleDateFormat;
import java.util.Date;
-
import javax.swing.table.AbstractTableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
@@ -183,21 +180,15 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public void setEndDate(Date date){
selectedEndDate = date;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public void setEntryBook(EntryBook entryBook) {
selectedEntryBook = entryBook;
- cacheDataList=getDataList();
- fireTableDataChanged();
}
public ReportsDatas getDataList(){
@@ -215,4 +206,9 @@
return results;
}
+ public void refresh(){
+ cacheDataList = getDataList();
+ 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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -41,35 +41,42 @@
getBeginDatePicker().setDate(beginDate);
getEndDatePicker().setDate(endDate);
+
+ void $afterCompleteSetup() {
+ getHandler().refresh();
+ }
]]>
</script>
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate());
- getHandler().updateFooterLabel()" />
+ getHandler().refresh()" />
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate());
- getHandler().updateFooterLabel()"/>
+ getHandler().refresh()"/>
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="entryBookSelectorLabel" text="lima.entrybook"/>
</cell>
- <cell>
+ <cell anchor="west">
<JComboBox id="entryBookComboBox"
model="{getModelEntryBook()}"
renderer="{new org.chorem.lima.ui.combobox.EntryBookRenderer()}"
- onItemStateChanged="getModelTable().setEntryBook((EntryBook) event.getItem());
- getHandler().updateFooterLabel()"
+ onActionPerformed="getModelTable().setEntryBook((EntryBook) entryBookComboBox.getSelectedItem());
+ getHandler().refresh()"
editable="false"
/>
</cell>
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -23,7 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.ui.ReportsHelper;
+import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
/**
@@ -42,24 +42,29 @@
LogFactory.getLog(EntryBooksReportsViewHandler.class);
protected EntryBooksReportsView view;
-
- /** Helper **/
- protected ReportsHelper helper;
+
+ protected EntryBooksReportsTable table;
+
+ protected EntryBooksReportsTableModel tableModel;
+
+ protected EntryBookComboBoxModel comboBoxModel;
protected EntryBooksReportsViewHandler(EntryBooksReportsView view) {
this.view = view;
}
-
-
+ public void refresh(){
+ tableModel = view.getModelTable();
+ tableModel.refresh();
+
+ comboBoxModel = view.getModelEntryBook();
+ comboBoxModel.refresh();
+
/**
* set text and amounts of labels credit, debit, solde
*/
- public void updateFooterLabel(){
- EntryBooksReportsTableModel tablemodel = view.getModelTable();
+ ReportsDatas cacheDataList = tableModel.cacheDataList;
- ReportsDatas cacheDataList = tablemodel.cacheDataList;
-
if (cacheDataList != null){
// set amounts credit, debit and solde
view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit()));
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -26,9 +26,7 @@
import javax.swing.table.AbstractTableModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.EntryBookService;
import org.chorem.lima.business.FinancialPeriodService;
-import org.chorem.lima.business.FiscalPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.EntryBook;
@@ -52,19 +50,13 @@
private static final Log log =
LogFactory.getLog(FinancialPeriodTableModel.class);
- /** services */
- protected FiscalPeriodService fiscalPeriodService;
- protected EntryBookService entryBookService;
+ /** service */
protected FinancialPeriodService financialPeriodService;
/** Datas cache */
protected List<ClosedPeriodicEntryBook> cacheDataList;
public FinancialPeriodTableModel() {
- fiscalPeriodService =
- LimaServiceFactory.getInstance().getFiscalPeriodService();
- entryBookService =
- LimaServiceFactory.getInstance().getEntryBookService();
financialPeriodService =
LimaServiceFactory.getInstance().getFinancialPeriodService();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -25,10 +25,7 @@
import java.util.Collections;
import java.util.Date;
import java.util.List;
-
-import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
-
import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,7 +46,6 @@
import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
-import com.sun.xml.bind.Util;
/**
* Basic transaction table model.
@@ -113,28 +109,33 @@
* @return
*/
protected List<Object> getDataList() {
-
List<Object> results = new ArrayList<Object>();
- try {
- List<FinancialTransaction> financialtransactions =
- financialTransactionService.getAllFinancialTransactionsForFinancialPeriod(
- selectedFinancialPeriod);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- results.add(financialtransaction);
- List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
- Collections.sort(entries, new EntryComparator());
- results.addAll(entries);
+ if (selectedFinancialPeriod != null){
+ try {
+ List<FinancialTransaction> financialtransactions =
+ financialTransactionService.getAllFinancialTransactionsForFinancialPeriod(
+ selectedFinancialPeriod);
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
+ Collections.sort(entries, new EntryComparator());
+ results.addAll(entries);
+ }
}
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
-
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+ }
return results;
}
+
+ public void refresh(){
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
@Override
public int getColumnCount() {
@@ -220,8 +221,7 @@
public int getRowCount() {
int result = 0;
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
+ if (cacheDataList != null) {
//cacheDataList = getDataList();
result = cacheDataList.size();
}
@@ -239,7 +239,7 @@
Object result = null;
// just prevent too much result
- if (selectedFinancialPeriod != null) {
+ if (cacheDataList != null) {
result = cacheDataList.get(row);
if (result instanceof FinancialTransaction) {
@@ -332,10 +332,7 @@
public void setFinancialPeriod(FinancialPeriod financialPeriod){
-
selectedFinancialPeriod = financialPeriod;
- cacheDataList = getDataList();
- fireTableDataChanged();
}
/**
@@ -363,7 +360,7 @@
public void addFinancialTransaction() throws LimaException{
/* Calling transaction service */
FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- //if a period and an entrybook is selected
+ //if a period is selected
if (selectedFinancialPeriod != null){
financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
// get today
@@ -422,8 +419,7 @@
@Override
public void setValueAt(Object value, int row, int column) {
int financialTransactionRow=0;
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
+ if (cacheDataList != null) {
Object currentRow = cacheDataList.get(row);
if (currentRow instanceof FinancialTransaction) {
FinancialTransaction currentFinancialTransaction =
@@ -501,9 +497,11 @@
}
public Object getElementAt(int row){
-
- Object currentRow = cacheDataList.get(row);
- return currentRow;
+ Object result = null;
+ if (cacheDataList != null){
+ result = cacheDataList.get(row);
+ }
+ return result;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,11 +19,16 @@
<FinancialTransactionViewHandler id="handler" javaBean="new FinancialTransactionViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
<org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/>
+ <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/>
<script>
<![CDATA[
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FinancialPeriod;
+
+ void $afterCompleteSetup() {
+ getHandler().refresh();
+ }
]]>
</script>
@@ -37,26 +42,31 @@
<JMenuItem text="lima.print"/>
</JPopupMenu> -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/>
</cell>
- <cell>
+ <cell anchor="west">
<JComboBox id="fiscalPeriodComboBox"
- model="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel()}"
+ model="{getModelFiscalPeriod()}"
renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}"
- onItemStateChanged="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) event.getItem())"
+ onActionPerformed="getModelFinancialPeriod().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem());
+ getHandler().refresh()"
editable="false"/>
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="financialPeriodLabel" text="lima.transaction.period"
/>
</cell>
- <cell>
+ <cell anchor="west">
<JComboBox id="financialPeriodComboBox"
model="{getModelFinancialPeriod()}"
renderer="{new org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer()}"
- onItemStateChanged="getFinancialTransactionTableModel().setFinancialPeriod((FinancialPeriod) event.getItem())"
+ onActionPerformed="getFinancialTransactionTableModel().setFinancialPeriod( (FinancialPeriod) financialPeriodComboBox.getSelectedItem());
+ getHandler().refresh()"
editable="false"
/>
</cell>
@@ -74,7 +84,7 @@
</cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
+ <cell fill="both" weightx="1" weighty="1" rows="3" columns="9">
<JScrollPane>
<org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel
id="financialTransactionTableModel"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -28,6 +28,8 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel;
+import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
import org.chorem.lima.util.DialogHelper;
@@ -47,6 +49,14 @@
LogFactory.getLog(FinancialTransactionViewHandler.class);
protected FinancialTransactionView view;
+
+ protected FinancialTransactionTable table;
+
+ protected FinancialTransactionTableModel tableModel;
+
+ protected FiscalPeriodComboBoxModel fiscalPeriodComboBoxModel;
+
+ protected FinancialPeriodComboBoxModel financialPeriodComboBoxModel;
protected FinancialTransactionViewHandler(FinancialTransactionView view) {
this.view = view;
@@ -54,13 +64,11 @@
//add a new transaction
public void addFinancialTransaction() {
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
+ table = view.getFinancialTransactionTable();
+ tableModel = view.getFinancialTransactionTableModel();
try {
- model.addFinancialTransaction();
+ tableModel.addFinancialTransaction();
//select the new line
int numberRow = table.getRowCount();
ListSelectionModel selectionModel =
@@ -81,16 +89,14 @@
//add a new entry to the selected transaction
public void addEmptyEntry(){
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
+ table = view.getFinancialTransactionTable();
+ tableModel = view.getFinancialTransactionTableModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
try {
- model.addEmptyEntry(selectedValue, indexSelectedRow);
+ tableModel.addEmptyEntry(selectedValue, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
@@ -120,15 +126,13 @@
*/
public void deleteSelectedRow(){
- FinancialTransactionTable table =
- (FinancialTransactionTable)view.getFinancialTransactionTable();
- FinancialTransactionTableModel model =
- (FinancialTransactionTableModel)table.getModel();
+ table = view.getFinancialTransactionTable();
+ tableModel = view.getFinancialTransactionTableModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
String message = null;
if (selectedValue instanceof FinancialTransaction) {
message = _("lima.question.remove.transaction");
@@ -143,7 +147,7 @@
if (response == JOptionPane.YES_OPTION) {
try {
- model.removeObject(selectedValue, indexSelectedRow);
+ tableModel.removeObject(selectedValue, indexSelectedRow);
//select the upper line
ListSelectionModel selectionModel =
table.getSelectionModel();
@@ -162,4 +166,15 @@
}
}
}
+
+ public void refresh(){
+ tableModel = view.getFinancialTransactionTableModel();
+ tableModel.refresh();
+
+ fiscalPeriodComboBoxModel = view.getModelFiscalPeriod();
+ fiscalPeriodComboBoxModel.refresh();
+
+ financialPeriodComboBoxModel = view.getModelFinancialPeriod();
+ financialPeriodComboBoxModel.refresh();
+ }
}
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -19,20 +19,13 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
import static org.nuiton.i18n.I18n._;
-
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-
import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.lang.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.EntryBookService;
-import org.chorem.lima.business.FinancialPeriodService;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.FinancialTransactionService;
import org.chorem.lima.business.utils.EntryComparator;
@@ -40,8 +33,6 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialPeriodImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
@@ -73,12 +64,6 @@
/** Transaction service. */
protected final FinancialTransactionService financialTransactionService;
- /** EntryBook service. */
- protected final EntryBookService entryBookService;
-
- /** FinancialPeriod service. */
- protected final FinancialPeriodService financialPeriodService;
-
/** selected financial period */
protected FiscalPeriod selectedFiscalPeriod;
@@ -96,8 +81,6 @@
public FinancialTransactionUnbalancedTableModel() {
/* Services */
financialTransactionService = LimaServiceFactory.getInstance().getTransactionService();
- entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
- financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService();
}
/**
@@ -107,28 +90,34 @@
* @return
*/
protected List<Object> getDataList() {
-
List<Object> results = new ArrayList<Object>();
- try {
- List<FinancialTransaction> financialtransactions =
- financialTransactionService.getAllFinancialTransactionsUnbalanced(selectedFiscalPeriod);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- results.add(financialtransaction);
- List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
- Collections.sort(entries, new EntryComparator());
- results.addAll(entries);
+ if(selectedFiscalPeriod != null){
+ try {
+ List<FinancialTransaction> financialtransactions =
+ financialTransactionService.getAllFinancialTransactionsUnbalanced(selectedFiscalPeriod);
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
+ Collections.sort(entries, new EntryComparator());
+ results.addAll(entries);
+ }
}
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
}
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
return results;
}
+
+ public void refresh(){
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
@Override
public int getColumnCount() {
@@ -215,8 +204,7 @@
int result = 0;
// just prevent too much result
- if (selectedFiscalPeriod != null) {
- //cacheDataList = getDataList();
+ if (cacheDataList != null) {
result = cacheDataList.size();
}
else {
@@ -233,7 +221,7 @@
Object result = null;
// just prevent too much result
- if (selectedFiscalPeriod != null) {
+ if (cacheDataList != null) {
result = cacheDataList.get(row);
if (result instanceof FinancialTransaction) {
@@ -324,11 +312,8 @@
return result;
}
- public void setFiscalPeriod(FiscalPeriod fiscalPeriod){
-
+ public void setFiscalPeriod(FiscalPeriod fiscalPeriod){
selectedFiscalPeriod = fiscalPeriod;
- cacheDataList = getDataList();
- fireTableDataChanged();
}
/**
@@ -371,8 +356,7 @@
entry.setFinancialTransaction(currentTransaction);
financialTransactionService.createEntry(entry);
//on recharge la liste
- cacheDataList = getDataList();
- fireTableDataChanged();
+ refresh();
}
/**
@@ -405,7 +389,7 @@
}
//update the financial transaction in entire
financialTransactionRow =
- getDataList().indexOf(((FinancialTransaction) currentRow));
+ cacheDataList.indexOf(((FinancialTransaction) currentRow));
}
else if (currentRow instanceof Entry) {
Entry currentEntry = (Entry)currentRow;
@@ -444,11 +428,11 @@
}
//update the financial transaction in entire
financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
+ cacheDataList.indexOf(((Entry) currentRow).
getFinancialTransaction());
}
//on recharge la liste
- cacheDataList = getDataList();
+ //TODO PEPIN 20100607 Get financial transaction of cachedatelist on replace it
fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
}
else {
@@ -484,8 +468,7 @@
financialTransactionService.removeEntry(currentEntry);
}
//on recharge la liste
- cacheDataList = getDataList();
- fireTableRowsDeleted(row, getRowCount());
+ refresh();
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -18,12 +18,15 @@
<Table>
<FinancialTransactionUnbalancedViewHandler id="handler" javaBean="new FinancialTransactionUnbalancedViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
- <org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel id="modelFinancialPeriod"/>
+ <org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel id="modelFiscalPeriod"/>
<script>
<![CDATA[
import org.chorem.lima.entity.FiscalPeriod;
- import org.chorem.lima.entity.FinancialPeriod;
+
+ void $afterCompleteSetup() {
+ getHandler().refresh();
+ }
]]>
</script>
@@ -37,19 +40,25 @@
<JMenuItem text="lima.print"/>
</JPopupMenu> -->
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="fiscalPeriodLabel" text="lima.charts.fiscalyear"/>
</cell>
- <cell>
+ <cell anchor="west">
<JComboBox id="fiscalPeriodComboBox"
- model="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel()}"
+ model="{modelFiscalPeriod}"
renderer="{new org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer()}"
- onItemStateChanged="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) event.getItem())"
+ onActionPerformed="getFinancialTransactionUnbalancedTableModel().setFiscalPeriod( (FiscalPeriod) fiscalPeriodComboBox.getSelectedItem());
+ getHandler().refresh()"
editable="false"/>
</cell>
<cell>
- <JButton text="lima.add.entry" onActionPerformed="getHandler().addEmptyEntry()"/>
+ <JButton text="lima.add.entry"
+ onActionPerformed="getHandler().addEmptyEntry()"
+ enabled="{isSelectedRow()}"/>
</cell>
<cell>
<JButton text="lima.common.remove"
@@ -58,7 +67,7 @@
</cell>
</row>
<row>
- <cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
+ <cell fill="both" weightx="1" weighty="1" rows="1" columns="9">
<JScrollPane>
<org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedTableModel
id="financialTransactionUnbalancedTableModel" />
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel;
import org.chorem.lima.util.DialogHelper;
/**
@@ -46,6 +47,12 @@
LogFactory.getLog(FinancialTransactionUnbalancedViewHandler.class);
protected FinancialTransactionUnbalancedView view;
+
+ protected FinancialTransactionUnbalancedTable table;
+
+ protected FinancialTransactionUnbalancedTableModel tableModel;
+
+ protected FiscalPeriodComboBoxModel comboBoxModel;
protected FinancialTransactionUnbalancedViewHandler(FinancialTransactionUnbalancedView view) {
this.view = view;
@@ -55,16 +62,14 @@
//add a new entry to the selected transaction
public void addEmptyEntry(){
- FinancialTransactionUnbalancedTable table =
- (FinancialTransactionUnbalancedTable)view.getFinancialTransactionUnbalancedTable();
- FinancialTransactionUnbalancedTableModel model =
- (FinancialTransactionUnbalancedTableModel)table.getModel();
+ table = view.getFinancialTransactionUnbalancedTable();
+ tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
try {
- model.addEmptyEntry(selectedValue, indexSelectedRow);
+ tableModel.addEmptyEntry(selectedValue, indexSelectedRow);
//select the new line
ListSelectionModel selectionModel =
table.getSelectionModel();
@@ -90,20 +95,18 @@
/**
* Delete selected row in table (could be transaction or entry).
*
- * Called by model.
+ * Called by tableModel.
* @throws LimaException
*/
public void deleteSelectedRow(){
- FinancialTransactionUnbalancedTable table =
- (FinancialTransactionUnbalancedTable)view.getFinancialTransactionUnbalancedTable();
- FinancialTransactionUnbalancedTableModel model =
- (FinancialTransactionUnbalancedTableModel)table.getModel();
+ table = view.getFinancialTransactionUnbalancedTable();
+ tableModel = view.getFinancialTransactionUnbalancedTableModel();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- Object selectedValue = model.getElementAt(indexSelectedRow);
+ Object selectedValue = tableModel.getElementAt(indexSelectedRow);
String message = null;
if (selectedValue instanceof FinancialTransaction) {
message = _("lima.question.remove.transaction");
@@ -118,7 +121,7 @@
if (response == JOptionPane.YES_OPTION) {
try {
- model.removeObject(selectedValue, indexSelectedRow);
+ tableModel.removeObject(selectedValue, indexSelectedRow);
//select the upper line
ListSelectionModel selectionModel =
table.getSelectionModel();
@@ -137,4 +140,12 @@
}
}
}
+
+ public void refresh(){
+ tableModel = view.getFinancialTransactionUnbalancedTableModel();
+ tableModel.refresh();
+
+ comboBoxModel = view.getModelFiscalPeriod();
+ comboBoxModel.refresh();
+ }
}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -1,56 +0,0 @@
-<!-- ##% Lima Swing
- 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 2
- 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<JDialog modal="true">
- <style source="styles.css" />
- <script>
- <![CDATA[
-
- ]]>
- </script>
- <Table>
- <row>
- <cell>
- <JLabel text="lima.closure.period.begin"/>
- </cell>
- <cell>
- <JPanel id="beginPeriod"/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text="lima.to"/>
- </cell>
- <cell>
- <JPanel id="endPeriod"/>
- </cell>
- </row>
- <row>
- <cell columns="2">
- <JTextArea styleClass="warning" text='{_("lima.closure.timespan.warning")}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" text="lima.common.ok" />
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="dispose()"/>
- </cell>
- </row>
- </Table>
-</JDialog>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -26,11 +26,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
-import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.DialogHelper;
/**
* TODO add comment here.
@@ -54,9 +52,6 @@
fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
}
- /*
- * @see javax.swing.table.TableModel#getRowCount()
- */
@Override
public int getRowCount() {
@@ -72,9 +67,6 @@
return result;
}
- /*
- * @see javax.swing.table.TableModel#getColumnCount()
- */
@Override
public int getColumnCount() {
return 2;
@@ -94,9 +86,6 @@
return currentRow;
}
- /*
- * @see javax.swing.table.TableModel#getColumnName(int)
- */
@Override
public String getColumnName(int columnIndex) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -26,18 +26,8 @@
]]>
</script>
- <!--
- <row fill="horizontal" weightx="1" anchor="center" columns="2">
- <cell>
- <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'>
- <JLabel text="lima.fiscalperiod.periodFilterLabel"/>
- <JComboBox id="periodFilterComboBox" />
- </JPanel>
- </cell>
- </row>
- -->
<row>
- <cell fill="both" weightx="1" weighty="1">
+ <cell fill="both" weightx="1" weighty="1" rows="4">
<JScrollPane>
<org.chorem.lima.ui.fiscalperiod.FiscalPeriodTable
id="fiscalPeriodTable" rowHeight="24"
@@ -48,26 +38,23 @@
onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
- <cell fill="horizontal" weighty="1" anchor="north">
- <Table>
- <row>
- <cell>
- <JButton id="addButton" text="lima.fiscalperiod.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/>
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="blockButton" text="lima.fiscalperiod.block" enabled="{isSelectedPeriod()}"
- onActionPerformed="getHandler().blockFiscalPeriod()" />
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="deleteButton" text="DEBUG delete all"
- onActionPerformed="getHandler().removeAllFiscalPeriods()" />
- </cell>
- </row>
- </Table>
- </cell>
</row>
+ <row>
+ <cell fill="horizontal">
+ <JButton id="addButton" text="lima.fiscalperiod.addFiscalPeriod"
+ onActionPerformed="getHandler().addFiscalPeriod()"/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="blockButton" text="lima.fiscalperiod.block" enabled="{isSelectedPeriod()}"
+ onActionPerformed="getHandler().blockFiscalPeriod()" />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JButton id="deleteButton" text="DEBUG delete all"
+ onActionPerformed="getHandler().removeAllFiscalPeriods()" />
+ </cell>
+ </row>
</Table>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css 2010-06-07 21:27:59 UTC (rev 2933)
@@ -1,8 +0,0 @@
-.warning {
- foreground: red;
- // JTextArea sur plusieurs lignes
- lineWrap: true;
- // Implique que les mots ne sont pas coupés
- wrapStyleWord: true;
- editable: false;
-}
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -75,8 +75,7 @@
/**
* Constructor.
*/
- public LedgerTableModel() {
-
+ public LedgerTableModel() {
reportService =
LimaServiceFactory.getInstance().getReportService();
}
@@ -86,7 +85,7 @@
int result = 0;
// just prevent too much result
- if (selectedBeginDate != null && selectedEndDate != null) {
+ if (cacheDataList != null) {
result = cacheDataList.size();
}
else {
@@ -140,7 +139,7 @@
Object result = null;
// just prevent too much result
- if (selectedBeginDate != null && selectedEndDate != null) {
+ if (cacheDataList != null) {
result = cacheDataList.get(row);
SimpleDateFormat simpleDateFormat
= new SimpleDateFormat("dd MMMMM yyyy");
@@ -240,14 +239,10 @@
public void setBeginDate(Date date){
selectedBeginDate = date;
- cacheDataList = getDataList();
- fireTableDataChanged();
}
public void setEndDate(Date date){
selectedEndDate = date;
- cacheDataList = getDataList();
- fireTableDataChanged();
}
/**
@@ -278,4 +273,9 @@
return results;
}
+ public void refresh(){
+ cacheDataList = getDataList();
+ 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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-06-07 21:27:59 UTC (rev 2933)
@@ -40,25 +40,32 @@
getBeginDatePicker().setDate(beginDate);
getEndDatePicker().setDate(endDate);
+
+ void $afterCompleteSetup() {
+ getHandler().refresh();
+ }
]]>
</script>
- <row fill="horizontal" weightx="1" weighty="0" anchor="center">
- <cell>
+ <row weightx="1" weighty="0" anchor="center">
+ <cell anchor="west">
+ <JButton text="lima.refresh" onActionPerformed="getHandler().refresh()"/>
+ </cell>
+ <cell anchor="east">
<JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate());
- getHandler().updateFooterLabel()" />
+ getHandler().refresh()" />
</cell>
- <cell>
+ <cell anchor="east">
<JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
</cell>
- <cell>
+ <cell anchor="west">
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate());
- getHandler().updateFooterLabel()"/>
+ getHandler().refresh()"/>
</cell>
</row>
<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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-06-07 21:27:59 UTC (rev 2933)
@@ -22,7 +22,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.beans.BalanceTrial;
-import org.chorem.lima.ui.ReportsHelper;
/**
@@ -42,30 +41,31 @@
protected LedgerView view;
- /** Helper **/
- protected ReportsHelper helper;
+ protected LedgerTableModel model;
protected LedgerViewHandler(LedgerView view) {
this.view = view;
}
+ public void refresh(){
+ model = view.getModelTable();
+ model.refresh();
- /*
+ /**
* set text and amounts of labels credit, debit, solde
*/
- public void updateFooterLabel(){
- LedgerTableModel tablemodel =
- (LedgerTableModel) view.getTable().getModel();
- BalanceTrial cacheDataList = tablemodel.balanceTrialCache;
+ BalanceTrial cacheDataList = model.balanceTrialCache;
if (cacheDataList != null){
// set amounts credit, debit and solde
- view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit()));
- view.amountDebitLabel.setText(String.valueOf(cacheDataList.getAmountDebit()));
+ view.amountCreditLabel.setText(
+ String.valueOf(cacheDataList.getAmountCredit()));
+ view.amountDebitLabel.setText(
+ String.valueOf(cacheDataList.getAmountDebit()));
Double amountSolde = cacheDataList.getAmountSolde();
- view.amountSoldeLabel.setText(String.valueOf(amountSolde));
+ view.amountSoldeLabel.setText(
+ String.valueOf(amountSolde));
-
if (amountSolde == 0){
view.soldeLabel.setText(_("lima.solde"));
}
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-07 21:27:59 UTC (rev 2933)
@@ -285,6 +285,7 @@
lima.question.remove.journal=Do you want to remove this journal ?
lima.question.remove.transaction=Do you want to remove this transaction ?
lima.quit=Quit
+lima.refresh=\u21BB
lima.remove=Remove
lima.remove.lettering=Remove a letter
lima.remove.transaction=Remove a transaction
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 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-07 21:27:59 UTC (rev 2933)
@@ -9,6 +9,7 @@
Loading\ accounting...=
TODO\ begincalendarPanel=
TODO\ endcalendarPanel=
+\\\\u21BB=
calendarPanel\ TODO=
lima.about.message=\u00C0 propos de Lima
lima.account=Compte
@@ -269,6 +270,7 @@
lima.question.remove.entry=Voulez-vous supprimer cette ligne de transaction?
lima.question.remove.journal=Voulez-vous supprimer ce journal?
lima.question.remove.transaction=Voulez-vous supprimer cette transaction?
+lima.refresh=\u21BB
lima.remove=
lima.remove.lettering=Supprimer la lettre
lima.remove.transaction=Supprimer une transaction
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-06-04 08:43:32 UTC (rev 2932)
+++ trunk/pom.xml 2010-06-07 21:27:59 UTC (rev 2933)
@@ -238,6 +238,7 @@
<properties>
<platform>chorem.org</platform>
<projectId>lima</projectId>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- customized libs version -->
<nuiton-utils.version>1.2.2</nuiton-utils.version>
1
0
Author: jpepin
Date: 2010-06-04 10:43:32 +0200 (Fri, 04 Jun 2010)
New Revision: 2932
Url: http://chorem.org/repositories/revision/lima/2932
Log:
Ajout message d'erreur dans l'ui. Tri des entr?\195?\169es dans l'?\195?\169dition de journal par date et transaction.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.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/financialperiod/FinancialPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -44,6 +44,8 @@
*/
public void createAccountRules(Account masterAccount, Account account) throws LimaException;
public void createSubLedgerRules(Account masterAccount, Account account) throws LimaException;
+ public void updateAccountRules(Account account) throws LimaException;
+ public void updateSubLedgerRules(Account account) throws LimaException;
public void removeAccountRules(Account account, TopiaContext transaction) throws LimaException;
/**
@@ -70,7 +72,7 @@
* @throws LimaException
*/
public void updateEntryRules(Entry entry, Entry entryOld, TopiaContext topiaTransaction) throws LimaException;
- public void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException;
+ public void updateFinancialTransactionDateRules(FinancialTransaction financialTransaction, FinancialTransaction financialTransactionOld, TopiaContext topiaContext) throws LimaException, LimaBusinessException;
/**
* Financialperiod/entrybook rules
* @param financialTransaction
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 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/DefaultAccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -318,7 +318,7 @@
}
catch (TopiaException eee) {
doCatch(topiaContext, eee, log);
- }
+ }
}
@@ -345,4 +345,22 @@
throw new LimaException("Exception during query", cause);
}
+ @Override
+ public void updateAccountRules(Account account) throws LimaException {
+ // Check if the numberaccount is not blank
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+ }
+
+ @Override
+ public void updateSubLedgerRules(Account account) throws LimaException {
+ // check the number account is not empty
+ if (StringUtils.isBlank(account.getAccountNumber())) {
+ throw new LimaBusinessException("Invalid AccountNumber : "
+ + account.getAccountNumber());
+ }
+ }
+
}
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -17,6 +17,7 @@
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialPeriodImpl;
+import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.entity.FiscalPeriodDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
@@ -26,6 +27,7 @@
import org.nuiton.topia.framework.TopiaQuery.Op;
public class FranceAccountingRules extends DefaultAccountingRules {
+
protected static final Log log =
LogFactory.getLog(DefaultAccountingRules.class);
@@ -60,6 +62,14 @@
}
+ public void updateAccountRules(Account account) throws LimaException {
+ super.updateAccountRules(account);
+ }
+
+ public void updateSubLedgerRules(Account account) throws LimaException {
+ super.updateSubLedgerRules(account);
+ }
+
/**
* Règles de vérification d'ouverture d'un exercice, appliquées à la comptabilité française
*
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -148,7 +148,6 @@
accountDAO.create(account);
- log.debug(masterAccount+" "+account);
// check if the masteraccount exist;
if (masterAccount != null) {
masterAccount.addSubLedgers(account);
@@ -344,7 +343,17 @@
TopiaContext transaction = null;
try {
- transaction = beginTransaction();
+ transaction = beginTransaction();
+
+ //TODO if account
+ //check rules account if ledger or account
+ if (account.getGeneralLedger()==null){
+ accountingRules.updateAccountRules(account);
+ }
+ else {
+ accountingRules.updateSubLedgerRules(account);
+ }
+
// update account
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(transaction);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -305,34 +305,29 @@
try {
topiaTransaction = beginTransaction();
EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaTransaction);
- TopiaQuery query = entryDAO.createQuery("E");
- String transactionDateProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.TRANSACTION_DATE);
- String amountCreditProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.AMOUNT_CREDIT);
- String amountDebitProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.AMOUNT_DEBIT);
- query
- .addWhere(amountCreditProperty+" = "+amountDebitProperty)
- .addEquals(Entry.ENTRY_BOOK, entryBook)
- .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
- .addParam("beginDate", beginDate)
- .addParam("endDate", endDate);
+ TopiaQuery entriesQuery = createEntryBookReportsQuery(
+ entryBook, beginDate, endDate, entryDAO, "E");
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
- query.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION);
- List<Entry> entries = entryDAO.findAllByQuery(query);
+ entriesQuery.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION);
+ String orderDateProperty =
+ TopiaQuery.getProperty("E", Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TRANSACTION_DATE);
+ String orderIdProperty =
+ TopiaQuery.getProperty("E", Entry.FINANCIAL_TRANSACTION, FinancialTransaction.TOPIA_ID);
+ entriesQuery.addOrder(orderDateProperty)
+ .addOrder(orderIdProperty);
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
+
+
//TODO 20100603 PEPIN imbriqué les deux conditions de comparator
// tri sur date, tri sur topiaid
- Collections.sort(entries, new EntryFinancialTransactionDateComparator());
- Collections.sort(entries, new EntryFinancialTransactionComparator());
- reportsDatas.setListEntry(entries);
+ //Collections.sort(entries, new EntryFinancialTransactionDateComparator());
+ //Collections.sort(entries, new EntryFinancialTransactionComparator());
- query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
- query.addGroup("E."+Entry.DEBIT);
- results = query.execute(topiaTransaction);
+ TopiaQuery amountsQuery =
+ createEntryBookReportsQuery(entryBook, beginDate, endDate, entryDAO, "E");
+ amountsQuery.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
+ amountsQuery.addGroup("E."+Entry.DEBIT);
+ results = amountsQuery.execute(topiaTransaction);
int nbAmount = results.size();
if(nbAmount==2){
debit = (Double)results.get(0)[1];
@@ -371,6 +366,31 @@
return reportsDatas;
}
+ /**
+ * Query for find entries for accountsreports and balancereports
+ * Just balanced transaction are calculated
+ */
+ public TopiaQuery createEntryBookReportsQuery(EntryBook entryBook, Date beginDate, Date endDate, EntryDAO entryDAO, String queryAlias) throws LimaException{
+ TopiaQuery query = entryDAO.createQuery(queryAlias);
+ String transactionDateProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.TRANSACTION_DATE);
+ String amountCreditProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_CREDIT);
+ String amountDebitProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_DEBIT);
+ query
+ .addWhere(amountCreditProperty+" = "+amountDebitProperty)
+ .addEquals(Entry.ENTRY_BOOK, entryBook)
+ .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ .addParam("beginDate", beginDate)
+ .addParam("endDate", endDate);
+
+ return query;
+ }
+
/**
* Get balance trial
*
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -27,10 +27,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.DialogHelper;
import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
/**
@@ -61,12 +63,6 @@
accountService = LimaServiceFactory.getInstance().getAccountService();
}
- /**
- * @deprecated can't be used
- */
- public Account getData() {
- return (Account) root;
- }
@Override
public int getColumnCount() {
@@ -213,7 +209,6 @@
if (parentAccount == getRoot()) {
parentAccount = null;
}
-
accountService.createAccount(parentAccount, account);
int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireTreeStructureChanged(path);
@@ -232,7 +227,7 @@
Account parentAccount = (Account)path.getLastPathComponent();
if (parentAccount == getRoot()) {
parentAccount = null;
- }
+ }
accountService.createSubLedger(parentAccount, account);
int index = getIndexOfChild(path.getLastPathComponent(), account);
modelSupport.fireTreeStructureChanged(path);
@@ -264,8 +259,8 @@
// Calling account service
int index = getIndexOfChild(
path.getParentPath().getLastPathComponent(), account);
- accountService.removeAccount(account);
- modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ accountService.removeAccount(account);
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -32,6 +32,7 @@
import org.chorem.lima.ui.account.AccountForm;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.account.SubLedgerForm;
+import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTreeTable;
@@ -86,11 +87,12 @@
// add it
try {
accountsTreeTableModel.addAccount(treePath, newAccount);
- } catch (LimaBusinessException ex) {
+ } catch (LimaBusinessException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add account", ex);
+ log.error("Can't add account", eee);
}
- ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
+
}
catch (LimaException ex) {
@@ -125,18 +127,18 @@
try {
accountsTreeTableModel.
addSubLedger(treePath, newAccount);
- } catch (LimaBusinessException ex) {
+ } catch (LimaBusinessException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add subledger", ex);
+ log.error("Can't add subledger", eee);
}
- ErrorHelper.showErrorDialog(ex.getMessage(), ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
- catch (LimaException ex) {
+ catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add subledger", ex);
+ log.error("Can't add subledger", eee);
}
- ErrorHelper.showErrorDialog("Can't add subledger", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
@@ -191,11 +193,11 @@
accountsTreeTableModel.
updateAccount(treePath, selectedObject);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add update", ex);
+ log.error("Can't add update", eee);
}
- ErrorHelper.showErrorDialog("Can't add update", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
@@ -228,11 +230,11 @@
try{
accountsTreeTableModel.removeAccount(treePath, account);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't delete account", ex);
+ log.error("Can't delete account", eee);
}
- ErrorHelper.showErrorDialog("Can't delete account", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -26,9 +26,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.DialogHelper;
/**
* Entry book table model.
@@ -108,16 +110,7 @@
return entryBook;
}
- /*
- * @param row
- * @return
- *
@Override
- public Object getRow(int row) {
- return data.get(row);
- }*/
-
- @Override
public Object getValueAt(int row, int column) {
Object result = null;
@@ -144,37 +137,9 @@
return result;
}
-
-
@Override
- public void setValueAt(Object value, int row, int column) {
-
- try {
- EntryBook entryBook = getEntryBookAtRow(row);
-
- switch (column) {
- case 0:
- entryBook.setCode((String)value);
- break;
- case 1:
- entryBook.setLabel((String)value);
- break;
- case 2:
- entryBook.setType((String)value);
- break;
- }
-
- // update on remote service
- entryBookService.updateEntryBook(entryBook);
- } catch (LimaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- @Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
- // TODO why false ?
+ // Ne cells editable
return false;
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -27,6 +27,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
+import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
@@ -69,11 +70,11 @@
// add it
try {
entryBookTableModel.addEntryBook(newEntryBook);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add entry book", ex);
+ log.error("Can't add entry book", eee);
}
- ErrorHelper.showErrorDialog("Can't add entry book", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
@@ -100,11 +101,11 @@
if (selectedEntryBook != null) {
entryBookTableModel.updateEntryBook(selectedEntryBook);
}
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add update book", ex);
+ log.error("Can't add update book", eee);
}
- ErrorHelper.showErrorDialog("Can't update entry book", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
@@ -129,11 +130,11 @@
if (response == JOptionPane.YES_OPTION) {
entryBookTableModel.removeEntryBook(selectedEntryBook);
}
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't delete update book", ex);
+ log.error("Can't delete update book", eee);
}
- ErrorHelper.showErrorDialog("Can't delete entry book", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
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 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -86,6 +86,9 @@
highlighterReportsDatasBoolean = !highlighterReportsDatasBoolean;
}
oldRow = financialTransaction;
+ if (adapter.row ==0){
+ highlighterReportsDatasBoolean=false;
+ }
return highlighterReportsDatasBoolean;
}
};
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 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -73,8 +73,7 @@
/**
* Constructor.
*/
- public EntryBooksReportsTableModel() {
-
+ public EntryBooksReportsTableModel() {
reportService =
LimaServiceFactory.getInstance().getReportService();
}
@@ -183,17 +182,13 @@
}
public void setBeginDate(Date date){
- log.debug("setBeginDate");
selectedBeginDate = date;
- log.debug(selectedBeginDate);
cacheDataList=getDataList();
fireTableDataChanged();
}
public void setEndDate(Date date){
- log.debug("setEndDate");
selectedEndDate = date;
- log.debug(selectedEndDate);
cacheDataList=getDataList();
fireTableDataChanged();
}
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 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -27,6 +27,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.ClosedPeriodicEntryBook;
+import org.chorem.lima.util.DialogHelper;
/**
* TODO add comment here.
@@ -61,12 +62,11 @@
if (response == JOptionPane.YES_OPTION) {
model.blockFinancialPeriod(closedPeriodicEntryBook);
}
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't block financialperiod", ex);
+ log.error("Can't block financialperiod", eee);
}
- JOptionPane.showMessageDialog(view,
- _("Can't block financialperiod"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -26,6 +26,7 @@
import java.util.Date;
import java.util.List;
+import javax.swing.JOptionPane;
import javax.swing.table.AbstractTableModel;
import org.apache.commons.lang.time.DateUtils;
@@ -45,8 +46,11 @@
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
+import com.sun.xml.bind.Util;
+
/**
* Basic transaction table model.
*
@@ -83,7 +87,7 @@
/** data cache */
protected List<Object> cacheDataList;
-
+
/** collection
@@ -126,8 +130,7 @@
if (log.isErrorEnabled()) {
log.debug("Can't update model", eee);
}
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
}
return results;
@@ -372,8 +375,9 @@
actualCalendar.get(Calendar.DAY_OF_MONTH));
// set date to the financial transaction
financialTransaction.setTransactionDate(transactionDate);
- // create it
+ // create it
financialTransactionService.createFinancialTransaction(financialTransaction);
+
//on recharge la liste
cacheDataList = getDataList();
int row = getDataList().indexOf(financialTransaction);
@@ -406,6 +410,7 @@
//create it
entry.setFinancialTransaction(currentTransaction);
financialTransactionService.createEntry(entry);
+
//on recharge la liste
cacheDataList = getDataList();
fireTableDataChanged();
@@ -433,10 +438,11 @@
try {
financialTransactionService.
updateFinancialTransaction(currentFinancialTransaction);
- } catch (LimaException e) {
+ } catch (LimaException eee) {
if (log.isDebugEnabled()){
- log.debug("Can't update financial transaction", e);
+ log.debug("Can't update financial transaction", eee);
}
+ DialogHelper.showMessageDialog(eee.getMessage());
}
//update the financial transaction in entire
financialTransactionRow =
@@ -472,10 +478,11 @@
try {
financialTransactionService.updateEntry(currentEntry);
- } catch (LimaException e) {
+ } catch (LimaException eee) {
if (log.isDebugEnabled()){
- log.debug("Can't update entry", e);
+ log.debug("Can't update entry", eee);
}
+ DialogHelper.showMessageDialog(eee.getMessage());
}
//update the financial transaction in entire
financialTransactionRow =
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-04 08:43:32 UTC (rev 2932)
@@ -77,7 +77,7 @@
<cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
<JScrollPane>
<org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel
- id="financialTransactionTableModel" />
+ id="financialTransactionTableModel"/>
<org.chorem.lima.ui.financialtransaction.FinancialTransactionTable
id="financialTransactionTable" sortable="false" rowHeight="22"
constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -29,6 +29,7 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
+import org.chorem.lima.util.DialogHelper;
/**
* Handler associated with financial transaction view.
@@ -68,12 +69,11 @@
//focus on first column
table.changeSelection(numberRow-1, 0, false, false);
table.requestFocusInWindow();
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add financialtransaction", ex);
+ log.error("Can't add financialtransaction", eee);
}
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
@@ -98,12 +98,11 @@
//focus on second column
table.changeSelection(indexSelectedRow+1, 1, false, false);
table.requestFocusInWindow();
- } catch (LimaException ex){
+ } catch (LimaException eee){
if (log.isErrorEnabled()) {
- log.error("Can't add emptyentry", ex);
+ log.error("Can't add emptyentry", eee);
}
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
else {
@@ -149,12 +148,11 @@
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't remove transaction or entry", ex);
+ log.error("Can't remove transaction or entry", eee);
}
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
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 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -45,6 +45,7 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -396,10 +397,11 @@
try {
financialTransactionService.
updateFinancialTransaction(currentFinancialTransaction);
- } catch (LimaException e) {
+ } catch (LimaException eee) {
if (log.isDebugEnabled()){
- log.debug("Can't update financial transaction", e);
+ log.debug("Can't update financial transaction", eee);
}
+ DialogHelper.showMessageDialog(eee.getMessage());
}
//update the financial transaction in entire
financialTransactionRow =
@@ -434,10 +436,11 @@
}
try {
financialTransactionService.updateEntry(currentEntry);
- } catch (LimaException e) {
+ } catch (LimaException eee) {
if (log.isDebugEnabled()){
- log.debug("Can't update entry", e);
+ log.debug("Can't update entry", eee);
}
+ DialogHelper.showMessageDialog(eee.getMessage());
}
//update the financial transaction in entire
financialTransactionRow =
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.util.DialogHelper;
/**
* Handler associated with financial transaction view.
@@ -71,12 +72,12 @@
//focus on second column
table.changeSelection(indexSelectedRow+1, 1, false, false);
table.requestFocusInWindow();
- } catch (LimaException ex){
+ } catch (LimaException eee){
if (log.isErrorEnabled()) {
- log.error("Can't add emptyentry", ex);
+ log.error("Can't add emptyentry", eee);
}
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
+ DialogHelper.showMessageDialog(eee.getMessage());
+
}
}
else {
@@ -122,12 +123,11 @@
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't remove transaction or entry", ex);
+ log.error("Can't remove transaction or entry", eee);
}
- JOptionPane.showMessageDialog(view,
- _("lima.warning.entrybookscloded"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -26,9 +26,11 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.DialogHelper;
/**
* TODO add comment here.
@@ -111,26 +113,19 @@
return result;
}
- /*
- * @see javax.swing.table.TableModel#getColumnClass(int)
- */
+
@Override
public Class<?> getColumnClass(int columnIndex) {
// both String
return String.class;
}
- /*
- * @see javax.swing.table.TableModel#isCellEditable(int, int)
- */
+
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return false;
}
- /*
- * @see javax.swing.table.TableModel#getValueAt(int, int)
- */
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
@@ -172,15 +167,6 @@
return result;
}
-
- /*
- * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
- */
- @Override
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
-
- }
-
public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException {
FiscalPeriod fiscalPeriod = null;
@@ -207,6 +193,7 @@
}
public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+
fiscalPeriodService.blockFiscalPeriod(fiscalPeriod);
fireTableDataChanged();
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -31,6 +31,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.ui.fiscalperiod.AddPeriod;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
+import org.chorem.lima.util.DialogHelper;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -81,11 +82,11 @@
if (n == JOptionPane.YES_OPTION || nbMonth ==11){
try {
model.addFiscalPeriod(fiscalPeriod);
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't add fiscal period", ex);
+ log.error("Can't add fiscal period", eee);
}
- ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
}
@@ -110,11 +111,11 @@
if (response == JOptionPane.YES_OPTION) {
model.blockFiscalPeriod(selectedFiscalPeriod);
}
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't block fiscalperiod", ex);
+ log.error("Can't block fiscalperiod", eee);
}
- ErrorHelper.showErrorDialog("Can't block fiscalperiod", ex);
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
@@ -124,11 +125,11 @@
(FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel();
try {
model.removeAllFiscalPeriods();
- } catch (LimaException ex) {
+ } catch (LimaException eee) {
if (log.isErrorEnabled()) {
- log.error("Can't delete all fiscal period", ex);
+ log.error("Can't delete all fiscal period", eee);
}
- ErrorHelper.showErrorDialog(_("Can't delete all fiscal period"));
+ DialogHelper.showMessageDialog(eee.getMessage());
}
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/DialogHelper.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -0,0 +1,80 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.util;
+
+import static org.nuiton.i18n.I18n._;
+import javax.swing.JFrame;
+import javax.swing.JOptionPane;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.Resource;
+
+/**
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class DialogHelper {
+
+ /**
+ * log
+ */
+ private static final Log log = LogFactory.getLog(DialogHelper.class);
+
+ public static int showConfirmDialog(String message) {
+ String[] response = {_("lima.response.yes"), _("lima.response.no")};
+ return JOptionPane.showOptionDialog(null,
+ message,
+ _("lima.question"),
+ JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE,
+ null, //do not use a custom Icon
+ response, //the titles of buttons
+ response[0]); //default button title
+ }
+
+ public static void showMessageDialog(String message) {
+ JFrame f = new JFrame();
+ f.setIconImage(Resource.getIcon("icons/lima.png").getImage());
+ JOptionPane.showMessageDialog(
+ f,
+ message,
+ _("lima.error"),
+ JOptionPane.ERROR_MESSAGE);
+ f.dispose();
+ }
+
+ /**
+ * Permet d'afficher une boite de dialogue.
+ * @param message
+ * @param titre
+ * @param type
+ */
+ public static void showMessageDialog (String message,String titre,int type)
+ {
+ JFrame f = new JFrame();
+ f.setIconImage(Resource.getIcon("icons/lima.png").getImage());
+ JOptionPane.showMessageDialog(
+ f,
+ message,
+ titre,
+ type);
+ f.dispose();
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-06-03 16:45:18 UTC (rev 2931)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/util/Util.java 2010-06-04 08:43:32 UTC (rev 2932)
@@ -1,224 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.util;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-
-import javax.swing.JFrame;
-import javax.swing.JOptionPane;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.util.Resource;
-
-/**
- * @author ore
- * @author Rémi Chapelet
- *
- * @deprecated since 0.4.0 with no replacement
- */
-public class Util {
-
- /**
- * log
- */
- private static final Log log = LogFactory.getLog(Util.class);
-
- /**
- * @param sDate
- * @param sFormat
- * @return
- * @throws java.lang.Exception
- */
- public static Date stringToDate(String sDate, String sFormat) {
- Date d = null;
- try {
- SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
- d = sdf.parse(sDate);
- } catch (Exception e) {}
- return d;
- }
-
- /**
- * Permet de transformer une date au format Date au format String
- * Il est précisé dans cette méthode le format de date attendue.
- * @param d
- * @param sFormat
- * @return
- */
- public static String DateToString(Date d, String sFormat) {
- String result = "";
- try {
- SimpleDateFormat sdf = new SimpleDateFormat(sFormat);
- result = sdf.format(d);
- } catch (Exception e) {}
- return result;
- }
-
- /**
- * @param date
- * @return
- */
- public static String dateToString(Date date) {
- // 1. Choix de la langue
- Locale locale = Locale.getDefault();
- DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.SHORT, locale);
- return dateFormat.format(date);
- }
-
- /**
- * Adds all of the elements in the second collection to the first collection if they're not already present.
- *
- * @param c1 collection who receives elements
- * @param c2 collection whose elements are to be added to first collection.
- * @return true if this collection changed as a result of the call.
- */
- public static boolean addAll(Collection c1, Collection c2) {
- boolean modified = false;
- for (Object aC2 : c2) {
- if (!c1.contains(aC2)) {
- if (c1.add(aC2)) {
- modified = true;
- }
- }
- }
- return modified;
- }
-
- public static int showConfirmDialog(String message) {
- String[] response = {_("lima.response.yes"), _("lima.response.no")};
- return JOptionPane.showOptionDialog(null,
- message,
- _("lima.question"),
- JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE,
- null, //do not use a custom Icon
- response, //the titles of buttons
- response[0]); //default button title
- }
-
- public static void showMessageDialog(String message) {
- JFrame f = new JFrame();
- f.setIconImage(Resource.getIcon("icons/lima.png").getImage());
- JOptionPane.showMessageDialog(
- f,
- message,
- _("lima.error"),
- JOptionPane.ERROR_MESSAGE);
- f.dispose();
- }
-
- /**
- * Permet d'afficher une boite de dialogue.
- * @param message
- * @param titre
- * @param type
- */
- public static void showMessageDialog (String message,String titre,int type)
- {
- JFrame f = new JFrame();
- f.setIconImage(Resource.getIcon("icons/lima.png").getImage());
- JOptionPane.showMessageDialog(
- f,
- message,
- titre,
- type);
- f.dispose();
- }
-
- /**
- * Permet de découper une date dans un tableau.
- * Indices :
- * 0 : année
- * 1 : mois
- * 2 : jour
- * @param d
- * @return
- */
- public static String[] arrayDate (Date d)
- {
- String dateTab[] = new String[3];
- // année
- dateTab[0] = Integer.toString(d.getYear()+1900);
- // mois
- dateTab[1] = Integer.toString(d.getMonth());
- // jour
- dateTab[2] = Integer.toString(d.getDate());
- return dateTab;
- }
-
- /**
- * Initialise la date d'entrée le premier du mois à minuit.
- * Exemple : 15 janvier 2009, alors date de sortie 1 Janvier 2009 00h00m00s
- * @param d date
- * @return
- */
- public static Date InitDateFirstDayMonth (Date d)
- {
- Date date_result = new Date(d.getYear(),d.getMonth(),1,0,0,0);
- return date_result;
- }
-
- /**
- * Permet de calculer la date sur le mois suivant.
- * @param d
- * @return
- */
- public static Date nextMonth (Date d)
- {
- Date date_result = new Date(d.getYear(),d.getMonth()+1,1,0,0,0);
- return date_result;
- }
-
- /**
- * Permet de retourner la date de fin de mois. Si on lui donne la date
- * 5 Janv 2000, elle retourne alors 31 Jan 2000.
- * @param d date de référence
- * @return la date du fin de mois
- */
- public static Date InitDateEndDayMonth (Date d)
- {
- Calendar c = new GregorianCalendar (d.getYear()+1900,d.getMonth(),d.getDate());
- // Calcul le dernier jour du mois, prend en compte les années bixestiles
- Integer maxDay = c.getActualMaximum(Calendar.DAY_OF_MONTH);
- //Date dateEnd = new Date(d.getYear(),d.getMonth(),maxDay,23,59,59);
- Calendar dateEnd = new GregorianCalendar (d.getYear()+1900,d.getMonth(),maxDay,23,59,59);
- Date result = dateEnd.getTime();
- return result;
- }
-
-
- public static int compareTo (String a,String b)
- {
- float A = Float.parseFloat(a.replace(',','.'));
- float B = Float.parseFloat(b.replace(',','.'));
- int result = Float.compare(A,B);
- return result;
- }
-
-}
1
0
Author: jpepin
Date: 2010-06-03 18:45:18 +0200 (Thu, 03 Jun 2010)
New Revision: 2931
Url: http://chorem.org/repositories/revision/lima/2931
Log:
Nettoyage classes dans l'UI. Affichage des entr?\195?\169es dans l'?\195?\169dition de journal regroup?\195?\169 par transaction.
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionComparator.java
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionDateComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-callao/src/main/xmi/accounting.zargo
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.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/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -20,6 +20,8 @@
package org.chorem.lima.business.ejb;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
@@ -33,11 +35,16 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportService;
import org.chorem.lima.business.ReportServiceLocal;
+import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.business.utils.EntryFinancialTransactionComparator;
+import org.chorem.lima.business.utils.EntryFinancialTransactionDateComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
+import org.chorem.lima.entity.FinancialPeriod;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
import org.nuiton.topia.TopiaContext;
@@ -316,7 +323,12 @@
.addParam("endDate", endDate);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
query.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION);
- reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
+ List<Entry> entries = entryDAO.findAllByQuery(query);
+ //TODO 20100603 PEPIN imbriqué les deux conditions de comparator
+ // tri sur date, tri sur topiaid
+ Collections.sort(entries, new EntryFinancialTransactionDateComparator());
+ Collections.sort(entries, new EntryFinancialTransactionComparator());
+ reportsDatas.setListEntry(entries);
query.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
query.addGroup("E."+Entry.DEBIT);
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionComparator.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,32 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Entry;
+
+public class EntryFinancialTransactionComparator implements Comparator<Entry>{
+
+ @Override
+ public int compare(Entry o1, Entry o2) {
+ return o1.getFinancialTransaction().getTopiaId().compareTo(o2.getFinancialTransaction().getTopiaId());
+ }
+
+}
Added: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionDateComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionDateComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryFinancialTransactionDateComparator.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,33 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Entry;
+
+public class EntryFinancialTransactionDateComparator implements Comparator<Entry>{
+
+ @Override
+ public int compare(Entry o1, Entry o2) {
+ return o1.getFinancialTransaction().getTransactionDate()
+ .compareTo(o2.getFinancialTransaction().getTransactionDate());
+ }
+
+}
Modified: trunk/lima-callao/src/main/xmi/accounting.zargo
===================================================================
(Binary files differ)
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java (from rev 2922, trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountTreeTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,271 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.account;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.List;
+
+import javax.swing.tree.TreePath;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.AccountService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.AccountImpl;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
+
+/**
+ * Tree table model for account edition.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class AccountTreeTableModel extends AbstractTreeTableModel {
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(AccountViewHandler.class);
+
+ /** Account service. */
+ protected final AccountService accountService;
+
+ /**
+ * Model constructor. Init account service used here.
+ */
+ public AccountTreeTableModel() {
+ // root
+ super(new AccountImpl());
+ // Gets factory service
+ accountService = LimaServiceFactory.getInstance().getAccountService();
+ }
+
+ /**
+ * @deprecated can't be used
+ */
+ public Account getData() {
+ return (Account) root;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = null;
+ switch (column) {
+ case 0:
+ res = _("lima.account.number");
+ break;
+ case 1:
+ res = _("lima.account.label");
+ break;
+ }
+ return res;
+ }
+
+ @Override
+ public int getChildCount(Object node) {
+ int result = 0;
+ if (node instanceof Account) {
+ if (node == getRoot()) {
+ try {
+ result = accountService.getChildrenAccounts(null).size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) node;
+ try {
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.size();
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getChild(Object parent, int index) {
+ Object result = null;
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
+ result = allAccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ Account parentAccount = (Account) parent;
+
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.get(index);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public int getIndexOfChild(Object parent, Object child) {
+ int result = 0;
+ Account parentAccount = (Account) parent;
+ Account childAccount = (Account) child;
+
+ if (parent == getRoot()) {
+ try {
+ List<Account> allAccounts =
+ accountService.getChildrenAccounts(null);
+ result = allAccounts.indexOf(child);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ else {
+ // FIXME sub account is a collection ?
+ try {
+ List<Account> subaccounts =
+ accountService.getChildrenAccounts(parentAccount);
+ result = subaccounts.indexOf(childAccount);
+ } catch (LimaException e) {
+ //FIXME
+ e.printStackTrace();
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(Object node, int column) {
+ Object result = "n/a";
+ if (node instanceof Account) {
+ Account account = (Account) node;
+ switch (column) {
+ case 0:
+ result = account.getAccountNumber();
+ break;
+ case 1:
+ result = account.getLabel();
+ break;
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public boolean isCellEditable(Object node, int column) {
+ return false;
+ }
+
+ @Override
+ public boolean isLeaf(Object node) {
+ return getChildCount(node) == 0;
+ }
+
+ /**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+
+ accountService.createAccount(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireTreeStructureChanged(path);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
+ * Add account (path can be null).
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void addSubLedger(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ Account parentAccount = (Account)path.getLastPathComponent();
+ if (parentAccount == getRoot()) {
+ parentAccount = null;
+ }
+ accountService.createSubLedger(parentAccount, account);
+ int index = getIndexOfChild(path.getLastPathComponent(), account);
+ modelSupport.fireTreeStructureChanged(path);
+ modelSupport.fireChildAdded(path, index, account);
+ }
+
+ /**
+ * Update account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void updateAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ accountService.updateAccount(account);
+ //refresh the tree of the node
+ modelSupport.fireTreeStructureChanged(path.getParentPath());
+ }
+
+ /**
+ * Remove account.
+ *
+ * @param path
+ * @param account
+ * @throws LimaException
+ */
+ public void removeAccount(TreePath path, Account account) throws LimaException {
+ // Calling account service
+ int index = getIndexOfChild(
+ path.getParentPath().getLastPathComponent(), account);
+ accountService.removeAccount(account);
+ modelSupport.fireChildRemoved(path.getParentPath(), index, account);
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -31,7 +31,7 @@
<JScrollPane>
<org.jdesktop.swingx.JXTreeTable id="accountsTreeTable"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- treeTableModel="{new org.chorem.lima.ui.account.model.AccountTreeTableModel()}"
+ treeTableModel="{new org.chorem.lima.ui.account.AccountTreeTableModel()}"
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" />
<javax.swing.ListSelectionModel
javaBean="getAccountsTreeTable().getSelectionModel()"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -29,7 +29,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountImpl;
-import org.chorem.lima.ui.account.model.AccountTreeTableModel;
import org.chorem.lima.ui.account.AccountForm;
import org.chorem.lima.ui.account.AccountView;
import org.chorem.lima.ui.account.SubLedgerForm;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -1,272 +0,0 @@
-/* *##% Lima Swing
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.account.model;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-import javax.swing.tree.TreePath;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.AccountService;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.AccountImpl;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.account.AccountViewHandler;
-import org.jdesktop.swingx.treetable.AbstractTreeTableModel;
-
-/**
- * Tree table model for account edition.
- *
- * @author ore
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class AccountTreeTableModel extends AbstractTreeTableModel {
-
- /** log. */
- private static final Log log = LogFactory.getLog(AccountViewHandler.class);
-
- /** Account service. */
- protected final AccountService accountService;
-
- /**
- * Model constructor. Init account service used here.
- */
- public AccountTreeTableModel() {
- // root
- super(new AccountImpl());
- // Gets factory service
- accountService = LimaServiceFactory.getInstance().getAccountService();
- }
-
- /**
- * @deprecated can't be used
- */
- public Account getData() {
- return (Account) root;
- }
-
- @Override
- public int getColumnCount() {
- return 2;
- }
-
- @Override
- public String getColumnName(int column) {
- String res = null;
- switch (column) {
- case 0:
- res = _("lima.account.number");
- break;
- case 1:
- res = _("lima.account.label");
- break;
- }
- return res;
- }
-
- @Override
- public int getChildCount(Object node) {
- int result = 0;
- if (node instanceof Account) {
- if (node == getRoot()) {
- try {
- result = accountService.getChildrenAccounts(null).size();
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- else {
- Account parentAccount = (Account) node;
- try {
- List<Account> subaccounts =
- accountService.getChildrenAccounts(parentAccount);
- result = subaccounts.size();
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- }
- return result;
- }
-
- @Override
- public Object getChild(Object parent, int index) {
- Object result = null;
- if (parent == getRoot()) {
- try {
- List<Account> allAccounts =
- accountService.getChildrenAccounts(null);
- result = allAccounts.get(index);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- else {
- Account parentAccount = (Account) parent;
-
- // FIXME sub account is a collection ?
- try {
- List<Account> subaccounts =
- accountService.getChildrenAccounts(parentAccount);
- result = subaccounts.get(index);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- return result;
- }
-
- @Override
- public int getIndexOfChild(Object parent, Object child) {
- int result = 0;
- Account parentAccount = (Account) parent;
- Account childAccount = (Account) child;
-
- if (parent == getRoot()) {
- try {
- List<Account> allAccounts =
- accountService.getChildrenAccounts(null);
- result = allAccounts.indexOf(child);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- else {
- // FIXME sub account is a collection ?
- try {
- List<Account> subaccounts =
- accountService.getChildrenAccounts(parentAccount);
- result = subaccounts.indexOf(childAccount);
- } catch (LimaException e) {
- //FIXME
- e.printStackTrace();
- }
- }
- return result;
- }
-
- @Override
- public Object getValueAt(Object node, int column) {
- Object result = "n/a";
- if (node instanceof Account) {
- Account account = (Account) node;
- switch (column) {
- case 0:
- result = account.getAccountNumber();
- break;
- case 1:
- result = account.getLabel();
- break;
- }
- }
- return result;
- }
-
- @Override
- public boolean isCellEditable(Object node, int column) {
- return false;
- }
-
- @Override
- public boolean isLeaf(Object node) {
- return getChildCount(node) == 0;
- }
-
- /**
- * Add account (path can be null).
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void addAccount(TreePath path, Account account) throws LimaException {
- // Calling account service
- Account parentAccount = (Account)path.getLastPathComponent();
- if (parentAccount == getRoot()) {
- parentAccount = null;
- }
-
- accountService.createAccount(parentAccount, account);
- int index = getIndexOfChild(path.getLastPathComponent(), account);
- modelSupport.fireTreeStructureChanged(path);
- modelSupport.fireChildAdded(path, index, account);
- }
-
- /**
- * Add account (path can be null).
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void addSubLedger(TreePath path, Account account) throws LimaException {
- // Calling account service
- Account parentAccount = (Account)path.getLastPathComponent();
- if (parentAccount == getRoot()) {
- parentAccount = null;
- }
- accountService.createSubLedger(parentAccount, account);
- int index = getIndexOfChild(path.getLastPathComponent(), account);
- modelSupport.fireTreeStructureChanged(path);
- modelSupport.fireChildAdded(path, index, account);
- }
-
- /**
- * Update account.
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void updateAccount(TreePath path, Account account) throws LimaException {
- // Calling account service
- accountService.updateAccount(account);
- //refresh the tree of the node
- modelSupport.fireTreeStructureChanged(path.getParentPath());
- }
-
- /**
- * Remove account.
- *
- * @param path
- * @param account
- * @throws LimaException
- */
- public void removeAccount(TreePath path, Account account) throws LimaException {
- // Calling account service
- int index = getIndexOfChild(
- path.getParentPath().getLastPathComponent(), account);
- accountService.removeAccount(account);
- modelSupport.fireChildRemoved(path.getParentPath(), index, account);
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -1,81 +0,0 @@
-/* *##% Lima Swing
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.account.model;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.AbstractListModel;
-import javax.swing.ComboBoxModel;
-
-/**
- * Combo box model with accounts types.
- * (actif, passif, produit, charge).
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class AccountTypeListModel extends AbstractListModel implements ComboBoxModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -6817328905036446359L;
-
- protected Object selectedObject;
-
- /** Data. TODO put string in another place, don't use hard coded string. */
- protected Object[] data = new Object[]{ _("lima.account.type1"), _("lima.account.type2"), _("lima.account.type3"), _("lima.account.type4")};
-
- public AccountTypeListModel() {
- super();
- }
-
- /*
- * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
- */
- @Override
- public void setSelectedItem(Object anItem) {
- selectedObject = anItem;
- }
-
- /*
- * @see javax.swing.ComboBoxModel#getSelectedItem()
- */
- @Override
- public Object getSelectedItem() {
- return selectedObject;
- }
-
- /*
- * @see javax.swing.ListModel#getSize()
- */
- @Override
- public int getSize() {
- return data.length;
- }
-
- /*
- * @see javax.swing.ListModel#getElementAt(int)
- */
- @Override
- public Object getElementAt(int index) {
- return data[index];
- }
-}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/combobox/EntryBookTypeListModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,73 @@
+package org.chorem.lima.ui.combobox;
+
+
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+import static org.nuiton.i18n.I18n._;
+import javax.swing.AbstractListModel;
+import javax.swing.ComboBoxModel;
+
+/**
+ * Combo box model with entrybook types.
+ * (achats, ventes, trésorerie, général, situation).
+ *
+ */
+public class EntryBookTypeListModel extends AbstractListModel implements ComboBoxModel {
+
+ protected Object selectedObject;
+
+ /** Data. TODO put string in another place, don't use hard coded string. */
+ protected Object[] data = new Object[]{ _("lima.entrybook.type1"), _("lima.entrybook.type2"), _("lima.entrybook.type3"), _("lima.entrybook.type4"), _("lima.entrybook.type5")};
+
+ public EntryBookTypeListModel() {
+ super();
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#setSelectedItem(java.lang.Object)
+ */
+ @Override
+ public void setSelectedItem(Object anItem) {
+ selectedObject = anItem;
+ }
+
+ /*
+ * @see javax.swing.ComboBoxModel#getSelectedItem()
+ */
+ @Override
+ public Object getSelectedItem() {
+ return selectedObject;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getSize()
+ */
+ @Override
+ public int getSize() {
+ return data.length;
+ }
+
+ /*
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+ @Override
+ public Object getElementAt(int index) {
+ return data[index];
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -57,7 +57,7 @@
<JLabel text="lima.entrybook.type"/>
</cell>
<cell>
- <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.entrybook.model.EntryBookTypeListModel()}'
+ <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.combobox.EntryBookTypeListModel()}'
selectedItem="{getEntryBook().getType()}"
onActionPerformed="getEntryBook().setType((String)getTypeComboBox().getSelectedItem())"/>
</cell>
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,215 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.entrybook;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class EntryBookTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(EntryBookTableModel.class);
+
+ /** Services. */
+ protected EntryBookService entryBookService;
+
+ /**
+ * Constructor.
+ */
+ public EntryBookTableModel() {
+ entryBookService = LimaServiceFactory.getInstance().getEntryBookService();
+ }
+
+ /*
+ * @return
+ *
+ public List<JournalDTO> getData() {
+ return data;
+ }*/
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ try {
+ result = entryBookService.getAllEntryBooks().size();
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 3;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.entrybook.code");
+ break;
+ case 1:
+ res = _("lima.entrybook.label");
+ break;
+ case 2:
+ res = _("lima.entrybook.type");
+ break;
+ }
+ return res;
+ }
+
+ public EntryBook getEntryBookAtRow(int row) throws LimaException {
+ EntryBook entryBook = null;
+ entryBook = entryBookService.getAllEntryBooks().get(row);
+
+ return entryBook;
+ }
+
+ /*
+ * @param row
+ * @return
+ *
+ @Override
+ public Object getRow(int row) {
+ return data.get(row);
+ }*/
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = null;
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ result = entryBook.getCode();
+ break;
+ case 1:
+ result = entryBook.getLabel();
+ break;
+ case 2:
+ result = entryBook.getType();
+ break;
+ }
+ } catch (LimaException eee) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't get EntryBook",eee);
+ }
+ }
+
+ return result;
+ }
+
+
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+
+ try {
+ EntryBook entryBook = getEntryBookAtRow(row);
+
+ switch (column) {
+ case 0:
+ entryBook.setCode((String)value);
+ break;
+ case 1:
+ entryBook.setLabel((String)value);
+ break;
+ case 2:
+ entryBook.setType((String)value);
+ break;
+ }
+
+ // update on remote service
+ entryBookService.updateEntryBook(entryBook);
+ } catch (LimaException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // TODO why false ?
+ return false;
+ }
+
+ /**
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void addEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.createEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsInserted(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void updateEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ entryBookService.updateEntryBook(entryBook);
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ fireTableRowsUpdated(row, row);
+ }
+
+ /**
+ *
+ * @param entryBook
+ * @throws LimaException
+ */
+ public void removeEntryBook(EntryBook entryBook) throws LimaException {
+ /* Calling journal service */
+ int row = entryBookService.getAllEntryBooks().indexOf(entryBook);
+ entryBookService.removeEntryBook(entryBook);
+ fireTableRowsDeleted(row, row);
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -30,7 +30,7 @@
<cell fill="both" weightx="1" weighty="1" rows='4'>
<JScrollPane>
<org.jdesktop.swingx.JXTable id="entryBooksTable" rowHeight="24"
- model="{new org.chorem.lima.ui.entrybook.model.EntryBookTableModel()}"
+ model="{new org.chorem.lima.ui.entrybook.EntryBookTableModel()}"
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
columnControlVisible="true"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -27,7 +27,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryBookImpl;
-import org.chorem.lima.ui.entrybook.model.EntryBookTableModel;
import org.chorem.lima.util.ErrorHelper;
import org.jdesktop.swingx.JXTable;
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTable.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,96 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.entrybooksreports;
+
+import java.awt.Color;
+import java.awt.Component;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class EntryBooksReportsTable extends JXTable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(EntryBooksReportsTable.class);
+
+ protected EntryBooksReportsViewHandler handler;
+
+ protected EntryBooksReportsTableModel model;
+
+ private Highlighter colorReportsDatas;
+
+ private FinancialTransaction oldRow;
+
+ private Boolean highlighterReportsDatasBoolean;
+
+ /**
+ */
+ public EntryBooksReportsTable(EntryBooksReportsViewHandler handler, EntryBooksReportsTableModel model) {
+
+ this.handler = handler;
+ this.model = model;
+ highlighterReportsDatasBoolean=true;
+ //highlight financial financial transactions
+ addColorReportsDatas();
+
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les reportsdatas dans le tableau
+ * afin de bien distinguer les entête de comptes et les entrées comptables.
+ * On récupère la première cellule, on vérifie que c'est pas null
+ */
+ protected void addColorReportsDatas() {
+ if (colorReportsDatas != null) {
+ removeHighlighter(colorReportsDatas);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ Entry entry = model.getElementAt(adapter.row);
+ FinancialTransaction financialTransaction = entry.getFinancialTransaction();
+ if (financialTransaction != oldRow){
+ highlighterReportsDatasBoolean = !highlighterReportsDatasBoolean;
+ }
+ oldRow = financialTransaction;
+ return highlighterReportsDatasBoolean;
+ }
+ };
+ colorReportsDatas =
+ new ColorHighlighter(predicate, new Color(222,222,222), null);
+ addHighlighter(colorReportsDatas);
+ }
+}
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 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -171,6 +171,10 @@
return result;
}
+ public Entry getElementAt(int row){
+ return cacheDataList.getListEntry().get(row);
+ }
+
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
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 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -19,7 +19,7 @@
<EntryBooksReportsViewHandler id="handler" javaBean="new EntryBooksReportsViewHandler(this)" />
<Boolean id="selectedRow" javaBean="false" />
<org.chorem.lima.ui.combobox.EntryBookComboBoxModel id="modelEntryBook"/>
- <org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTableModel id="modelEntryBooksReportsTable"/>
+ <org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTableModel id="modelTable"/>
<script>
<![CDATA[
@@ -32,12 +32,12 @@
// set begindate to JAN 1 - 0:00.000 of this years
Date beginDate = calendarBegin.getTime();
beginDate = DateUtils.truncate(beginDate, Calendar.YEAR);
- getModelEntryBooksReportsTable().setBeginDate(beginDate);
+ getModelTable().setBeginDate(beginDate);
// get end date
Calendar calendarEnd = Calendar.getInstance();
Date endDate = calendarEnd.getTime();
- getModelEntryBooksReportsTable().setEndDate(endDate);
+ getModelTable().setEndDate(endDate);
getBeginDatePicker().setDate(beginDate);
getEndDatePicker().setDate(endDate);
@@ -50,7 +50,7 @@
</cell>
<cell>
<org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
- onActionPerformed="getModelEntryBooksReportsTable().setBeginDate(beginDatePicker.getDate());
+ onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate());
getHandler().updateFooterLabel()" />
</cell>
<cell>
@@ -58,7 +58,7 @@
</cell>
<cell>
<org.jdesktop.swingx.JXDatePicker id="endDatePicker"
- onActionPerformed="getModelEntryBooksReportsTable().setEndDate(endDatePicker.getDate());
+ onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate());
getHandler().updateFooterLabel()"/>
</cell>
<cell>
@@ -68,7 +68,7 @@
<JComboBox id="entryBookComboBox"
model="{getModelEntryBook()}"
renderer="{new org.chorem.lima.ui.combobox.EntryBookRenderer()}"
- onItemStateChanged="getModelEntryBooksReportsTable().setEntryBook((EntryBook) event.getItem());
+ onItemStateChanged="getModelTable().setEntryBook((EntryBook) event.getItem());
getHandler().updateFooterLabel()"
editable="false"
/>
@@ -77,12 +77,11 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
- <org.jdesktop.swingx.JXTable id="entryBooksReportsTable" rowHeight="24"
- model="{getModelEntryBooksReportsTable()}"
- highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
- <javax.swing.ListSelectionModel javaBean="getEntryBooksReportsTable().getSelectionModel()"/>
+ <org.chorem.lima.ui.entrybooksreports.EntryBooksReportsTable
+ id="table" sortable="false" rowHeight="24"
+ constructorParams="getHandler(), getModelTable()" model="{getModelTable()}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
+ <javax.swing.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 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybooksreports/EntryBooksReportsViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -51,12 +51,12 @@
}
- /*
- * set text and amounts of labels credit, debit, solde
+
+ /**
+ * set text and amounts of labels credit, debit, solde
*/
public void updateFooterLabel(){
- EntryBooksReportsTableModel tablemodel =
- (EntryBooksReportsTableModel) view.getEntryBooksReportsTable().getModel();
+ EntryBooksReportsTableModel tablemodel = view.getModelTable();
ReportsDatas cacheDataList = tablemodel.cacheDataList;
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java (from rev 2930, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,202 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.financialtransaction;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.util.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.DateTableCellEditor;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class FinancialTransactionTable extends JXTable implements KeyListener {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
+
+ protected FinancialTransactionViewHandler handler;
+
+ private Highlighter colorTransaction;
+
+ private ColorHighlighter colorBalance;
+
+ /**
+ */
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
+
+ this.handler = handler;
+
+ addKeyListener(this);
+
+ //Get new date editor
+ setDefaultEditor(Date.class, new DateTableCellEditor());
+ //Get new entry book editor
+ setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
+ //Get new account editor
+ setDefaultEditor(Account.class, new AccountTableCellEditor());
+
+ //highlight financial financial transactions
+ addColorTransaction();
+ // highlight unbalanced financial transactions
+ addColorNonBalancedTransaction();
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les transactions dans le tableau
+ * afin de bien distinguer les transactions et entrées comptables.
+ * On récupère la première cellule, on vérifie que c'est une date
+ */
+ protected void addColorTransaction() {
+ if (colorTransaction != null) {
+ removeHighlighter(colorTransaction);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return adapter.getValueAt(adapter.row, 0) instanceof Date;
+ }
+ };
+ colorTransaction =
+ new ColorHighlighter(predicate, new Color(222,222,222), null);
+ addHighlighter(colorTransaction);
+ }
+
+
+
+ /**
+ * Permet de surligner une transaction dans le tableau lorsque
+ * cette dernière n'est pas équilibrée.
+ * On récupère la dernière cellule de la ligne
+ * et on vérifie si la valeur est différente de 0
+ */
+ protected void addColorNonBalancedTransaction() {
+ if (colorBalance != null) {
+ removeHighlighter(colorBalance);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ boolean isHighlighted = false;
+ Object value = adapter.getValueAt(adapter.row, 8);
+ if (value instanceof Double) {
+ Double currentBalance = (Double) value;
+ if (currentBalance != 0) {
+ isHighlighted = true;
+ }
+ }
+ return isHighlighted;
+ }
+ };
+ colorTransaction =
+ new ColorHighlighter(predicate, new Color(255, 198, 209), null);
+ addHighlighter(colorTransaction);
+ }
+
+ /**
+ * for each action combination key are think
+ * for extend keyboard and laptop keyboard
+ */
+ @Override
+ public void keyPressed(KeyEvent e) {
+
+ //TODO combinaison de touches dans la config
+
+ // delete selected row with the key : delete or ctrl clear
+ // ou de l'entree
+ if ((e.getKeyCode() == KeyEvent.VK_DELETE )
+ || (e.getKeyCode() == KeyEvent.VK_CLEAR
+ && e.getModifiers() == KeyEvent.CTRL_MASK)){
+ handler.deleteSelectedRow();
+ }
+
+ // add entry with the key combination : insert or ctrl + enter
+ if ((e.getKeyCode() == KeyEvent.VK_INSERT )
+ || (e.getKeyCode() == KeyEvent.VK_ENTER
+ && e.getModifiers() == KeyEvent.CTRL_MASK)) {
+ handler.addEmptyEntry();
+ }
+
+ // add financial transaction with the key combination : ctrl + tab
+ if (e.getKeyCode() == KeyEvent.VK_TAB
+ && e.getModifiers() == KeyEvent.CTRL_MASK) {
+ handler.addFinancialTransaction();
+ }
+
+ /**
+ * Touche tab
+ * Ajoute une entrée comptable si tab est sur
+ * la dernière cellule.
+ */
+ if (e.getKeyChar() == KeyEvent.VK_TAB) {
+ // Vérifie si la cellule sélectionnée est la dernière
+
+ int x = this.getSelectedColumn();
+ int y = this.getSelectedRow();
+ int max_x = this.getColumnCount() - 1;
+ int max_y = this.getRowCount() - 1;
+ if (x == max_x && y == max_y) {
+ handler.addEmptyEntry();
+ // positionne la sélection sur la nouvelle ligne créée
+ this.setColumnSelectionInterval(0, 0);
+ this.setRowSelectionInterval(max_y + 1, max_y + 1);
+ }
+ }
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyTyped(KeyEvent e) {
+
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent e) {
+
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java (from rev 2929, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,526 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.financialtransaction;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import javax.swing.table.AbstractTableModel;
+
+import org.apache.commons.lang.time.DateUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.EntryBookService;
+import org.chorem.lima.business.FinancialPeriodService;
+import org.chorem.lima.business.LimaBusinessException;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.FinancialTransactionService;
+import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.entity.EntryImpl;
+import org.chorem.lima.entity.FinancialPeriod;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Basic transaction table model.
+ *
+ * Le modele est filtré sur {@link #selectedEntryBook} et
+ * {@link #selectedFinancialPeriod} (montée en charge !).
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2897 $
+ *
+ * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $
+ * By : $Author: jpepin $
+ */
+public class FinancialTransactionTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3914954536809622358L;
+
+ /** log. */
+ private static final Log log = LogFactory
+ .getLog(FinancialTransactionTableModel.class);
+
+ /** Transaction service. */
+ protected final FinancialTransactionService financialTransactionService;
+
+ /** EntryBook service. */
+ protected final EntryBookService entryBookService;
+
+ /** FinancialPeriod service. */
+ protected final FinancialPeriodService financialPeriodService;
+
+ /** selected financial period */
+ protected FinancialPeriod selectedFinancialPeriod;
+
+ /** data cache */
+ protected List<Object> cacheDataList;
+
+ /** collection
+
+
+ /**
+ * Model constructor.
+ *
+ * Just init service proxies.
+ */
+ public FinancialTransactionTableModel() {
+ /* Services */
+ financialTransactionService = LimaServiceFactory.getInstance()
+ .getTransactionService();
+ entryBookService = LimaServiceFactory.getInstance().
+ getEntryBookService();
+ financialPeriodService = LimaServiceFactory.getInstance().
+ getFinancialPeriodService();
+ }
+
+ /**
+ * Le model est une combinaison de Transaction/Entries.
+ *
+ *
+ * @return
+ */
+ protected List<Object> getDataList() {
+
+ List<Object> results = new ArrayList<Object>();
+ try {
+ List<FinancialTransaction> financialtransactions =
+ financialTransactionService.getAllFinancialTransactionsForFinancialPeriod(
+ selectedFinancialPeriod);
+ for (FinancialTransaction financialtransaction : financialtransactions) {
+ results.add(financialtransaction);
+ List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
+ Collections.sort(entries, new EntryComparator());
+ results.addAll(entries);
+ }
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+
+ ErrorHelper.showErrorDialog("Can't get transaction list", eee);
+ }
+
+ return results;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 9;
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+
+ Class<?> result = null;
+
+ switch (column) {
+ case 0:
+ result = Date.class;
+ break;
+ case 1:
+ result = EntryBook.class;
+ break;
+ case 2:
+ result = String.class;
+ break;
+ case 3:
+ result = Account.class;
+ break;
+ case 4:
+ result = String.class;
+ break;
+ case 5:
+ result = String.class;
+ break;
+ case 6:
+ result = Double.class;
+ break;
+ case 7:
+ result = Double.class;
+ break;
+ case 8:
+ result = Double.class;
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String result = "n/a";
+
+ switch (column) {
+ case 0:
+ result = _("lima.transaction.column.date");
+ break;
+ case 1:
+ result = _("lima.transaction.column.entrybook");
+ break;
+ case 2:
+ result = _("lima.transaction.column.voucher");
+ break;
+ case 3:
+ result = _("lima.transaction.column.account");
+ break;
+ case 4:
+ result = _("lima.transaction.column.description");
+ break;
+ case 5:
+ result = _("lima.transaction.column.position");
+ break;
+ case 6:
+ result = _("lima.transaction.column.debit");
+ break;
+ case 7:
+ result = _("lima.transaction.column.credit");
+ break;
+ case 8:
+ result = _("lima.transaction.column.balance");
+ break;
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ //cacheDataList = getDataList();
+ result = cacheDataList.size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ result = cacheDataList.get(row);
+
+ if (result instanceof FinancialTransaction) {
+ FinancialTransaction currentRow = (FinancialTransaction)result;
+ Double amountDebit = currentRow.getAmountDebit();
+ Double amountCredit = currentRow.getAmountCredit();
+
+ switch (column) {
+ case 0:
+ result = currentRow.getTransactionDate();
+ break;
+ case 1:
+ result = null; // voucher
+ break;
+ case 2:
+ result = null; //entrybook
+ break;
+ case 3:
+ result = null; // account
+ break;
+ case 4:
+ result = null; // description
+ break;
+ case 5 :
+ result = null; // position
+ break;
+ case 6:
+ result = amountDebit;
+ break;
+ case 7:
+ result = amountCredit;
+ break;
+ case 8:
+ result = amountDebit - amountCredit;
+ break;
+ }
+ }
+ else if (result instanceof Entry) {
+ Entry currentEntry = (Entry)result;
+ switch (column) {
+ case 0:
+ result = null; // date
+ break;
+ case 1 : // entry book
+ if (currentEntry.getEntryBook() != null){
+ result = currentEntry.getEntryBook().getCode();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 2:
+ result = currentEntry.getVoucher();
+ break;
+ case 3: // account
+ if (currentEntry.getAccount() != null){
+ result = currentEntry.getAccount().getAccountNumber();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 4:
+ result = currentEntry.getDescription();
+ break;
+ case 5 :
+ result = currentEntry.getPosition();
+ break;
+ case 6:
+ result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
+ break;
+ case 7:
+ result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
+ break;
+ case 8:
+ result = null; // balance
+ break;
+ }
+
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ public void setFinancialPeriod(FinancialPeriod financialPeriod){
+
+ selectedFinancialPeriod = financialPeriod;
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
+
+ /**
+ * To set cells editable or not
+ * different condition for entry or financial transaction
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ boolean editableCell=false;
+ Object currentRow = cacheDataList.get(rowIndex);
+ // cells editable for the entry row, all cells exclude the date
+ if ((currentRow instanceof Entry) && !(columnIndex==0)) {
+ editableCell=true;
+ }
+ // cells editable for the financialtransaction row, no cells exclude the date
+ if ((currentRow instanceof FinancialTransaction) && (columnIndex==0)){
+ editableCell=true;
+ }
+ return editableCell;
+ }
+
+ /**
+ * @throws LimaException
+ */
+ public void addFinancialTransaction() throws LimaException{
+ /* Calling transaction service */
+ FinancialTransaction financialTransaction = new FinancialTransactionImpl();
+ //if a period and an entrybook is selected
+ if (selectedFinancialPeriod != null){
+ financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
+ // get today
+ Calendar actualCalendar = Calendar.getInstance();
+ // get the financial period date
+ Date transactionDate = selectedFinancialPeriod.getBeginDate();
+ // change the day
+ transactionDate = DateUtils.setDays(transactionDate,
+ actualCalendar.get(Calendar.DAY_OF_MONTH));
+ // set date to the financial transaction
+ financialTransaction.setTransactionDate(transactionDate);
+ // create it
+ financialTransactionService.createFinancialTransaction(financialTransaction);
+ //on recharge la liste
+ cacheDataList = getDataList();
+ int row = getDataList().indexOf(financialTransaction);
+ fireTableRowsInserted(row, row);
+ //fireTableDataChanged();
+ }
+ else {
+ throw new LimaBusinessException("No financial period selected");
+ }
+ }
+
+
+
+ /**
+ * @throws LimaException
+ */
+ public void addEmptyEntry(Object value, int row) throws LimaException {
+ FinancialTransaction currentTransaction = null;
+ Object currentRow = cacheDataList.get(row);
+ Entry entry = new EntryImpl();
+ //check if current row is a transaction or an entry
+ if (currentRow instanceof FinancialTransaction) {
+ currentTransaction = (FinancialTransaction)currentRow;
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ //get back the parent transaction of the entry
+ currentTransaction = currentEntry.getFinancialTransaction();
+ }
+ //create it
+ entry.setFinancialTransaction(currentTransaction);
+ financialTransactionService.createEntry(entry);
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableDataChanged();
+ }
+
+ /**
+ * to modifiy financialtransaction or entry
+ */
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+ int financialTransactionRow=0;
+ // just prevent too much result
+ if (selectedFinancialPeriod != null) {
+ Object currentRow = cacheDataList.get(row);
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentFinancialTransaction =
+ (FinancialTransaction)currentRow;
+ switch (column) {
+ case 0:
+ //update
+ currentFinancialTransaction.setTransactionDate((Date)value);
+ break;
+ }
+ // notify service for modification
+ try {
+ financialTransactionService.
+ updateFinancialTransaction(currentFinancialTransaction);
+ } catch (LimaException e) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't update financial transaction", e);
+ }
+ }
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList().indexOf(((FinancialTransaction) currentRow));
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ switch (column) {
+ case 1 :
+ currentEntry.setEntryBook((EntryBook)value);
+ break;
+ case 2 :
+ currentEntry.setVoucher((String)value);
+ break;
+ case 3:
+ currentEntry.setAccount((Account)value);
+ break;
+ case 4:
+ currentEntry.setDescription((String)value);
+ break;
+ case 5 :
+ currentEntry.setPosition((String)value);
+ break;
+ case 6:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(true);
+ break;
+ case 7:
+ currentEntry.setAmount((Double)value);
+ currentEntry.setDebit(false);
+ break;
+ }
+ try {
+ financialTransactionService.updateEntry(currentEntry);
+
+ } catch (LimaException e) {
+ if (log.isDebugEnabled()){
+ log.debug("Can't update entry", e);
+ }
+ }
+ //update the financial transaction in entire
+ financialTransactionRow =
+ getDataList().indexOf(((Entry) currentRow).
+ getFinancialTransaction());
+ }
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No fiscalPeriod selected skip table model update");
+ }
+ }
+ }
+
+ public Object getElementAt(int row){
+
+ Object currentRow = cacheDataList.get(row);
+ return currentRow;
+ }
+
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ *
+ * Called by model.
+ * @param Object, int
+ * @throws LimaException
+ */
+ public void removeObject(Object object, int row) throws LimaException {
+ Object currentRow = cacheDataList.get(row);
+ if (currentRow instanceof FinancialTransaction) {
+ FinancialTransaction currentTransaction =
+ (FinancialTransaction)currentRow;
+ financialTransactionService.removeFinancialTransaction(currentTransaction);
+ }
+ else if (currentRow instanceof Entry) {
+ Entry currentEntry = (Entry)currentRow;
+ financialTransactionService.removeEntry(currentEntry);
+ }
+ //on recharge la liste
+ cacheDataList = getDataList();
+ fireTableRowsDeleted(row, getRowCount());
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -76,9 +76,9 @@
<row>
<cell fill="both" weightx="1" weighty="1" rows="3" columns="7">
<JScrollPane>
- <org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTableModel
+ <org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel
id="financialTransactionTableModel" />
- <org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTable
+ <org.chorem.lima.ui.financialtransaction.FinancialTransactionTable
id="financialTransactionTable" sortable="false" rowHeight="22"
constructorParams="getHandler()" model="{getFinancialTransactionTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -29,8 +29,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
-import org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTable;
-import org.chorem.lima.ui.financialtransaction.table.FinancialTransactionTableModel;
/**
* Handler associated with financial transaction view.
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -1,203 +0,0 @@
-/* *##% Lima Swing
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.financialtransaction.table;
-
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.util.Date;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
-import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionViewHandler;
-import org.jdesktop.swingx.JXTable;
-import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.ComponentAdapter;
-import org.jdesktop.swingx.decorator.HighlightPredicate;
-import org.jdesktop.swingx.decorator.Highlighter;
-
-
-/**
- * Table des transaction qui ajoute des comportement (keys).
- *
- * @author ore
- * @author Rémi Chapelet
- */
-public class FinancialTransactionTable extends JXTable implements KeyListener {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3133690382049594727L;
-
- /** log. */
- private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
-
- protected FinancialTransactionViewHandler handler;
-
- private Highlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- /**
- */
- public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
-
- this.handler = handler;
-
- addKeyListener(this);
-
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
- //Get new entry book editor
- setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
- //Get new account editor
- setDefaultEditor(Account.class, new AccountTableCellEditor());
-
- //highlight financial financial transactions
- addColorTransaction();
- // highlight unbalanced financial transactions
- addColorNonBalancedTransaction();
- }
-
- /**
- * Cette méthode permet de colorer toutes les transactions dans le tableau
- * afin de bien distinguer les transactions et entrées comptables.
- * On récupère la première cellule, on vérifie que c'est une date
- */
- protected void addColorTransaction() {
- if (colorTransaction != null) {
- removeHighlighter(colorTransaction);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- return adapter.getValueAt(adapter.row, 0) instanceof Date;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(222,222,222), null);
- addHighlighter(colorTransaction);
- }
-
-
-
- /**
- * Permet de surligner une transaction dans le tableau lorsque
- * cette dernière n'est pas équilibrée.
- * On récupère la dernière cellule de la ligne
- * et on vérifie si la valeur est différente de 0
- */
- protected void addColorNonBalancedTransaction() {
- if (colorBalance != null) {
- removeHighlighter(colorBalance);
- }
- HighlightPredicate predicate = new HighlightPredicate() {
- @Override
- public boolean isHighlighted(Component renderer,
- ComponentAdapter adapter) {
- boolean isHighlighted = false;
- Object value = adapter.getValueAt(adapter.row, 8);
- if (value instanceof Double) {
- Double currentBalance = (Double) value;
- if (currentBalance != 0) {
- isHighlighted = true;
- }
- }
- return isHighlighted;
- }
- };
- colorTransaction =
- new ColorHighlighter(predicate, new Color(255, 198, 209), null);
- addHighlighter(colorTransaction);
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
-
- //TODO combinaison de touches dans la config
-
- // delete selected row with the key : delete or ctrl clear
- // ou de l'entree
- if ((e.getKeyCode() == KeyEvent.VK_DELETE )
- || (e.getKeyCode() == KeyEvent.VK_CLEAR
- && e.getModifiers() == KeyEvent.CTRL_MASK)){
- handler.deleteSelectedRow();
- }
-
- // add entry with the key combination : insert or ctrl + enter
- if ((e.getKeyCode() == KeyEvent.VK_INSERT )
- || (e.getKeyCode() == KeyEvent.VK_ENTER
- && e.getModifiers() == KeyEvent.CTRL_MASK)) {
- handler.addEmptyEntry();
- }
-
- // add financial transaction with the key combination : ctrl + tab
- if (e.getKeyCode() == KeyEvent.VK_TAB
- && e.getModifiers() == KeyEvent.CTRL_MASK) {
- handler.addFinancialTransaction();
- }
-
- /**
- * Touche tab
- * Ajoute une entrée comptable si tab est sur
- * la dernière cellule.
- */
- if (e.getKeyChar() == KeyEvent.VK_TAB) {
- // Vérifie si la cellule sélectionnée est la dernière
-
- int x = this.getSelectedColumn();
- int y = this.getSelectedRow();
- int max_x = this.getColumnCount() - 1;
- int max_y = this.getRowCount() - 1;
- if (x == max_x && y == max_y) {
- handler.addEmptyEntry();
- // positionne la sélection sur la nouvelle ligne créée
- this.setColumnSelectionInterval(0, 0);
- this.setRowSelectionInterval(max_y + 1, max_y + 1);
- }
- }
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
- */
- @Override
- public void keyTyped(KeyEvent e) {
-
- }
-
- /*
- * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
- */
- @Override
- public void keyReleased(KeyEvent e) {
-
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -1,526 +0,0 @@
-/* *##% Lima Swing
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.ui.financialtransaction.table;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.apache.commons.lang.time.DateUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.EntryBookService;
-import org.chorem.lima.business.FinancialPeriodService;
-import org.chorem.lima.business.LimaBusinessException;
-import org.chorem.lima.business.LimaException;
-import org.chorem.lima.business.FinancialTransactionService;
-import org.chorem.lima.business.utils.EntryComparator;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialPeriod;
-import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.util.ErrorHelper;
-
-/**
- * Basic transaction table model.
- *
- * Le modele est filtré sur {@link #selectedEntryBook} et
- * {@link #selectedFinancialPeriod} (montée en charge !).
- *
- * @author ore
- * @author chatellier
- * @version $Revision: 2897 $
- *
- * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $
- * By : $Author: jpepin $
- */
-public class FinancialTransactionTableModel extends AbstractTableModel {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3914954536809622358L;
-
- /** log. */
- private static final Log log = LogFactory
- .getLog(FinancialTransactionTableModel.class);
-
- /** Transaction service. */
- protected final FinancialTransactionService financialTransactionService;
-
- /** EntryBook service. */
- protected final EntryBookService entryBookService;
-
- /** FinancialPeriod service. */
- protected final FinancialPeriodService financialPeriodService;
-
- /** selected financial period */
- protected FinancialPeriod selectedFinancialPeriod;
-
- /** data cache */
- protected List<Object> cacheDataList;
-
- /** collection
-
-
- /**
- * Model constructor.
- *
- * Just init service proxies.
- */
- public FinancialTransactionTableModel() {
- /* Services */
- financialTransactionService = LimaServiceFactory.getInstance()
- .getTransactionService();
- entryBookService = LimaServiceFactory.getInstance().
- getEntryBookService();
- financialPeriodService = LimaServiceFactory.getInstance().
- getFinancialPeriodService();
- }
-
- /**
- * Le model est une combinaison de Transaction/Entries.
- *
- *
- * @return
- */
- protected List<Object> getDataList() {
-
- List<Object> results = new ArrayList<Object>();
- try {
- List<FinancialTransaction> financialtransactions =
- financialTransactionService.getAllFinancialTransactionsForFinancialPeriod(
- selectedFinancialPeriod);
- for (FinancialTransaction financialtransaction : financialtransactions) {
- results.add(financialtransaction);
- List<Entry> entries = (List<Entry>) financialtransaction.getEntry();
- Collections.sort(entries, new EntryComparator());
- results.addAll(entries);
- }
- }
- catch (LimaException eee) {
- if (log.isErrorEnabled()) {
- log.debug("Can't update model", eee);
- }
-
- ErrorHelper.showErrorDialog("Can't get transaction list", eee);
- }
-
- return results;
- }
-
- @Override
- public int getColumnCount() {
- return 9;
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = null;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = EntryBook.class;
- break;
- case 2:
- result = String.class;
- break;
- case 3:
- result = Account.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = String.class;
- break;
- case 6:
- result = Double.class;
- break;
- case 7:
- result = Double.class;
- break;
- case 8:
- result = Double.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.transaction.column.date");
- break;
- case 1:
- result = _("lima.transaction.column.entrybook");
- break;
- case 2:
- result = _("lima.transaction.column.voucher");
- break;
- case 3:
- result = _("lima.transaction.column.account");
- break;
- case 4:
- result = _("lima.transaction.column.description");
- break;
- case 5:
- result = _("lima.transaction.column.position");
- break;
- case 6:
- result = _("lima.transaction.column.debit");
- break;
- case 7:
- result = _("lima.transaction.column.credit");
- break;
- case 8:
- result = _("lima.transaction.column.balance");
- break;
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- int result = 0;
-
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- //cacheDataList = getDataList();
- result = cacheDataList.size();
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- result = cacheDataList.get(row);
-
- if (result instanceof FinancialTransaction) {
- FinancialTransaction currentRow = (FinancialTransaction)result;
- Double amountDebit = currentRow.getAmountDebit();
- Double amountCredit = currentRow.getAmountCredit();
-
- switch (column) {
- case 0:
- result = currentRow.getTransactionDate();
- break;
- case 1:
- result = null; // voucher
- break;
- case 2:
- result = null; //entrybook
- break;
- case 3:
- result = null; // account
- break;
- case 4:
- result = null; // description
- break;
- case 5 :
- result = null; // position
- break;
- case 6:
- result = amountDebit;
- break;
- case 7:
- result = amountCredit;
- break;
- case 8:
- result = amountDebit - amountCredit;
- break;
- }
- }
- else if (result instanceof Entry) {
- Entry currentEntry = (Entry)result;
- switch (column) {
- case 0:
- result = null; // date
- break;
- case 1 : // entry book
- if (currentEntry.getEntryBook() != null){
- result = currentEntry.getEntryBook().getCode();
- }
- else {
- result = null;
- }
- break;
- case 2:
- result = currentEntry.getVoucher();
- break;
- case 3: // account
- if (currentEntry.getAccount() != null){
- result = currentEntry.getAccount().getAccountNumber();
- }
- else {
- result = null;
- }
- break;
- case 4:
- result = currentEntry.getDescription();
- break;
- case 5 :
- result = currentEntry.getPosition();
- break;
- case 6:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : 0;
- break;
- case 7:
- result = currentEntry.getDebit() ? 0 : currentEntry.getAmount();
- break;
- case 8:
- result = null; // balance
- break;
- }
-
- }
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
-
- return result;
- }
-
-
- public void setFinancialPeriod(FinancialPeriod financialPeriod){
-
- selectedFinancialPeriod = financialPeriod;
- cacheDataList = getDataList();
- fireTableDataChanged();
- }
-
- /**
- * To set cells editable or not
- * different condition for entry or financial transaction
- */
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- boolean editableCell=false;
- Object currentRow = cacheDataList.get(rowIndex);
- // cells editable for the entry row, all cells exclude the date
- if ((currentRow instanceof Entry) && !(columnIndex==0)) {
- editableCell=true;
- }
- // cells editable for the financialtransaction row, no cells exclude the date
- if ((currentRow instanceof FinancialTransaction) && (columnIndex==0)){
- editableCell=true;
- }
- return editableCell;
- }
-
- /**
- * @throws LimaException
- */
- public void addFinancialTransaction() throws LimaException{
- /* Calling transaction service */
- FinancialTransaction financialTransaction = new FinancialTransactionImpl();
- //if a period and an entrybook is selected
- if (selectedFinancialPeriod != null){
- financialTransaction.setFinancialPeriod(selectedFinancialPeriod);
- // get today
- Calendar actualCalendar = Calendar.getInstance();
- // get the financial period date
- Date transactionDate = selectedFinancialPeriod.getBeginDate();
- // change the day
- transactionDate = DateUtils.setDays(transactionDate,
- actualCalendar.get(Calendar.DAY_OF_MONTH));
- // set date to the financial transaction
- financialTransaction.setTransactionDate(transactionDate);
- // create it
- financialTransactionService.createFinancialTransaction(financialTransaction);
- //on recharge la liste
- cacheDataList = getDataList();
- int row = getDataList().indexOf(financialTransaction);
- fireTableRowsInserted(row, row);
- //fireTableDataChanged();
- }
- else {
- throw new LimaBusinessException("No financial period selected");
- }
- }
-
-
-
- /**
- * @throws LimaException
- */
- public void addEmptyEntry(Object value, int row) throws LimaException {
- FinancialTransaction currentTransaction = null;
- Object currentRow = cacheDataList.get(row);
- Entry entry = new EntryImpl();
- //check if current row is a transaction or an entry
- if (currentRow instanceof FinancialTransaction) {
- currentTransaction = (FinancialTransaction)currentRow;
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- //get back the parent transaction of the entry
- currentTransaction = currentEntry.getFinancialTransaction();
- }
- //create it
- entry.setFinancialTransaction(currentTransaction);
- financialTransactionService.createEntry(entry);
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableDataChanged();
- }
-
- /**
- * to modifiy financialtransaction or entry
- */
- @Override
- public void setValueAt(Object value, int row, int column) {
- int financialTransactionRow=0;
- // just prevent too much result
- if (selectedFinancialPeriod != null) {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentFinancialTransaction =
- (FinancialTransaction)currentRow;
- switch (column) {
- case 0:
- //update
- currentFinancialTransaction.setTransactionDate((Date)value);
- break;
- }
- // notify service for modification
- try {
- financialTransactionService.
- updateFinancialTransaction(currentFinancialTransaction);
- } catch (LimaException e) {
- if (log.isDebugEnabled()){
- log.debug("Can't update financial transaction", e);
- }
- }
- //update the financial transaction in entire
- financialTransactionRow =
- getDataList().indexOf(((FinancialTransaction) currentRow));
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- switch (column) {
- case 1 :
- currentEntry.setEntryBook((EntryBook)value);
- break;
- case 2 :
- currentEntry.setVoucher((String)value);
- break;
- case 3:
- currentEntry.setAccount((Account)value);
- break;
- case 4:
- currentEntry.setDescription((String)value);
- break;
- case 5 :
- currentEntry.setPosition((String)value);
- break;
- case 6:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(true);
- break;
- case 7:
- currentEntry.setAmount((Double)value);
- currentEntry.setDebit(false);
- break;
- }
- try {
- financialTransactionService.updateEntry(currentEntry);
-
- } catch (LimaException e) {
- if (log.isDebugEnabled()){
- log.debug("Can't update entry", e);
- }
- }
- //update the financial transaction in entire
- financialTransactionRow =
- getDataList().indexOf(((Entry) currentRow).
- getFinancialTransaction());
- }
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableRowsUpdated(financialTransactionRow, getRowCount()-1);
- }
- else {
- if (log.isDebugEnabled()) {
- log.debug("No fiscalPeriod selected skip table model update");
- }
- }
- }
-
- public Object getElementAt(int row){
-
- Object currentRow = cacheDataList.get(row);
- return currentRow;
- }
-
-
- /**
- * Delete selected row in table (could be transaction or entry).
- *
- * Called by model.
- * @param Object, int
- * @throws LimaException
- */
- public void removeObject(Object object, int row) throws LimaException {
- Object currentRow = cacheDataList.get(row);
- if (currentRow instanceof FinancialTransaction) {
- FinancialTransaction currentTransaction =
- (FinancialTransaction)currentRow;
- financialTransactionService.removeFinancialTransaction(currentTransaction);
- }
- else if (currentRow instanceof Entry) {
- Entry currentEntry = (Entry)currentRow;
- financialTransactionService.removeEntry(currentEntry);
- }
- //on recharge la liste
- cacheDataList = getDataList();
- fireTableRowsDeleted(row, getRowCount());
- }
-
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -15,7 +15,7 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##% -->
<JDialog modal="true">
- <org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel id="modelFiscalPeriodTable"/>
+ <org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel id="modelFiscalPeriodTable"/>
<script>
<![CDATA[
import org.chorem.lima.entity.FiscalPeriod;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -1,19 +0,0 @@
-<!-- ##% Lima Swing
- 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 2
- 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-<JFrame title="lima.export" width="620" height="300" iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
-
-</JFrame>
\ No newline at end of file
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,74 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.fiscalperiod;
+
+import java.awt.Color;
+import java.awt.Component;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+import org.jdesktop.swingx.decorator.HighlighterFactory;
+
+public class FiscalPeriodTable extends JXTable {
+
+private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class);
+
+ protected FiscalPeriodViewHandler handler;
+
+ protected FiscalPeriodTableModel model;
+
+ protected FiscalPeriodService financialPeriodService;
+
+ private Highlighter colorTransaction;
+
+ public FiscalPeriodTable(FiscalPeriodViewHandler handler) {
+
+ this.handler = handler;
+ model = this.handler.getView().getModelFiscalPeriodTable();
+ financialPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ addHighlighter(HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222)));
+ //highlight financial financial transactions
+ addBlockColor();
+ }
+
+ protected void addBlockColor() {
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ FiscalPeriod fiscalPeriod = (FiscalPeriod) model.getElementAt(adapter.row);
+ // true if locked
+ return (fiscalPeriod.getLocked());
+ }
+ };
+ colorTransaction =
+ new ColorHighlighter(predicate, null, new Color(222,0,0));
+ addHighlighter(colorTransaction);
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -0,0 +1,213 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.fiscalperiod;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+import javax.swing.table.AbstractTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.FiscalPeriodService;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.service.LimaServiceFactory;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class FiscalPeriodTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 77027335135838258L;
+
+ private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class);
+
+ protected FiscalPeriodService fiscalPeriodService;
+
+ public FiscalPeriodTableModel() {
+ fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService();
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+
+ int result = 0;
+ try {
+ result = fiscalPeriodService.getAllFiscalPeriods().size();
+ }
+ catch (LimaException eee) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't get row count",eee);
+ }
+ }
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+
+ public Object getElementAt(int row){
+
+ Object currentRow=null;
+ try {
+ currentRow = fiscalPeriodService.getAllFiscalPeriods().get(row);
+ } catch (LimaException eee) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't get elenment at table",eee);
+ }
+ }
+ return currentRow;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int columnIndex) {
+
+ String result = "n/a";
+
+ switch(columnIndex) {
+ case 0 :
+ result = _("lima.tab.fiscalperiod");
+ break;
+ case 1:
+ result = _("lima.closure");
+ break;
+ }
+
+ return result;
+ }
+ /*
+ * @see javax.swing.table.TableModel#getColumnClass(int)
+ */
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ // both String
+ return String.class;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#isCellEditable(int, int)
+ */
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return false;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+
+ Object result = "n/a";
+
+ List<FiscalPeriod> periods;
+ try {
+ periods = fiscalPeriodService.getAllFiscalPeriods();
+ FiscalPeriod fiscalPeriod = periods.get(rowIndex);
+
+ if (fiscalPeriod != null){
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy");
+
+ switch (columnIndex) {
+ case 0:
+ result = simpleDateFormat.
+ format(fiscalPeriod.getBeginDate())
+ + " - " + simpleDateFormat.
+ format(fiscalPeriod.getEndDate());
+ break;
+ case 1:
+ if(fiscalPeriod.getLocked()){
+ result = _("lima.close");
+ }
+ else{
+ result = _("lima.open");
+ }
+ break;
+ }
+ }
+
+
+
+ } catch (LimaException eee) {
+ if(log.isDebugEnabled()){
+ log.debug("Can't update table",eee);
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
+ */
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+
+ }
+
+
+ public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException {
+ FiscalPeriod fiscalPeriod = null;
+ fiscalPeriod = fiscalPeriodService.getAllFiscalPeriods().get(row);
+ return fiscalPeriod;
+ }
+
+
+ /**
+ * @param period
+ */
+ public void addFiscalPeriod(FiscalPeriod period) throws LimaException {
+
+ int currentRowCount = getRowCount();
+
+ // Calling fiscal period service
+ fiscalPeriodService.createFiscalPeriod(period);
+ fireTableRowsInserted(currentRowCount, currentRowCount);
+ }
+
+ public void removeAllFiscalPeriods() throws LimaException {
+ fiscalPeriodService.removeAllFiscalPeriods();
+ fireTableDataChanged();
+ }
+
+ public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
+ fiscalPeriodService.blockFiscalPeriod(fiscalPeriod);
+ fireTableDataChanged();
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-06-03 16:45:18 UTC (rev 2931)
@@ -19,7 +19,7 @@
<FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" />
<Boolean id="selectedPeriod" javaBean="false" />
- <org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel id="modelFiscalPeriodTable"/>
+ <org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel id="modelFiscalPeriodTable"/>
<script>
<![CDATA[
@@ -39,7 +39,7 @@
<row>
<cell fill="both" weightx="1" weighty="1">
<JScrollPane>
- <org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTable
+ <org.chorem.lima.ui.fiscalperiod.FiscalPeriodTable
id="fiscalPeriodTable" rowHeight="24"
constructorParams="getHandler()" model="{getModelFiscalPeriodTable()}"
selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -29,7 +29,6 @@
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel;
import org.chorem.lima.ui.fiscalperiod.AddPeriod;
import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView;
import org.chorem.lima.util.ErrorHelper;
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 2010-06-03 14:46:55 UTC (rev 2930)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2010-06-03 16:45:18 UTC (rev 2931)
@@ -46,8 +46,6 @@
protected LedgerViewHandler handler;
- protected LedgerTableModel model;
-
private Highlighter colorReportsDatas;
/**
1
0
Author: jpepin
Date: 2010-06-03 16:46:55 +0200 (Thu, 03 Jun 2010)
New Revision: 2930
Url: http://chorem.org/repositories/revision/lima/2930
Log:
Visualisation du Grand-Livre
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.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
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-business/src/main/java/org/chorem/lima/business/ReportService.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ReportService.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -59,11 +59,18 @@
/**
* Generation de la balance.
*
- * @param financialPeriod la periode
* @return la balance
* @throws LimaException
*/
- BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException;
+ BalanceTrial generateBalanceTrial(Date beginDate, Date endDate, Boolean getEntries) throws LimaException;
+
+ /**
+ * Generation du grand-livre
+ *
+ * @throws LimaException
+ */
+ BalanceTrial generateLedger(Date beginDate, Date endDate) throws LimaException;
+
/**
* Generation du rapports des comptes
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -174,7 +174,7 @@
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
entriesQuery.addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
-
+
TopiaQuery amountsQuery =
createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
amountsQuery.setSelect("E."+Entry.DEBIT, "SUM(E."+Entry.AMOUNT+")");
@@ -217,16 +217,26 @@
/**
* Calculate all credit, debit and solde amounts for the balance
+ *
+ * Get all entries if true
*/
@SuppressWarnings("unchecked")
- protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, TopiaContext topiaContext) throws LimaException {
+ protected ReportsDatas generateSubAccountBalanceWithTransaction(Account account, Date beginDate, Date endDate, Boolean getEntries, TopiaContext topiaContext) throws LimaException {
ReportsDatas reportsDatas = new ReportsDatasImpl();
double credit = 0, debit = 0, solde = 0;
List<Object[]> results = new ArrayList<Object[]>();
String queryAlias = "E";
if (beginDate != null && endDate != null){
try {
- EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+ EntryDAO entryDAO= LimaCallaoDAOHelper.getEntryDAO(topiaContext);
+
+ if (getEntries){
+ TopiaQuery entriesQuery =
+ createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ entriesQuery.addLoad(Entry.ENTRY_BOOK, Entry.FINANCIAL_TRANSACTION);
+ reportsDatas.setListEntry(entryDAO.findAllByQuery(entriesQuery));
+ }
TopiaQuery amountsQuery =
createEntryQuery(account, beginDate, endDate, entryDAO, queryAlias);
@@ -353,9 +363,13 @@
* Get balance trial
*
* Calculate the amounts and the solde for all subaccounts
+ *
+ * Boolean Param GetEntries is for get entries in datasreports or not :
+ * - GetEntries = false for generate balance
+ * - GetEntries = true for generate ledger
*/
@Override
- public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate) throws LimaException {
+ public BalanceTrial generateBalanceTrial(Date beginDate, Date endDate, Boolean getEntries) throws LimaException {
BalanceTrial balanceTrial = new BalanceTrialImpl();
balanceTrial.setReportsDatas(new ArrayList<ReportsDatas>());
double credit = 0, debit = 0, solde = 0;
@@ -371,7 +385,7 @@
for (Account account : accounts) {
ReportsDatas reportsDatas =
generateSubAccountBalanceWithTransaction(account, beginDate,
- endDate, topiaTransaction);
+ endDate, getEntries, topiaTransaction);
reportsDatas.setAccount(account);
// add balance sheet to balance trial
balanceTrial.addReportsDatas(reportsDatas);
@@ -402,6 +416,19 @@
return balanceTrial;
}
+
+ /**
+ * Get Ledger
+ *
+ * Calculate the amounts and the solde for all subaccounts
+ * Get all entries
+ */
+ @Override
+ public BalanceTrial generateLedger(Date beginDate, Date endDate) throws LimaException {
+ return generateBalanceTrial(beginDate, endDate, true);
+ }
+
+
protected TopiaContext beginTransaction() throws TopiaException {
// basic check done, make check in database
// TODO move it into JTA
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -136,8 +136,8 @@
switch (column) {
case 0:
- result = StringUtils.capitalize(simpleDateFormat.
- format(currentRow.getFinancialTransaction().getTransactionDate()));
+ result = simpleDateFormat.
+ format(currentRow.getFinancialTransaction().getTransactionDate());
break;
case 1:
if (currentRow.getEntryBook() != null){
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/balance/BalanceTableModel.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -20,21 +20,16 @@
package org.chorem.lima.ui.balance;
import static org.nuiton.i18n.I18n._;
-
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.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportService;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.ReportsHelper;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -58,12 +53,6 @@
/** Services. */
protected ReportService reportService;
- /** Helper */
- protected ReportsHelper helper;
-
- /** Account. */
- protected Account selectedAccount;
-
/** Begin Date. */
protected Date selectedBeginDate;
@@ -187,7 +176,7 @@
BalanceTrial results = null;
try {
- results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate);
+ results = reportService.generateBalanceTrial(selectedBeginDate, selectedEndDate, false);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -0,0 +1,81 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.celleditor;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.table.TableCellEditor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.chorem.lima.ui.combobox.AccountRenderer;
+import org.chorem.lima.ui.combobox.SubAccountComboBoxModel;
+import org.chorem.lima.widgets.JWideComboBox;
+
+public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
+ private final JWideComboBox comboBox;
+ private static final long serialVersionUID = 2580476608066111095L;
+ private static AccountTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public AccountTableCellEditor() {
+ comboBox = new JWideComboBox();
+ SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel();
+ comboBox.setModel(accountComboBoxModel);
+ AccountRenderer accountRenderer = new AccountRenderer();
+ comboBox.setRenderer(accountRenderer);
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Account){
+ comboBox.setSelectedItem((Account) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static AccountTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new AccountTableCellEditor();
+ }
+ return editor;
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -0,0 +1,72 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.celleditor;
+
+import org.chorem.lima.LimaContext;
+import org.jdesktop.swingx.JXDatePicker;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import java.awt.*;
+import java.awt.event.MouseEvent;
+import java.util.Date;
+import java.util.EventObject;
+
+/**
+ * @author ore
+ */
+public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private final JXDatePicker datePicker;
+ private static final long serialVersionUID = -8455896587828255307L;
+ private static DateTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public DateTableCellEditor() {
+ datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof Date) {
+ datePicker.setDate((Date) value);
+ }
+ return datePicker;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return datePicker.getDate();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static DateTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new DateTableCellEditor();
+ }
+ return editor;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java (from rev 2920, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -0,0 +1,86 @@
+/**
+ * *##% Lima Main
+ * Copyright (C) 2008 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.celleditor;
+
+import java.awt.Component;
+import java.awt.event.MouseEvent;
+import java.util.EventObject;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.table.TableCellEditor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
+import org.chorem.lima.ui.combobox.EntryBookRenderer;
+import org.chorem.lima.widgets.JWideComboBox;
+
+public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
+ private final JWideComboBox comboBox;
+ private static final long serialVersionUID = 2580476608066111095L;
+ private static EntryBookTableCellEditor editor;
+
+ /**
+ * constructor
+ */
+ public EntryBookTableCellEditor() {
+ comboBox = new JWideComboBox();
+ EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
+ comboBox.setModel(entryBookComboBoxModel);
+ EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
+ comboBox.setRenderer(entryBookRenderer);
+
+ /*// Property Change Listener
+ LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
+ comboBox.setModel(comboBoxModel);
+ // AutoCompletion
+ AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (value instanceof EntryBook){
+ comboBox.setSelectedItem((EntryBook) value);
+
+ }
+ return comboBox;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+ return comboBox.getSelectedItem();
+ }
+
+ @Override
+ public boolean isCellEditable(EventObject evt) {
+ return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
+ }
+
+ public static EntryBookTableCellEditor getInstance() {
+ if (editor == null) {
+ editor = new EntryBookTableCellEditor();
+ }
+ return editor;
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/AccountTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -1,81 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.financialtransaction.table;
-
-import java.awt.Component;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.ui.combobox.AccountRenderer;
-import org.chorem.lima.ui.combobox.SubAccountComboBoxModel;
-import org.chorem.lima.widgets.JWideComboBox;
-
-public class AccountTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
- private final JWideComboBox comboBox;
- private static final long serialVersionUID = 2580476608066111095L;
- private static AccountTableCellEditor editor;
-
- /**
- * constructor
- */
- public AccountTableCellEditor() {
- comboBox = new JWideComboBox();
- SubAccountComboBoxModel accountComboBoxModel = new SubAccountComboBoxModel();
- comboBox.setModel(accountComboBoxModel);
- AccountRenderer accountRenderer = new AccountRenderer();
- comboBox.setRenderer(accountRenderer);
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Account){
- comboBox.setSelectedItem((Account) value);
-
- }
- return comboBox;
- }
-
- @Override
- public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static AccountTableCellEditor getInstance() {
- if (editor == null) {
- editor = new AccountTableCellEditor();
- }
- return editor;
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/DateTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -1,72 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.financialtransaction.table;
-
-import org.chorem.lima.LimaContext;
-import org.jdesktop.swingx.JXDatePicker;
-
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.util.Date;
-import java.util.EventObject;
-
-/**
- * @author ore
- */
-public class DateTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- private final JXDatePicker datePicker;
- private static final long serialVersionUID = -8455896587828255307L;
- private static DateTableCellEditor editor;
-
- /**
- * constructor
- */
- public DateTableCellEditor() {
- datePicker = new JXDatePicker(LimaContext.getContext().getConfig().getLocale());
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof Date) {
- datePicker.setDate((Date) value);
- }
- return datePicker;
- }
-
- @Override
- public Object getCellEditorValue() {
- return datePicker.getDate();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static DateTableCellEditor getInstance() {
- if (editor == null) {
- editor = new DateTableCellEditor();
- }
- return editor;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/EntryBookTableCellEditor.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -1,86 +0,0 @@
-/**
- * *##% Lima Main
- * Copyright (C) 2008 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.financialtransaction.table;
-
-import java.awt.Component;
-import java.awt.event.MouseEvent;
-import java.util.EventObject;
-
-import javax.swing.AbstractCellEditor;
-import javax.swing.JTable;
-import javax.swing.table.TableCellEditor;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.combobox.EntryBookComboBoxModel;
-import org.chorem.lima.ui.combobox.EntryBookRenderer;
-import org.chorem.lima.widgets.JWideComboBox;
-
-public class EntryBookTableCellEditor extends AbstractCellEditor implements TableCellEditor {
-
- protected static final Log log = LogFactory.getLog(EntryBookTableCellEditor.class);
- private final JWideComboBox comboBox;
- private static final long serialVersionUID = 2580476608066111095L;
- private static EntryBookTableCellEditor editor;
-
- /**
- * constructor
- */
- public EntryBookTableCellEditor() {
- comboBox = new JWideComboBox();
- EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel();
- comboBox.setModel(entryBookComboBoxModel);
- EntryBookRenderer entryBookRenderer = new EntryBookRenderer();
- comboBox.setRenderer(entryBookRenderer);
-
- /*// Property Change Listener
- LimaContext.getContext().getDataManager().getJournalModel().addPropertyChangeListener(comboBoxModel);
- comboBox.setModel(comboBoxModel);
- // AutoCompletion
- AutoCompleteDecorator.decorate(comboBox, JournalToStringConverter.getInstance());*/
- }
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (value instanceof EntryBook){
- comboBox.setSelectedItem((EntryBook) value);
-
- }
- return comboBox;
- }
-
- @Override
- public Object getCellEditorValue() {
- return comboBox.getSelectedItem();
- }
-
- @Override
- public boolean isCellEditable(EventObject evt) {
- return !(evt instanceof MouseEvent) || ((MouseEvent) evt).getClickCount() == 2;
- }
-
- public static EntryBookTableCellEditor getInstance() {
- if (editor == null) {
- editor = new EntryBookTableCellEditor();
- }
- return editor;
- }
-}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTable.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -28,6 +28,9 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.DateTableCellEditor;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionViewHandler;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -28,10 +28,10 @@
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
+import org.chorem.lima.ui.celleditor.DateTableCellEditor;
+import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedViewHandler;
-import org.chorem.lima.ui.financialtransaction.table.AccountTableCellEditor;
-import org.chorem.lima.ui.financialtransaction.table.DateTableCellEditor;
-import org.chorem.lima.ui.financialtransaction.table.EntryBookTableCellEditor;
import org.jdesktop.swingx.JXTable;
import org.jdesktop.swingx.decorator.ColorHighlighter;
import org.jdesktop.swingx.decorator.ComponentAdapter;
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTable.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -0,0 +1,83 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.ledger;
+
+import java.awt.Color;
+import java.awt.Component;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.entity.Account;
+import org.jdesktop.swingx.JXTable;
+import org.jdesktop.swingx.decorator.ColorHighlighter;
+import org.jdesktop.swingx.decorator.ComponentAdapter;
+import org.jdesktop.swingx.decorator.HighlightPredicate;
+import org.jdesktop.swingx.decorator.Highlighter;
+
+
+/**
+ * Table des transaction qui ajoute des comportement (keys).
+ *
+ * @author ore
+ * @author Rémi Chapelet
+ */
+public class LedgerTable extends JXTable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3133690382049594727L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(LedgerTable.class);
+
+ protected LedgerViewHandler handler;
+
+ protected LedgerTableModel model;
+
+ private Highlighter colorReportsDatas;
+
+ /**
+ */
+ public LedgerTable(LedgerViewHandler handler) {
+
+ this.handler = handler;
+ //highlight financial financial transactions
+ addColorReportsDatas();
+
+ }
+
+ /**
+ * Cette méthode permet de colorer toutes les reportsdatas dans le tableau
+ * afin de bien distinguer les entête de comptes et les entrées comptables.
+ * On récupère la première cellule, on vérifie que c'est pas null
+ */
+ protected void addColorReportsDatas() {
+ if (colorReportsDatas != null) {
+ removeHighlighter(colorReportsDatas);
+ }
+ HighlightPredicate predicate = new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer,
+ ComponentAdapter adapter) {
+ return (adapter.getValueAt(adapter.row, 0) != null);
+ }
+ };
+ colorReportsDatas =
+ new ColorHighlighter(predicate, new Color(222,222,222), null);
+ addHighlighter(colorReportsDatas);
+ }
+}
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -21,14 +21,18 @@
import static org.nuiton.i18n.I18n._;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
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.beans.BalanceTrial;
import org.chorem.lima.beans.ReportsDatas;
-import org.chorem.lima.beans.ReportsDatasImpl;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.business.ReportService;
+import org.chorem.lima.business.utils.EntryComparator;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.service.LimaServiceFactory;
@@ -65,7 +69,8 @@
protected Date selectedEndDate;
/** data cache */
- protected ReportsDatas cacheDataList;
+ protected List<Object> cacheDataList;
+ protected BalanceTrial balanceTrialCache;
/**
* Constructor.
@@ -81,12 +86,12 @@
int result = 0;
// just prevent too much result
- if (selectedEntryBook != null) {
- result = cacheDataList.getListEntry().size();
+ if (selectedBeginDate != null && selectedEndDate != null) {
+ result = cacheDataList.size();
}
else {
if (log.isDebugEnabled()) {
- log.debug("No account selected skip table model update");
+ log.debug("No period selected skip table model update");
}
}
@@ -95,7 +100,7 @@
@Override
public int getColumnCount() {
- return 6;
+ return 8;
}
@Override
@@ -103,41 +108,50 @@
String res = "n/a";
switch (column) {
case 0:
- res = _("lima.transaction.column.date"); //Date
+ res = _("lima.transaction.column.account"); //Account
break;
case 1:
- res = _("lima.transaction.column.account"); //Account
+ res = _("lima.transaction.column.date"); //Date
break;
case 2:
+ res = _("lima.transaction.column.entrybook");
+ break;
+ case 3:
res = _("lima.transaction.column.voucher"); // Voucher
break;
- case 3:
+ case 4:
res = _("lima.transaction.column.description"); //Description
break;
- case 4:
+ case 5:
res = _("lima.transaction.column.debit"); //Debit
break;
- case 5:
+ case 6:
res = _("lima.transaction.column.credit"); //Credit
break;
+ case 7:
+ res = _("lima.transaction.column.solde");
+ break;
}
return res;
}
-
+
@Override
public Object getValueAt(int row, int column) {
Object result = null;
- if(selectedEntryBook != null) {
- Entry currentRow = cacheDataList.getListEntry().get(row);
- SimpleDateFormat simpleDateFormat =
- new SimpleDateFormat("dd MMMMM yyyy");
-
- switch (column) {
+
+ // just prevent too much result
+ if (selectedBeginDate != null && selectedEndDate != null) {
+ result = cacheDataList.get(row);
+ SimpleDateFormat simpleDateFormat
+ = new SimpleDateFormat("dd MMMMM yyyy");
+
+ if (result instanceof ReportsDatas) {
+ ReportsDatas currentRow = (ReportsDatas)result;
+ Double amountDebit = currentRow.getAmountDebit();
+ Double amountCredit = currentRow.getAmountCredit();
+
+ switch (column) {
case 0:
- result = simpleDateFormat.
- format(currentRow.getFinancialTransaction().getTransactionDate());
- break;
- case 1:
if (currentRow.getAccount() != null){
result = currentRow.getAccount().getAccountNumber();
}
@@ -145,30 +159,79 @@
result = null;
}
break;
+ case 1:
+ result = null; // date
+ break;
case 2:
- result = currentRow.getVoucher();
+ result = null; //entrybook
break;
case 3:
- result = currentRow.getDescription();
+ result = null; // voucher
break;
case 4:
- result = currentRow.getDebit() ? currentRow.getAmount() : 0;
+ result = null; // description
break;
- case 5:
- result = currentRow.getDebit() ? 0 : currentRow.getAmount();
+ case 5 :
+ result = amountDebit; // position
break;
+ case 6:
+ result = amountCredit;
+ break;
+ case 7:
+ result = amountDebit - amountCredit;
+ break;
+ }
}
- }
+ else if (result instanceof Entry) {
+ Entry currentRow = (Entry)result;
+ Double amountDebit = currentRow.getDebit() ? currentRow.getAmount() : 0;
+ Double amountCredit = currentRow.getDebit() ? 0 : currentRow.getAmount();
+
+ switch (column) {
+ case 0:
+ result = null; // account
+ break;
+ case 1 : // date
+ result = simpleDateFormat.
+ format(currentRow.getFinancialTransaction().getTransactionDate());
+ break;
+ case 2:
+ if (currentRow.getEntryBook() != null){
+ result = currentRow.getEntryBook().getCode();
+ }
+ else { //entrybook
+ result = null;
+ }
+ break;
+ case 3: // description
+ result = currentRow.getVoucher();
+ break;
+ case 4:
+ result = currentRow.getDescription();
+ break;
+ case 5 :
+ result = amountDebit;
+ break;
+ case 6:
+ result = amountCredit;
+ break;
+ case 7:
+ result = amountDebit - amountCredit;
+ break;
+ }
+
+ }
+ }
else {
if (log.isDebugEnabled()) {
- log.debug("No EntryBook selected skip table model update");
+ log.debug("No fiscalPeriod selected skip table model update");
}
}
-
+
return result;
}
+
-
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
// Just read, no write
@@ -176,33 +239,26 @@
}
public void setBeginDate(Date date){
- log.debug("setBeginDate");
selectedBeginDate = date;
- log.debug(selectedBeginDate);
- cacheDataList=getDataList();
+ cacheDataList = getDataList();
fireTableDataChanged();
}
public void setEndDate(Date date){
- log.debug("setEndDate");
selectedEndDate = date;
- log.debug(selectedEndDate);
- cacheDataList=getDataList();
+ cacheDataList = getDataList();
fireTableDataChanged();
}
-
- public void setEntryBook(EntryBook entryBook) {
- selectedEntryBook = entryBook;
- cacheDataList=getDataList();
- fireTableDataChanged();
- }
-
- public ReportsDatas getDataList(){
- ReportsDatas results = new ReportsDatasImpl();
+ /**
+ * get all account fot the selected period
+ * @return
+ */
+ public List<Object> getDataList(){
+ List<Object> results = new ArrayList<Object>();
+
try {
- results =
- reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate);
+ balanceTrialCache = reportService.generateLedger(selectedBeginDate, selectedEndDate);
}
catch (LimaException eee) {
if (log.isErrorEnabled()) {
@@ -210,6 +266,15 @@
}
ErrorHelper.showErrorDialog("Can't get entries list", eee);
}
+ for (ReportsDatas reportsDatas : balanceTrialCache.getReportsDatas()) {
+ results.add(reportsDatas);
+ List<Entry> entries = (List<Entry>) reportsDatas.getListEntry();
+ log.debug(reportsDatas);
+ if (entries != null){
+ Collections.sort(entries, new EntryComparator());
+ results.addAll(entries);
+ }
+ }
return results;
}
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-06-03 14:46:55 UTC (rev 2930)
@@ -64,11 +64,10 @@
<row>
<cell fill="both" weightx="1" weighty="1" columns="7">
<JScrollPane>
- <org.jdesktop.swingx.JXTable id="table" rowHeight="24"
- model="{getModelTable()}"
- highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
- selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
+ <org.chorem.lima.ui.ledger.LedgerTable
+ id="table" sortable="false" rowHeight="24"
+ constructorParams="getHandler()" model="{getModelTable()}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}" />
<javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()"/>
</JScrollPane>
</cell>
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-06-03 14:46:55 UTC (rev 2930)
@@ -21,7 +21,7 @@
import static org.nuiton.i18n.I18n._;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.beans.BalanceTrial;
import org.chorem.lima.ui.ReportsHelper;
@@ -56,9 +56,8 @@
public void updateFooterLabel(){
LedgerTableModel tablemodel =
(LedgerTableModel) view.getTable().getModel();
+ BalanceTrial cacheDataList = tablemodel.balanceTrialCache;
- ReportsDatas cacheDataList = tablemodel.cacheDataList;
-
if (cacheDataList != null){
// set amounts credit, debit and solde
view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit()));
@@ -79,7 +78,7 @@
view.soldeLabel.setText(_("lima.soldecredit"));
}
}
- }
+ }
}
}
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-03 14:46:55 UTC (rev 2930)
@@ -347,6 +347,7 @@
lima.transaction.column.entrybook=Entrybook
lima.transaction.column.period=Period
lima.transaction.column.position=
+lima.transaction.column.solde=Solde
lima.transaction.column.status=Status
lima.transaction.column.voucher=
lima.transaction.confirmdelete=
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 2010-06-03 10:51:13 UTC (rev 2929)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-03 14:46:55 UTC (rev 2930)
@@ -319,6 +319,7 @@
lima.transaction.column.entrybook=Journal
lima.transaction.column.period=P\u00E9riode
lima.transaction.column.position=Statut
+lima.transaction.column.solde=Solde
lima.transaction.column.voucher=Pi\u00E8ce comptable
lima.transaction.confirmdelete=
lima.transaction.entrybook=Journal
1
0
r2929 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui java/org/chorem/lima/ui/financialtransaction java/org/chorem/lima/ui/financialtransaction/table java/org/chorem/lima/ui/financialtransactionunbalanced java/org/chorem/lima/ui/ledger resources/i18n
by jpepin@users.chorem.org 03 Jun '10
by jpepin@users.chorem.org 03 Jun '10
03 Jun '10
Author: jpepin
Date: 2010-06-03 12:51:13 +0200 (Thu, 03 Jun 2010)
New Revision: 2929
Url: http://chorem.org/repositories/revision/lima/2929
Log:
Cr?\195?\169ation UI Grand-Livre.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/
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
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.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/MainView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-06-03 10:51:13 UTC (rev 2929)
@@ -142,7 +142,8 @@
<JMenu text="lima.reports">
<JMenuItem text="lima.reports.accounts" onActionPerformed='getHandler().showAccountReports(this)'/>
<JMenuItem text="lima.reports.entrybooks" onActionPerformed='getHandler().showEntryBookReports(this)'/>
- <JMenuItem text="lima.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
+ <JMenuItem text="lima.reports.balance" onActionPerformed='getHandler().showBalanceView(this)'/>
+ <JMenuItem text="lima.reports.ledger" onActionPerformed='getHandler().showLedgerView(this)'/>
<JMenuItem text="lima.reports" onActionPerformed='getHandler().showReportsView(this)' actionIcon='rapport'/>
<JMenuItem text="lima.bilan" onActionPerformed='getHandler().showBilanView(this)'/>
<JMenuItem text="lima.result" onActionPerformed='getHandler().showResultView(this)'/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -44,6 +44,7 @@
import org.chorem.lima.ui.financialtransaction.FinancialTransactionView;
import org.chorem.lima.ui.financialtransaction.LetteringView;
import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView;
+import org.chorem.lima.ui.ledger.LedgerView;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -285,7 +286,7 @@
public void showAccountView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
AccountView accountView = new AccountView(mainView);
- mainView.showTab(_("lima.tab.account"), accountView);
+ mainView.showTab(_("lima.charts.account"), accountView);
}
/**
* Show account tree table view to create or modify accounts
@@ -294,7 +295,7 @@
public void showEntryBookView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
EntryBookView entryBookView= new EntryBookView(mainView);
- mainView.showTab(_("lima.entrybooks"), entryBookView);
+ mainView.showTab(_("lima.charts.entrybook"), entryBookView);
}
/**
@@ -304,7 +305,7 @@
public void showFiscalPeriodView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView);
- mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView);
+ mainView.showTab(_("lima.charts.fiscalyear"), fiscalPeriodView);
}
/**
@@ -345,7 +346,7 @@
public void showTransactionView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
FinancialTransactionView transactionView = new FinancialTransactionView(mainView);
- mainView.showTab(_("lima.tab.transaction"), transactionView);
+ mainView.showTab(_("lima.entries.addtransaction"), transactionView);
}
public void showTransactionUnbalancedView(JAXXContext rootContext) {
@@ -357,9 +358,15 @@
public void showBalanceView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
BalanceView balanceView = new BalanceView(mainView);
- mainView.showTab(_("lima.tab.balance"), balanceView);
+ mainView.showTab(_("lima.reports.balance"), balanceView);
}
+ public void showLedgerView(JAXXContext rootContext) {
+ MainView mainView = getUI(rootContext);
+ LedgerView ledgerView = new LedgerView(mainView);
+ mainView.showTab(_("lima.reports.ledger"), ledgerView);
+ }
+
public void showBilanView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
// BilanView bilanView = new BilanView(mainView);
@@ -385,7 +392,7 @@
public void showLetteringView(JAXXContext rootContext) {
MainView mainView = getUI(rootContext);
LetteringView letteringView = new LetteringView(mainView);
- mainView.showTab(_("lima.tab.lettering"), letteringView);
+ mainView.showTab(_("lima.entries.lettering"), letteringView);
}
public void showSearchView(JAXXContext rootContext) {
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionHelper.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -1,84 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.financialtransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class FinancialTransactionHelper {
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
-
- /**
- * Get total credit for a transaction.
- *
- * @param transaction transaction to get credit
- * @return total credit
- */
- public static double getCredit(FinancialTransaction financialtransaction) {
- double credit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (!entry.getDebit()) {
- credit += entry.getAmount();
- }
- }
- return credit;
- }
-
- /**
- * Get total debit for a transaction.
- *
- * @param transaction transaction to get debit
- * @return total debit
- */
- public static double getDebit(FinancialTransaction financialtransaction) {
- double debit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (entry.getDebit()) {
- debit += entry.getAmount();
- }
- }
- return debit;
- }
-
- /**
- * Return true if transaction is balanced (credit == debit).
- *
- * @param transaction transaction to test
- * @return {@code true} if transaction is balanced
- */
- public static boolean isBalanced(FinancialTransaction financialtransaction) {
- boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
- return balanced;
- }
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchFinancialTransactionViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -1,14 +0,0 @@
-package org.chorem.lima.ui.financialtransaction;
-
-public class SearchFinancialTransactionViewHandler {
-
-
- protected void addCriteriaWidget() {
-
- }
-
- protected void doSearch() {
-
- }
-
-}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/SearchTransactionView.jaxx 2010-06-03 10:51:13 UTC (rev 2929)
@@ -1,60 +0,0 @@
-<!-- ##% Lima Swing
- 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 2
- 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, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- ##% -->
-
-<JFrame title="lima.search" width="620" height="300" locationRelativeTo="{null}"
- onWindowClosing="windowClosing()"
- defaultCloseOperation="do_nothing_on_close"
- iconImage='{Toolkit.getDefaultToolkit().getImage(getClass().getResource("/icons/lima.png"))}'>
- <script>
- protected void addCriteriaWidget() {};
- protected void doSearch() {};
- protected void windowClosing() {};
- </script>
- <JScrollPane>
- <Table fill="horizontal" insets='5,5,5,5' anchor="north" weighty="1" weightx="1">
- <row>
- <cell>
- <JButton id="addButton" text="lima.common.add" width="100" onActionPerformed="addCriteriaWidget()"/>
- </cell>
- <cell>
- <JLabel text="lima.search.items.where" width="200"/>
- </cell>
- <cell>
- <JAXXComboBox id="criteriaAllAnyComboBox" width="200">
- <item value='all' label='{_("lima.all.criteria")}' selected="true"/>
- <item value='any' label='{_("lima.any.criteria")}'/>
- </JAXXComboBox>
- </cell>
- </row>
- <row>
- <cell columns="3">
- <VBox id="criteriaWidgetPanel"
- border='{BorderFactory.createTitledBorder(_("lima.search.title.criteria.box"))}'
- />
- </cell>
- </row>
- <row>
- <cell>
- <JButton id="okButton" onActionPerformed="doSearch()" text="lima.common.ok"/>
- </cell>
- <cell>
- <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="windowClosing()"/>
- </cell>
- </row>
- </Table>
- </JScrollPane>
-</JFrame>
\ No newline at end of file
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/table/FinancialTransactionTableModel.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -264,10 +264,10 @@
result = null; // position
break;
case 6:
- result = amountDebit;//FinancialTransactionHelper.getDebit(currentRow);
+ result = amountDebit;
break;
case 7:
- result = amountCredit;//FinancialTransactionHelper.getCredit(currentRow);
+ result = amountCredit;
break;
case 8:
result = amountDebit - amountCredit;
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedHelper.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -1,84 +0,0 @@
-/* *##% Lima Main
- * Copyright (C) 2008 - 2010 CodeLutin
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
- */
-
-package org.chorem.lima.ui.financialtransactionunbalanced;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.ui.accountsreports.AccountsReportsTableModel;
-
-/**
- * TODO add comment here.
- *
- * @author chatellier
- * @version $Revision: 2901 $
- *
- * Last update : $Date: 2010-05-19 12:52:43 +0200 (mer. 19 mai 2010) $
- * By : $Author: jpepin $
- */
-public class FinancialTransactionUnbalancedHelper {
- /** log. */
- private static final Log log = LogFactory.getLog(AccountsReportsTableModel.class);
-
- /**
- * Get total credit for a transaction.
- *
- * @param transaction transaction to get credit
- * @return total credit
- */
- public static double getCredit(FinancialTransaction financialtransaction) {
- double credit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (!entry.getDebit()) {
- credit += entry.getAmount();
- }
- }
- return credit;
- }
-
- /**
- * Get total debit for a transaction.
- *
- * @param transaction transaction to get debit
- * @return total debit
- */
- public static double getDebit(FinancialTransaction financialtransaction) {
- double debit = 0;
- for (Entry entry : financialtransaction.getEntry()) {
- // TODO EC-20100407 voir si le modele correspond (amount, credit,debit)
- if (entry.getDebit()) {
- debit += entry.getAmount();
- }
- }
- return debit;
- }
-
- /**
- * Return true if transaction is balanced (credit == debit).
- *
- * @param transaction transaction to test
- * @return {@code true} if transaction is balanced
- */
- public static boolean isBalanced(FinancialTransaction financialtransaction) {
- boolean balanced = getDebit(financialtransaction) == getCredit(financialtransaction);
- return balanced;
- }
-}
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 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -45,7 +45,6 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionHelper;
import org.chorem.lima.util.ErrorHelper;
/**
@@ -237,7 +236,9 @@
result = cacheDataList.get(row);
if (result instanceof FinancialTransaction) {
- FinancialTransaction currentRow = (FinancialTransaction)result;
+ FinancialTransaction currentRow = (FinancialTransaction)result;
+ Double amountDebit = currentRow.getAmountDebit();
+ Double amountCredit = currentRow.getAmountCredit();
switch (column) {
case 0:
@@ -259,14 +260,13 @@
result = null; // position
break;
case 6:
- result = FinancialTransactionHelper.getDebit(currentRow);
+ result = amountDebit;
break;
case 7:
- result = FinancialTransactionHelper.getCredit(currentRow);
+ result = amountCredit;
break;
case 8:
- result = FinancialTransactionHelper.getDebit(currentRow)
- - FinancialTransactionHelper.getCredit(currentRow);
+ result = amountDebit - amountCredit;
break;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -22,6 +22,7 @@
import javax.swing.JOptionPane;
+import javax.swing.ListSelectionModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -63,6 +64,13 @@
Object selectedValue = model.getElementAt(indexSelectedRow);
try {
model.addEmptyEntry(selectedValue, indexSelectedRow);
+ //select the new line
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(indexSelectedRow+1, indexSelectedRow+1);
+ //focus on second column
+ table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.requestFocusInWindow();
} catch (LimaException ex){
if (log.isErrorEnabled()) {
log.error("Can't add emptyentry", ex);
@@ -110,6 +118,10 @@
try {
model.removeObject(selectedValue, indexSelectedRow);
+ //select the upper line
+ ListSelectionModel selectionModel =
+ table.getSelectionModel();
+ selectionModel.setSelectionInterval(indexSelectedRow-1, indexSelectedRow-1);
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
log.error("Can't remove transaction or entry", ex);
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerTableModel.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -0,0 +1,216 @@
+/*
+ * *##% Lima Main
+ * Copyright (C) 2008 - 2010 CodeLutin
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%*
+ */
+
+package org.chorem.lima.ui.ledger;
+
+import static org.nuiton.i18n.I18n._;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import javax.swing.table.AbstractTableModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.beans.ReportsDatasImpl;
+import org.chorem.lima.business.LimaException;
+import org.chorem.lima.business.ReportService;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.util.ErrorHelper;
+
+/**
+ * Entry book table model.
+ *
+ * @author ore
+ * @author chatellier
+ * @version $Revision: 2865 $
+ *
+ * Last update : $Date: 2010-04-19 15:19:30 +0200 (lun. 19 avril 2010) $
+ * By : $Author: jpepin $
+ */
+public class LedgerTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 7578692417919755647L;
+
+ /** log. */
+ private static final Log log = LogFactory.getLog(LedgerTableModel.class);
+
+ /** Services. */
+ protected ReportService reportService;
+
+ /** Account. */
+ protected EntryBook selectedEntryBook;
+
+ /** Begin Date. */
+ protected Date selectedBeginDate;
+
+ /** EndDate. */
+ protected Date selectedEndDate;
+
+ /** data cache */
+ protected ReportsDatas cacheDataList;
+
+ /**
+ * Constructor.
+ */
+ public LedgerTableModel() {
+
+ reportService =
+ LimaServiceFactory.getInstance().getReportService();
+ }
+
+ @Override
+ public int getRowCount() {
+ int result = 0;
+
+ // just prevent too much result
+ if (selectedEntryBook != null) {
+ result = cacheDataList.getListEntry().size();
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No account selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public int getColumnCount() {
+ return 6;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String res = "n/a";
+ switch (column) {
+ case 0:
+ res = _("lima.transaction.column.date"); //Date
+ break;
+ case 1:
+ res = _("lima.transaction.column.account"); //Account
+ break;
+ case 2:
+ res = _("lima.transaction.column.voucher"); // Voucher
+ break;
+ case 3:
+ res = _("lima.transaction.column.description"); //Description
+ break;
+ case 4:
+ res = _("lima.transaction.column.debit"); //Debit
+ break;
+ case 5:
+ res = _("lima.transaction.column.credit"); //Credit
+ break;
+ }
+ return res;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+ Object result = null;
+ if(selectedEntryBook != null) {
+ Entry currentRow = cacheDataList.getListEntry().get(row);
+ SimpleDateFormat simpleDateFormat =
+ new SimpleDateFormat("dd MMMMM yyyy");
+
+ switch (column) {
+ case 0:
+ result = simpleDateFormat.
+ format(currentRow.getFinancialTransaction().getTransactionDate());
+ break;
+ case 1:
+ if (currentRow.getAccount() != null){
+ result = currentRow.getAccount().getAccountNumber();
+ }
+ else {
+ result = null;
+ }
+ break;
+ case 2:
+ result = currentRow.getVoucher();
+ break;
+ case 3:
+ result = currentRow.getDescription();
+ break;
+ case 4:
+ result = currentRow.getDebit() ? currentRow.getAmount() : 0;
+ break;
+ case 5:
+ result = currentRow.getDebit() ? 0 : currentRow.getAmount();
+ break;
+ }
+ }
+ else {
+ if (log.isDebugEnabled()) {
+ log.debug("No EntryBook selected skip table model update");
+ }
+ }
+
+ return result;
+ }
+
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ // Just read, no write
+ return false;
+ }
+
+ public void setBeginDate(Date date){
+ log.debug("setBeginDate");
+ selectedBeginDate = date;
+ log.debug(selectedBeginDate);
+ cacheDataList=getDataList();
+ fireTableDataChanged();
+ }
+
+ public void setEndDate(Date date){
+ log.debug("setEndDate");
+ selectedEndDate = date;
+ log.debug(selectedEndDate);
+ cacheDataList=getDataList();
+ fireTableDataChanged();
+ }
+
+
+ public void setEntryBook(EntryBook entryBook) {
+ selectedEntryBook = entryBook;
+ cacheDataList=getDataList();
+ fireTableDataChanged();
+ }
+
+ public ReportsDatas getDataList(){
+ ReportsDatas results = new ReportsDatasImpl();
+ try {
+ results =
+ reportService.generateEntryBooksReports(selectedEntryBook, selectedBeginDate, selectedEndDate);
+ }
+ catch (LimaException eee) {
+ if (log.isErrorEnabled()) {
+ log.debug("Can't update model", eee);
+ }
+ ErrorHelper.showErrorDialog("Can't get entries list", eee);
+ }
+ return results;
+ }
+
+}
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerView.jaxx 2010-06-03 10:51:13 UTC (rev 2929)
@@ -0,0 +1,96 @@
+<!-- ##% Lima Swing
+ 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 2
+ 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ ##% -->
+
+<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"/>
+ <script>
+ <![CDATA[
+
+ import org.apache.commons.lang.time.DateUtils;
+ import java.util.Calendar;
+
+ // 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);
+ getModelTable().setBeginDate(beginDate);
+
+ // get end date
+ Calendar calendarEnd = Calendar.getInstance();
+ Date endDate = calendarEnd.getTime();
+ getModelTable().setEndDate(endDate);
+
+ getBeginDatePicker().setDate(beginDate);
+ getEndDatePicker().setDate(endDate);
+
+ ]]>
+ </script>
+ <row fill="horizontal" weightx="1" weighty="0" anchor="center">
+ <cell>
+ <JLabel id="beginCalendarPanelLabel" text="lima.accountsreports.begincalendar"/>
+ </cell>
+ <cell>
+ <org.jdesktop.swingx.JXDatePicker id="beginDatePicker"
+ onActionPerformed="getModelTable().setBeginDate(beginDatePicker.getDate());
+ getHandler().updateFooterLabel()" />
+ </cell>
+ <cell>
+ <JLabel id="endCalendarPanelLabel" text="lima.accountsreports.endcalendar"/>
+ </cell>
+ <cell>
+ <org.jdesktop.swingx.JXDatePicker id="endDatePicker"
+ onActionPerformed="getModelTable().setEndDate(endDatePicker.getDate());
+ getHandler().updateFooterLabel()"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" weightx="1" weighty="1" columns="7">
+ <JScrollPane>
+ <org.jdesktop.swingx.JXTable id="table" rowHeight="24"
+ model="{getModelTable()}"
+ highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
+ columnControlVisible="true"/>
+ <javax.swing.ListSelectionModel javaBean="getTable().getSelectionModel()"/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill="horizontal" anchor="center">
+ <cell>
+ <JLabel text="lima.amountdebit" />
+ </cell>
+ <cell>
+ <JLabel id="amountDebitLabel" />
+ </cell>
+ <cell>
+ <JLabel text="lima.amountcredit"/>
+ </cell>
+ <cell>
+ <JLabel id="amountCreditLabel" />
+ </cell>
+ <cell>
+ <JLabel id="soldeLabel" text="lima.solde"/>
+ </cell>
+ <cell>
+ <JLabel id="amountSoldeLabel"/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/ledger/LedgerViewHandler.java 2010-06-03 10:51:13 UTC (rev 2929)
@@ -0,0 +1,85 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.ui.ledger;
+
+import static org.nuiton.i18n.I18n._;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.beans.ReportsDatas;
+import org.chorem.lima.ui.ReportsHelper;
+
+
+/**
+ * Handler associated with accounts reports view.
+ *
+ * @author chatellier
+ * @version $Revision: 2884 $
+ *
+ * Last update : $Date: 2010-05-06 11:57:19 +0200 (jeu. 06 mai 2010) $
+ * By : $Author: jpepin $
+ */
+public class LedgerViewHandler {
+
+ /** log. */
+ private static final Log log =
+ LogFactory.getLog(LedgerViewHandler.class);
+
+ protected LedgerView view;
+
+ /** Helper **/
+ protected ReportsHelper helper;
+
+ protected LedgerViewHandler(LedgerView view) {
+ this.view = view;
+ }
+
+
+ /*
+ * set text and amounts of labels credit, debit, solde
+ */
+ public void updateFooterLabel(){
+ LedgerTableModel tablemodel =
+ (LedgerTableModel) view.getTable().getModel();
+
+ ReportsDatas cacheDataList = tablemodel.cacheDataList;
+
+ if (cacheDataList != null){
+ // set amounts credit, debit and solde
+ view.amountCreditLabel.setText(String.valueOf(cacheDataList.getAmountCredit()));
+ view.amountDebitLabel.setText(String.valueOf(cacheDataList.getAmountDebit()));
+ Double amountSolde = cacheDataList.getAmountSolde();
+ view.amountSoldeLabel.setText(String.valueOf(amountSolde));
+
+
+ if (amountSolde == 0){
+ view.soldeLabel.setText(_("lima.solde"));
+ }
+ else {
+ // set label solde: credit or debit
+ if (cacheDataList.getSoldeDebit()) {
+ view.soldeLabel.setText(_("lima.soldedebit"));
+ }
+ else {
+ view.soldeLabel.setText(_("lima.soldecredit"));
+ }
+ }
+ }
+ }
+
+}
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 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-06-03 10:51:13 UTC (rev 2929)
@@ -41,7 +41,6 @@
lima.amountcredit=
lima.amountdebit=
lima.any.criteria=Any criteria are met
-lima.balance=Balance
lima.balance.account.libelle=Title
lima.balance.account.number=N\u00B0 account
lima.balance.move.credit=Credit
@@ -291,7 +290,9 @@
lima.remove.transaction=Remove a transaction
lima.reports=Reports
lima.reports.accounts=Edit account
+lima.reports.balance=Balance
lima.reports.entrybooks=Edit entrybook
+lima.reports.ledger=Ledger
lima.response.no=No
lima.response.yes=Yes
lima.result=Result
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 2010-06-03 09:59:29 UTC (rev 2928)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-06-03 10:51:13 UTC (rev 2929)
@@ -40,7 +40,6 @@
lima.amountcredit=Total Cr\u00E9dit
lima.amountdebit=Total D\u00E9bit
lima.any.criteria=Au moins un crit\u00E8re correspond
-lima.balance=Balance
lima.balance.account.libelle=Libell\u00E9
lima.balance.account.number=N\u00B0 de compte
lima.balance.move.credit=Mouvement au cr\u00E9dit
@@ -275,7 +274,9 @@
lima.remove.transaction=Supprimer une transaction
lima.reports=Rapports
lima.reports.accounts=Edition compte
+lima.reports.balance=Balance
lima.reports.entrybooks=Edition journal
+lima.reports.ledger=Grand Livre
lima.response.no=Non
lima.response.yes=Oui
lima.result=Compte de r\u00E9sultat
@@ -301,19 +302,11 @@
lima.subledger.label=
lima.subledger.type=
lima.success=Succ\u00E8s
-lima.tab.account=Plan Comptable
-lima.tab.accounts=
-lima.tab.balance=Balance
-lima.tab.bilan=Bilan
-lima.tab.blocked=Block\u00E9
-lima.tab.financialperiod=
-lima.tab.fiscalperiod=Exercice
+lima.tab.bilan=
+lima.tab.fiscalperiod=
lima.tab.home=Accueil
-lima.tab.lettering=Lettrage
-lima.tab.reports=Rapports
-lima.tab.result=Compte de r\u00E9sultat
-lima.tab.search.result=Recherche
-lima.tab.transaction=Ecriture
+lima.tab.reports=
+lima.tab.result=
lima.title=Lutin Invoice Monitoring and Accounting
lima.title.about=A propos de Lima...
lima.to=A
1
0
r2928 - in trunk/lima-business/src: main/java/org/chorem/lima/business/ejb test/java/org/chorem/lima/business
by jpepin@users.chorem.org 03 Jun '10
by jpepin@users.chorem.org 03 Jun '10
03 Jun '10
Author: jpepin
Date: 2010-06-03 11:59:29 +0200 (Thu, 03 Jun 2010)
New Revision: 2928
Url: http://chorem.org/repositories/revision/lima/2928
Log:
Requ?\195?\170te affichage des transactions non ?\195?\169quilibr?\195?\169s. Calcul balance, edition compte et journaux ne prend plus en compte les transactions non ?\195?\169quilibr?\195?\169s.Tri des p?\195?\169riodes financi?\195?\168res/journaux.
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.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/ReportServiceImpl.java
trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928)
@@ -206,7 +206,6 @@
LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext);
closedPeriodicEntryBook = closedPeriodicEntryBookDAO.findbyEntryBookAndFinancialPeriod(entryBook, financialPeriod);
-
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
@@ -235,8 +234,11 @@
query.addFrom(FiscalPeriod.class, "F")
.addInElements("E." + ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
"F."+FiscalPeriod.FINANCIAL_PERIOD)
- .addEquals("F."+FiscalPeriod.LOCKED, Boolean.FALSE)
- .addOrder(FiscalPeriod.FINANCIAL_PERIOD, FinancialPeriod.BEGIN_DATE);
+ .addEquals("F."+FiscalPeriod.LOCKED, Boolean.FALSE);
+ String orderProperty =
+ TopiaQuery.getProperty("E", ClosedPeriodicEntryBook.FINANCIAL_PERIOD,
+ FinancialPeriod.BEGIN_DATE);
+ query.addOrder(orderProperty);
//IMPORTANT : LOADING ClosedPeriodicEntryBook AND IS COLUMN FOR NO LAZY EXCEPTION
String loadEntryBookProperty =
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 2010-06-02 15:33:55 UTC (rev 2927)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928)
@@ -23,6 +23,8 @@
import java.util.Date;
import java.util.List;
import javax.ejb.Stateless;
+import javax.management.Query;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.AccountingRules;
@@ -30,6 +32,7 @@
import org.chorem.lima.business.FinancialTransactionServiceLocal;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
+import org.chorem.lima.entity.ClosedPeriodicEntryBook;
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.EntryBook;
import org.chorem.lima.entity.EntryDAO;
@@ -161,20 +164,45 @@
return financialTransactions;
}
-
+
+
+ /**
+ * Get unbalanced financialtransaction from selected fiscalperiod
+ */
@Override
- //TODO No terminated
public List<FinancialTransaction> getAllFinancialTransactionsUnbalanced(FiscalPeriod fiscalPeriod) throws LimaException {
TopiaContext topiaContext = null;
List<FinancialTransaction> result = null;
try {
topiaContext = beginTransaction();
-
+
FinancialTransactionDAO financialTransactionDAO =
LimaCallaoDAOHelper.getFinancialTransactionDAO(topiaContext);
-
- //TODO
+ TopiaQuery query = financialTransactionDAO.createQuery("E");
+ query.addFrom(FiscalPeriod.class, "F")
+ .addWhere("E.amountCredit != E.amountDebit")
+ .addInElements("E.financialPeriod", "F.financialPeriod")
+ .addEquals("F", fiscalPeriod);
+ result = financialTransactionDAO.findAllByQuery(query);
+ /* Just for fun : IN HQL
+ result = topiaContext.find(
+ "FROM org.chorem.lima.entity.FinancialTransaction "+
+ "WHERE amountCredit != amountDebit and (financialPeriod in (" +
+ "FROM org.chorem.lima.entity.FinancialPeriod " +
+ "WHERE (fiscalPeriod = :fiscalPeriod)))","fiscalPeriod",fiscalPeriod);*/
+
+ //IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
+ for (FinancialTransaction financialTransaction : result) {
+
+ for (Entry entry : financialTransaction.getEntry()) {
+ entry.getEntryBook();
+ entry.getAccount();
+ entry.getFinancialTransaction();
+ entry.getFinancialTransaction().getFinancialPeriod();
+ }
+ }
+
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-03 09:59:29 UTC (rev 2928)
@@ -101,7 +101,6 @@
// First subaccount
List<Account> accounts = account.getSubAccounts();
accounts.addAll(account.getSubLedgers());
- log.debug(accounts);
if (accounts.size() == 0){
reportsDatas = generateSubAccountReportsWithTransaction(account,
beginDate, endDate, topiaContext);
@@ -133,6 +132,7 @@
/**
* Query for find entries for accountsreports and balancereports
+ * Just balanced transaction are calculated
*/
public TopiaQuery createEntryQuery(Account account, Date beginDate, Date endDate, EntryDAO entryDAO, String queryAlias) throws LimaException{
TopiaQuery query = entryDAO.createQuery(queryAlias);
@@ -140,7 +140,15 @@
String transactionDateProperty =
TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
FinancialTransaction.TRANSACTION_DATE);
- query.addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
+ String amountCreditProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_CREDIT);
+ String amountDebitProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_DEBIT);
+ query
+ .addWhere(amountCreditProperty+" = "+amountDebitProperty)
+ .addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
.addParam("beginDate", beginDate)
.addParam("endDate", endDate)
.addEquals(Entry.ACCOUNT, account);
@@ -265,6 +273,8 @@
*
* Calculate the amounts and the solde
*
+ * Just balanced transaction are calculated
+ *
*/
@SuppressWarnings({ "unchecked" })
@Override
@@ -282,7 +292,15 @@
String transactionDateProperty =
TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
FinancialTransaction.TRANSACTION_DATE);
- query.addEquals(Entry.ENTRY_BOOK, entryBook)
+ String amountCreditProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_CREDIT);
+ String amountDebitProperty =
+ TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
+ FinancialTransaction.AMOUNT_DEBIT);
+ query
+ .addWhere(amountCreditProperty+" = "+amountDebitProperty)
+ .addEquals(Entry.ENTRY_BOOK, entryBook)
.addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
.addParam("beginDate", beginDate)
.addParam("endDate", endDate);
Modified: trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java
===================================================================
--- trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-06-02 15:33:55 UTC (rev 2927)
+++ trunk/lima-business/src/test/java/org/chorem/lima/business/FilesServiceImplTest.java 2010-06-03 09:59:29 UTC (rev 2928)
@@ -26,7 +26,7 @@
@BeforeClass
public static void setUpClass() throws Exception {
- LimaConfig.getInstance();
+ LimaConfig.getInstance();
}
/**
1
0
r2927 - in trunk: lima-business/src/main/java/org/chorem/lima/business/ejb lima-business/src/main/java/org/chorem/lima/business/utils lima-business/src/main/resources lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/resources
by jpepin@users.chorem.org 02 Jun '10
by jpepin@users.chorem.org 02 Jun '10
02 Jun '10
Author: jpepin
Date: 2010-06-02 17:33:55 +0200 (Wed, 02 Jun 2010)
New Revision: 2927
Url: http://chorem.org/repositories/revision/lima/2927
Log:
Nettoyage du code dans business. Modification du dao account pour cr?\195?\169er une req?\195?\187ete qui liste les comptes "feuilles".
Added:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java
Removed:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountComparator.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.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/ejb/ReportServiceImpl.java
trunk/lima-business/src/main/resources/lima.properties
trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
trunk/lima-swing/src/main/resources/lima-config.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -32,7 +32,7 @@
import org.chorem.lima.business.LimaBusinessException;
import org.chorem.lima.business.LimaConfig;
import org.chorem.lima.business.LimaException;
-import org.chorem.lima.entity.AccountComparator;
+import org.chorem.lima.business.utils.AccountComparator;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.AccountDAO;
import org.chorem.lima.entity.LimaCallaoDAOHelper;
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 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -141,8 +141,6 @@
LimaCallaoDAOHelper.getEntryBookDAO(transaction);
List<EntryBook> EntryBooks = EntryBookDAO.findAll();
EntryBooksList.addAll(EntryBooks);
-
- commitTransaction(transaction);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FilesServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -20,9 +20,6 @@
package org.chorem.lima.business.ejb;
import java.util.List;
-
-import javax.ejb.EJB;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.Account;
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -112,10 +112,7 @@
EntryBookDAO entryBookDAO =
LimaCallaoDAOHelper.getEntryBookDAO(topiaContext);
//create all financial period
- log.debug(financialPeriods);
for (FinancialPeriod financialPeriod : financialPeriods) {
- log.debug(financialPeriod);
-
//create ClosedPeriodicEntryBook for all entrybook
for (EntryBook entryBook : entryBookDAO.findAll()) {
//new closed periodic entrybook
@@ -153,8 +150,6 @@
FinancialPeriodDAO financialPeriodDAO = LimaCallaoDAOHelper.
getFinancialPeriodDAO(transaction);
result = financialPeriodDAO.findAllByLocked(false);
-
- commitTransaction(transaction);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -254,9 +249,7 @@
query.addLoad(loadFinancialPeriodProperty);
//call query
- result = closedPeriodicEntryBookDAO.findAllByQuery(query);
-
- commitTransaction(transaction);
+ result = closedPeriodicEntryBookDAO.findAllByQuery(query);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
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 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialTransactionServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -138,7 +138,7 @@
if (financialPeriod != null) {
query.addEquals("financialPeriod", financialPeriod);
}
-
+ query.addOrder(FinancialTransaction.TOPIA_CREATE_DATE);
financialTransactions = transactionDAO.findAllByQuery(query);
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
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 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -88,7 +88,6 @@
//check rules before create the account
List<FinancialPeriod> financialPeriods =
accountingRules.createFiscalPeriodRules(fiscalPeriod, transaction);
- log.debug("financialPeriods : "+financialPeriods);
financialPeriodService.
createFinancialPeriodsWithTransaction(financialPeriods, transaction);
@@ -122,9 +121,7 @@
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
- result = fiscalPeriodDAO.findAll();
-
- commitTransaction(transaction);
+ result = fiscalPeriodDAO.findAll();
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
@@ -150,17 +147,6 @@
FiscalPeriodDAO fiscalPeriodDAO =
LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction);
result = fiscalPeriodDAO.findAllByLocked(false);
-
- //IMPORTANT : LOADING FINANCIAL PERIOD FOR NO LAZY EXCEPTION
- for (FiscalPeriod fiscalPeriod : result) {
- //FIXME besoin d'appeler une lecture bidon de toutes les financialperiod
- //TODO make this by topiaquery ?
- //sinon il pete tout de même une lazy exception
- for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) {
- }
- }
-
- commitTransaction(transaction);
}
catch (TopiaException ex) {
doCatch(transaction, ex, log);
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/ReportServiceImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -197,7 +197,7 @@
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
- commitTransaction(topiaContext);
+ //commitTransaction(topiaContext);
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
@@ -250,7 +250,7 @@
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
- commitTransaction(topiaContext);
+ //commitTransaction(topiaContext);
}
catch (TopiaException ex) {
doCatch(topiaContext, ex, log);
@@ -286,10 +286,6 @@
.addWhere(transactionDateProperty+" BETWEEN :beginDate AND :endDate")
.addParam("beginDate", beginDate)
.addParam("endDate", endDate);
- /*String orderProperty =
- TopiaQuery.getProperty(Entry.FINANCIAL_TRANSACTION,
- FinancialTransaction.TRANSACTION_DATE);
- query.addOrder(orderProperty);*/
//IMPORTANT : LOADING ENTRIES AND IS COLUMN FOR NO LAZY EXCEPTION
query.addLoad(Entry.ACCOUNT, Entry.FINANCIAL_TRANSACTION);
reportsDatas.setListEntry(entryDAO.findAllByQuery(query));
@@ -322,7 +318,7 @@
reportsDatas.setAmountDebit(debit);
reportsDatas.setAmountSolde(solde);
- commitTransaction(topiaTransaction);
+ //commitTransaction(topiaTransaction);
}
catch (TopiaException ex) {
doCatch(topiaTransaction, ex, log);
@@ -353,7 +349,8 @@
AccountDAO accountDAO =
LimaCallaoDAOHelper.getAccountDAO(topiaTransaction);
//for each account create a balance sheet with a ReportsDatas
- for (Account account : accountDAO.findAllSubAccounts()) {
+ List<Account> accounts = accountDAO.findAllSubAccounts();
+ for (Account account : accounts) {
ReportsDatas reportsDatas =
generateSubAccountBalanceWithTransaction(account, beginDate,
endDate, topiaTransaction);
Copied: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java (from rev 2923, trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountComparator.java)
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java (rev 0)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/AccountComparator.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -0,0 +1,35 @@
+/* *##% Lima Swing
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * ##%*/
+
+package org.chorem.lima.business.utils;
+
+import java.util.Comparator;
+
+import org.chorem.lima.entity.Account;
+
+public class AccountComparator implements Comparator<Account>{
+
+ /**
+ * sort by accout number in lexicographical order
+ */
+ @Override
+ public int compare(Account o1, Account o2) {
+ return o1.getAccountNumber().compareTo(o2.getAccountNumber());
+ }
+
+}
Modified: trunk/lima-business/src/main/resources/lima.properties
===================================================================
--- trunk/lima-business/src/main/resources/lima.properties 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-business/src/main/resources/lima.properties 2010-06-02 15:33:55 UTC (rev 2927)
@@ -1,6 +1,6 @@
# Proprietes par defaut pour une base de donnees de type H2
hibernate.hbm2ddl.auto=update
-hibernate.show_sql=false
+#hibernate.show_sql=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
hibernate.connection.username=sa
@@ -8,4 +8,4 @@
hibernate.connection.driver_class=org.h2.Driver
hibernate.connection.url=jdbc:h2:file:~/.lima/limadb
-lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
\ No newline at end of file
+lima.rules=org.chorem.lima.business.accountingrules.FranceAccountingRules
Deleted: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountComparator.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountComparator.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountComparator.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -1,35 +0,0 @@
-/* *##% Lima Swing
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- * ##%*/
-
-package org.chorem.lima.entity;
-
-import java.util.Comparator;
-
-import org.chorem.lima.entity.Account;
-
-public class AccountComparator implements Comparator<Account>{
-
- /**
- * sort by accout number in lexicographical order
- */
- @Override
- public int compare(Account o1, Account o2) {
- return o1.getAccountNumber().compareTo(o2.getAccountNumber());
- }
-
-}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/AccountDAOImpl.java 2010-06-02 15:33:55 UTC (rev 2927)
@@ -1,10 +1,10 @@
package org.chorem.lima.entity;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.framework.TopiaQuery;
public class AccountDAOImpl <E extends Account> extends AccountDAOAbstract<E> {
@@ -15,18 +15,21 @@
@Override
public List<Account> findAllSubAccounts() throws TopiaException {
List<Account> accountsList = new ArrayList<Account>();
-
- //FIXME use topia query
- List<Account> accounts = (List<Account>) findAll();
- for (Account account : accounts) {
- //check if parentaccount have no subaccount and no subledgers
- if (account.getSubAccounts().size() == 0
- && account.getSubLedgers().size() == 0){
- accountsList.add(account);
- }
- }
- Collections.sort(accountsList, new AccountComparator());
- return accountsList;
+ TopiaQuery query = createQuery();
+ String subAccountsProperty = TopiaQuery.getProperty(Account.SUB_ACCOUNTS);
+ String subLedgersProperty = TopiaQuery.getProperty(Account.SUB_LEDGERS);
+ query.addWhere("not exists elements ("+subAccountsProperty+")")
+ .addWhere("not exists elements ("+subLedgersProperty+")")
+ .addOrder(Account.ACCOUNT_NUMBER);
+
+ /* alternative query
+ * wich are the best ? exist or count ?
+ *
+ * query.addWhere("size ("+subAccountsProperty+") = 0")
+ * .addWhere("size ("+subLedgersProperty+") = 0");
+ *
+ */
+ return (List<Account>) findAllByQuery(query);
}
}
Modified: trunk/lima-swing/src/main/resources/lima-config.properties
===================================================================
--- trunk/lima-swing/src/main/resources/lima-config.properties 2010-06-02 13:17:06 UTC (rev 2926)
+++ trunk/lima-swing/src/main/resources/lima-config.properties 2010-06-02 15:33:55 UTC (rev 2927)
@@ -23,4 +23,4 @@
#java.naming.factory.initial=org.apache.openejb.client.RemoteInitialContextFactory
#java.naming.provider.url=ejbd://127.0.0.1:4201
#java.naming.security.principal=jonathan
-#java.naming.security.credentials=secret
\ No newline at end of file
+#java.naming.security.credentials=secret
1
0
r2926 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by jpepin@users.chorem.org 02 Jun '10
by jpepin@users.chorem.org 02 Jun '10
02 Jun '10
Author: jpepin
Date: 2010-06-02 15:17:06 +0200 (Wed, 02 Jun 2010)
New Revision: 2926
Url: http://chorem.org/repositories/revision/lima/2926
Log:
Focus d'?\195?\169dition sur la bonne colonne apr?\195?\168s ajout transaction/entr?\195?\169e
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-02 10:54:31 UTC (rev 2925)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2010-06-02 13:17:06 UTC (rev 2926)
@@ -67,6 +67,9 @@
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(numberRow-1, numberRow-1);
+ //focus on first column
+ table.changeSelection(numberRow-1, 0, false, false);
+ table.requestFocusInWindow();
} catch (LimaException ex) {
if (log.isErrorEnabled()) {
log.error("Can't add financialtransaction", ex);
@@ -94,6 +97,9 @@
ListSelectionModel selectionModel =
table.getSelectionModel();
selectionModel.setSelectionInterval(indexSelectedRow+1, indexSelectedRow+1);
+ //focus on second column
+ table.changeSelection(indexSelectedRow+1, 1, false, false);
+ table.requestFocusInWindow();
} catch (LimaException ex){
if (log.isErrorEnabled()) {
log.error("Can't add emptyentry", ex);
1
0