Author: jpepin Date: 2010-05-12 19:06:24 +0200 (Wed, 12 May 2010) New Revision: 2896 Url: http://chorem.org/repositories/revision/lima/2896 Log: Am?\195?\169lioration fonction ?\195?\169tat clot?\195?\187re p?\195?\169riode financi?\195?\168re/journal. Modifications visuelles Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.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/FiscalPeriodTableModel.java 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/FinancialPeriodService.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/FinancialPeriodService.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -46,7 +46,9 @@ FinancialPeriod getFinancialPeriodWithDate(Date date) throws LimaException; - /** Methode for closedperiodicentrybook */ + /** Methodes for closedperiodicentrybook */ ClosedPeriodicEntryBook getClosedPeriodicEntryBook(EntryBook entryBook, FinancialPeriod financialPeriod) throws LimaException; + + void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException; } Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java =================================================================== --- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FinancialPeriodServiceImpl.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -98,7 +98,8 @@ LimaCallaoDAOHelper.getEntryBookDAO(transaction); for (EntryBook entryBook : entryBookDAO.findAll()) { //new closed periodic entrybook - ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + ClosedPeriodicEntryBook closedPeriodicEntryBook + = new ClosedPeriodicEntryBookImpl(); // set entrybook closedPeriodicEntryBook.setEntryBook(entryBook); // set financial period @@ -238,6 +239,31 @@ return closedPeriodicEntryBook; } + + @Override + public void blockClosedPeriodicEntryBook(ClosedPeriodicEntryBook closedPeriodicEntryBook) throws LimaException { + TopiaContext topiaContext = null; + try { + topiaContext = rootContext.beginTransaction(); + + ClosedPeriodicEntryBookDAO closedPeriodicEntryBookDAO = + LimaCallaoDAOHelper.getClosedPeriodicEntryBookDAO(topiaContext); + + closedPeriodicEntryBook.setLocked(true); + closedPeriodicEntryBookDAO.update(closedPeriodicEntryBook); + + //commit + topiaContext.commitTransaction(); + } + catch (TopiaException ex) { + doCatch(topiaContext, ex, log); + } + finally { + doFinally(topiaContext, log); + } + + } + } 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-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/FiscalPeriodServiceImpl.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -219,9 +219,7 @@ fiscalPeriod.setLocked(true); // locked all financialperiod of the fiscalperiod for ( FinancialPeriod financialPeriod : fiscalPeriod.getFinancialPeriod()) { - log.debug(financialPeriod); financialPeriod.setLocked(true); - log.debug(financialPeriod); } fiscalPeriodDAO.update(fiscalPeriod); Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/accountsreports/AccountsReportsTableModel.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -21,12 +21,14 @@ import static org.nuiton.i18n.I18n._; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.swing.table.AbstractTableModel; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.EntryBookService; @@ -134,10 +136,13 @@ Object result = null; if(selectedAccount != null) { Entry currentRow = cacheDataList.get(row); - + SimpleDateFormat simpleDateFormat + = new SimpleDateFormat("dd MMM yyyy"); + switch (column) { case 0: - result = currentRow.getFinancialTransaction().getTransactionDate(); + result = StringUtils.capitalize(simpleDateFormat. + format(currentRow.getFinancialTransaction().getTransactionDate())); break; case 1: if (currentRow.getEntryBook() != null){ Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2010-05-12 17:06:24 UTC (rev 2896) @@ -39,7 +39,7 @@ </JScrollPane> </cell> <cell fill="horizontal"> - <JButton id="addButton" text="lima.common.add" + <JButton id="addButton" text="lima.entrybook.add" onActionPerformed="getHandler().addEntryBook()"/> </cell> </row> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodEntryBook.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -0,0 +1,32 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialperiod; + +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.FinancialPeriod; + +/** Object to encapsulate entrybook and financialperiod */ +public class FinancialPeriodEntryBook{ + FinancialPeriod financialPeriod; + EntryBook entryBook; + FinancialPeriodEntryBook(FinancialPeriod financialPeriod, EntryBook entryBook){ + this.financialPeriod=financialPeriod; + this.entryBook=entryBook; + } +} \ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTable.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -0,0 +1,84 @@ +package org.chorem.lima.ui.financialperiod; + +import java.awt.Color; +import java.awt.Component; +import java.text.SimpleDateFormat; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialPeriodService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; +import org.chorem.lima.service.LimaServiceFactory; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; + +public class FinancialPeriodTable extends JXTable { + + private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); + + protected FinancialPeriodViewHandler handler; + + protected FinancialPeriodTableModel model; + + protected FinancialPeriodService financialPeriodService; + + private Highlighter colorTransaction; + + public FinancialPeriodTable(FinancialPeriodViewHandler handler) { + + this.handler = handler; + model = this.handler.getView().modelFinancialPeriodTable; + financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService(); + + //highlight financial financial transactions + addMonthColor(); + addBlockColor(); + } + + protected void addMonthColor() { + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + FinancialPeriodEntryBook financialPeriodEntryBook + = (FinancialPeriodEntryBook) model.getElementAt(adapter.row); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM"); + int month = Integer.parseInt(simpleDateFormat.format( + financialPeriodEntryBook.financialPeriod.getBeginDate())); + // true if month is even + return ((month % 2)==0); + + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(222,222,222), null); + addHighlighter(colorTransaction); + } + + protected void addBlockColor() { + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + FinancialPeriodEntryBook financialPeriodEntryBook = (FinancialPeriodEntryBook) model.getElementAt(adapter.row); + ClosedPeriodicEntryBook closedPeriodicEntryBook = new ClosedPeriodicEntryBookImpl(); + // true if locked + try { + closedPeriodicEntryBook = financialPeriodService.getClosedPeriodicEntryBook(financialPeriodEntryBook.entryBook, financialPeriodEntryBook.financialPeriod); + } catch (LimaException eee) { + log.debug("Can't get closePeriodicEntryBook",eee); + } + return (closedPeriodicEntryBook.getLocked()); + } + }; + colorTransaction = + new ColorHighlighter(predicate, null, new Color(222,0,0)); + addHighlighter(colorTransaction); + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodTableModel.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -20,25 +20,22 @@ import static org.nuiton.i18n.I18n._; +import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Calendar; -import java.util.Date; import java.util.List; import javax.swing.table.AbstractTableModel; -import javax.transaction.Transaction; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.openejb.spi.TransactionService; import org.chorem.lima.business.EntryBookService; import org.chorem.lima.business.FinancialPeriodService; -import org.chorem.lima.business.FinancialTransactionService; import org.chorem.lima.business.FiscalPeriodService; import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; import org.chorem.lima.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FinancialTransaction; import org.chorem.lima.entity.FiscalPeriod; import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.util.ErrorHelper; @@ -72,16 +69,6 @@ entryBookService = LimaServiceFactory.getInstance().getEntryBookService(); financialPeriodService = LimaServiceFactory.getInstance().getFinancialPeriodService(); } - - /** Object to encapsulate entrybook and financialperiod */ - class FinancialPeriodEntryBook{ - FinancialPeriod financialPeriod; - EntryBook entryBook; - FinancialPeriodEntryBook(FinancialPeriod financialPeriod, EntryBook entryBook){ - this.financialPeriod=financialPeriod; - this.entryBook=entryBook; - } - } /* * @see javax.swing.table.TableModel#getRowCount() @@ -140,6 +127,17 @@ return false; } + public FinancialPeriodEntryBook getFinancialPeriodAtRow(int row) throws LimaException { + return cacheDataList.get(row); + } + + + public Object getElementAt(int row){ + + Object currentRow = cacheDataList.get(row); + return currentRow; + } + /* * @see javax.swing.table.TableModel#getValueAt(int, int) */ @@ -148,27 +146,21 @@ Object result = null; try { - FinancialPeriodEntryBook financialPeriodEntryBook = cacheDataList.get(rowIndex); - - String[] monthName = {_("lima.date.january"), _("lima.date.february"), - _("lima.date.march"), _("lima.date.april"), _("lima.date.may"), - _("lima.date.june"), _("lima.date.july"), _("lima.date.august"), - _("lima.date.september"), _("lima.date.october"), - _("lima.date.november"), _("lima.date.december")}; + FinancialPeriodEntryBook financialPeriodEntryBook + = cacheDataList.get(rowIndex); if (financialPeriodEntryBook != null){ - FinancialPeriod financialPeriod = financialPeriodEntryBook.financialPeriod; + FinancialPeriod financialPeriod + = financialPeriodEntryBook.financialPeriod; EntryBook entryBook = financialPeriodEntryBook.entryBook; - Date date = financialPeriod.getBeginDate(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - String formatBeginDate = monthName[calendar.get(Calendar.MONTH)] - +" "+String.valueOf(calendar.get(Calendar.YEAR)); + SimpleDateFormat simpleDateFormat + = new SimpleDateFormat("MMMMM yyyy"); switch (columnIndex) { case 0: - result = formatBeginDate; + result = StringUtils.capitalize(simpleDateFormat. + format(financialPeriod.getBeginDate())); break; case 1: result = entryBook.getCode()+" - "+entryBook.getLabel(); @@ -191,16 +183,18 @@ } return result; } - + public void getDataList(){ - List<FinancialPeriodEntryBook> results = new ArrayList<FinancialPeriodEntryBook>(); + List<FinancialPeriodEntryBook> results + = new ArrayList<FinancialPeriodEntryBook>(); List<FinancialPeriod> periods = new ArrayList<FinancialPeriod>(); List<EntryBook> entrybooks = new ArrayList<EntryBook>(); try { // get all fiscal period unblocked - List<FiscalPeriod> fiscalPeriods = fiscalPeriodService.getAllUnblockedFiscalPeriods(); + List<FiscalPeriod> fiscalPeriods + = fiscalPeriodService.getAllUnblockedFiscalPeriods(); for (FiscalPeriod fiscalPeriod : fiscalPeriods) { // get all financial period from unblocked fiscal period periods.addAll(fiscalPeriod.getFinancialPeriod()); @@ -210,7 +204,8 @@ // build the list with entrybook and financial period for (FinancialPeriod period : periods) { for (EntryBook entryB : entrybooks){ - FinancialPeriodEntryBook financialPeriodEntryBook = new FinancialPeriodEntryBook(period, entryB); + FinancialPeriodEntryBook financialPeriodEntryBook + = new FinancialPeriodEntryBook(period, entryB); results.add(financialPeriodEntryBook); } } @@ -225,9 +220,12 @@ cacheDataList=results; } - - public void blockFinancialPeriod(FiscalPeriod fiscalPeriod) throws LimaException { - fiscalPeriodService.blockFiscalPeriod(fiscalPeriod); + public void blockFinancialPeriod(FinancialPeriodEntryBook financialPeriodEntryBook) throws LimaException { + ClosedPeriodicEntryBook closedPeriodicEntryBook + = financialPeriodService.getClosedPeriodicEntryBook( + financialPeriodEntryBook.entryBook, + financialPeriodEntryBook.financialPeriod); + financialPeriodService.blockClosedPeriodicEntryBook(closedPeriodicEntryBook); fireTableDataChanged(); } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodView.jaxx 2010-05-12 17:06:24 UTC (rev 2896) @@ -30,10 +30,9 @@ <row> <cell fill="both" weightx="1" weighty="1"> <JScrollPane> - <org.jdesktop.swingx.JXTable id="financialPeriodTable" - model="{getModelFinancialPeriodTable()}" - highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))}" - rowHeight="24" + <org.chorem.lima.ui.financialperiod.FinancialPeriodTable + id="financialPeriodTable" rowHeight="24" + constructorParams="getHandler()" model="{getModelFinancialPeriodTable()}" selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" columnControlVisible="true" /> <javax.swing.ListSelectionModel javaBean="getFinancialPeriodTable().getSelectionModel()" @@ -45,7 +44,7 @@ <row> <cell> <JButton id="blockButton" text="lima.financialperiod.block" enabled="{isSelectedPeriod()}" - onActionPerformed="getHandler().blockFinancialPeriod()" /> + onActionPerformed="getHandler().blockFinancialPeriod();" /> </cell> </row> </Table> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialperiod/FinancialPeriodViewHandler.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -20,25 +20,13 @@ import static org.nuiton.i18n.I18n._; -import java.util.Calendar; -import java.util.Date; - import javax.swing.JOptionPane; -import org.apache.commons.lang.NotImplementedException; import org.jdesktop.swingx.JXTable; -import org.nuiton.util.DateUtils; 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.entity.EntryBook; import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FinancialPeriodImpl; -import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.ui.entrybook.model.EntryBookTableModel; -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; @@ -62,24 +50,28 @@ } public void blockFinancialPeriod() { - /* JXTable financialPeriodeTable = view.getFinancialPeriodTable(); + JXTable financialPeriodeTable = view.getFinancialPeriodTable(); int selectedRow = financialPeriodeTable.getSelectedRow(); FinancialPeriodTableModel model = (FinancialPeriodTableModel)view.getFinancialPeriodTable().getModel(); // blocked it try { - FinancialPeriod selectedFinancialPeriod = model.getFinancialPeriodAtRow(selectedRow); + FinancialPeriodEntryBook selectedFinancialPeriodEntryBook = model.getFinancialPeriodAtRow(selectedRow); int response = JOptionPane.showConfirmDialog(view, _("lima.question.financialperiod.blocked"), _("lima.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { - model.blockFinancialPeriod(selectedFinancialPeriod); + model.blockFinancialPeriod(selectedFinancialPeriodEntryBook); } } catch (LimaException ex) { if (log.isErrorEnabled()) { log.error("Can't block financialperiod", ex); } ErrorHelper.showErrorDialog("Can't block financialperiod", ex); - }*/ - } + } + } + + public FinancialPeriodView getView() { + return view; + } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2010-05-12 17:06:24 UTC (rev 2896) @@ -19,6 +19,7 @@ <FiscalPeriodViewHandler id="handler" javaBean="new FiscalPeriodViewHandler(this)" /> <Boolean id="selectedPeriod" javaBean="false" /> + <org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel id="modelFiscalPeriodTable"/> <script> <![CDATA[ @@ -38,10 +39,9 @@ <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.createSimpleStriping(new java.awt.Color(222,222,222))}" - rowHeight="24" + <org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTable + id="fiscalPeriodTable" rowHeight="24" + constructorParams="getHandler()" model="{getModelFiscalPeriodTable()}" selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" columnControlVisible="true" /> <javax.swing.ListSelectionModel javaBean="getFiscalPeriodTable().getSelectionModel()" Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -20,23 +20,15 @@ import static org.nuiton.i18n.I18n._; -import java.util.Calendar; -import java.util.Date; - import javax.swing.JOptionPane; -import org.apache.commons.lang.NotImplementedException; import org.jdesktop.swingx.JXTable; import org.nuiton.util.DateUtils; 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.entity.EntryBook; -import org.chorem.lima.entity.FinancialPeriod; -import org.chorem.lima.entity.FinancialPeriodImpl; + import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.ui.entrybook.model.EntryBookTableModel; import org.chorem.lima.ui.fiscalperiod.model.FiscalPeriodTableModel; import org.chorem.lima.ui.fiscalperiod.AddPeriod; import org.chorem.lima.ui.fiscalperiod.FiscalPeriodView; @@ -55,20 +47,20 @@ private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); - protected FiscalPeriodView view; + private FiscalPeriodView view; protected FiscalPeriodViewHandler(FiscalPeriodView view) { - this.view = view; + this.view=view; } public void addFiscalPeriod() { FiscalPeriodTableModel model = - (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); - AddPeriod addPeriodDialog = new AddPeriod(view); + AddPeriod addPeriodDialog = new AddPeriod(getView()); // jaxx don't call super() ? - addPeriodDialog.setLocationRelativeTo(view); + addPeriodDialog.setLocationRelativeTo(getView()); addPeriodDialog.setVisible(true); FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod(); @@ -80,7 +72,7 @@ fiscalPeriod.getEndDate()); int n = 0; if(nbMonth !=12){ - n = JOptionPane.showConfirmDialog(view, + n = JOptionPane.showConfirmDialog(getView(), _("lima.question.fiscalperiod.morethan12"), _("lima.question"), JOptionPane.YES_NO_OPTION, @@ -100,17 +92,17 @@ } public void blockFiscalPeriod() { - JXTable fiscalPeriodeTable = view.getFiscalPeriodTable(); + JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); int selectedRow = fiscalPeriodeTable.getSelectedRow(); FiscalPeriodTableModel model = - (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); // blocked it try { FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAtRow(selectedRow); int response = - JOptionPane.showConfirmDialog(view, + JOptionPane.showConfirmDialog(getView(), _("lima.question.fiscalperiod.blocked"), _("lima.question"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); @@ -129,7 +121,7 @@ /** just for debug, no release version */ public void removeAllFiscalPeriods(){ FiscalPeriodTableModel model = - (FiscalPeriodTableModel)view.getFiscalPeriodTable().getModel(); + (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); try { model.removeAllFiscalPeriods(); } catch (LimaException ex) { @@ -139,4 +131,8 @@ ErrorHelper.showErrorDialog(_("Can't delete all fiscal period")); } } + + public FiscalPeriodView getView() { + return view; + } } Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTable.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -0,0 +1,82 @@ +/* *##% 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.model; + +import java.awt.Color; +import java.awt.Component; +import java.text.SimpleDateFormat; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialPeriodService; +import org.chorem.lima.business.FiscalPeriodService; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.ClosedPeriodicEntryBook; +import org.chorem.lima.entity.ClosedPeriodicEntryBookImpl; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.ui.financialperiod.FinancialPeriodEntryBook; +import org.chorem.lima.ui.financialperiod.FinancialPeriodTableModel; +import org.chorem.lima.ui.financialperiod.FinancialPeriodViewHandler; +import org.chorem.lima.ui.fiscalperiod.FiscalPeriodViewHandler; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; +import org.jdesktop.swingx.decorator.Highlighter; +import org.jdesktop.swingx.decorator.HighlighterFactory; + +public class FiscalPeriodTable extends JXTable { + +private static final Log log = LogFactory.getLog(FinancialPeriodTableModel.class); + + protected FiscalPeriodViewHandler handler; + + protected FiscalPeriodTableModel model; + + protected FiscalPeriodService financialPeriodService; + + private Highlighter colorTransaction; + + public FiscalPeriodTable(FiscalPeriodViewHandler handler) { + + this.handler = handler; + model = this.handler.getView().getModelFiscalPeriodTable(); + financialPeriodService = LimaServiceFactory.getInstance().getFiscalPeriodService(); + addHighlighter(HighlighterFactory.createSimpleStriping(new java.awt.Color(222,222,222))); + //highlight financial financial transactions + addBlockColor(); + } + + protected void addBlockColor() { + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + FiscalPeriod fiscalPeriod = (FiscalPeriod) model.getElementAt(adapter.row); + // true if locked + return (fiscalPeriod.getLocked()); + } + }; + colorTransaction = + new ColorHighlighter(predicate, null, new Color(222,0,0)); + addHighlighter(colorTransaction); + } + +} 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/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/model/FiscalPeriodTableModel.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -20,12 +20,12 @@ import static org.nuiton.i18n.I18n._; -import java.util.Calendar; -import java.util.Date; +import java.text.SimpleDateFormat; import java.util.List; import javax.swing.table.AbstractTableModel; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodService; @@ -65,9 +65,10 @@ try { result = fiscalPeriodService.getAllFiscalPeriods().size(); } - catch (LimaException ex) { - // FIXME - ex.printStackTrace(); + catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't get row count",eee); + } } return result; } @@ -80,6 +81,20 @@ return 2; } + + public Object getElementAt(int row){ + + Object currentRow=null; + try { + currentRow = fiscalPeriodService.getAllFiscalPeriods().get(row); + } catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't get elenment at table",eee); + } + } + return currentRow; + } + /* * @see javax.swing.table.TableModel#getColumnName(int) */ @@ -129,30 +144,16 @@ try { periods = fiscalPeriodService.getAllFiscalPeriods(); FiscalPeriod fiscalPeriod = periods.get(rowIndex); - - String[] monthName = {_("lima.date.january"), _("lima.date.february"), - _("lima.date.march"), _("lima.date.april"), _("lima.date.may"), - _("lima.date.june"), _("lima.date.july"), _("lima.date.august"), - _("lima.date.september"), _("lima.date.october"), - _("lima.date.november"), _("lima.date.december")}; if (fiscalPeriod != null){ - Date date = fiscalPeriod.getBeginDate(); - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - String formatBeginDate = monthName[calendar.get(Calendar.MONTH)] - +" "+String.valueOf(calendar.get(Calendar.YEAR)); - date = fiscalPeriod.getEndDate(); - calendar.setTime(date); - String formatEndDate = monthName[calendar.get(Calendar.MONTH)] - +" "+String.valueOf(calendar.get(Calendar.YEAR)); - date = fiscalPeriod.getEndDate(); - - + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMMM yyyy"); + switch (columnIndex) { case 0: - result = formatBeginDate - + " - " + formatEndDate; + result = StringUtils.capitalize(simpleDateFormat. + format(fiscalPeriod.getBeginDate())) + + " - " + StringUtils.capitalize(simpleDateFormat. + format(fiscalPeriod.getEndDate())); break; case 1: if(fiscalPeriod.getLocked()){ @@ -167,9 +168,10 @@ - } catch (LimaException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + } catch (LimaException eee) { + if(log.isDebugEnabled()){ + log.debug("Can't update table",eee); + } } return result; 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-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/table/FinancialTransactionTableModel.java 2010-05-12 17:06:24 UTC (rev 2896) @@ -20,6 +20,7 @@ import static org.nuiton.i18n.I18n._; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; @@ -27,6 +28,7 @@ import javax.swing.table.AbstractTableModel; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -247,10 +249,11 @@ result = cacheDataList.get(row); if (result instanceof FinancialTransaction) { - FinancialTransaction currentRow = (FinancialTransaction)result; + FinancialTransaction currentRow = (FinancialTransaction)result; + switch (column) { case 0: - result = currentRow.getTransactionDate(); + result = currentRow.getTransactionDate(); break; case 1: result = null; // voucher 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-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-05-12 17:06:24 UTC (rev 2896) @@ -107,6 +107,7 @@ lima.entries.lettering= lima.entries.searchtransaction= lima.entrybook=Entry Book +lima.entrybook.add=Add Entry Book lima.entrybook.code= lima.entrybook.label= lima.entrybook.type= 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-05-12 12:04:45 UTC (rev 2895) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-05-12 17:06:24 UTC (rev 2896) @@ -59,7 +59,7 @@ lima.chartofaccounts.journal=Journaux lima.chartofaccounts.management=Plan comptable lima.chartofaccounts.subledgers=Plan tiers -lima.close=Ferm\uFFFD +lima.close=Ferm\u00E9 lima.closure=Cloture lima.closure.period.begin=P\u00E9riode de lima.closure.timespan.warning=Attention \: lorsque la p\u00E9riode est bloqu\u00E9e, il n'est plus possible d'ajouter, modifier et supprimer les entr\u00E9es comptables sur cette p\u00E9riode. @@ -105,6 +105,7 @@ lima.entries.lettering=Ajouter une lettre lima.entries.searchtransaction=Recherche les transactions lima.entrybook=Journal +lima.entrybook.add=Ajouter un journal lima.entrybook.code=Code lima.entrybook.label=Libelle lima.entrybook.type=Type @@ -155,7 +156,7 @@ lima.filter.less.than=Inf\u00E9rieur \u00E0 lima.filter.not.contains=Ne contient pas lima.filter.starts.with=Commence par -lima.financialperiod.block= +lima.financialperiod.block=Cloturer une p\u00E9riode lima.financialperiod.management=P\u00E9riodes comptables lima.find.transaction=Rechercher transaction lima.fiscalperiod.addFiscalPeriod=Nouvel exercice