branch feature/1169-Saisie_du_jour_uniquement created (now 46ab5ea)
This is an automated email from the git hooks/post-receive script. New change to branch feature/1169-Saisie_du_jour_uniquement in repository lima. See http://git.chorem.org/lima.git at 46ab5ea fixes #1169 Saisie du jour uniquement sur l'édition des entrées This branch includes the following new commits: new 46ab5ea fixes #1169 Saisie du jour uniquement sur l'édition des entrées The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 46ab5ea34c73a5bba753aa8557b66b81600abf68 Author: dcosse <japbiw74> Date: Thu Feb 19 16:08:46 2015 +0100 fixes #1169 Saisie du jour uniquement sur l'édition des entrées -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch feature/1169-Saisie_du_jour_uniquement in repository lima. See http://git.chorem.org/lima.git commit 46ab5ea34c73a5bba753aa8557b66b81600abf68 Author: dcosse <japbiw74> Date: Thu Feb 19 16:08:46 2015 +0100 fixes #1169 Saisie du jour uniquement sur l'édition des entrées --- .../ui/celleditor/DayLimaTableCellRenderer.java | 37 ++++++++ .../ui/common/FinancialTransactionTableModel.java | 9 +- .../lima/ui/financialtransaction/DayColumn.java | 100 +++++++++++++++++++++ .../FinancialTransactionDefaultTable.java | 5 ++ .../FinancialTransactionViewHandler.java | 2 + .../resources/i18n/lima-swing_en_GB.properties | 1 + .../resources/i18n/lima-swing_fr_FR.properties | 1 + 7 files changed, 149 insertions(+), 6 deletions(-) diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DayLimaTableCellRenderer.java b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DayLimaTableCellRenderer.java new file mode 100644 index 0000000..62da36f --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DayLimaTableCellRenderer.java @@ -0,0 +1,37 @@ +package org.chorem.lima.ui.celleditor; + +/* + * #%L + * Lima :: Swing + * %% + * Copyright (C) 2008 - 2013 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import java.text.DateFormat; +import java.util.Date; + +/** + * @author Sylvain Bavencoff <bavencoff@codelutin.com> + */ +public class DayLimaTableCellRenderer extends DefaultLimaTableCellRenderer { + + @Override + protected void setValue(Object value) { + super.setValue(value); + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java b/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java index 53c028c..cffc679 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java @@ -22,6 +22,7 @@ package org.chorem.lima.ui.common; * #L% */ +import jaxx.runtime.SwingUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.api.FinancialTransactionService; @@ -38,6 +39,7 @@ import org.chorem.lima.service.LimaServiceFactory; import org.chorem.lima.ui.financialtransaction.AccountColumn; import org.chorem.lima.ui.financialtransaction.CreditColumn; import org.chorem.lima.ui.financialtransaction.DateColumn; +import org.chorem.lima.ui.financialtransaction.DayColumn; import org.chorem.lima.ui.financialtransaction.DebitColumn; import org.chorem.lima.ui.financialtransaction.DescriptionColumn; import org.chorem.lima.ui.financialtransaction.VoucherColumn; @@ -62,7 +64,6 @@ public class FinancialTransactionTableModel extends TableModelWithGroup<Entry> { protected FinancialTransactionService financialTransactionService; public FinancialTransactionTableModel() { - setComparator(new EntryComparator()); financialTransactionService = @@ -71,15 +72,12 @@ public class FinancialTransactionTableModel extends TableModelWithGroup<Entry> { @Override protected void initColumn() { - - addColumn(new DateColumn()); + addColumn(new DayColumn()); addColumn(new VoucherColumn()); addColumn(new AccountColumn()); addColumn(new DescriptionColumn()); addColumn(new DebitColumn()); addColumn(new CreditColumn()); - - } public void setTransactions(List<FinancialTransaction> transactions) { @@ -116,7 +114,6 @@ public class FinancialTransactionTableModel extends TableModelWithGroup<Entry> { } } return result; - } /** diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DayColumn.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DayColumn.java new file mode 100644 index 0000000..17b328c --- /dev/null +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DayColumn.java @@ -0,0 +1,100 @@ +package org.chorem.lima.ui.financialtransaction; + +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.ui.common.AbstractColumn; +import org.chorem.lima.ui.common.FinancialTransactionTableModel; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +import static org.nuiton.i18n.I18n.t; + +/** + * @author David Cossé <cosse@codelutin.com> + */ +public class DayColumn extends AbstractColumn<FinancialTransactionTableModel> { + + protected SimpleDateFormat dateFormat = new SimpleDateFormat("dd"); + + public DayColumn(){ + super(Integer.class, t("lima.financialTransaction.day"), true); + } + + @Override + public Object getValueAt(int row) { + Integer result; + Entry entry = tableModel.get(row); + FinancialTransaction transaction = entry.getFinancialTransaction(); + if (row == 0 || tableModel.get(row - 1).getFinancialTransaction() != transaction) { + + result = Integer.valueOf(dateFormat.format(transaction.getTransactionDate())); // date + } else { + result = null; + } + return result; + } + + @Override + public boolean isCellEditable(int row) { + return row == 0 + || tableModel.get(row).getFinancialTransaction() != tableModel.get(row - 1).getFinancialTransaction(); + } + + @Override + public boolean setValueAt(Object value, int row) { + FinancialTransaction transaction = tableModel.get(row).getFinancialTransaction(); + boolean update = false; + if (value != null) { + // valid that the day is into month range (date not > to 1rst day of next month) + Date newDate = validAndGetNewDay(transaction, value); + if (newDate != null) { + Integer newDay = (Integer) value; + update = (transaction.getTransactionDate().compareTo(newDate) != 0); + if (update) { + transaction.setTransactionDate(newDate); + if (!tableModel.updateTransaction(transaction)) { + Date previousDate = transaction.getTransactionDate(); + transaction.setTransactionDate(previousDate); + update = false; + } + } + } + } + + return update; + } + + protected Date validAndGetNewDay(FinancialTransaction transaction, Object newDayValue) { + Date result = null; + if (newDayValue != null) { + try { + Integer newDay = (Integer) newDayValue; + // valid that the day is into month range (date not > to 1rst day of next month) + if (newDay > 0) { + + Date previousDate = transaction.getTransactionDate(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(previousDate); + calendar.add(Calendar.MONTH, +1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + Date maxDate = calendar.getTime(); + + calendar = Calendar.getInstance(); + calendar.setTime(previousDate); + calendar.set(Calendar.DAY_OF_MONTH, (Integer) newDayValue); + Date newDate = calendar.getTime(); + + if (newDate.before(maxDate)) { + result = newDate; + } + } + } catch (Exception e) { + // nothing to do + } + + } + return result; + } +} diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java index 625cf91..1177c8d 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java @@ -29,6 +29,7 @@ import org.chorem.lima.entity.EntryBook; import org.chorem.lima.ui.celleditor.AccountTableCellRenderer; import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer; import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer; +import org.chorem.lima.ui.celleditor.DayLimaTableCellRenderer; import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer; import org.chorem.lima.ui.celleditor.EntryBookTableCellRender; import org.chorem.lima.ui.celleditor.TableCellErrorDetector; @@ -66,6 +67,10 @@ public class FinancialTransactionDefaultTable<H> extends AbstractLimaTable<H> { renderer.setMandatory(true); setDefaultRenderer(Date.class, renderer); + renderer = new DayLimaTableCellRenderer(); + renderer.setMandatory(true); + setDefaultRenderer(Integer.class, renderer); + renderer = new BigDecimalTableCellRenderer(); renderer.setErrorDetector(errorDetector); setDefaultRenderer(BigDecimal.class, renderer); diff --git a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java index a4e54cd..ed57405 100644 --- a/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java +++ b/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java @@ -23,6 +23,7 @@ package org.chorem.lima.ui.financialtransaction; import com.google.common.collect.Maps; +import jaxx.runtime.SwingUtil; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -135,6 +136,7 @@ public class FinancialTransactionViewHandler implements ServiceListener, TableMo FinancialTransactionTable table = view.getFinancialTransactionTable(); table.getColumnModel().addColumnModelListener(this); + SwingUtil.fixTableColumnWidth(table, 0, 40); } protected void initShortCuts() { diff --git a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties index 0142911..ec5e45f 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties @@ -274,6 +274,7 @@ lima.financialStatements.check= lima.financialStatements.check.nothing= lima.financialStatements.check.warn= lima.financialTransaction.date= +lima.financialTransaction.day=Day lima.financialTransaction.nextFinancialPeriod= lima.financialTransaction.previousFinancialPeriod= lima.financialTransaction.remove.confirm= diff --git a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties index 7480da3..33f0270 100644 --- a/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties +++ b/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties @@ -286,6 +286,7 @@ lima.financialStatements.check=Vérification des comptes aux postes lima.financialStatements.check.nothing=Introuvable \: %s - %s lima.financialStatements.check.warn=Attention cette fonctionnalité n'est qu'une aide utilisateur.\n Certains comptes ne doivent pas être présent au bilan et compte de résultat.\n Il est donc normal que des comptes sont marqués comme introuvable. lima.financialTransaction.date=Date +lima.financialTransaction.day=Jour lima.financialTransaction.nextFinancialPeriod=Période suivante lima.financialTransaction.previousFinancialPeriod=Période précédente lima.financialTransaction.remove.confirm=Voulez-vous supprimer cette transaction? -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.
participants (1)
-
chorem.org scm