r2870 - in trunk: lima-business/src/main/java/org/chorem/lima/business lima-business/src/main/java/org/chorem/lima/business/ejb lima-swing/src/main/java/org/chorem/lima/service lima-swing/src/main/java/org/chorem/lima/ui lima-swing/src/main/java/org/chorem/lima/ui/account lima-swing/src/main/java/org/chorem/lima/ui/account/model lima-swing/src/main/java/org/chorem/lima/ui/entrybook lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model lima-swing/src/main/java/org/chorem/lima/ui/fiscalpe
Author: jpepin Date: 2010-04-21 18:09:27 +0200 (Wed, 21 Apr 2010) New Revision: 2870 Log: Suppression compte tiers et sa fiche d'identit?\195?\169 ; Modification de l'UI ; Cr?\195?\169ation de la m?\195?\169thode m?\195?\169tier de cr?\195?\169ation d'exercice en cours. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 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/fiscalperiod/model/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.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/EntryBookServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 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/account/AccountViewHandler.java 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/EntryBookForm.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.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/AccountService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/AccountService.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -51,10 +51,8 @@ void updateAccount(Account account) throws LimaException; - void updateIdentity(Identity identity) throws LimaException; - void removeAccount(Account account) throws LimaException; - + void removeAccountwithSubAccounts(Account account) throws LimaException; List<Account> getChildrenAccounts(Account masterAccount) 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/AccountServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -174,7 +174,8 @@ transaction = rootContext.beginTransaction(); // check if the accountnumber already exist - AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction); + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(transaction); Account existAccount = accountDAO.findByAccountNumber(account.getAccountNumber()); if (existAccount != null) { @@ -192,15 +193,14 @@ accountDAO.create(account); - IdentityDAO identityDAO = LimaCallaoDAOHelper.getIdentityDAO(transaction); + IdentityDAO identityDAO = + LimaCallaoDAOHelper.getIdentityDAO(transaction); identityDAO.create(identity); account.setIdentity(identity); // check if the masteraccount exist; if (masterAccount != null) { masterAccount.addSubLedgers(account); - //account.setIdentity(identity); - System.out.println(identity.getName()+" "+identity.getAddress()); accountDAO.update(masterAccount); } @@ -680,13 +680,22 @@ if (account.getSubAccounts().size() > 0){ throw new LimaBusinessException("Account not empty"); } - else { - // remove account - AccountDAO accountDAO = - LimaCallaoDAOHelper.getAccountDAO(transaction); - accountDAO.delete(account); - // commit - transaction.commitTransaction(); + else { + Identity existIdentity = account.getIdentity(); + // remove account + AccountDAO accountDAO = + LimaCallaoDAOHelper.getAccountDAO(transaction); + accountDAO.delete(account); + //check if account is a subledger with identity + if (existIdentity != null) { + System.out.println(existIdentity.getAddress()); + // delete identity + IdentityDAO identityDAO = + LimaCallaoDAOHelper.getIdentityDAO(transaction); + identityDAO.delete(existIdentity); + } + // commit + transaction.commitTransaction(); } } catch (TopiaException ex) { @@ -783,7 +792,14 @@ TopiaContext transaction = null; try { transaction = rootContext.beginTransaction(); - + //Check if the account is a subledger + Identity existIdentity = account.getIdentity(); + if (existIdentity != null) { + // update identity + IdentityDAO identityDAO = + LimaCallaoDAOHelper.getIdentityDAO(transaction); + identityDAO.update(existIdentity); + } // update account AccountDAO accountDAO = LimaCallaoDAOHelper.getAccountDAO(transaction); @@ -793,34 +809,12 @@ } catch (TopiaException ex) { if (log.isErrorEnabled()) { - log.error("Error during create account", ex); + log.error("Error during update account", ex); } throw new LimaException("Can't update account", ex); } } - @Override - public void updateIdentity(Identity identity) throws LimaException { - // TODO Auto-generated method stub - TopiaContext transaction = null; - try { - transaction = rootContext.beginTransaction(); - - // update account - IdentityDAO identityDAO = - LimaCallaoDAOHelper.getIdentityDAO(transaction); - identityDAO.update(identity); - // commit - transaction.commitTransaction(); - } - catch (TopiaException ex) { - if (log.isErrorEnabled()) { - log.error("Error during update identity", ex); - } - throw new LimaException("Can't update identity", ex); - } - } - /* * Permet de modifier un compte sur son label et son compte père. * Il recherche le compte père avec le numéro de compte fourni. Appel ensuite 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -274,12 +274,7 @@ // TODO move it into JTA transaction = rootContext.beginTransaction(); - // test si un EntryBook de ce nom existe deja EntryBookDAO entryBookDAO = LimaCallaoDAOHelper.getEntryBookDAO(transaction); - EntryBook existingEntryBook = entryBookDAO.findByLabel(entryBook.getLabel()); - if (existingEntryBook != null) { - throw new LimaBusinessException(_("An EntryBook already exists with this label : %s", entryBook.getLabel())); - } // creation du EntryBook entryBookDAO.update(entryBook); 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -22,6 +22,7 @@ import static org.nuiton.i18n.I18n._; import java.util.List; +import java.util.ListIterator; import javax.ejb.Stateless; @@ -31,6 +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.Account; import org.chorem.lima.entity.FinancialPeriod; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.entity.FiscalPeriodDAO; @@ -41,9 +43,8 @@ import org.nuiton.topia.TopiaNotFoundException; /** - * Gestion des périodes. - * Chaque période doit posséder 12 timespans mensuels. - * Une période ne peut être supprimée et débloquée. + * Gestion des exercices. + * Un exercice ne peut être supprimée et débloquée après cloture. * * @author Rémi Chapelet */ @@ -85,7 +86,8 @@ */ @Override public void createFiscalPeriod(FiscalPeriod fiscalPeriod /*Date beginTimeSpan, Date endTimeSpan, boolean lock*/) throws LimaException { - /*// Par défaut lock est à false + + /*// Par défaut lock est à false lock = false; String result = ServiceHelper.RESPOND_ERROR; @@ -152,28 +154,69 @@ // un exercice ne peut pas faire plus de 24 mois dans tous les cas // un exercice doit faire au moins une période - if ( fiscalPeriod.getFinancialPeriod() == null || + /*if ( fiscalPeriod.getFinancialPeriod() == null || fiscalPeriod.getFinancialPeriod().isEmpty()) { throw new LimaBusinessException(_("A fiscal period must have at least one financial period !")); - } + }*/ // un exercice doit être collé au precedent // un exercice ne peut être crée que si l'anti precedent est fermé // on peut creer un exercice si le precedent n'est pas fermé - + TopiaContext transaction = null; try { // basic check done, make check in database // TODO move it into JTA transaction = rootContext.beginTransaction(); + FiscalPeriodDAO fiscalPeriodDAO = + LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); - // TODO maybe put this in antoher place - for (FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) { - financialPeriodService.createFinancialPeriod(transaction, financialPeriod); + //check if the enddate period is after the begindate period + if (fiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){ + //TODO Exception + throw new LimaBusinessException("The enddate is before the begindate"); } + + //check if all fiscal period is locked + if (fiscalPeriodDAO.findAll().size() == + fiscalPeriodDAO.findAllByLocked(true).size()){ + //TODO Exception + throw new LimaBusinessException("Last fiscal period is not locked"); + } + + //check if the last enddate period is before the new begindate period + FiscalPeriod lastFiscalPeriod = null; + List<FiscalPeriod> listFiscalPeriods = getAllFiscalPeriods(); + ListIterator<FiscalPeriod> itr = listFiscalPeriods.listIterator(); + while(itr.hasNext()){ + FiscalPeriod thisFiscalPeriod = itr.next(); + if (thisFiscalPeriod.getEndDate(). + after(lastFiscalPeriod.getEndDate())){ + lastFiscalPeriod=thisFiscalPeriod; + } + } + if (lastFiscalPeriod.getEndDate().before(fiscalPeriod.getBeginDate())){ + //TODO Exception + throw new LimaBusinessException + ("The begindate is before the enddate of the last fiscalperiod"); + } + + + //count the month number + int monthNumber = fiscalPeriod.getEndDate().getMonth() + -fiscalPeriod.getBeginDate().getMonth(); + + //check if fiscalperiod have 12 months, ask a confirmation + if(monthNumber!=12){ + //TODO Exception + throw new LimaBusinessException("The fiscal period has not 12 months"); + } + + //TODO create the financialperiods, much as period as months + for (int i = 0; i < monthNumber; i++) { + } - FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); fiscalPeriodDAO.create(fiscalPeriod); // commit @@ -198,7 +241,8 @@ // TODO move it into JTA transaction = rootContext.beginTransaction(); - FiscalPeriodDAO fiscalPeriodDAO = LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); + FiscalPeriodDAO fiscalPeriodDAO = + LimaCallaoDAOHelper.getFiscalPeriodDAO(transaction); result = fiscalPeriodDAO.findAll(); // commit Modified: trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/service/LimaServiceFactory.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -199,7 +199,7 @@ // TODO EC-20100410 put lookup name in configuration // name should be fully configurable due to custom implementation used - String lookupName = "TransactionServiceImplLocal"; + String lookupName = "FinancialTransactionServiceImplLocal"; FinancialTransactionService ejbHome = null; try { ejbHome = (FinancialTransactionService)ctx.lookup(lookupName); 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -115,22 +115,14 @@ text="lima.common.quit" onActionPerformed='getHandler().close(this)'/> </JMenu> - <JMenu text="lima.chartofaccounts"> + <JMenu text="lima.structure"> <JMenuItem text="lima.chartofaccounts.management" onActionPerformed='getHandler().showAccountView(this)' actionIcon='account'/> <JMenuItem text="lima.chartofaccounts.journal" onActionPerformed='getHandler().showJournalView(this)' actionIcon='journal'/> + <JMenuItem text="lima.fiscalyear.management" onActionPerformed='getHandler().showFiscalPeriodView(this)'/> </JMenu> - <JMenu text="lima.fiscalyear"> - <JMenuItem text="lima.fiscalyear.addperiod" onActionPerformed='getHandler().showAddPeriod(this)'/> - <JMenuItem text="lima.fiscalyear.closeperiod" onActionPerformed='getHandler().showClosureTimeSpanView(this)' - actionIcon='closure-timespan'/> - <JMenuItem text="lima.fiscalyear.closefiscalyear" onActionPerformed='getHandler().showClosurePeriodView(this)'/> - <JMenuItem text="lima.fiscalyear.listclosed" onActionPerformed='getHandler().showFiscalPeriodView(this)' - actionIcon='closure'/> - </JMenu> - <JMenu text="lima.entries"> <JMenuItem text="lima.entries.addtransaction" onActionPerformed='getHandler().showTransactionView(this)' actionIcon='transaction'/> @@ -139,7 +131,6 @@ <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)' actionIcon='lettering'/> </JMenu> - <JMenu text="lima.view"> <JCheckBoxMenuItem id="viewFlatten" text="lima.view.flatten" onItemStateChanged='getHandler().onChangeView(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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -38,7 +38,7 @@ import org.chorem.lima.LimaContext; import org.chorem.lima.ui.account.AccountView; import org.chorem.lima.ui.entrybook.EntryBookView; -import org.chorem.lima.ui.period.FiscalPeriodView; +import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; import org.chorem.lima.ui.report.BalanceView; import org.chorem.lima.ui.report.BilanView; import org.chorem.lima.ui.report.ReportsView; @@ -292,21 +292,13 @@ public void showFiscalPeriodView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); FiscalPeriodView fiscalPeriodView = new FiscalPeriodView(mainView); - mainView.showTab(_("lima.tab.period"), fiscalPeriodView); + mainView.showTab(_("lima.tab.fiscalperiod"), fiscalPeriodView); } - public void showClosurePeriodView(JAXXContext rootContext) { - - } - public void showClosureTimeSpanView(JAXXContext rootContext) { //getClosureView().initBlockForm(); } - public void showAddPeriod(JAXXContext rootContext) { - //getClosureView().initAddPeriod(); - } - public void showImportView(String type) { /*if (!getImportView(type).isEnabled()) { getImportView(type).setEnabled(true); 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -146,7 +146,8 @@ treePath = view.getAccountsTreeTable().getPathForRow(selectedRow); // add it try { - accountsTreeTableModel.addSubLedger(treePath, newAccount, newIdentity); + accountsTreeTableModel. + addSubLedger(treePath, newAccount, newIdentity); } catch (LimaBusinessException ex) { if (log.isErrorEnabled()) { log.error("Can't add subledger", ex); @@ -195,48 +196,32 @@ accountForm.setVisible(true); // null == cancel action selectedObject = accountForm.getAccount(); - if (selectedObject != null){ - // update it - try { - - accountsTreeTableModel. - updateAccount(treePath, selectedObject); - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add update", ex); - } - ErrorHelper.showErrorDialog("Can't add update", ex); - } - } } // else is a subledger else{ SubLedgerForm subLedgerForm = new SubLedgerForm(view); subLedgerForm.setAccount(selectedObject); - //log.debug("nom :"+selectedObject.getIdentity().getName()); - Identity identity=selectedObject.getIdentity(); - subLedgerForm.setIdentity(identity); + subLedgerForm.setIdentity(existIdentity); // jaxx constructor don't call super() ? subLedgerForm.setLocationRelativeTo(view); subLedgerForm.setVisible(true); // null == cancel action selectedObject = subLedgerForm.getAccount(); - if (selectedObject != null){ - // update it - try { - accountsTreeTableModel. - updateIdentity(identity); - accountsTreeTableModel. - updateAccount(treePath, selectedObject); - - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add update", ex); - } - ErrorHelper.showErrorDialog("Can't add update", ex); - } - } } + //if action confirmed + if (selectedObject != null){ + // update it + try { + + accountsTreeTableModel. + updateAccount(treePath, selectedObject); + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add update", ex); + } + ErrorHelper.showErrorDialog("Can't add update", ex); + } + } } } @@ -250,7 +235,7 @@ JXTreeTable accountsTreeTable = view.getAccountsTreeTable(); AccountTreeTableModel accountsTreeTableModel = (AccountTreeTableModel)accountsTreeTable.getTreeTableModel(); - + // Any row selected int selectedRow = view.getAccountsTreeTable().getSelectedRow(); if ( selectedRow != -1) { @@ -264,6 +249,7 @@ TreePath treePath = view.getAccountsTreeTable(). getPathForRow(selectedRow); Account account = (Account) treePath.getLastPathComponent(); + try{ try { accountsTreeTableModel.removeAccount(treePath, account); Modified: 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTreeTableModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -257,18 +257,6 @@ } /** - * Update identity. - * - * @param path - * @param account - * @throws LimaException - */ - public void updateIdentity(Identity identity) throws LimaException { - // Calling account service - accountService.updateIdentity(identity); - } - - /** * Remove account. * * @param path Modified: 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/model/AccountTypeListModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -18,6 +18,8 @@ package org.chorem.lima.ui.account.model; +import static org.nuiton.i18n.I18n._; + import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; @@ -39,7 +41,7 @@ protected Object selectedObject; /** Data. TODO put string in another place, don't use hard coded string. */ - protected Object[] data = new Object[]{ "actif", "passif", "produit", "charge" }; + protected Object[] data = new Object[]{ _("lima.account.type1"), _("lima.account.type2"), _("lima.account.type3"), _("lima.account.type4")}; public AccountTypeListModel() { super(); 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -57,10 +57,9 @@ <JLabel text="lima.entrybook.type"/> </cell> <cell> - <JTextField id="entryBookTypeField" text="{getEntryBook().getType()}"/> - <javax.swing.text.Document javaBean="getEntryBookTypeField().getDocument()" - onInsertUpdate='getEntryBook().setType(getEntryBookTypeField().getText())' - onRemoveUpdate='getEntryBook().setType(getEntryBookTypeField().getText())' /> + <JComboBox id="typeComboBox" model='{new org.chorem.lima.ui.entrybook.model.EntryBookTypeListModel()}' + selectedItem="{getEntryBook().getType()}" + onActionPerformed="getEntryBook().setType((String)getTypeComboBox().getSelectedItem())"/> </cell> </row> <row> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/model/EntryBookTypeListModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,73 @@ +package org.chorem.lima.ui.entrybook.model; + + +/* *##% 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]; + } +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -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. + ##% --> +<JDialog modal="true"> + + <script> + <![CDATA[ + import org.nuiton.util.MonthEnum; + import org.chorem.lima.entity.FiscalPeriodImpl; + import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodMonthComboBoxModel; + import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodSplinnerModel; + import java.util.Calendar; + + protected void performOk() { + if (period == null) { + // FIXME never ever use IMPL !!! + setPeriod(new FiscalPeriodImpl()); + } + + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal()); + calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue()); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal()); + calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue()); + + getPeriod().setBeginDate(calendarBegin.getTime()); + getPeriod().setEndDate(calendarEnd.getTime()); + + dispose(); + } + + protected void performCancel() { + setPeriod(null); + dispose(); + } + ]]> + </script> + + <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" /> + + <Table fill="both"> + <row> + <cell> + <JLabel text="lima.period.begindate"/> + </cell> + <cell> + <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/> + </cell> + <cell> + <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/> + </cell> + </row> + <row> + <cell> + <JLabel text="lima.period.enddate"/> + </cell> + <cell> + <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/> + </cell> + <cell> + <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/> + </cell> + </row> + <row> + <cell> + <Table fill="none" anchor="center" weighty="1"> + <row> + <cell> + <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/> + </cell> + <cell> + <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/> + </cell> + </row> + </Table> + </cell> + </row> + </Table> +</JDialog> \ No newline at end of file Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosurePeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,19 @@ +<!-- ##% 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/ClosureTimeSpanForm.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureTimeSpanForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,56 @@ +<!-- ##% 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 Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/ClosureViewImpl.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,410 @@ +/* *##% 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.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; + +import javax.swing.JComboBox; +import javax.swing.ListSelectionModel; +import javax.swing.RowFilter; + +import jaxx.runtime.JAXXContext; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.LimaContext; +import org.chorem.lima.combobox.model.PeriodComboBoxModel; +import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; +import org.chorem.lima.dto.PeriodDTO; +import org.chorem.lima.dto.StatusDTO; +import org.chorem.lima.dto.TransactionDTO; +import org.chorem.lima.dto.util.TriPeriodAsc; +import org.chorem.lima.dto.util.TriPeriodDesc; +import org.chorem.lima.table.model.ClosureTableModel; +import org.chorem.lima.ui.ErrorMessage; +import org.chorem.lima.ui.period.AddPeriod; +import org.chorem.lima.ui.period.ClosureTimeSpanForm; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.HighlighterFactory; + + +/** + * Permet l'affichage du tableau avec les périodes mensuelles. + * + * @author Rémi Chapelet + */ +public class ClosureViewImpl extends ClosureView { + + /** serialVersionUID. */ + private static final long serialVersionUID = -8759564865633991757L; + + /** log. */ + private static final Log log = LogFactory.getLog(ClosureViewImpl.class); + + private final JXTable table; + private JComboBox comboBoxPeriod = new JComboBox(); + private final ClosureTimeSpanForm form; + private final AddPeriod addPeriodForm; + private static boolean blockPeriod; + private JComboBox comboBoxBeginPeriod = new JComboBox(); + private JComboBox comboBoxEndPeriod = new JComboBox(); + private JComboBox comboBeginYearPeriod = new JComboBox(); + private JComboBox comboBeginMonthPeriod = new JComboBox(); + private JComboBox comboEndYearPeriod = new JComboBox(); + private JComboBox comboEndMonthPeriod = new JComboBox(); + + /** + * @param parentContext + */ + public ClosureViewImpl(JAXXContext parentContext) { + super(parentContext); + + // Initialisation du choix pour les périodes + initComboBoxPeriod(); + + /* Set Period model */ + // Création du model pour le tableau + table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel()); + table.setRowHeight(24); + // Permet d'alterner les couleurs des lignes pour le tableau + table.setHighlighters(HighlighterFactory.createAlternateStriping()); + // Definition de la selection possible sur les lignes + table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); + table.setColumnControlVisible(true); + + /* + * Ajout d'un listener lorsque l'utilisateur change de période. + */ + comboBoxPeriod.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + // Récupère la période master + PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); + //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)}; + //FilterPipeline filters = new FilterPipeline(filterArray); + + RowFilter<Object, Object> filter = null; + if (periodMaster != null) { + // 0 = check only in first column + // filter : + // period name containing selected periode + // Final = ??? TODO + Calendar calendar = Calendar.getInstance(); + calendar.setTime(periodMaster.getBegin()); + filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0); + if (log.isDebugEnabled()) { + log.debug("Apply filter on " + calendar.get(Calendar.YEAR)); + } + } + table.setRowFilter(filter); + } + }); + + // Ajout du tableau dans l'UI + getClosureScrollPane().setViewportView(table); + + /* + * Initialisation du formulaire pour bloquer ou débloquer une période. + */ + form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm(); + form.getOkButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + updatePeriod(); + } + }); + + /** + * Initialisation du formulaire pour ajouter un exercice + */ + addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod(); + + Calendar cal = Calendar.getInstance(); + + //Init YEAR Periode Combobox + // take care about previous year #120 + int todayYear = cal.get(Calendar.YEAR); + for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) { + comboBeginYearPeriod.addItem(currentYear); + comboEndYearPeriod.addItem(currentYear); + } + comboBeginYearPeriod.setSelectedItem(todayYear); + comboEndYearPeriod.setSelectedItem(todayYear); + + + //Add BeginYear ComboBox to addPeriodForm + addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod); + addPeriodForm.getBeginYearPeriodPanel().validate(); + + //Add EndYear ComboBox to addPeriodForm + addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod); + addPeriodForm.getEndYearPeriodPanel().validate(); + + //Init MONTH Periode Combobox + cal.set(Calendar.MONTH, Calendar.JANUARY); + for (int j = 0; j <= 11; j++) { + comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); + comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); + cal.add(Calendar.MONTH, 1); + } + + //Add BeginMonth ComboBox to addPeriodForm + addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod); + addPeriodForm.getBeginMonthPeriodPanel().validate(); + + //Add EndMonth ComboBox to addPeriodForm + addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod); + addPeriodForm.getEndMonthPeriodPanel().validate(); + + addPeriodForm.getOkButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addPeriod(); + addPeriodForm.dispose(); + } + }); + + } + + + /** + * Cette méthode permet de charger les périodes (annuelles) pour choisir + * les périodes mensuelles à afficher dans le tableau. + */ + public void initComboBoxPeriod() { + /** + * Charge pour le JComboBox le choix des périodes (exercices) à afficher. + */ + // Récupère les périodes + ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); + PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); + // Création Combobox debut période + comboBoxPeriod.setModel(periodModel); + comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); + // Ajout des combobox + periodPanel.add(comboBoxPeriod); + periodPanel.validate(); + } + + + /** + * Cette méthode permet d'initialiser le formulaire pour bloquer une ou + * plusieurs périodes. + */ + @Override + public void initBlockForm() { + blockPeriod = true; + form.setTitle(_("lima.ui.block.timespan")); + initComboBoxForm(); + form.setVisible(true); + } + + + /** + * Initialise le formulaire pour débloquer des périodes mensuelles. + */ + @Override + public void initUnblockForm() { + blockPeriod = false; + form.setTitle(_("lima.ui.unblock.timespan")); + initComboBoxForm(); + form.setVisible(true); + } + + + /** + * Initialise les combobox pour le formulaire de période. Il ajoute ainsi + * les deux combobox nécessaires pour début et fin de période. + */ + public void initComboBoxForm() { + /** + * Charge pour les JComboBox le choix des périodes mensuelles à bloquer. + */ + // Récupère les périodes + ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); + PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); + // Création Combobox debut période + comboBoxBeginPeriod.setModel(periodModel); + comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); + // Création Combobox fin période + comboBoxEndPeriod.setModel(periodModel); + comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); + // Ajout des combobox + form.beginPeriod.add(comboBoxBeginPeriod); + form.endPeriod.add(comboBoxEndPeriod); + + /** + * Positionne, si les lignes sont sélectionnées, les comboBox sur + * les bonnes périodes (période min et période max). + */ + // Si une ou plusieurs lignes sont sélectionnées + if (table.getSelectedRow() != -1) { + // Récupère les périodes sélectionnées + List<PeriodDTO> listPeriod = getSelectedPeriod(); + // Parcours du vecteur + comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0)); + comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1))); + } + } + + + /** + * Permet d'ajouter un nouvel exercice. + */ + protected void addPeriod() { + if (log.isDebugEnabled()) { + log.debug("addPeriod : "); + //Get form data + } + PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod(); + List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); + + // get begin date + Calendar beginCalendar = Calendar.getInstance(); + if (periodCurrent != null) { + beginCalendar.setTime(periodCurrent.getBegin()); + } + beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem()); + beginCalendar.set(Calendar.DAY_OF_MONTH, 1); + // month is equals to list index + beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex()); + Date beginDate = beginCalendar.getTime(); + + // get end date + Calendar endCalendar = Calendar.getInstance(); + endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem()); + endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex()); + int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); + endCalendar.set(Calendar.DAY_OF_MONTH, maximum); + Date endDate = endCalendar.getTime(); + + if (log.isDebugEnabled()) { + log.debug("Add new periode from " + beginDate + " to " + endDate); + } + + String periodName = null; + if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) { + periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR)); + } + else { + periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)); + } + + // TODO what is status.get(3) ??? + PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3)); + + ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); + closureModel.addPeriod(period, status); + } + + /** + * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer + * une ou plusieurs périodes, ou bien débloquer. + * On récupère l'intervalle des périodes donné par le formulaire. On prend + * les périodes aux extrémités. + * Si on bloque les périodes, on va trier par ordre croissant sinon par + * ordre décroissant. En effet, pour débloquer une période, il est important + * que les périodes qui suivent soient bloquées ; par conséquent on doit + * commencer par les dernières. + */ + protected void updatePeriod() { + // Liste des status + List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); + // Liste des transactions + List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData(); + // Chargement du model + ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); + /** + * Récupère l'intervalle des périodes sélectionnées + */ + PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem(); + PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem(); + // Exercice + PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); + // Si block période, on trie la liste en croissant ou bien décroissant + List<PeriodDTO> listPeriod = periodMaster.getChildren(); + if (blockPeriod) { + Collections.sort(listPeriod, new TriPeriodAsc()); + } else { + Collections.sort(listPeriod, new TriPeriodDesc()); + } + // Pour toutes les périodes mensuelles + for (PeriodDTO period : listPeriod) { + if (((period.getBegin().after(periodBegin.getBegin())) + && (period.getBegin().before(periodEnd.getBegin()))) + || (period.equals(periodBegin)) + || (period.equals(periodEnd))) { + if (log.isDebugEnabled()) { + log.debug("updatePeriod : " + period.getIdName() + " : " + + blockPeriod); + } + /** + * Détection des messages d'erreur + */ + String message = closureModel.updatePeriod(period, blockPeriod, status, transactions); + ErrorMessage.showMessage(message); + } + } + // On trie par ordre croissant si c'était en décroissant, sinon l'affichage + // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre + // décroissant). + if (!blockPeriod) { + Collections.sort(listPeriod, new TriPeriodAsc()); + } + form.setVisible(false); + form.dispose(); + } + + /** + * Cette méthode permet de retourner une liste des périodes sélectionnées. + * + * @return liste des périodes sélectionnées + */ + protected List<PeriodDTO> getSelectedPeriod() { + // récupère les lignes sélectionnées + int viewIndex[] = table.getSelectedRows(); + // chargement du model (tableau des périodes) + ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); + LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>(); + // Pour chaque ligne sélectionnée + for (int i : viewIndex) { + int modelIndex = table.convertRowIndexToModel(i); + listPeriod.add(closureModel.getRow(modelIndex)); + } + return listPeriod; + } + + + public void initAddPeriod() { + addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod")); + addPeriodForm.setVisible(true); + } + +} Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,67 @@ +<!-- ##% 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> + + <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" /> + <Boolean id="selectedPeriod" javaBean="false" /> + + <script> + <![CDATA[ + + ]]> + </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"> + <JScrollPane> + <org.jdesktop.swingx.JXTable id="fiscalPeriodTable" + model="{new org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel()}" + highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}" + rowHeight="24" + selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" + columnControlVisible="true" /> + <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()" + 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> + </Table> + </cell> + </row> +</Table> Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,103 @@ +/* *##% 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.util.Calendar; +import java.util.Date; + +import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FinancialPeriodImpl; +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; + +/** + * TODO add comment here. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class FiscalPeriodViewHandler { + + private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); + + protected FiscalPeriodView view; + + protected FiscalPeriodViewHandler(FiscalPeriodView view) { + this.view = view; + } + + public void addFiscalPeriod() { + + FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + + AddPeriod addPeriodDialog = new AddPeriod(view); + // jaxx don't call super() ? + addPeriodDialog.setLocationRelativeTo(view); + addPeriodDialog.setVisible(true); + + FiscalPeriod period = addPeriodDialog.getPeriod(); + // null = cancel + if (period != null) { + + Date beginDate = period.getBeginDate(); + Date endDate = period.getEndDate(); + // set both to 0:00.000 + beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR); + endDate = DateUtils.ceiling(beginDate, Calendar.HOUR); + + // on cree pour l'instant des periodes de 1mois + Date loopDate = beginDate; + while (loopDate.compareTo(endDate) < 0) { + Date loopUpperDate = DateUtils.addMonths(loopDate, 1); + Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1); + FinancialPeriod financialPeriod = new FinancialPeriodImpl(); + financialPeriod.setBeginDate(loopDate); + financialPeriod.setEndDate(periodEndDate); + period.addFinancialPeriod(financialPeriod); + loopDate = loopUpperDate; + } + + try { + model.addFiscalPeriod(period); + } catch (LimaException ex) { + if (log.isErrorEnabled()) { + log.error("Can't add fiscal period", ex); + } + ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex); + } + } + } + + public void blockFiscalPeriod() { + throw new NotImplementedException("To be continued..."); + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodMonthComboBoxModel.java 2010-04-12 15:46:09 UTC (rev 2859) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodMonthComboBoxModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ##%*/ -package org.chorem.lima.ui.period.model; +package org.chorem.lima.ui.fiscalperiod.model; import javax.swing.ComboBoxModel; import javax.swing.event.ListDataListener; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodSplinnerModel.java 2010-04-12 15:46:09 UTC (rev 2859) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodSplinnerModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ##%*/ -package org.chorem.lima.ui.period.model; +package org.chorem.lima.ui.fiscalperiod.model; import java.util.Calendar; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/model/FiscalPeriodTableModel.java 2010-04-12 15:46:09 UTC (rev 2859) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ##%*/ -package org.chorem.lima.ui.period.model; +package org.chorem.lima.ui.fiscalperiod.model; import static org.nuiton.i18n.I18n._; @@ -88,7 +88,7 @@ switch(columnIndex) { case 0 : - result = _("Exercice"); + result = _("lima.tab.fiscalperiod"); break; case 1: result = _("Bloquée"); Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css (from rev 2859, trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/styles.css 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,8 @@ +.warning { + foreground: red; + // JTextArea sur plusieurs lignes + lineWrap: true; + // Implique que les mots ne sont pas coupés + wrapStyleWord: true; + editable: false; +} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/AddPeriod.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,96 +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"> - - <script> - <![CDATA[ - import org.nuiton.util.MonthEnum; - import org.chorem.lima.entity.FiscalPeriodImpl; - import org.chorem.lima.ui.period.model.FiscalPeriodMonthComboBoxModel; - import org.chorem.lima.ui.period.model.FiscalPeriodSplinnerModel; - import java.util.Calendar; - - protected void performOk() { - if (period == null) { - // FIXME never ever use IMPL !!! - setPeriod(new FiscalPeriodImpl()); - } - - // get begin date - Calendar calendarBegin = Calendar.getInstance(); - calendarBegin.set(Calendar.MONTH, ((MonthEnum)periodBeginMonth.getSelectedItem()).ordinal()); - calendarBegin.set(Calendar.YEAR, (Integer)periodBeginYear.getValue()); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - calendarEnd.set(Calendar.MONTH, ((MonthEnum)periodEndMonth.getSelectedItem()).ordinal()); - calendarEnd.set(Calendar.YEAR, (Integer)periodEndYear.getValue()); - - getPeriod().setBeginDate(calendarBegin.getTime()); - getPeriod().setEndDate(calendarEnd.getTime()); - - dispose(); - } - - protected void performCancel() { - setPeriod(null); - dispose(); - } - ]]> - </script> - - <org.chorem.lima.entity.FiscalPeriod id="period" javaBean="null" /> - - <Table fill="both"> - <row> - <cell> - <JLabel text="lima.period.begindate"/> - </cell> - <cell> - <JComboBox id="periodBeginMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.JANUARY)}"/> - </cell> - <cell> - <JSpinner id="periodBeginYear" model="{new FiscalPeriodSplinnerModel()}"/> - </cell> - </row> - <row> - <cell> - <JLabel text="lima.period.enddate"/> - </cell> - <cell> - <JComboBox id="periodEndMonth" model="{new FiscalPeriodMonthComboBoxModel(MonthEnum.DECEMBER)}"/> - </cell> - <cell> - <JSpinner id="periodEndYear" model="{new FiscalPeriodSplinnerModel()}"/> - </cell> - </row> - <row> - <cell> - <Table fill="none" anchor="center" weighty="1"> - <row> - <cell> - <JButton id="okButton" text="lima.common.ok" onActionPerformed="performOk()"/> - </cell> - <cell> - <JButton id="cancelButton" text="lima.common.cancel" onActionPerformed="performCancel()"/> - </cell> - </row> - </Table> - </cell> - </row> - </Table> -</JDialog> \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosurePeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -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 Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureTimeSpanForm.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -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 Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/ClosureViewImpl.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,408 +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.period; - -import static org.nuiton.i18n.I18n._; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.Calendar; -import java.util.Collections; -import java.util.Date; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; - -import javax.swing.JComboBox; -import javax.swing.ListSelectionModel; -import javax.swing.RowFilter; - -import jaxx.runtime.JAXXContext; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import org.chorem.lima.combobox.model.PeriodComboBoxModel; -import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.dto.StatusDTO; -import org.chorem.lima.dto.TransactionDTO; -import org.chorem.lima.dto.util.TriPeriodAsc; -import org.chorem.lima.dto.util.TriPeriodDesc; -import org.chorem.lima.table.model.ClosureTableModel; -import org.chorem.lima.ui.ErrorMessage; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.decorator.HighlighterFactory; - - -/** - * Permet l'affichage du tableau avec les périodes mensuelles. - * - * @author Rémi Chapelet - */ -public class ClosureViewImpl extends ClosureView { - - /** serialVersionUID. */ - private static final long serialVersionUID = -8759564865633991757L; - - /** log. */ - private static final Log log = LogFactory.getLog(ClosureViewImpl.class); - - private final JXTable table; - private JComboBox comboBoxPeriod = new JComboBox(); - private final ClosureTimeSpanForm form; - private final AddPeriod addPeriodForm; - private static boolean blockPeriod; - private JComboBox comboBoxBeginPeriod = new JComboBox(); - private JComboBox comboBoxEndPeriod = new JComboBox(); - private JComboBox comboBeginYearPeriod = new JComboBox(); - private JComboBox comboBeginMonthPeriod = new JComboBox(); - private JComboBox comboEndYearPeriod = new JComboBox(); - private JComboBox comboEndMonthPeriod = new JComboBox(); - - /** - * @param parentContext - */ - public ClosureViewImpl(JAXXContext parentContext) { - super(parentContext); - - // Initialisation du choix pour les périodes - initComboBoxPeriod(); - - /* Set Period model */ - // Création du model pour le tableau - table = new JXTable(LimaContext.getContext().getDataManager().getClosureModel()); - table.setRowHeight(24); - // Permet d'alterner les couleurs des lignes pour le tableau - table.setHighlighters(HighlighterFactory.createAlternateStriping()); - // Definition de la selection possible sur les lignes - table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - table.setColumnControlVisible(true); - - /* - * Ajout d'un listener lorsque l'utilisateur change de période. - */ - comboBoxPeriod.addItemListener(new ItemListener() { - @Override - public void itemStateChanged(ItemEvent e) { - // Récupère la période master - PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); - //Filter[] filterArray = {new PatternFilter("(.*" + (periodMaster.getBegin().getYear() + 1900) + ".*)|(.*Final.*)", 0, 0)}; - //FilterPipeline filters = new FilterPipeline(filterArray); - - RowFilter<Object, Object> filter = null; - if (periodMaster != null) { - // 0 = check only in first column - // filter : - // period name containing selected periode - // Final = ??? TODO - Calendar calendar = Calendar.getInstance(); - calendar.setTime(periodMaster.getBegin()); - filter = RowFilter.regexFilter("(.*" + calendar.get(Calendar.YEAR) + ".*)|(.*Final.*)", 0); - if (log.isDebugEnabled()) { - log.debug("Apply filter on " + calendar.get(Calendar.YEAR)); - } - } - table.setRowFilter(filter); - } - }); - - // Ajout du tableau dans l'UI - getClosureScrollPane().setViewportView(table); - - /* - * Initialisation du formulaire pour bloquer ou débloquer une période. - */ - form = LimaContext.getContext().getMainUI().getClosureTimeSpanForm(); - form.getOkButton().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - updatePeriod(); - } - }); - - /** - * Initialisation du formulaire pour ajouter un exercice - */ - addPeriodForm = LimaContext.getContext().getMainUI().getAddPeriod(); - - Calendar cal = Calendar.getInstance(); - - //Init YEAR Periode Combobox - // take care about previous year #120 - int todayYear = cal.get(Calendar.YEAR); - for (int currentYear = todayYear - 1; currentYear <= todayYear + 5; currentYear ++) { - comboBeginYearPeriod.addItem(currentYear); - comboEndYearPeriod.addItem(currentYear); - } - comboBeginYearPeriod.setSelectedItem(todayYear); - comboEndYearPeriod.setSelectedItem(todayYear); - - - //Add BeginYear ComboBox to addPeriodForm - addPeriodForm.getBeginYearPeriodPanel().add(comboBeginYearPeriod); - addPeriodForm.getBeginYearPeriodPanel().validate(); - - //Add EndYear ComboBox to addPeriodForm - addPeriodForm.getEndYearPeriodPanel().add(comboEndYearPeriod); - addPeriodForm.getEndYearPeriodPanel().validate(); - - //Init MONTH Periode Combobox - cal.set(Calendar.MONTH, Calendar.JANUARY); - for (int j = 0; j <= 11; j++) { - comboBeginMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); - comboEndMonthPeriod.addItem(cal.getDisplayName(Calendar.MONTH, 2, Locale.getDefault())); - cal.add(Calendar.MONTH, 1); - } - - //Add BeginMonth ComboBox to addPeriodForm - addPeriodForm.getBeginMonthPeriodPanel().add(comboBeginMonthPeriod); - addPeriodForm.getBeginMonthPeriodPanel().validate(); - - //Add EndMonth ComboBox to addPeriodForm - addPeriodForm.getEndMonthPeriodPanel().add(comboEndMonthPeriod); - addPeriodForm.getEndMonthPeriodPanel().validate(); - - addPeriodForm.getOkButton().addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - addPeriod(); - addPeriodForm.dispose(); - } - }); - - } - - - /** - * Cette méthode permet de charger les périodes (annuelles) pour choisir - * les périodes mensuelles à afficher dans le tableau. - */ - public void initComboBoxPeriod() { - /** - * Charge pour le JComboBox le choix des périodes (exercices) à afficher. - */ - // Récupère les périodes - ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); - PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); - // Création Combobox debut période - comboBoxPeriod.setModel(periodModel); - comboBoxPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Ajout des combobox - periodPanel.add(comboBoxPeriod); - periodPanel.validate(); - } - - - /** - * Cette méthode permet d'initialiser le formulaire pour bloquer une ou - * plusieurs périodes. - */ - @Override - public void initBlockForm() { - blockPeriod = true; - form.setTitle(_("lima.ui.block.timespan")); - initComboBoxForm(); - form.setVisible(true); - } - - - /** - * Initialise le formulaire pour débloquer des périodes mensuelles. - */ - @Override - public void initUnblockForm() { - blockPeriod = false; - form.setTitle(_("lima.ui.unblock.timespan")); - initComboBoxForm(); - form.setVisible(true); - } - - - /** - * Initialise les combobox pour le formulaire de période. Il ajoute ainsi - * les deux combobox nécessaires pour début et fin de période. - */ - public void initComboBoxForm() { - /** - * Charge pour les JComboBox le choix des périodes mensuelles à bloquer. - */ - // Récupère les périodes - ClosureTableModel closureModel = LimaContext.getContext().getDataManager().getClosureModel(); - PeriodComboBoxModel periodModel = new PeriodComboBoxModel(closureModel); - // Création Combobox debut période - comboBoxBeginPeriod.setModel(periodModel); - comboBoxBeginPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Création Combobox fin période - comboBoxEndPeriod.setModel(periodModel); - comboBoxEndPeriod.setRenderer(PeriodComboBoxRenderer.getInstance()); - // Ajout des combobox - form.beginPeriod.add(comboBoxBeginPeriod); - form.endPeriod.add(comboBoxEndPeriod); - - /** - * Positionne, si les lignes sont sélectionnées, les comboBox sur - * les bonnes périodes (période min et période max). - */ - // Si une ou plusieurs lignes sont sélectionnées - if (table.getSelectedRow() != -1) { - // Récupère les périodes sélectionnées - List<PeriodDTO> listPeriod = getSelectedPeriod(); - // Parcours du vecteur - comboBoxBeginPeriod.setSelectedItem(listPeriod.get(0)); - comboBoxEndPeriod.setSelectedItem(listPeriod.get((listPeriod.size() - 1))); - } - } - - - /** - * Permet d'ajouter un nouvel exercice. - */ - protected void addPeriod() { - if (log.isDebugEnabled()) { - log.debug("addPeriod : "); - //Get form data - } - PeriodDTO periodCurrent = LimaContext.getContext().getDataManager().getCurrentPeriod(); - List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); - - // get begin date - Calendar beginCalendar = Calendar.getInstance(); - if (periodCurrent != null) { - beginCalendar.setTime(periodCurrent.getBegin()); - } - beginCalendar.set(Calendar.YEAR, (Integer)comboBeginYearPeriod.getSelectedItem()); - beginCalendar.set(Calendar.DAY_OF_MONTH, 1); - // month is equals to list index - beginCalendar.set(Calendar.MONTH, comboBeginMonthPeriod.getSelectedIndex()); - Date beginDate = beginCalendar.getTime(); - - // get end date - Calendar endCalendar = Calendar.getInstance(); - endCalendar.set(Calendar.YEAR, (Integer)comboEndYearPeriod.getSelectedItem()); - endCalendar.set(Calendar.MONTH , comboEndMonthPeriod.getSelectedIndex()); - int maximum = endCalendar.getActualMaximum(Calendar.DAY_OF_MONTH); - endCalendar.set(Calendar.DAY_OF_MONTH, maximum); - Date endDate = endCalendar.getTime(); - - if (log.isDebugEnabled()) { - log.debug("Add new periode from " + beginDate + " to " + endDate); - } - - String periodName = null; - if (comboBeginYearPeriod.getSelectedIndex() != comboEndYearPeriod.getSelectedIndex()) { - periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)) + "-" + Integer.toString(endCalendar.get(Calendar.YEAR)); - } - else { - periodName = Integer.toString(beginCalendar.get(Calendar.YEAR)); - } - - // TODO what is status.get(3) ??? - PeriodDTO period = new PeriodDTO("", periodName, beginDate, endDate, null, null, status.get(3)); - - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - closureModel.addPeriod(period, status); - } - - /** - * Permet de mettre à jour une période. Si l'utilisateur souhaite bloquer - * une ou plusieurs périodes, ou bien débloquer. - * On récupère l'intervalle des périodes donné par le formulaire. On prend - * les périodes aux extrémités. - * Si on bloque les périodes, on va trier par ordre croissant sinon par - * ordre décroissant. En effet, pour débloquer une période, il est important - * que les périodes qui suivent soient bloquées ; par conséquent on doit - * commencer par les dernières. - */ - protected void updatePeriod() { - // Liste des status - List<StatusDTO> status = LimaContext.getContext().getDataManager().getStatus(); - // Liste des transactions - List<TransactionDTO> transactions = LimaContext.getContext().getDataManager().getTransactionModel().getData(); - // Chargement du model - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - /** - * Récupère l'intervalle des périodes sélectionnées - */ - PeriodDTO periodBegin = (PeriodDTO) comboBoxBeginPeriod.getSelectedItem(); - PeriodDTO periodEnd = (PeriodDTO) comboBoxEndPeriod.getSelectedItem(); - // Exercice - PeriodDTO periodMaster = (PeriodDTO) comboBoxPeriod.getSelectedItem(); - // Si block période, on trie la liste en croissant ou bien décroissant - List<PeriodDTO> listPeriod = periodMaster.getChildren(); - if (blockPeriod) { - Collections.sort(listPeriod, new TriPeriodAsc()); - } else { - Collections.sort(listPeriod, new TriPeriodDesc()); - } - // Pour toutes les périodes mensuelles - for (PeriodDTO period : listPeriod) { - if (((period.getBegin().after(periodBegin.getBegin())) - && (period.getBegin().before(periodEnd.getBegin()))) - || (period.equals(periodBegin)) - || (period.equals(periodEnd))) { - if (log.isDebugEnabled()) { - log.debug("updatePeriod : " + period.getIdName() + " : " - + blockPeriod); - } - /** - * Détection des messages d'erreur - */ - String message = closureModel.updatePeriod(period, blockPeriod, status, transactions); - ErrorMessage.showMessage(message); - } - } - // On trie par ordre croissant si c'était en décroissant, sinon l'affichage - // dans les vues est bouleversé. (les périodes seront affichées dans l'ordre - // décroissant). - if (!blockPeriod) { - Collections.sort(listPeriod, new TriPeriodAsc()); - } - form.setVisible(false); - form.dispose(); - } - - /** - * Cette méthode permet de retourner une liste des périodes sélectionnées. - * - * @return liste des périodes sélectionnées - */ - protected List<PeriodDTO> getSelectedPeriod() { - // récupère les lignes sélectionnées - int viewIndex[] = table.getSelectedRows(); - // chargement du model (tableau des périodes) - ClosureTableModel closureModel = (ClosureTableModel) table.getModel(); - LinkedList<PeriodDTO> listPeriod = new LinkedList<PeriodDTO>(); - // Pour chaque ligne sélectionnée - for (int i : viewIndex) { - int modelIndex = table.convertRowIndexToModel(i); - listPeriod.add(closureModel.getRow(modelIndex)); - } - return listPeriod; - } - - - public void initAddPeriod() { - addPeriodForm.setTitle(_("lima.menubar.closure.addPeriod")); - addPeriodForm.setVisible(true); - } - -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,65 +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. - ##% --> - -<Table> - - <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" /> - <Boolean id="selectedPeriod" javaBean="false" /> - - <script> - <![CDATA[ - - ]]> - </script> - <row fill="horizontal" weightx="1" anchor="center" columns="2"> - <cell> - <JPanel border='{BorderFactory.createTitledBorder(_("lima.period.filter"))}'> - <JLabel text="lima.period.periodFilterLabel"/> - <JComboBox id="periodFilterComboBox" /> - </JPanel> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1"> - <JScrollPane> - <org.jdesktop.swingx.JXTable id="fiscalPeriodTable" - model="{new org.chorem.lima.ui.period.model.FiscalPeriodTableModel()}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createAlternateStriping()}" - rowHeight="24" - selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" - columnControlVisible="true" /> - <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()" - onValueChanged="setSelectedPeriod(fiscalPeriodTable.getSelectedRow() != -1)"/> - </JScrollPane> - </cell> - <cell fill="horizontal" weighty="1" anchor="north"> - <Table> - <row> - <cell> - <JButton id="addButton" text="lima.period.addFiscalPeriod" onActionPerformed="getHandler().addFiscalPeriod()"/> - </cell> - </row> - <row> - <cell> - <JButton id="blockButton" text="lima.period.block" enabled="{isSelectedPeriod()}" - onActionPerformed="getHandler().blockFiscalPeriod()" /> - </cell> - </row> - </Table> - </cell> - </row> -</Table> Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/FiscalPeriodViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,103 +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.period; - -import static org.nuiton.i18n.I18n._; - -import java.util.Calendar; -import java.util.Date; - -import org.apache.commons.lang.NotImplementedException; -import org.apache.commons.lang.time.DateUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FinancialPeriodImpl; -import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.ui.period.model.FiscalPeriodTableModel; -import org.chorem.lima.util.ErrorHelper; - -/** - * TODO add comment here. - * - * @author chatellier - * @version $Revision$ - * - * Last update : $Date$ - * By : $Author$ - */ -public class FiscalPeriodViewHandler { - - private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); - - protected FiscalPeriodView view; - - protected FiscalPeriodViewHandler(FiscalPeriodView view) { - this.view = view; - } - - public void addFiscalPeriod() { - - FiscalPeriodTableModel model = (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); - - AddPeriod addPeriodDialog = new AddPeriod(view); - // jaxx don't call super() ? - addPeriodDialog.setLocationRelativeTo(view); - addPeriodDialog.setVisible(true); - - FiscalPeriod period = addPeriodDialog.getPeriod(); - // null = cancel - if (period != null) { - - Date beginDate = period.getBeginDate(); - Date endDate = period.getEndDate(); - // set both to 0:00.000 - beginDate = DateUtils.ceiling(beginDate, Calendar.HOUR); - endDate = DateUtils.ceiling(beginDate, Calendar.HOUR); - - // on cree pour l'instant des periodes de 1mois - Date loopDate = beginDate; - while (loopDate.compareTo(endDate) < 0) { - Date loopUpperDate = DateUtils.addMonths(loopDate, 1); - - Date periodEndDate = DateUtils.addMilliseconds(loopUpperDate, -1); - FinancialPeriod financialPeriod = new FinancialPeriodImpl(); - financialPeriod.setBeginDate(loopDate); - financialPeriod.setEndDate(periodEndDate); - period.addFinancialPeriod(financialPeriod); - - loopDate = loopUpperDate; - } - - try { - model.addFiscalPeriod(period); - } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add fiscal period", ex); - } - ErrorHelper.showErrorDialog(_("Can't add fiscal period"), ex); - } - } - } - - public void blockFiscalPeriod() { - throw new NotImplementedException("To be continued..."); - } -} Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/period/styles.css 2010-04-21 16:09:27 UTC (rev 2870) @@ -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/transaction/FinancialTransactionViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/FinancialTransactionViewHandler.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -20,26 +20,17 @@ import static org.nuiton.i18n.I18n._; -import java.util.List; import javax.swing.JOptionPane; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; -import org.chorem.lima.entity.Entry; -import org.chorem.lima.entity.EntryBook; -import org.chorem.lima.entity.EntryBookImpl; import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.entity.FinancialTransactionImpl; -import org.chorem.lima.ui.entrybook.EntryBookForm; -import org.chorem.lima.ui.entrybook.model.EntryBookTableModel; import org.chorem.lima.ui.transaction.table.FinancialTransactionTable; import org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel; import org.chorem.lima.util.ErrorHelper; -import org.jdesktop.swingx.JXTable; - /** * Handler associated with account view. * @@ -68,11 +59,9 @@ try { model.addFinancialTransaction(); } catch (LimaException ex) { - if (log.isErrorEnabled()) { - log.error("Can't add transaction", ex); + JOptionPane.showMessageDialog(view, + _("lima.warning.financialtransaction.noselect")); } - ErrorHelper.showErrorDialog("Can't add transaction", ex); - } } //implement new transaction button Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionView.jaxx 2010-04-21 16:09:27 UTC (rev 2870) @@ -38,29 +38,38 @@ <row fill="horizontal" weightx="1" weighty="0" anchor="center"> <cell> - <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/> + <JLabel id="fiscalPeriodLabel" text="lima.fiscalyear.management"/> </cell> <cell> - <JComboBox id="entryBookComboBox" - model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}" - onItemStateChanged="getTransactionTableModel().setEntryBook((EntryBook) event.getItem())" + <JComboBox id="fiscalPeriodComboBox" + model="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxModel()}" + renderer="{new org.chorem.lima.ui.transaction.model.FiscalPeriodComboBoxRenderer()}" editable="false"/> </cell> <cell> - <JLabel id="periodLabel" text="lima.transaction.period" + <JLabel id="financialPeriodLabel" text="lima.transaction.period" /> </cell> <cell> <JComboBox id="financialPeriodComboBox" model="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxModel()}" - renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodRenderer()}" + renderer="{new org.chorem.lima.ui.transaction.model.FinancialPeriodComboBoxRenderer()}" editable="false" /> + </cell> + <cell> + <JLabel id="entryBookLabel" text="lima.transaction.entrybook"/> </cell> + <cell> + <JComboBox id="entryBookComboBox" + model="{new org.chorem.lima.ui.transaction.model.EntryBookComboBoxModel()}" + renderer="{new org.chorem.lima.ui.transaction.model.EntryBookRenderer()}" + onItemStateChanged="getFinancialTransactionTableModel().setEntryBook((EntryBook) event.getItem())" + editable="false"/> + </cell> </row> <row> - <cell fill="both" weightx="1" weighty="1" rows="3" columns="4"> + <cell fill="both" weightx="1" weighty="1" rows="3" columns="5"> <JScrollPane> <org.chorem.lima.ui.transaction.table.FinancialTransactionTableModel id="financialTransactionTableModel" /> @@ -75,7 +84,7 @@ </cell> <cell> <JButton text="lima.add.transaction" - onActionPerformed="getHandler().addEmptyTransaction()"/> + onActionPerformed="getHandler().addFinancialTransaction()"/> </cell> </row> <row> Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java (from rev 2862, trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java) =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodComboBoxRenderer.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,54 @@ +/* *##% 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.transaction.model; + +import java.awt.Component; +import java.text.SimpleDateFormat; +import java.util.Date; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.FinancialPeriod; + + +public class FinancialPeriodComboBoxRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + FinancialPeriod financialperiod = (FinancialPeriod) value; + if (financialperiod != null){ + //Date d = financialperiod.getBeginDate(); + //String date = d.getMonth() + " " + (d.getYear() + 1900); + //label.setText(date); + label.setText(financialperiod.getBeginDate().toString()); + } + return label; + } + + +} \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FinancialPeriodRenderer.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,36 +0,0 @@ -package org.chorem.lima.ui.transaction.model; - -import java.awt.Component; -import java.text.SimpleDateFormat; -import java.util.Date; - -import javax.swing.DefaultListCellRenderer; -import javax.swing.JLabel; -import javax.swing.JList; - -import org.chorem.lima.entity.FinancialPeriod; - - -public class FinancialPeriodRenderer extends DefaultListCellRenderer { - - @Override - public Component getListCellRendererComponent(JList list, - Object value, - int index, - boolean isSelected, - boolean cellHasFocus) { - // TODO Auto-generated method stub - - JLabel label = new JLabel(); - FinancialPeriod financialperiod = (FinancialPeriod) value; - if (financialperiod != null){ - //Date d = financialperiod.getBeginDate(); - //String date = d.getMonth() + " " + (d.getYear() + 1900); - //label.setText(date); - label.setText(financialperiod.getBeginDate().toString()); - } - return label; - } - - -} \ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,102 @@ +/* *##% 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.transaction.model; + +import javax.swing.ComboBoxModel; +import javax.swing.event.ListDataListener; + +import org.chorem.lima.business.FiscalPeriodService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.service.LimaServiceFactory; + +public class FiscalPeriodComboBoxModel implements ComboBoxModel{ + + protected Object selectedFiscalPeriod; + + protected FiscalPeriodService fiscalPeriodService; + + public FiscalPeriodComboBoxModel(){ + fiscalPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService(); + } + + /* + * @see javax.swing.ListModel#getSize() + */ + @Override + public int getSize() { + int result = 0; + // TODO add cache + try { + result = fiscalPeriodService.getAllFiscalPeriods().size(); + } + catch (LimaException ex) { + // TODO Auto-generated catch block + ex.printStackTrace(); + } + return result; + } + + /* + * @see javax.swing.ListModel#getElementAt(int) + */ + @Override + public Object getElementAt(int index) { + Object result = null; + try { + result = fiscalPeriodService.getAllFiscalPeriods().get(index); + } + catch (LimaException ex) { + ex.printStackTrace(); + } + return result; + } + + /* + * @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; + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/model/FiscalPeriodComboBoxRenderer.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -0,0 +1,52 @@ +/* *##% 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.transaction.model; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JLabel; +import javax.swing.JList; + +import org.chorem.lima.entity.FinancialPeriod; +import org.chorem.lima.entity.FiscalPeriod; + +public class FiscalPeriodComboBoxRenderer extends DefaultListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, + Object value, + int index, + boolean isSelected, + boolean cellHasFocus) { + // TODO Auto-generated method stub + + JLabel label = new JLabel(); + FiscalPeriod fiscalPeriod = (FiscalPeriod) value; + if (fiscalPeriod != null){ + //Date d = financialperiod.getBeginDate(); + //String date = d.getMonth() + " " + (d.getYear() + 1900); + //label.setText(date); + label.setText(fiscalPeriod.getBeginDate().toString()); + } + return label; + } + + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-04-21 16:09:27 UTC (rev 2870) @@ -24,10 +24,12 @@ import java.util.Date; import java.util.List; +import javax.swing.JOptionPane; import javax.swing.table.AbstractTableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.LimaBusinessException; import org.chorem.lima.business.LimaException; import org.chorem.lima.business.RecordService; import org.chorem.lima.business.FinancialTransactionService; @@ -336,14 +338,21 @@ /* Calling transaction service */ //TODO transaction = currentdate, current periode, current journal FinancialTransaction financialtransaction =null; - financialtransaction.setFinancialPeriod(selectedFinancialPeriod); - financialtransaction.setEntryBook(selectedEntryBook); - //financialransaction.setDescription(description); - transactionService.createFinancialTransaction(financialtransaction); - int row = getDataList().indexOf(financialtransaction); - //int row = transactionService.getAllTransactions().indexOf(transaction); - log.debug(row); - fireTableRowsInserted(row, row); + //if a period and an entrybook is selected + if (selectedEntryBook != null && selectedFinancialPeriod != null){ + financialtransaction.setFinancialPeriod(selectedFinancialPeriod); + financialtransaction.setEntryBook(selectedEntryBook); + //financialransaction.setDescription(description); + //create it + transactionService.createFinancialTransaction(financialtransaction); + int row = getDataList().indexOf(financialtransaction); + //int row = transactionService.getAllTransactions().indexOf(transaction); + log.debug(row); + fireTableRowsInserted(row, row); + } + else { + throw new LimaBusinessException("No financialperiod or no entrybook selected"); + } } 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-04-21 16:09:27 UTC (rev 2870) @@ -10,6 +10,10 @@ lima.account.label=Label lima.account.number=Number lima.account.type=Account type +lima.account.type1= +lima.account.type2= +lima.account.type3= +lima.account.type4= lima.accountplan=Plan de comptes lima.actif=Asset lima.action.commandline.disable.main.ui=Do not launch main ui @@ -44,7 +48,6 @@ lima.block=block lima.cancel=Cancel lima.charge=Expense -lima.chartofaccounts= lima.chartofaccounts.journal= lima.chartofaccounts.management= lima.chartofaccounts.subledgers= @@ -94,6 +97,11 @@ lima.entrybook.code= lima.entrybook.label= lima.entrybook.type= +lima.entrybook.type1= +lima.entrybook.type2= +lima.entrybook.type3= +lima.entrybook.type4= +lima.entrybook.type5= lima.error=Error lima.error.account.double=It exists an account with a same number lima.error.account.not.exist=This account doesn't exist @@ -136,11 +144,15 @@ lima.filter.not.contains=Not contains lima.filter.starts.with=Starts with lima.find.transaction=Find transaction +lima.fiscalperiod.addFiscalPeriod= +lima.fiscalperiod.block= +lima.fiscalperiod.periodFilterLabel= lima.fiscalyear= lima.fiscalyear.addperiod= lima.fiscalyear.closefiscalyear= lima.fiscalyear.closeperiod= lima.fiscalyear.listclosed= +lima.fiscalyear.management= lima.grand.livre=General Ledger lima.home=Home - TODO lima.identity.address= @@ -272,6 +284,7 @@ lima.status.tr.balanced=Balanced lima.status.tr.finalized=Finalized lima.status.tr.wip=Work in progress +lima.structure=Structure lima.subledger.accountnumber= lima.subledger.code=Code lima.subledger.label= @@ -281,6 +294,7 @@ lima.tab.balance=Balance lima.tab.bilan=Results lima.tab.closure=Closure +lima.tab.fiscalperiod= lima.tab.home=Home lima.tab.journal=Journal lima.tab.lettering=Lettering @@ -317,5 +331,6 @@ lima.view=View lima.view.flatten=Flatten view lima.voucher=Voucher +lima.warning.financialtransaction.noselect=No Financial Period or EntryBook are selectionned lima.warning.nimbus.landf=Could not find Numbus Look&Feel lima.warning.no.ui=No ui display detected 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-04-20 16:33:17 UTC (rev 2869) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-04-21 16:09:27 UTC (rev 2870) @@ -1,8 +1,6 @@ -Bloqu\u00E9e= Can't\ add\ fiscal\ period= Confirmation= Do\ you\ really\ want\ to\ delete\ entry\ book\ %s\ ?= -Exercice= Global\ lima\ exception= Loading\ accounting...= lima.about.message=\u00C0 propos de Lima @@ -12,6 +10,10 @@ lima.account.number=Num\u00E9ro du compte lima.account.parentnumber= lima.account.type=Type de compte +lima.account.type1=Actif +lima.account.type2=Passif +lima.account.type3=Produit +lima.account.type4=Charge lima.actif=Actif lima.action.commandline.disable.main.ui=Ne pas lancer l'ui lima.action.commandline.help=Afficher l'aide en console @@ -43,7 +45,6 @@ lima.bilan.total=Total lima.block=Bloquer lima.charge=Charge -lima.chartofaccounts=Structure lima.chartofaccounts.journal=Journaux lima.chartofaccounts.management=Plan comptable lima.chartofaccounts.subledgers=Plan tiers @@ -86,13 +87,18 @@ lima.description=Description lima.edit=Editer lima.edit.transaction=Editer une transaction -lima.entries=Entr\u00E9es comptable -lima.entries.addtransaction=Ajouter une transaction +lima.entries=Traitement +lima.entries.addtransaction=Saisir des \u00E9critures lima.entries.lettering=Ajouter une lettre lima.entries.searchtransaction=Recherche les transactions lima.entrybook.code=Code lima.entrybook.label=Libelle lima.entrybook.type=Type +lima.entrybook.type1=Achats +lima.entrybook.type2=Ventes +lima.entrybook.type3=Tr\u00E9sorerie +lima.entrybook.type4=G\u00E9n\u00E9ral +lima.entrybook.type5=Situation lima.error=Erreur lima.error.account.double=Il existe un compte avec ce m\u00EAme num\u00E9ro de compte lima.error.account.not.exist=Ce num\u00E9ro de compte n'existe pas @@ -135,11 +141,14 @@ lima.filter.not.contains=Ne contient pas lima.filter.starts.with=Commence par lima.find.transaction=Rechercher transaction -lima.fiscalyear=Exercice comptable +lima.fiscalperiod.addFiscalPeriod=Nouvel exercice +lima.fiscalperiod.block=Cloturer un exercice +lima.fiscalperiod.periodFilterLabel= lima.fiscalyear.addperiod=Ajouter une p\u00E9riode lima.fiscalyear.closefiscalyear=Cl\u00F4turer l'exercice lima.fiscalyear.closeperiod=Cl\u00F4turer une p\u00E9riode lima.fiscalyear.listclosed=Voir toutes les cl\u00F4tures +lima.fiscalyear.management=Exercices lima.grand.livre=Grand-Livre lima.home=Page d'accueil - TODO lima.identity.address=Adresse @@ -210,16 +219,8 @@ lima.number=Num\u00E9ro lima.openejb.remotemode.description= lima.passif=Passif -lima.period=P\u00E9riode -lima.period.addFiscalPeriod=Nouvel exercice -lima.period.begindate=D\u00E9but de l'exercice \: -lima.period.block=Bloquer l'exercice -lima.period.close=Ferm\u00E9 -lima.period.enddate=Fin de l'exercice \: -lima.period.filter=Filtre -lima.period.menu= -lima.period.open=Ouvert -lima.period.periodFilterLabel= +lima.period.begindate=D\u00E9but +lima.period.enddate=Fin lima.preferences=Pr\u00E9f\u00E9rences lima.prefix=Pr\u00E9fixe lima.produit=Produit @@ -263,6 +264,7 @@ lima.status.tr.balanced=Equilibr\u00E9e lima.status.tr.finalized=Valid\u00E9e lima.status.tr.wip=En cours +lima.structure=Structure lima.subledger.accountnumber= lima.subledger.code=Code lima.subledger.label= @@ -271,14 +273,14 @@ lima.tab.account=Plan Comptable lima.tab.balance=Balance lima.tab.bilan=Bilan +lima.tab.blocked=Block\u00E9 +lima.tab.fiscalperiod=Exercice lima.tab.home=Accueil lima.tab.journal=Journal lima.tab.lettering=Lettrage -lima.tab.period= lima.tab.reports=Rapports lima.tab.result=Compte de r\u00E9sultat lima.tab.search.result=Recherche -lima.tab.subledgers=Plan Tiers lima.tab.transaction=Ecriture lima.title=Lutin Invoice Monitoring and Accounting lima.title.about=A propos de Lima... @@ -307,5 +309,6 @@ lima.view=Vue lima.view.flatten=Vue aplatie lima.voucher=Document +lima.warning.financialtransaction.noselect=journal et/ou p\u00E9riode non s\u00E9lectionn\u00E9 lima.warning.nimbus.landf=Le look and feel nymbus n'a pas \u00E9t\u00E9 trouv\u00E9 lima.warning.no.ui=Aucun environnement graphique d\u00E9tect\u00E9.
participants (1)
-
jpepin@users.chorem.org