r3355 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/fiscalperiod resources/i18n
Author: echatellier Date: 2012-04-06 12:07:48 +0200 (Fri, 06 Apr 2012) New Revision: 3355 Url: http://chorem.org/repositories/revision/lima/3355 Log: Debut du refactoring de gestion des exercices (le report ?\195?\160 nouveau est encore a gerer et ?\195?\160 d?\195?\169placer dans les services). Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/package-info.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2012-04-06 10:07:48 UTC (rev 3355) @@ -22,84 +22,44 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JDialog modal="true" +<JDialog title="lima.ui.fiscalperiod.addfiscalperiodtitle" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> <import> - java.util.Date - java.util.Calendar - org.apache.commons.lang3.time.DateUtils - org.jdesktop.swingx.JXDatePicker - org.chorem.lima.entity.FiscalPeriodImpl org.chorem.lima.entity.FiscalPeriod - org.chorem.lima.business.LimaException - org.chorem.lima.business.monitorable.FiscalPeriodServiceMonitorable - org.chorem.lima.service.LimaServiceFactory - org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel </import> + + <FiscalPeriodViewHandler id='handler' initializer='getContextValue(FiscalPeriodView.class,JAXXUtil.PARENT).getHandler()'/> + <FiscalPeriodTableModel id="modelFiscalPeriodTable"/> + + <FiscalPeriod id="period" javaBean="new org.chorem.lima.entity.FiscalPeriodImpl()"/> + <script> <![CDATA[ - - getRootPane().setDefaultButton(okButton); - - protected FiscalPeriodServiceMonitorable fiscalPeriodService = - LimaServiceFactory.getService( - FiscalPeriodServiceMonitorable.class); - - // set begin date picker - Date endDate = null; - Calendar calendarBegin = Calendar.getInstance(); - // set begindate to JAN 1 - 0:00.000 of this years - Date beginDate = calendarBegin.getTime(); - beginDate = DateUtils.truncate(beginDate, Calendar.DATE); - try { - FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod(); - if (result != null){ - beginDate = result.getEndDate(); - } + public void $afterCompleteSetup() { + getHandler().init(this); } - catch (LimaException eee){ - if(log.isDebugEnabled()){ - log.debug("Can't get last fiscal period", eee); - } - } - beginDate = DateUtils.addDays(beginDate, 1); - getBeginDatePicker().setDate(beginDate); - - // get end date - Calendar calendarEnd = Calendar.getInstance(); - endDate = DateUtils.addYears(beginDate, 1); - endDate = DateUtils.addDays(endDate, -1); - getEndDatePicker().setDate(endDate); - protected void performOk() { - if (period == null) { - // FIXME never ever use IMPL !!! - setPeriod(new FiscalPeriodImpl()); - } getPeriod().setBeginDate(beginDatePicker.getDate()); getPeriod().setEndDate(endDatePicker.getDate()); dispose(); } - + protected void performCancel() { setPeriod(null); dispose(); } - ]]> - </script> + ]]></script> - <FiscalPeriod id="period" javaBean="null"/> - <Table fill="both"> <row> <cell> <JLabel text="lima.common.begindate"/> </cell> <cell> - <JXDatePicker id="beginDatePicker"/> + <org.jdesktop.swingx.JXDatePicker id="beginDatePicker"/> </cell> </row> <row> @@ -107,7 +67,7 @@ <JLabel text="lima.common.enddate"/> </cell> <cell> - <JXDatePicker id="endDatePicker"/> + <org.jdesktop.swingx.JXDatePicker id="endDatePicker"/> </cell> </row> <row> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java 2012-04-06 10:07:48 UTC (rev 3355) @@ -0,0 +1,62 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.chorem.lima.ui.fiscalperiod; + +import java.awt.Component; + +import javax.swing.DefaultListCellRenderer; +import javax.swing.JList; + +import org.chorem.lima.entity.EntryBook; + +/** + * EntryBook renderer for fiscal period retaining earning list. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class EntryBookListRenderer extends DefaultListCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -9089182547408397051L; + + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + + EntryBook entryBook = (EntryBook)value; + Object newValue = entryBook; + if (entryBook != null) { + newValue = entryBook.getCode() + " - " + entryBook.getLabel(); + } + return super.getListCellRendererComponent(list, value, index, isSelected, + cellHasFocus); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EntryBookListRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2012-04-06 10:07:48 UTC (rev 3355) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2008 - 2010 CodeLutin + * Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -39,6 +39,23 @@ import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import javax.swing.table.TableModel; + +/** + * Fiscal period table add support for JXTable. + * + * Including: + * <ul> + * <li>Locked period red highlight + * <li> + * </ul> + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ public class FiscalPeriodTable extends JXTable implements KeyListener, MouseListener { @@ -50,26 +67,28 @@ private Highlighter colorTransaction; - public FiscalPeriodTable(FiscalPeriodViewHandler handler) { - + public FiscalPeriodTable(FiscalPeriodTableModel model) { + super(model); + this.model = model; this.handler = handler; addKeyListener(this); addMouseListener(this); - model = this.handler.getView().getModelFiscalPeriodTable(); - - //highlight financial financial transactions + // highlight financial financial transactions addBlockColor(); } + /** + * Highlight locked period in RED. + */ 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 + FiscalPeriod fiscalPeriod = model.getFiscalPeriodAt(adapter.row); return fiscalPeriod.getLocked(); } }; Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2012-04-06 10:07:48 UTC (rev 3355) @@ -25,34 +25,18 @@ package org.chorem.lima.ui.fiscalperiod; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.business.LimaException; -import org.chorem.lima.business.ServiceListener; -import org.chorem.lima.business.ejbinterface.FinancialTransactionService; -import org.chorem.lima.business.ejbinterface.FiscalPeriodService; -import org.chorem.lima.business.monitorable.FinancialTransactionServiceMonitorable; -import org.chorem.lima.business.monitorable.FiscalPeriodServiceMonitorable; -import org.chorem.lima.business.monitorable.ImportServiceMonitorable; -import org.chorem.lima.business.utils.FiscalPeriodComparator; -import org.chorem.lima.entity.FinancialTransaction; -import org.chorem.lima.entity.FiscalPeriod; -import org.chorem.lima.service.LimaServiceFactory; -import org.chorem.lima.util.ErrorHelper; -import org.nuiton.util.Resource; +import static org.nuiton.i18n.I18n._; -import javax.swing.JFrame; -import javax.swing.JOptionPane; -import javax.swing.table.AbstractTableModel; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import static org.nuiton.i18n.I18n._; +import javax.swing.table.AbstractTableModel; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.entity.FiscalPeriod; + /** - * TODO add comment here. + * Modele de Fiscal period (rendu de list) * * @author chatellier * @version $Revision$ @@ -60,62 +44,24 @@ * Last update : $Date$ * By : $Author$ */ -public class FiscalPeriodTableModel extends AbstractTableModel implements ServiceListener { +public class FiscalPeriodTableModel extends AbstractTableModel { /** serialVersionUID. */ private static final long serialVersionUID = 77027335135838258L; - private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class); + protected List<FiscalPeriod> fiscalPeriods; - protected FiscalPeriodService fiscalPeriodService; - - protected FinancialTransactionService financialTransactionService; - - /** data cache */ - protected List<?> cacheDataList; - - public FiscalPeriodTableModel() { - fiscalPeriodService = - LimaServiceFactory.getService( - FiscalPeriodServiceMonitorable.class); - LimaServiceFactory.addServiceListener(fiscalPeriodService, this); - LimaServiceFactory.addServiceListener(ImportServiceMonitorable.class, this); - financialTransactionService = - LimaServiceFactory.getService( - FinancialTransactionServiceMonitorable.class); - LimaServiceFactory.addServiceListener(financialTransactionService, this); - cacheDataList = null; - } - - protected List<Object> getDataList() { - List<Object> results = new ArrayList<Object>(); - try { - List<FiscalPeriod> fiscalPeriod = - fiscalPeriodService.getAllFiscalPeriods(); - Collections.sort(fiscalPeriod, new FiscalPeriodComparator()); - results.addAll(fiscalPeriod); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't update model", eee); - } - ErrorHelper.showErrorDialog(_("lima.fiscalperiod.listerror"), eee); - } - return results; - } - - public void refresh() { - cacheDataList = getDataList(); + public void setFiscalPeriods(List<FiscalPeriod> fiscalPeriods) { + this.fiscalPeriods = fiscalPeriods; fireTableDataChanged(); } @Override public int getRowCount() { int result = 0; - - if (cacheDataList != null) { - result = cacheDataList.size(); + if (fiscalPeriods != null) { + result = fiscalPeriods.size(); } - return result; } @@ -124,16 +70,9 @@ return 2; } - - public Object getElementAt(int row) { - - Object currentRow = null; - - if (cacheDataList != null) { - currentRow = cacheDataList.get(row); - } - - return currentRow; + public FiscalPeriod getFiscalPeriodAt(int row) { + FiscalPeriod result = fiscalPeriods.get(row); + return result; } @Override @@ -143,10 +82,10 @@ switch (columnIndex) { case 0: - result = _("lima.table.fiscalperiod"); + result = _("lima.ui.fiscalperiod.fiscalperiod"); break; case 1: - result = _("lima.table.closure"); + result = _("lima.ui.fiscalperiod.closure"); break; } @@ -154,27 +93,14 @@ } @Override - public Class<?> getColumnClass(int columnIndex) { - // both String - return String.class; - } - - - @Override - public boolean isCellEditable(int rowIndex, int columnIndex) { - return false; - } - - @Override public Object getValueAt(int rowIndex, int columnIndex) { Object result = "n/a"; - List<?> periods; - periods = cacheDataList; - FiscalPeriod fiscalPeriod = (FiscalPeriod) periods.get(rowIndex); + FiscalPeriod fiscalPeriod = getFiscalPeriodAt(rowIndex); if (fiscalPeriod != null) { + // FIXME echatellier 20120405 i18n problem (hard coded) SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy"); switch (columnIndex) { @@ -186,9 +112,9 @@ break; case 1: if (fiscalPeriod.getLocked()) { - result = _("lima.common.closed"); + result = _("lima.ui.fiscalperiod.closed"); } else { - result = _("lima.common.open"); + result = _("lima.ui.fiscalperiod.open"); } break; } @@ -197,35 +123,14 @@ return result; } - public FiscalPeriod getFiscalPeriodAtRow(int row) throws LimaException { - FiscalPeriod fiscalPeriod; - fiscalPeriod = (FiscalPeriod) cacheDataList.get(row); - return fiscalPeriod; + public void addFiscalPeriod(FiscalPeriod fiscalPeriod) { + fiscalPeriods.add(fiscalPeriod); + int row = fiscalPeriods.indexOf(fiscalPeriod); + fireTableRowsInserted(row, row); } - /** - * @param period - * @throws LimaException - */ - public void addFiscalPeriod(FiscalPeriod period) throws LimaException { - - try { - // Calling fiscal period service - fiscalPeriodService.createFiscalPeriod(period); - //on recharge la liste - cacheDataList = getDataList(); - int row = getDataList().indexOf(period); - fireTableRowsInserted(row, row); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't create FiscalPeriod", eee); - } - ErrorHelper.showErrorDialog(_("lima.fiscalperiod.creationerror"), eee); - } - } - - public void blockFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { - List<FinancialTransaction> financialTransactionsUnbal = + public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException { + /*List<FinancialTransaction> financialTransactionsUnbal = financialTransactionService.getAllInexactFinancialTransactions(fiscalPeriod); if (financialTransactionsUnbal.size() > 0) { JFrame f = new JFrame(); @@ -239,14 +144,8 @@ } else { fiscalPeriodService.blockFiscalPeriod(fiscalPeriod); refresh(); - } + }*/ + int row = fiscalPeriods.indexOf(fiscalPeriod); + fireTableRowsInserted(row, row); } - - @Override - public void notifyMethod(String serviceName, String methodeName) { - //refresh on import datas - if (methodeName.contains("importAll")) { - refresh(); - } - } } 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 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2012-04-06 10:07:48 UTC (rev 3355) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2008 - 2010 CodeLutin + Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -29,29 +29,24 @@ javax.swing.ListSelectionModel org.chorem.lima.entity.FiscalPeriod org.chorem.lima.entity.FinancialPeriod - org.chorem.lima.ui.fiscalperiod.FiscalPeriodTable - org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel </import> - <FiscalPeriodViewHandler id="handler" - javaBean="new FiscalPeriodViewHandler(this)"/> + + <FiscalPeriodViewHandler id="handler" constructorParams="this"/> <Boolean id="selectedPeriod" javaBean="false"/> - <script> - <![CDATA[ + <script><![CDATA[ void $afterCompleteSetup() { - getHandler().refresh(); + getHandler().init(); } - - ]]> - </script> + ]]></script> + <row> <cell fill="both" weightx="1" weighty="1" rows="5"> <JScrollPane> - <FiscalPeriodTableModel - id="modelFiscalPeriodTable"/> + <FiscalPeriodTableModel id="fiscalPeriodTableModel" /> <FiscalPeriodTable id="fiscalPeriodTable" sortable="false" rowHeight="24" - constructorParams="getHandler()" model="{getModelFiscalPeriodTable()}" + constructorParams="getFiscalPeriodTableModel()" selectionMode="{ListSelectionModel.SINGLE_INTERVAL_SELECTION}" columnControlVisible="true"/> <ListSelectionModel 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 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2012-04-06 10:07:48 UTC (rev 3355) @@ -25,9 +25,24 @@ package org.chorem.lima.ui.fiscalperiod; +import static org.nuiton.i18n.I18n._; + +import java.math.BigDecimal; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import javax.swing.JOptionPane; + +import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.LimaRuntimeException; +import org.chorem.lima.business.ServiceListener; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.business.ejbinterface.FiscalPeriodService; import org.chorem.lima.business.monitorable.FinancialTransactionServiceMonitorable; import org.chorem.lima.business.monitorable.FiscalPeriodServiceMonitorable; import org.chorem.lima.entity.Entry; @@ -40,15 +55,8 @@ import org.jdesktop.swingx.JXTable; import org.nuiton.util.DateUtil; -import javax.swing.JOptionPane; -import java.math.BigDecimal; -import java.util.Collection; -import java.util.List; - -import static org.nuiton.i18n.I18n._; - /** - * TODO add comment here. + * Handler pour la gestion des exercices (creation/fermeture). * * @author chatellier * @version $Revision$ @@ -56,86 +64,133 @@ * Last update : $Date$ * By : $Author$ */ -public class FiscalPeriodViewHandler { +public class FiscalPeriodViewHandler implements ServiceListener { private static final Log log = LogFactory.getLog(FiscalPeriodViewHandler.class); private FiscalPeriodView view; - protected FiscalPeriodTable table; - - protected FiscalPeriodTableModel tableModel; - /** Service. */ - protected FiscalPeriodServiceMonitorable fiscalPeriodService; + protected FiscalPeriodService fiscalPeriodService; - protected FinancialTransactionServiceMonitorable financialTransactionService; + protected FinancialTransactionService financialTransactionService; - protected FiscalPeriodViewHandler(FiscalPeriodView view) { + /** + * Constructor. + * + * @param view managed view + */ + public FiscalPeriodViewHandler(FiscalPeriodView view) { this.view = view; - fiscalPeriodService = - LimaServiceFactory.getService( - FiscalPeriodServiceMonitorable.class); + fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodServiceMonitorable.class); + financialTransactionService = LimaServiceFactory.getService(FinancialTransactionServiceMonitorable.class); - financialTransactionService = - LimaServiceFactory.getService( - FinancialTransactionServiceMonitorable.class); + LimaServiceFactory.addServiceListener(FiscalPeriodServiceMonitorable.class, this); } + public void init() { + loadAllFiscalPeriod(); + } + + /** + * Reload fiscal period list from service and update ui. + */ + public void loadAllFiscalPeriod() { + try { + List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods(); + view.getFiscalPeriodTableModel().setFiscalPeriods(periods); + } catch (LimaException ex) { + throw new LimaRuntimeException("Cant get fiscal perdiods", ex); + } + } + + /** + * Display add period form and perform add. + */ public void addFiscalPeriod() { - FiscalPeriodTableModel model = - (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); + FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTable().getModel(); - AddPeriod addPeriodDialog = new AddPeriod(getView()); - // jaxx don't call super() ? - addPeriodDialog.setLocationRelativeTo(getView()); + AddPeriod addPeriodDialog = new AddPeriod(view); + addPeriodDialog.setLocationRelativeTo(view); addPeriodDialog.setVisible(true); FiscalPeriod fiscalPeriod = addPeriodDialog.getPeriod(); // null = cancel if (fiscalPeriod != null) { //check if fiscalperiod have 12 months, ask a confirmation - int nbMonth = - DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), - fiscalPeriod.getEndDate()); - int n = 0; + int nbMonth = DateUtil.getDifferenceInMonths(fiscalPeriod.getBeginDate(), + fiscalPeriod.getEndDate()); + int response = JOptionPane.NO_OPTION; if (nbMonth != 12) { - n = JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.morethan12"), - _("lima.common.question"), - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.addfiscalperiod.morethan12"), + _("lima.ui.fiscalperiod.addfiscalperiodtitle"), + JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); } - if (n == JOptionPane.YES_OPTION || nbMonth == 11) { + // FIXME echatellier 20120405 je ne comprend pas le "|| nbMonth == 11" + if (response == JOptionPane.YES_OPTION || nbMonth == 11) { try { + fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod); model.addFiscalPeriod(fiscalPeriod); - } catch (LimaException eee) { - if (log.isErrorEnabled()) { - log.error("Can't add fiscal period", eee); - } - DialogHelper.showErrorMessageDialog(view, eee); + } catch (LimaException ex) { + throw new LimaRuntimeException("Can't add fiscal period", ex); } } } } + /** + * Init add period view. + * + * @param addPeriod view to init + */ + public void init(AddPeriod addPeriod) { + addPeriod.getRootPane().setDefaultButton(addPeriod.getOkButton()); + + // set begin date picker + Date endDate = null; + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.DATE); + try { + FiscalPeriod result = fiscalPeriodService.getLastFiscalPeriod(); + if (result != null){ + beginDate = result.getEndDate(); + } + } + catch (LimaException eee){ + if(log.isDebugEnabled()){ + log.debug("Can't get last fiscal period", eee); + } + } + beginDate = DateUtils.addDays(beginDate, 1); + addPeriod.getBeginDatePicker().setDate(beginDate); + + // get end date + endDate = DateUtils.addYears(beginDate, 1); + endDate = DateUtils.addDays(endDate, -1); + addPeriod.getEndDatePicker().setDate(endDate); + } + + /** + * Block selected fiscal period after user confirmation. + */ public void blockFiscalPeriod() { - JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); + JXTable fiscalPeriodeTable = view.getFiscalPeriodTable(); int selectedRow = fiscalPeriodeTable.getSelectedRow(); - FiscalPeriodTableModel model = - (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); - // blocked it + FiscalPeriodTableModel model = view.getFiscalPeriodTableModel(); + FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow); + try { - FiscalPeriod selectedFiscalPeriod = - model.getFiscalPeriodAtRow(selectedRow); + //check if the user want to block the fiscal year - int response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.blocked"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.confirmation"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.WARNING_MESSAGE); if (response == JOptionPane.YES_OPTION) { //use to tell if the user wants to create a new fiscal year boolean newyear = false; @@ -144,19 +199,22 @@ newyear = true; //two are open } else { //check if the user wants to create a new fiscal year - response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.newyear"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - //create a new fiscal year + response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.newyear"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); + // create a new fiscal year if (response == JOptionPane.YES_OPTION) { addFiscalPeriod(); newyear = true; } } + + // FIXME report a nouveau et bloquage en une seule opération + // transactionnelle addRetainedEarnings(selectedFiscalPeriod, newyear); - model.blockFiscalPeriod(selectedFiscalPeriod); + selectedFiscalPeriod = fiscalPeriodService.blockFiscalPeriod(selectedFiscalPeriod); + model.updateFiscalPeriod(selectedFiscalPeriod); } } catch (LimaException eee) { if (log.isErrorEnabled()) { @@ -167,16 +225,15 @@ } /** - * Sets EntryBook and Date to use + * Report à nouveau. * + * @deprecated a déplacer en partie en metier * @param selectedFiscalPeriod * @param newyear */ + @Deprecated public void addRetainedEarnings(FiscalPeriod selectedFiscalPeriod, boolean newyear) { -// JXTable fiscalPeriodeTable = getView().getFiscalPeriodTable(); -// int selectedRow = fiscalPeriodeTable.getSelectedRow(); -// FiscalPeriodTableModel model = -// (FiscalPeriodTableModel)getView().getFiscalPeriodTable().getModel(); + try { boolean found = false; List<FinancialTransaction> financialTransactionsList = @@ -199,11 +256,10 @@ //report if they are at least one transaction to be report if (found) { //check if the user wants to report datas - int response = - JOptionPane.showConfirmDialog(getView(), - _("lima.charts.fiscalperiod.question.addretainedearnings"), - _("lima.common.question"), JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); + int response = JOptionPane.showConfirmDialog(view, + _("lima.ui.fiscalperiod.block.addretainedearnings"), + _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE); //ask user for the entrybook to use for retained earnings if (response == JOptionPane.YES_OPTION) { //Sets EntryBook @@ -230,13 +286,12 @@ } } - - public FiscalPeriodView getView() { - return view; + + @Override + public void notifyMethod(String serviceName, String methodeName) { + //refresh on import datas + if (methodeName.contains("importAll")) { + loadAllFiscalPeriod(); + } } - - public void refresh() { - tableModel = (FiscalPeriodTableModel) getView().getFiscalPeriodTable().getModel(); - tableModel.refresh(); - } } Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/RetainedEarningsEntryBookForm.jaxx 2012-04-06 10:07:48 UTC (rev 3355) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2008 - 2011 CodeLutin + Copyright (C) 2008 - 2012 CodeLutin, Chatellier Eric %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -22,22 +22,21 @@ <http://www.gnu.org/licenses/gpl-3.0.html>. #L% --> -<JDialog modal="true" +<JDialog title="lima.ui.fiscalperiod.block.retainedearningstitle" modal="true" defaultCloseOperation="{JDialog.DO_NOTHING_ON_CLOSE}" onWindowClosing="performCancel();"> <import> javax.swing.text.Document org.chorem.lima.entity.EntryBook - org.chorem.lima.ui.LimaRendererUtil org.chorem.lima.ui.combobox.EntryBookComboBoxModel </import> + <EntryBook id="entryBook" javaBean="null"/> <Boolean id="addState" javaBean='true'/> <script> <![CDATA[ - getRootPane().setDefaultButton(okButton); /** @@ -96,7 +95,7 @@ <EntryBookComboBoxModel id="modelEntryBookComboBox"/> <JComboBox id="entryBookComboBox" model="{getModelEntryBookComboBox()}" - renderer="{LimaRendererUtil.newDecoratorListCellRenderer(EntryBook.class)}" + renderer="{new EntryBookListRenderer()}" editable="false" onItemStateChanged="getEntryBook().setCode(((EntryBook)getEntryBookComboBox().getSelectedItem()).getCode()); getEntryBook().setLabel(((EntryBook)getEntryBookComboBox().getSelectedItem()).getLabel())"/> </cell> Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/package-info.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/package-info.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/package-info.java 2012-04-06 10:07:48 UTC (rev 3355) @@ -0,0 +1,31 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ +/** + * Gestion des exercices. + * + * Onglet presentant la liste des exercices, avec option de création et de + * cloture avec option de report à nouveau. + */ +package org.chorem.lima.ui.fiscalperiod; Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/package-info.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2012-04-06 10:07:48 UTC (rev 3355) @@ -293,6 +293,18 @@ lima.ui.entrybook.label= lima.ui.entrybook.remove= lima.ui.entrybook.update= +lima.ui.fiscalperiod.addfiscalperiod.morethan12= +lima.ui.fiscalperiod.addfiscalperiodtitle= +lima.ui.fiscalperiod.addperiodtitle= +lima.ui.fiscalperiod.block.addretainedearnings= +lima.ui.fiscalperiod.block.confirmation= +lima.ui.fiscalperiod.block.newyear= +lima.ui.fiscalperiod.block.retainedearningstitle= +lima.ui.fiscalperiod.block.title= +lima.ui.fiscalperiod.closed= +lima.ui.fiscalperiod.closure= +lima.ui.fiscalperiod.fiscalperiod= +lima.ui.fiscalperiod.open= lima.ui.importexport.importcsv= lima.ui.importexport.importebp= lima.vatreport.listerror=Can't get entries list Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-04-05 14:09:35 UTC (rev 3354) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2012-04-06 10:07:48 UTC (rev 3355) @@ -292,6 +292,18 @@ lima.ui.entrybook.label=Libellé lima.ui.entrybook.remove=Supprimer lima.ui.entrybook.update=Modifier +lima.ui.fiscalperiod.addfiscalperiod.morethan12=La période sélectionnée n'est pas de 12 mois, voulez-vous continuer ? +lima.ui.fiscalperiod.addfiscalperiodtitle=Nouvel exercice +lima.ui.fiscalperiod.addperiodtitle= +lima.ui.fiscalperiod.block.addretainedearnings=Reporter à nouveau? +lima.ui.fiscalperiod.block.confirmation=Ètes vous sûre de vouloir clôturer cette période ? Cette action est irréversible \! +lima.ui.fiscalperiod.block.newyear=Voulez vous créer un nouvel exercice? +lima.ui.fiscalperiod.block.retainedearningstitle=Report à nouveau +lima.ui.fiscalperiod.block.title=Cloture de l'excercice +lima.ui.fiscalperiod.closed=Cloturé +lima.ui.fiscalperiod.closure=Cloture +lima.ui.fiscalperiod.fiscalperiod=Exercice +lima.ui.fiscalperiod.open=Ouvert lima.ui.importexport.importcsv=Import/Export CSV lima.ui.importexport.importebp=Import/Export EBP lima.vatreport.listerror=Erreur lors de la récupération des données de la liste
participants (1)
-
echatellier@users.chorem.org