Lima-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
December 2013
- 1 participants
- 9 discussions
r3726 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: common financialtransaction lettering
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 17:45:49 +0100 (Tue, 31 Dec 2013)
New Revision: 3726
Url: http://chorem.org/projects/lima/repository/revisions/3726
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/VoucherColumn.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -28,6 +28,8 @@
public AbstractLimaTable(H handler) {
this.handler = handler;
+ lineRenderer = new LineRenderer();
+
setShowHorizontalLines(true);
setShowVerticalLines(true);
setGridColor(new Color(232, 232, 246));
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -61,7 +61,7 @@
public void addAll(Collection<E> values) {
int row = this.values.size();
this.values.addAll(values);
- fireTableRowsInserted(row, row + values.size() -1);
+ fireTableRowsInserted(row, row + values.size() - 1);
sort();
}
@@ -69,6 +69,10 @@
values.clear();
}
+ public List<E> getValues() {
+ return values;
+ }
+
public void remove(E value) {
int row = indexOf(value);
values.remove(value);
@@ -167,5 +171,4 @@
fireTableCellUpdated(row, column);
}
}
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -9,7 +9,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public abstract class LineRenderer extends DefaultLimaTableCellRenderer {
+public class LineRenderer extends DefaultLimaTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -25,7 +25,6 @@
*/
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
import org.chorem.lima.ui.celleditor.StringTableCellEditor;
import org.chorem.lima.ui.common.DefaultColumn;
import org.chorem.lima.ui.common.FinancialTransactionTableModel;
@@ -38,7 +37,6 @@
public class LetterColumn extends DefaultColumn<FinancialTransactionTableModel> {
public LetterColumn() {
- renderer = new EntryTableCellRenderer();
editor = new StringTableCellEditor();
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AccountColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AccountColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/AccountColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,58 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Account;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class AccountColumn extends DefaultColumn<LetteringTableModel> {
+
+ public AccountColumn() {
+ renderer = new AccountTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return Account.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.account");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getAccount();
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/CreditColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/CreditColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/CreditColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,59 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class CreditColumn extends DefaultColumn<LetteringTableModel> {
+
+ public CreditColumn() {
+ renderer = new BigDecimalTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return BigDecimal.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.credit");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DateColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DateColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,35 @@
+package org.chorem.lima.ui.lettering;
+
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DateColumn extends DefaultColumn<LetteringTableModel> {
+
+ public DateColumn() {
+ renderer = new DateLimaTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return Date.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.date");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getFinancialTransaction().getTransactionDate();
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DebitColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DebitColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DebitColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,59 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import java.math.BigDecimal;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DebitColumn extends DefaultColumn<LetteringTableModel> {
+
+ public DebitColumn() {
+ renderer = new BigDecimalTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return BigDecimal.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.debit");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
+ }
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DescriptionColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DescriptionColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/DescriptionColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,53 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DescriptionColumn extends DefaultColumn<LetteringTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.financialtransaction.description");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getDescription();
+ }
+
+}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetterColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,52 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LetterColumn extends DefaultColumn<LetteringTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.letter");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getLettering();
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -25,101 +25,21 @@
package org.chorem.lima.ui.lettering;
-import org.chorem.lima.entity.Account;
-import org.chorem.lima.entity.EntryBook;
-import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
-import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
-import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
-import org.jdesktop.swingx.JXTable;
+import org.chorem.lima.ui.common.AbstractLimaTable;
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.math.BigDecimal;
-import java.util.Date;
-
/**
* Table des transaction qui ajoute des comportement (keys).
*
* @author jpepin
*/
-public class LetteringTable extends JXTable {
+public class LetteringTable extends AbstractLimaTable<LetteringViewHandler> {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected final LetteringViewHandler handler;
+ public LetteringTable(LetteringViewHandler handler) {
+ super(handler);
- public LetteringTable(LetteringTableModel letteringTableModel, final LetteringViewHandler handler) {
- super(letteringTableModel);
-
- this.handler = handler;
-
- //To block reaction of the dual key 'ctrl+a' (Selection of all lines)
- InputMap inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- ActionMap actionMap = getActionMap();
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none");
-
- // add action on Ctrl + L
- String binding = "lettering";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.addLetter();
- }
- });
-
- // add action on Ctrl + Delete
- binding = "un-lettering";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.removeLetter();
- }
- });
-
- // add action on Ctrl + B
- binding = "balance";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.roundAndCreateEntry();
- }
- });
-
- // refresh
- binding = "refresh";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.updateAllEntries();
- }
- });
-
-
-
- //Get new date editor
- setDefaultEditor(Date.class, new DateTableCellEditor());
-
- //Get new account editor
- setDefaultEditor(String.class, new DefaultCellEditor(new JTextField()));
-
- //Get new entry book editor
- setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor());
- //Get new account editor
- setDefaultEditor(Account.class, new AccountTableCellEditor());
-
- //Get new amount editor
- setDefaultEditor(BigDecimal.class, new BigDecimalTableCellEditor());
- //Get new BigDecimal renderer
- setDefaultRenderer(BigDecimal.class, new BigDecimalTableCellRenderer());
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTableModel.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -25,230 +25,30 @@
package org.chorem.lima.ui.lettering;
-import org.chorem.lima.LimaContext;
-import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
-import org.nuiton.util.decorator.Decorator;
-import org.nuiton.util.decorator.DecoratorProvider;
+import org.chorem.lima.ui.common.AbstractLimaTableModel;
-import javax.swing.table.AbstractTableModel;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
/**
* Basic transaction table model.
* <p/>
- * Le modele est filtré sur {@link #selectedBeginDate} et
- * {@link #selectedEndDate} (montée en charge !).
*
* @author ore
* @author chatellier
*/
-public class LetteringTableModel extends AbstractTableModel{
+public class LetteringTableModel extends AbstractLimaTableModel<Entry> {
/** serialVersionUID. */
private static final long serialVersionUID = 1L;
- /** Begin Date. */
- protected Date selectedBeginDate;
-
- /** EndDate. */
- protected Date selectedEndDate;
-
- protected List<Entry> entries;
- protected List<Date> datesEntree;
- protected List<String> entryBooks;
-
- /**
- * To decorate account objects.
- */
- protected final Decorator<Account> accountDecorator;
-
- public LetteringTableModel() {
- DecoratorProvider decoratorProvider =
- LimaContext.get().getDecoratorProvider();
- accountDecorator = decoratorProvider.getDecoratorByType(Account.class);
- }
-
- public List<Entry> getEntries(){
- return entries;
- }
-
- public Date getDateEntree(int row) {
- return datesEntree.get(row);
- }
-
- public Integer getIndexOfEntry(Entry entrySearch){
- return entries.indexOf(entrySearch);
- }
-
- public int getNumberOfEntries(){
- return entries.size();
- }
-
- public void updateEntries(List<Entry> entries,List<Date> datesEntree, List<String> entryBooks) {
-
- this.entries = entries;
- setDate(datesEntree);
- setJournal(entryBooks);
- fireTableDataChanged();
- }
-
- protected void setDate(List<Date> datesEntree){
- this.datesEntree=datesEntree;
- }
-
- protected void setJournal(List<String> entryBooks){
- this.entryBooks = entryBooks;
- }
-
@Override
- public int getColumnCount() {
- return 7;
+ protected void initColumn() {
+ addColumn(new DateColumn());
+ addColumn(new AccountColumn());
+ addColumn(new VoucherColumn());
+ addColumn(new DescriptionColumn());
+ addColumn(new LetterColumn());
+ addColumn(new DebitColumn());
+ addColumn(new CreditColumn());
}
- public Entry getEntryAt(int row) {
- if (row == -1) {
- return null;
- }
-
- return entries.get(row);
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
-
- Class<?> result = String.class;
-
- switch (column) {
- case 0:
- result = Date.class;
- break;
- case 1:
- result = String.class;
- break;
- case 2:
- result = String.class;
- break;
- case 3:
- result = Account.class;
- break;
- case 4:
- result = String.class;
- break;
- case 5:
- result = BigDecimal.class;
- break;
- case 6:
- result = BigDecimal.class;
- break;
- }
-
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
-
- switch (column) {
- case 0:
- result = _("lima.table.date");
- break;
- case 1:
- result = _("lima.table.account");
- break;
- case 2:
- result = _("lima.table.voucher");
- break;
- case 3:
- result = _("lima.table.description");
- break;
- case 4:
- result = _("lima.table.letter");
- break;
- case 5:
- result = _("lima.table.debit");
- break;
- case 6:
- result = _("lima.table.credit");
- break;
- }
-
- return result;
- }
-
- @Override
- public int getRowCount() {
- if (entries != null){
- return entries.size();
- }
- return 0;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
-
- if (entries.size() > 0){
- Entry currentEntry = entries.get(row);
- switch (column) {
- case 0:
- result = datesEntree.get(row); // date
- break;
- case 1: // account
- Account acc = currentEntry.getAccount();
- result = accountDecorator.toString(acc);
- break;
- case 2:
- result = currentEntry.getVoucher();
- break;
- case 3:
- result = currentEntry.getDescription();
- break;
- case 4:
- result = currentEntry.getLettering();
- break;
- case 5:
- result = currentEntry.getDebit() ? currentEntry.getAmount() : BigDecimal.ZERO;
- break;
- case 6:
- result = currentEntry.getDebit() ? BigDecimal.ZERO : currentEntry.getAmount();
- break;
- }
- }
- return result;
- }
-
- /**
- * Only cell of "Letter" could be editable
- */
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return false;
- }
-
- public Object getElementAt(int row) {
- return entries.get(row);
- }
-
- /**add one entry*/
- public void addEntry(Entry entry, Date dateEntree) {
- entries.add(entry);
- datesEntree.add(dateEntree);
- int row = entries.indexOf(entry);
- fireTableRowsInserted(row, row);
- }
-
- /**update selected entries*/
- public void updateLettersSelectedEntries(int[] entries, String letters) {
- for (int rowEntry : entries){
- getEntryAt(rowEntry).setLettering(letters);
- fireTableRowsUpdated(rowEntry, rowEntry);
- }
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-12-31 16:45:49 UTC (rev 3726)
@@ -35,13 +35,12 @@
</import>
<LetteringViewHandler id="handler" constructorParams="this"/>
- <LetteringTableModel id="tableModel"/>
+
<LetteringEditModel id='editModel'/>
- <LettringSelectionModel id='lettringSelectionModel' constructorParams=' tableModel'
- onValueChanged="handler.balanceAndActions()"/>
+
<script>
<![CDATA[
void $afterCompleteSetup() {
@@ -155,10 +154,16 @@
<row>
<cell fill="both" weightx="1" weighty="1" >
<JScrollPane>
- <LetteringTable
- id="table" sortable="false" rowHeight="22"
- constructorParams="getTableModel(), handler"
- selectionModel="{lettringSelectionModel}" />
+ <LetteringTableModel id="tableModel"/>
+ <LettringSelectionModel id='lettringSelectionModel' constructorParams='tableModel'
+ onValueChanged="handler.balanceAndActions()"/>
+
+ <LetteringTable id="table"
+ sortable="false"
+ rowHeight="22"
+ constructorParams="handler"
+ model="{tableModel}"
+ selectionModel="{lettringSelectionModel}" />
</JScrollPane>
</cell>
</row>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -36,13 +36,14 @@
import org.chorem.lima.business.api.FiscalPeriodService;
import org.chorem.lima.entity.Account;
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
import java.math.BigDecimal;
-import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -82,6 +83,7 @@
public LetteringViewHandler(LetteringView view) {
this.view = view;
+ initShortCuts();
financialPeriodService = LimaServiceFactory.getService(FinancialPeriodService.class);
fiscalPeriodService = LimaServiceFactory.getService(FiscalPeriodService.class);
accountService = LimaServiceFactory.getService(AccountService.class);
@@ -99,6 +101,56 @@
loadComboAndRows();
}
+ protected void initShortCuts() {
+
+ InputMap inputMap= view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = view.getActionMap();
+ Object binding;
+
+ //To block reaction of the dual key 'ctrl+a' (Selection of all lines)
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none");
+
+ // add action on Ctrl + L
+ binding = "lettering";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addLetter();
+ }
+ });
+
+ // add action on Ctrl + Delete
+ binding = "un-lettering";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ removeLetter();
+ }
+ });
+
+ // add action on Ctrl + B
+ binding = "balance";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ roundAndCreateEntry();
+ }
+ });
+
+ // refresh
+ binding = "refresh";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateAllEntries();
+ }
+ });
+ }
+
public void balanceAndActions() {
if (log.isDebugEnabled()) {
log.debug("balanceAndActions");
@@ -125,8 +177,8 @@
}
/*Treatment only if one of values contains decimals*/
LetteringTableModel tableModel = view.getTableModel();
- Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
- Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
+ Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
+ Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
/*Get decimals*/
BigDecimal firstSelectedEntryAmount = firstSelectedEntry.getAmount();
@@ -169,7 +221,7 @@
public boolean letteringNotExist(int row){
boolean emptyOrNull = false;
if (row != -1) {
- Entry entry = view.getTableModel().getEntryAt(row);
+ Entry entry = view.getTableModel().get(row);
String lettering = entry.getLettering();
emptyOrNull = (lettering==null||lettering.isEmpty());
}
@@ -202,7 +254,7 @@
LetteringTableModel tableModel = view.getTableModel();
for (int i = 0; i < tableModel.getRowCount(); i ++){
if (view.getLettringSelectionModel().isSelectedIndex(i)){
- selectedEntry = tableModel.getEntryAt(i);
+ selectedEntry = tableModel.get(i);
//Set values for calculation (By LetteringEditModel) of balance
onBalanceChanged(selectedEntry);
}
@@ -319,22 +371,8 @@
if (filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) {
List<Entry> entries = findAllEntries(filter);
- List<String> journalEntrees = new ArrayList<String>();
- List<Date> datesEntree = new ArrayList<Date>();
- for (Entry entry : entries){
- FinancialTransaction financialTransaction = entry.getFinancialTransaction();
- datesEntree.add(financialTransaction.getTransactionDate());
- if (financialTransaction.getEntryBook() == null ||
- financialTransaction.getEntryBook().getLabel() == null) {
- journalEntrees.add("");
- } else {
- journalEntrees.add(financialTransaction.getEntryBook().getLabel());
- }
-
- }
-
- view.getTableModel().updateEntries(entries, datesEntree, journalEntrees);
+ view.getTableModel().setValues(entries);
}
onBalanceChanged(null);
}
@@ -350,16 +388,16 @@
int[] selectedRows = view.getTable().getSelectedRows();
if (editModel.isEqualized() && selectedRows.length == 2) {
/*Treatment only if one of values contains decimals*/
- Entry firstSelectedEntry = tableModel.getEntryAt(selectedRows[0]);
- Entry secondSelectedEntry = tableModel.getEntryAt(selectedRows[1]);
+ Entry firstSelectedEntry = tableModel.get(selectedRows[0]);
+ Entry secondSelectedEntry = tableModel.get(selectedRows[1]);
Entry[] newEntriesFormEqualizing = financialTransactionService.getEntriesFromEqualizing(firstSelectedEntry, secondSelectedEntry);
/*Add new entries to the model and the table*/
Entry newSameAccountEntry = newEntriesFormEqualizing[0];
Entry newCostOrProductEntry = newEntriesFormEqualizing[1];
- tableModel.addEntry(newSameAccountEntry, newSameAccountEntry.getFinancialTransaction().getTransactionDate());
- tableModel.addEntry(newCostOrProductEntry, newCostOrProductEntry.getFinancialTransaction().getTransactionDate());
+ tableModel.addValue(newSameAccountEntry);
+ tableModel.addValue(newCostOrProductEntry);
/*Re-select the two entries (firstSelectedEntry and secondSelectedEntry)
* and the new sameAccountEntry
@@ -419,10 +457,14 @@
int[] entrieSelected = view.getTable().getSelectedRows();
- view.getTableModel().updateLettersSelectedEntries(entrieSelected, newLetters);
+ LetteringTableModel tableModel = view.getTableModel();
for (int indexEntry : entrieSelected){
- financialTransactionService.updateEntry(view.getTableModel().getEntryAt(indexEntry));
+ Entry entry = tableModel.get(indexEntry);
+ entry.setLettering(newLetters);
+ financialTransactionService.updateEntry(entry);
+ tableModel.fireTableRowsUpdated(indexEntry, indexEntry);
+
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java 2013-12-31 15:11:52 UTC (rev 3725)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LettringSelectionModel.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -64,7 +64,7 @@
for(Entry entry : getEntries()){
if (StringUtils.isNotBlank(entry.getLettering())){
if (entry.getLettering().equals(currentLettring)){
- int entryToSelect = letteringTableModel.getIndexOfEntry(entry);
+ int entryToSelect = letteringTableModel.indexOf(entry);
super.addSelectionInterval(entryToSelect, entryToSelect);
}
}
@@ -77,7 +77,7 @@
//To clear the selection when it changes from lettered entry to unlettered
for(Entry entry : getEntries()){
if (!StringUtils.isBlank(entry.getLettering())) {
- int entryToSelect = letteringTableModel.getIndexOfEntry(entry);
+ int entryToSelect = letteringTableModel.indexOf(entry);
super.removeSelectionInterval(entryToSelect, entryToSelect);
}
}
@@ -97,14 +97,14 @@
* */
public boolean letteringNotExist(int row){
boolean emptyOrNull;
- entry = letteringTableModel.getEntryAt(row);
+ entry = letteringTableModel.get(row);
String lettering = entry.getLettering();
emptyOrNull = (lettering==null||lettering.isEmpty());
return emptyOrNull;
}
public List<Entry> getEntries(){
- return letteringTableModel.getEntries();
+ return letteringTableModel.getValues();
}
public String getCurrentLettring(){
@@ -112,7 +112,7 @@
}
public Entry getCurrentEntrySelected(){
- return letteringTableModel.getEntryAt(lineSelected);
+ return letteringTableModel.get(lineSelected);
}
/**After rounding one of two entries, selection of its, and of the new entry,
@@ -125,7 +125,7 @@
addSelectionInterval(indexSecondRoundedEntry, indexSecondRoundedEntry);
}
/*New entry*/
- int newEntryIndex = letteringTableModel.getIndexOfEntry(newResultRoundedEntry);
+ int newEntryIndex = letteringTableModel.indexOf(newResultRoundedEntry);
addSelectionInterval(newEntryIndex, newEntryIndex);
}
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/VoucherColumn.java (from rev 3725, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/VoucherColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/VoucherColumn.java 2013-12-31 16:45:49 UTC (rev 3726)
@@ -0,0 +1,52 @@
+package org.chorem.lima.ui.lettering;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 org.chorem.lima.entity.Entry;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class VoucherColumn extends DefaultColumn<LetteringTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.table.voucher");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ Entry entry = tableModel.get(row);
+ return entry.getVoucher();
+ }
+}
1
0
r3725 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/common
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:11:52 +0100 (Tue, 31 Dec 2013)
New Revision: 3725
Url: http://chorem.org/projects/lima/repository/revisions/3725
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/FinancialTransactionTableModel.java 2013-12-31 15:11:52 UTC (rev 3725)
@@ -0,0 +1,213 @@
+package org.chorem.lima.ui.common;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.business.api.FinancialTransactionService;
+import org.chorem.lima.business.utils.EntryComparator;
+import org.chorem.lima.entity.Entry;
+import org.chorem.lima.entity.EntryImpl;
+import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.entity.FinancialTransactionImpl;
+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.DebitColumn;
+import org.chorem.lima.ui.financialtransaction.DescriptionColumn;
+import org.chorem.lima.ui.financialtransaction.VoucherColumn;
+
+import java.math.BigDecimal;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FinancialTransactionTableModel extends TableModelWithGroup<Entry> {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -7495388454688562991L;
+
+ protected static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class);
+
+ /** Service (just to update setValueAt(). */
+ protected FinancialTransactionService financialTransactionService;
+
+ public FinancialTransactionTableModel() {
+
+
+ setComparator(new EntryComparator());
+
+ financialTransactionService =
+ LimaServiceFactory.getService(FinancialTransactionService.class);
+ }
+
+ @Override
+ protected void initColumn() {
+
+ addColumn(new DateColumn());
+ addColumn(new VoucherColumn());
+ addColumn(new AccountColumn());
+ addColumn(new DescriptionColumn());
+ addColumn(new DebitColumn());
+ addColumn(new CreditColumn());
+
+
+ }
+
+ public void setTransactions(List<FinancialTransaction> transactions) {
+ clear();
+ for (FinancialTransaction transaction : transactions) {
+ addAll(transaction.getEntry());
+ }
+ }
+
+ public FinancialTransaction getTransactionAt(int row) {
+ Entry entry = get(row);
+ return entry.getFinancialTransaction();
+ }
+
+ public int indexOf(FinancialTransaction transaction) {
+ int index = 0;
+ Collection<Entry> entriesTransaction = transaction.getEntry();
+ for (Entry entry : values) {
+ if (!entriesTransaction.contains(entry)) {
+ index++;
+ } else {
+ break;
+ }
+ }
+ return index;
+ }
+
+ public boolean contains(FinancialTransaction transaction) {
+ boolean result = false;
+ for (Entry entry : transaction.getEntry()) {
+ if (contains(entry)) {
+ result = true;
+ break;
+ }
+ }
+ return result;
+
+ }
+
+ /**
+ * Insert new entry.
+ *
+ * @param entry entry to insert
+ */
+ public Entry addEntry(Entry entry) {
+ Entry newEntry = null;
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ if (contains(transaction)) {
+ newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(transaction);
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setAccount(entry.getAccount());
+ newEntry.setDescription(entry.getDescription());
+ newEntry.setAmount(entry.getAmount());
+ newEntry.setDebit(entry.getDebit());
+ newEntry = financialTransactionService.createEntry(newEntry);
+
+ transaction.addEntry(newEntry);
+ financialTransactionService.updateFinancialTransaction(transaction);
+ addValue(newEntry);
+ }
+ return newEntry;
+ }
+
+ /**
+ * Delete selected row in table (could be transaction or entry).
+ * <p/>
+ * Called by model.
+ *
+ * @param row
+ */
+ public void removeTransaction(int row) {
+ FinancialTransaction transaction = getTransactionAt(row);
+ removeAll(transaction.getEntry());
+ financialTransactionService.removeFinancialTransaction(transaction);
+ }
+
+ public void removeEntry(int row) {
+ Entry entry = get(row);
+ FinancialTransaction transaction = entry.getFinancialTransaction();
+ if (transaction.sizeEntry() > 1) {
+ financialTransactionService.removeEntry(entry);
+ transaction.removeEntry(entry);
+ remove(entry);
+ } else {
+ financialTransactionService.removeFinancialTransaction(transaction);
+ removeAll(transaction.getEntry());
+ }
+ }
+
+ public FinancialTransaction addTransaction(FinancialTransaction transaction) {
+ FinancialTransaction newTransaction = new FinancialTransactionImpl();
+ newTransaction.setEntryBook(transaction.getEntryBook());
+ newTransaction.setTransactionDate(transaction.getTransactionDate());
+ newTransaction = financialTransactionService.createFinancialTransaction(newTransaction);
+
+ if (transaction.getEntry() == null || transaction.getEntry().isEmpty()) {
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(newTransaction);
+ newEntry = financialTransactionService.createEntry(newEntry);
+ newTransaction.addEntry(newEntry);
+
+ newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(newTransaction);
+ newEntry = financialTransactionService.createEntry(newEntry);
+ newTransaction.addEntry(newEntry);
+ } else {
+ for (Entry entry : transaction.getEntry()) {
+ Entry newEntry = new EntryImpl();
+ newEntry.setFinancialTransaction(newTransaction);
+ newEntry.setVoucher(entry.getVoucher());
+ newEntry.setAccount(entry.getAccount());
+ newEntry.setDescription(entry.getDescription());
+ newEntry.setAmount(entry.getAmount());
+ newEntry.setDebit(entry.getDebit());
+ newEntry = financialTransactionService.createEntry(newEntry);
+ newTransaction.addEntry(newEntry);
+ }
+ financialTransactionService.updateFinancialTransaction(newTransaction);
+ }
+
+ addAll(newTransaction.getEntry());
+ return newTransaction;
+ }
+
+ public BigDecimal getBalanceTransactionInRow(int row) {
+ FinancialTransaction transaction = getTransactionAt(row);
+ BigDecimal debit = transaction.getAmountDebit();
+ BigDecimal credit = transaction.getAmountCredit();
+ BigDecimal balance = debit.subtract(credit);
+ return balance;
+ }
+
+ @Override
+ public boolean sameGroup(Entry e1, Entry e2) {
+ return e1.getFinancialTransaction().equals(e2.getFinancialTransaction());
+ }
+
+ public void updateEntry(Entry entry) {
+ if (log.isDebugEnabled()) {
+ log.debug("Update Entry");
+ }
+ financialTransactionService.updateEntry(entry);
+ }
+
+ public void updateTransaction(FinancialTransaction transaction) {
+ if (log.isDebugEnabled()) {
+ log.debug("Update transaction");
+ }
+ financialTransactionService.updateFinancialTransaction(transaction);
+ }
+
+ public void fireTransaction(FinancialTransaction transaction) {
+ int firstRow = indexOf(transaction);
+ int lastRow = firstRow + transaction.sizeEntry() - 1;
+ fireTableRowsUpdated(firstRow, lastRow);
+ }
+}
1
0
r3724 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: common financialtransaction
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:06:23 +0100 (Tue, 31 Dec 2013)
New Revision: 3724
Url: http://chorem.org/projects/lima/repository/revisions/3724
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/DefaultColumn.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/DefaultColumn.java (from rev 3719, trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/DefaultColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/DefaultColumn.java 2013-12-31 15:06:23 UTC (rev 3724)
@@ -0,0 +1,65 @@
+package org.chorem.lima.ui.common;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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 javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class DefaultColumn<T extends AbstractLimaTableModel> implements Column<T> {
+
+ protected T tableModel;
+
+ protected TableCellRenderer renderer;
+
+ protected TableCellEditor editor;
+
+ @Override
+ public void setTableModel(T tableModel) {
+ this.tableModel = tableModel;
+ }
+
+ @Override
+ public TableCellRenderer getCellRenderer(int row) {
+ return renderer;
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row) {
+ return editor;
+ }
+
+ @Override
+ public boolean isCellEditable(int row) {
+ return false;
+ }
+
+ @Override
+ public boolean setValueAt(Object value, int row) {
+ return false;
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java 2013-12-31 15:06:05 UTC (rev 3723)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionColumn.java 2013-12-31 15:06:23 UTC (rev 3724)
@@ -1,59 +0,0 @@
-package org.chorem.lima.ui.financialtransaction;
-
-/*
- * #%L
- * Lima :: Swing
- * $Id$
- * $HeadURL$
- * %%
- * 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 org.chorem.lima.ui.common.Column;
-
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public abstract class FinancialTransactionColumn implements Column {
-
- protected FinancialTransactionTableModel tableModel;
-
- protected TableCellRenderer renderer;
-
- protected TableCellEditor editor;
-
-
- public FinancialTransactionColumn(FinancialTransactionTableModel tableModel) {
- this.tableModel = tableModel;
- this.renderer = null;
- this.editor = null;
- }
-
- @Override
- public TableCellRenderer getCellRenderer(int row) {
- return renderer;
- }
-
- @Override
- public TableCellEditor getCellEditor(int row) {
- return editor;
- }
-}
1
0
r3723 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/common
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:06:05 +0100 (Tue, 31 Dec 2013)
New Revision: 3723
Url: http://chorem.org/projects/lima/repository/revisions/3723
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTable.java 2013-12-31 15:06:05 UTC (rev 3723)
@@ -0,0 +1,108 @@
+package org.chorem.lima.ui.common;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
+import org.jdesktop.swingx.JXTable;
+
+import javax.swing.*;
+import javax.swing.table.TableCellEditor;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class AbstractLimaTable<H> extends JXTable {
+
+ private static final Log log = LogFactory.getLog(AbstractLimaTable.class);
+
+ protected H handler;
+
+ protected LineRenderer lineRenderer;
+
+ public AbstractLimaTable(H handler) {
+ this.handler = handler;
+
+ setShowHorizontalLines(true);
+ setShowVerticalLines(true);
+ setGridColor(new Color(232, 232, 246));
+
+ initNavigation();
+
+ addMouseListener(new MyMouseAdapter());
+
+ setDefaultRenderer(Object.class, new DefaultLimaTableCellRenderer());
+
+ }
+
+ protected void initNavigation() {
+
+ InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = getActionMap();
+
+ // action on Tab
+ Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0));
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ clearSelection();
+ }
+ });
+
+
+ }
+
+ public H getHandler() {
+ return handler;
+ }
+
+ @Override
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ TableCellRenderer renderer;
+
+ if (lineRenderer != null) {
+ renderer = lineRenderer;
+ } else {
+ renderer = super.getCellRenderer(row, column);
+ }
+
+ return renderer;
+ }
+
+ @Override
+ public TableCellEditor getCellEditor(int row, int column) {
+ TableCellEditor editor;
+ AbstractLimaTableModel tableModel = (AbstractLimaTableModel) getModel();
+ Column columnTable = tableModel.getColumn(column);
+ editor = columnTable.getCellEditor(row);
+ if (editor == null) {
+ editor = super.getCellEditor(row, column);
+ }
+ return editor;
+ }
+
+ public void exit() {
+ if (isEditing()) {
+ TableCellEditor editor = getCellEditor();
+ editor.stopCellEditing();
+ }
+ }
+
+
+ private class MyMouseAdapter extends MouseAdapter {
+
+ @Override
+ public void mousePressed(MouseEvent e) {
+ if (rowAtPoint(e.getPoint()) == -1) {
+ clearSelection();
+ }
+ }
+ }
+
+
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/AbstractLimaTableModel.java 2013-12-31 15:06:05 UTC (rev 3723)
@@ -0,0 +1,171 @@
+package org.chorem.lima.ui.common;
+
+import com.google.common.collect.Lists;
+
+import javax.swing.table.AbstractTableModel;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class AbstractLimaTableModel<E> extends AbstractTableModel {
+
+ protected List<E> values;
+
+ protected List<Column<AbstractLimaTableModel<E>>> columns;
+
+ protected Comparator<E> comparator;
+
+ public AbstractLimaTableModel() {
+
+ values = Lists.newArrayList();
+
+ columns = Lists.newArrayList();
+
+ initColumn();
+
+ }
+
+ protected abstract void initColumn();
+
+ public void setComparator(Comparator<E> comparator) {
+ this.comparator = comparator;
+ }
+
+ public void sort() {
+ if (comparator != null) {
+ Collections.sort(values, comparator);
+ fireTableDataChanged();
+ }
+ }
+
+ public void setValues(Collection<E> values) {
+ this.values.clear();
+ this.values.addAll(values);
+ sort();
+ fireTableDataChanged();
+ }
+
+ public void addValue(E value) {
+ int row = values.size();
+ values.add(value);
+ fireTableRowsInserted(row, row);
+ sort();
+ }
+
+ public void addAll(Collection<E> values) {
+ int row = this.values.size();
+ this.values.addAll(values);
+ fireTableRowsInserted(row, row + values.size() -1);
+ sort();
+ }
+
+ public void clear() {
+ values.clear();
+ }
+
+ public void remove(E value) {
+ int row = indexOf(value);
+ values.remove(value);
+ fireTableRowsDeleted(row, row);
+ }
+
+ public void removeAll(Collection<E> values) {
+ for (E value : values) {
+ remove(value);
+ }
+ }
+
+ public void remove(int row) {
+ values.remove(row);
+ fireTableRowsDeleted(row, row);
+ }
+
+ public E get(int row) {
+ return values.get(row);
+ }
+
+ public int indexOf(E value) {
+ return values.indexOf(value);
+ }
+
+ public boolean contains(E value) {
+ return values.contains(value);
+ }
+
+ public void addColumn(Column column) {
+ column.setTableModel(this);
+ columns.add(column);
+ fireTableStructureChanged();
+ }
+
+ public Column getColumn(int column) {
+ return columns.get(column);
+ }
+
+ @Override
+ public int getColumnCount() {
+ return columns.size();
+ }
+
+ @Override
+ public int getRowCount() {
+ return size();
+ }
+
+ public int size() {
+ return values.size();
+ }
+
+ @Override
+ public Class<?> getColumnClass(int column) {
+ Class result = null;
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).getColumnClass();
+ }
+ return result;
+ }
+
+ @Override
+ public String getColumnName(int column) {
+ String result = _("lima.ui.nonaffect");
+ if (column >= 0 && column < columns.size()) {
+ result = columns.get(column).getColumnName();
+ }
+ return result;
+ }
+
+ @Override
+ public Object getValueAt(int row, int column) {
+
+ Object result = columns.get(column).getValueAt(row);
+
+ return result;
+ }
+
+ /**
+ * To set cells editable or not
+ *
+ */
+ @Override
+ public boolean isCellEditable(int row, int column) {
+ boolean result = columns.get(column).isCellEditable(row);
+ return result;
+ }
+
+ @Override
+ public void setValueAt(Object value, int row, int column) {
+ boolean update = columns.get(column).setValueAt(value, row);
+ // some modification must update all other
+ // first row modification update following rows
+ if (update) {
+ fireTableCellUpdated(row, column);
+ }
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java 2013-12-31 15:05:26 UTC (rev 3722)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/Column.java 2013-12-31 15:06:05 UTC (rev 3723)
@@ -30,7 +30,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public interface Column {
+public interface Column<T extends AbstractLimaTableModel> {
public Class<?> getColumnClass();
@@ -45,4 +45,6 @@
public TableCellRenderer getCellRenderer(int row);
public TableCellEditor getCellEditor(int row);
+
+ public void setTableModel(T tableModel);
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/LineRenderer.java 2013-12-31 15:06:05 UTC (rev 3723)
@@ -0,0 +1,38 @@
+package org.chorem.lima.ui.common;
+
+import org.chorem.lima.ui.celleditor.DefaultLimaTableCellRenderer;
+
+import javax.swing.*;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public abstract class LineRenderer extends DefaultLimaTableCellRenderer {
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ AbstractLimaTableModel tableModel = (AbstractLimaTableModel) table.getModel();
+ Column columnTable = tableModel.getColumn(column);
+ TableCellRenderer renderer = columnTable.getCellRenderer(row);
+
+ Component component;
+
+ if (renderer != null) {
+
+ component = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ } else {
+
+ component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ }
+
+
+ return component;
+
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java 2013-12-31 15:05:26 UTC (rev 3722)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/common/TableModelWithGroup.java 2013-12-31 15:06:05 UTC (rev 3723)
@@ -27,7 +27,21 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public interface TableModelWithGroup {
+public abstract class TableModelWithGroup<E> extends AbstractLimaTableModel<E> {
- public int indexGroupAt(int row);
+ public int indexGroupAt(int row) {
+ int countGroup = 0;
+ E precedingValue = get(0);
+ for (int precedingRow = 1; precedingRow <= row; precedingRow++) {
+ E value = get(precedingRow);
+ if ( ! sameGroup(precedingValue, value)) {
+ countGroup++;
+ }
+ precedingValue = value;
+ }
+ return countGroup;
+
+ }
+
+ public abstract boolean sameGroup(E e1, E e2);
}
1
0
r3722 - in trunk/lima-swing/src/main/java/org/chorem/lima/ui: entrybook financialtransaction financialtransactionsearch financialtransactionunbalanced fiscalperiod
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:05:26 +0100 (Tue, 31 Dec 2013)
New Revision: 3722
Url: http://chorem.org/projects/lima/repository/revisions/3722
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/CodeColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/LabelColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/BeginColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EndColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/StatusColumn.java
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/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
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/CodeColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/CodeColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/CodeColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,26 @@
+package org.chorem.lima.ui.entrybook;
+
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class CodeColumn extends DefaultColumn<EntryBookTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.entrybook.code");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ return tableModel.get(row).getCode();
+ }
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -24,73 +24,15 @@
*/
package org.chorem.lima.ui.entrybook;
-import org.jdesktop.swingx.JXTable;
+import org.chorem.lima.ui.common.AbstractLimaTable;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
+public class EntryBookTable extends AbstractLimaTable<EntryBookViewHandler> {
-public class EntryBookTable extends JXTable
- implements KeyListener, MouseListener {
-
/** serialVersionUID. */
private static final long serialVersionUID = 6228396251512013262L;
- protected EntryBookViewHandler handler;
-
public EntryBookTable(EntryBookViewHandler handler) {
-
- this.handler = handler;
-
- addKeyListener(this);
- addMouseListener(this);
-
+ super(handler);
}
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookTableModel.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,13 +25,8 @@
package org.chorem.lima.ui.entrybook;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
import org.chorem.lima.entity.EntryBook;
+import org.chorem.lima.ui.common.AbstractLimaTableModel;
/**
* Entry book table model only rendering entry book list.
@@ -43,84 +38,20 @@
* Last update : $Date$
* By : $Author$
*/
-public class EntryBookTableModel extends AbstractTableModel {
+public class EntryBookTableModel extends AbstractLimaTableModel<EntryBook> {
/** serialVersionUID. */
private static final long serialVersionUID = 7578692417919755647L;
- protected List<EntryBook> entryBooks;
-
- public EntryBookTableModel(List<EntryBook> entryBooks) {
- this.entryBooks = entryBooks;
- }
-
@Override
- public int getRowCount() {
- int result = entryBooks.size();
- return result;
+ protected void initColumn() {
+ addColumn(new CodeColumn());
+ addColumn(new LabelColumn());
}
- @Override
- public int getColumnCount() {
- return 2;
- }
-
- @Override
- public String getColumnName(int column) {
- String res = "n/a";
- switch (column) {
- case 0:
- res = _("lima.ui.entrybook.code");
- break;
- case 1:
- res = _("lima.ui.entrybook.label");
- break;
- }
- return res;
- }
-
- public EntryBook getEntryBookAtRow(int row) {
- EntryBook entryBook = entryBooks.get(row);
- return entryBook;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
-
- Object result = null;
- EntryBook entryBook = getEntryBookAtRow(row);
-
- switch (column) {
- case 0:
- result = entryBook.getCode();
- break;
- case 1:
- result = entryBook.getLabel();
- break;
- }
-
- return result;
- }
-
- @Override
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return false;
- }
-
- public void addEntryBook(EntryBook entryBook) {
- entryBooks.add(entryBook);
- int row = entryBooks.indexOf(entryBook);
- fireTableRowsInserted(row, row);
- }
-
public void updateEntryBook(EntryBook entryBook) {
- int row = entryBooks.indexOf(entryBook);
+ int row = values.indexOf(entryBook);
fireTableRowsUpdated(row, row);
}
- public void removeEntryBook(EntryBook entryBook) {
- int row = entryBooks.indexOf(entryBook);
- entryBooks.remove(entryBook);
- fireTableRowsDeleted(row, row);
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2013-12-31 15:05:26 UTC (rev 3722)
@@ -73,11 +73,13 @@
<row>
<cell fill="both" weightx="1" weighty="1">
<JScrollPane>
+ <EntryBookTableModel id="entryBookTableModel" />
<EntryBookTable id="entryBooksTable" rowHeight="24"
constructorParams="getHandler()"
highlighters="{org.jdesktop.swingx.decorator.HighlighterFactory.createSimpleStriping(new java.awt.Color(233,233,233))}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
- columnControlVisible="true"/>
+ columnControlVisible="true"
+ model="{entryBookTableModel}"/>
<ListSelectionModel javaBean="getEntryBooksTable().getSelectionModel()"
onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/>
</JScrollPane>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -128,10 +128,9 @@
if (log.isDebugEnabled()) {
log.debug(String.format("Loaded %d entry books from service", entryBooks.size()));
}
-
- EntryBookTableModel model = new EntryBookTableModel(entryBooks);
- EntryBookTable table = view.getEntryBooksTable();
- table.setModel(model);
+
+ EntryBookTableModel model = view.getEntryBookTableModel();
+ model.setValues(entryBooks);
}
/**
@@ -165,9 +164,8 @@
newEntryBook = entryBookService.createEntryBook(newEntryBook);
// ui refresh
- JXTable entryBookTable = view.getEntryBooksTable();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
- entryBookTableModel.addEntryBook(newEntryBook);
+ EntryBookTableModel model = view.getEntryBookTableModel();
+ model.addValue(newEntryBook);
}
}
@@ -177,11 +175,11 @@
public void updateEntryBook() {
JXTable entryBookTable = view.getEntryBooksTable();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
+ EntryBookTableModel entryBookTableModel = view.getEntryBookTableModel();
int selectedRow = entryBookTable.getSelectedRow();
if (selectedRow >= 0) {
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBook selectedEntryBook = entryBookTableModel.get(selectedRow);
final EntryBookForm entryBookForm = new EntryBookForm(view);
InputMap inputMap = entryBookForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
@@ -220,9 +218,9 @@
int selectedRow = entryBookTable.getSelectedRow();
if (selectedRow >= 0) {
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
+ EntryBookTableModel entryBookTableModel = view.getEntryBookTableModel();
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ EntryBook selectedEntryBook = entryBookTableModel.get(selectedRow);
int response = JOptionPane.showConfirmDialog(view,
_("lima.ui.entrybook.deletemessage", selectedEntryBook.getLabel()),
@@ -232,7 +230,7 @@
if (response == JOptionPane.YES_OPTION) {
entryBookService.removeEntryBook(selectedEntryBook);
- entryBookTableModel.removeEntryBook(selectedEntryBook);
+ entryBookTableModel.remove(selectedEntryBook);
}
}
}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/LabelColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/LabelColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/LabelColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,28 @@
+package org.chorem.lima.ui.entrybook;
+
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class LabelColumn extends DefaultColumn<EntryBookTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.entrybook.label");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ return tableModel.get(row).getLabel();
+ }
+
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/AccountColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -28,16 +28,17 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.celleditor.AccountTableCellEditor;
import org.chorem.lima.ui.celleditor.AccountTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import static org.nuiton.i18n.I18n._;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class AccountColumn extends FinancialTransactionColumn {
+public class AccountColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public AccountColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public AccountColumn() {
renderer = new AccountTableCellRenderer();
editor = new AccountTableCellEditor();
}
@@ -54,7 +55,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getAccount();
}
@@ -65,7 +66,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
Account account = (Account) value;
boolean update = ((entry.getAccount()) == null != (account == null))
|| (entry.getAccount() != null
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/BalanceColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -26,6 +26,8 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import java.math.BigDecimal;
@@ -34,11 +36,10 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class BalanceColumn extends FinancialTransactionColumn {
+public class BalanceColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public BalanceColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public BalanceColumn() {
renderer = new BigDecimalTableCellRenderer();
}
@@ -56,7 +57,7 @@
public Object getValueAt(int row) {
BigDecimal result;
FinancialTransaction transaction = tableModel.getTransactionAt(row);
- if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ if (row == 0 || tableModel.get(row - 1).getFinancialTransaction() != transaction) {
result = transaction.getAmountDebit().subtract(transaction.getAmountCredit());
} else {
result = BigDecimal.ZERO;
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/CreditColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -27,6 +27,8 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import java.math.BigDecimal;
@@ -35,10 +37,9 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class CreditColumn extends FinancialTransactionColumn {
+public class CreditColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public CreditColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public CreditColumn() {
renderer = new BigDecimalTableCellRenderer();
editor = new BigDecimalTableCellEditor();
}
@@ -55,7 +56,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getDebit() ? BigDecimal.ZERO : entry.getAmount();
}
@@ -66,7 +67,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
BigDecimal credit= (BigDecimal) value;
boolean update = (credit.signum() > 0 && (entry.isDebit() || entry.getAmount().compareTo(credit) != 0));
if (update) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DateColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -27,7 +27,9 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.celleditor.DateTableCellEditor;
-import org.chorem.lima.ui.celleditor.DateTableCellRenderer;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import java.util.Date;
@@ -36,12 +38,11 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class DateColumn extends FinancialTransactionColumn {
+public class DateColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public DateColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
- renderer = new DateTableCellRenderer();
+ public DateColumn() {
+ renderer = new DateLimaTableCellRenderer();
editor = new DateTableCellEditor();
}
@@ -58,9 +59,9 @@
@Override
public Object getValueAt(int row) {
Date result;
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
- if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ if (row == 0 || tableModel.get(row - 1).getFinancialTransaction() != transaction) {
result = transaction.getTransactionDate(); // date
} else {
result = null;
@@ -71,12 +72,12 @@
@Override
public boolean isCellEditable(int row) {
return row == 0
- || tableModel.getEntryAt(row).getFinancialTransaction() != tableModel.getEntryAt(row - 1).getFinancialTransaction();
+ || tableModel.get(row).getFinancialTransaction() != tableModel.get(row - 1).getFinancialTransaction();
}
@Override
public boolean setValueAt(Object value, int row) {
- FinancialTransaction transaction = tableModel.getTransactionAt(row);
+ FinancialTransaction transaction = tableModel.get(row).getFinancialTransaction();
boolean update = (transaction.getTransactionDate().compareTo((Date) value) != 0);
if (update) {
transaction.setTransactionDate((Date) value);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DebitColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -27,6 +27,8 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor;
import org.chorem.lima.ui.celleditor.BigDecimalTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import java.math.BigDecimal;
@@ -35,10 +37,9 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class DebitColumn extends FinancialTransactionColumn {
+public class DebitColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public DebitColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public DebitColumn() {
renderer = new BigDecimalTableCellRenderer();
editor = new BigDecimalTableCellEditor();
}
@@ -55,7 +56,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getDebit() ? entry.getAmount() : BigDecimal.ZERO;
}
@@ -66,7 +67,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
BigDecimal debit = (BigDecimal) value;
boolean update = (debit.signum() > 0 && (!entry.isDebit() || entry.getAmount().compareTo(debit) != 0));
if (update) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/DescriptionColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,19 +25,18 @@
*/
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import static org.nuiton.i18n.I18n._;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class DescriptionColumn extends FinancialTransactionColumn {
+public class DescriptionColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public DescriptionColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
- renderer = new EntryTableCellRenderer();
+ public DescriptionColumn() {
editor = new StringTableCellEditor();
}
@@ -53,7 +52,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getDescription();
}
@@ -64,7 +63,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
String description = ((String) value).trim();
boolean update = (entry.getDescription() == null ||entry.getDescription().compareTo(description) != 0);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/EntryBookColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -29,17 +29,18 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor;
import org.chorem.lima.ui.celleditor.EntryBookTableCellRender;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import static org.nuiton.i18n.I18n._;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class EntryBookColumn extends FinancialTransactionColumn {
+public class EntryBookColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public EntryBookColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public EntryBookColumn() {
renderer = new EntryBookTableCellRender();
editor = new EntryBookTableCellEditor();
}
@@ -57,9 +58,9 @@
@Override
public Object getValueAt(int row) {
EntryBook result;
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
FinancialTransaction transaction = entry.getFinancialTransaction();
- if (row == 0 || tableModel.getEntryAt(row - 1).getFinancialTransaction() != transaction) {
+ if (row == 0 || tableModel.get(row - 1).getFinancialTransaction() != transaction) {
result = transaction.getEntryBook(); // date
} else {
result = null;
@@ -70,7 +71,7 @@
@Override
public boolean isCellEditable(int row) {
return row == 0
- || tableModel.getEntryAt(row).getFinancialTransaction() != tableModel.getEntryAt(row - 1).getFinancialTransaction();
+ || tableModel.get(row).getFinancialTransaction() != tableModel.get(row - 1).getFinancialTransaction();
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionDefaultTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -26,40 +26,33 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
+import org.chorem.lima.ui.common.AbstractLimaTable;
import org.chorem.lima.ui.common.CellRouteHorizontalAction;
import org.chorem.lima.ui.common.CellRouteVerticalAction;
-import org.chorem.lima.ui.common.Column;
import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.*;
import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class FinancialTransactionDefaultTable extends JTable {
+public class FinancialTransactionDefaultTable<H> extends AbstractLimaTable<H> {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
- public FinancialTransactionDefaultTable() {
-
- setShowHorizontalLines(true);
- setShowVerticalLines(true);
- setGridColor(new Color(210,210,210));
-
- initNavigation();
-
- addMouseListener(new MyMouseAdapter());
+ public FinancialTransactionDefaultTable(H handler) {
+ super(handler);
+ setSortable(false);
+ lineRenderer = new EntryTableCellRenderer();
}
+ @Override
protected void initNavigation() {
+ super.initNavigation();
InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
ActionMap actionMap = getActionMap();
@@ -80,45 +73,4 @@
actionMap.put(binding, new CellRouteVerticalAction(this, false));
}
-
- @Override
- public TableCellRenderer getCellRenderer(int row, int column) {
- TableCellRenderer renderer;
- FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
- Column columnTable = tableModel.getColumn(column);
- renderer = columnTable.getCellRenderer(row);
- if (renderer == null) {
- renderer = super.getCellRenderer(row, column);
- }
- return renderer;
- }
-
- @Override
- public TableCellEditor getCellEditor(int row, int column) {
- TableCellEditor editor;
- FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
- Column columnTable = tableModel.getColumn(column);
- editor = columnTable.getCellEditor(row);
- if (editor == null) {
- editor = super.getCellEditor(row, column);
- }
- return editor;
- }
-
- public void exit() {
- if (isEditing()) {
- TableCellEditor editor = getCellEditor();
- editor.stopCellEditing();
- }
- }
-
- private class MyMouseAdapter extends MouseAdapter {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
- }
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -28,6 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.entity.FinancialTransaction;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import javax.swing.*;
import java.awt.event.ActionEvent;
@@ -45,18 +46,15 @@
* @author jpepin
* @author echatellier
*/
-public class FinancialTransactionTable extends FinancialTransactionDefaultTable {
+public class FinancialTransactionTable extends FinancialTransactionDefaultTable<FinancialTransactionViewHandler> {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
private static final Log log = LogFactory.getLog(FinancialTransactionTable.class);
- protected final FinancialTransactionViewHandler handler;
-
- public FinancialTransactionTable(final FinancialTransactionViewHandler handler) {
- super();
- this.handler = handler;
+ public FinancialTransactionTable(FinancialTransactionViewHandler handler) {
+ super(handler);
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionView.jaxx 2013-12-31 15:05:26 UTC (rev 3722)
@@ -31,6 +31,7 @@
org.chorem.lima.entity.FinancialPeriod
org.chorem.lima.entity.EntryBook
org.chorem.lima.ui.common.EntryBookListRenderer
+ org.chorem.lima.ui.common.FinancialTransactionTableModel
java.awt.event.KeyEvent
javax.swing.KeyStroke
</import>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionViewHandler.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -42,6 +42,7 @@
import org.chorem.lima.entity.FinancialTransactionImpl;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
@@ -334,7 +335,7 @@
editor.stopCellEditing();
}
- Entry entry = tableModel.getEntryAt(rowSelected);
+ Entry entry = tableModel.get(rowSelected);
FinancialTransaction transaction = entry.getFinancialTransaction();
BigDecimal credit = transaction.getAmountCredit();
BigDecimal debit = transaction.getAmountDebit();
@@ -377,7 +378,7 @@
FinancialTransactionTable table = view.getFinancialTransactionTable();
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow != -1) {
- clipBoard = view.getFinancialTransactionTableModel().getEntryAt(indexSelectedRow);
+ clipBoard = view.getFinancialTransactionTableModel().get(indexSelectedRow);
view.setTransactionInClipBoard(false);
view.setEntryInClipBoard(true);
}
@@ -517,10 +518,10 @@
}
//First case, where line selected is an entry : take its transaction
//to select the last entry of the transaction
- Entry entryAt = tableModel.getEntryAt(indexSelectedRow);
+ Entry entryAt = tableModel.get(indexSelectedRow);
FinancialTransaction transaction = entryAt.getFinancialTransaction();
int rowLasEntry = tableModel.indexOf(transaction) + transaction.sizeEntry() - 1;
- Entry lastEntry = tableModel.getEntryAt(rowLasEntry);
+ Entry lastEntry = tableModel.get(rowLasEntry);
if (log.isDebugEnabled()) {
log.debug("Selected row : " + indexSelectedRow);
@@ -631,7 +632,7 @@
int indexSelectedRow = table.getSelectedRow();
if (indexSelectedRow >= 0) {
- Entry entry = tableModel.getEntryAt(indexSelectedRow);
+ Entry entry = tableModel.get(indexSelectedRow);
TableCellEditor cellEditor = table.getCellEditor();
if (cellEditor != null) {
cellEditor.cancelCellEditing();
@@ -670,7 +671,7 @@
int selectedRow = table.getSelectedRow();
int selectedColumn = table.getSelectedColumn();
if (selectedRow >= 0 && (selectedColumn == 1 || selectedColumn == 3)) {
- Entry entrySource = tableModel.getEntryAt(selectedRow);
+ Entry entrySource = tableModel.get(selectedRow);
FinancialTransaction transaction = entrySource.getFinancialTransaction();
for (Entry entryTarget : transaction.getEntry()) {
if (entrySource != entryTarget) {
@@ -752,8 +753,8 @@
FinancialTransactionTable table = view.getFinancialTransactionTable();
FinancialTransactionTableModel tableModel = view.getFinancialTransactionTableModel();
- Entry entry = tableModel.getEntryAt(e.getFirstRow());
- tableModel.sortEntries();
+ Entry entry = tableModel.get(e.getFirstRow());
+ tableModel.sort();
int newRow = tableModel.indexOf(entry);
table.changeSelection(newRow, 0, false, false);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/LetterColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -27,16 +27,17 @@
import org.chorem.lima.entity.Entry;
import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import static org.nuiton.i18n.I18n._;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class LetterColumn extends FinancialTransactionColumn {
+public class LetterColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public LetterColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
+ public LetterColumn() {
renderer = new EntryTableCellRenderer();
editor = new StringTableCellEditor();
}
@@ -53,7 +54,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getLettering();
}
@@ -64,7 +65,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
String letter = ((String) value).trim();
boolean update = (entry.getLettering() == null || entry.getLettering().compareTo(letter) != 0);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/VoucherColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,19 +25,18 @@
*/
import org.chorem.lima.entity.Entry;
-import org.chorem.lima.ui.celleditor.EntryTableCellRenderer;
import org.chorem.lima.ui.celleditor.StringTableCellEditor;
+import org.chorem.lima.ui.common.DefaultColumn;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import static org.nuiton.i18n.I18n._;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class VoucherColumn extends FinancialTransactionColumn {
+public class VoucherColumn extends DefaultColumn<FinancialTransactionTableModel> {
- public VoucherColumn(FinancialTransactionTableModel tableModel) {
- super(tableModel);
- renderer = new EntryTableCellRenderer();
+ public VoucherColumn() {
editor = new StringTableCellEditor();
}
@@ -53,7 +52,7 @@
@Override
public Object getValueAt(int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
return entry.getVoucher();
}
@@ -64,7 +63,7 @@
@Override
public boolean setValueAt(Object value, int row) {
- Entry entry = tableModel.getEntryAt(row);
+ Entry entry = tableModel.get(row);
String voucher = ((String) value).trim();
boolean update = (entry.getVoucher() == null || entry.getVoucher().compareTo(voucher) != 0);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -34,13 +34,13 @@
* @author ore
* @author Rémi Chapelet
*/
-public class FinancialTransactionSearchTable extends FinancialTransactionDefaultTable {
+public class FinancialTransactionSearchTable extends FinancialTransactionDefaultTable<FinancialTransactionSearchViewHandler> {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- public FinancialTransactionSearchTable() {
- super();
+ public FinancialTransactionSearchTable(FinancialTransactionSearchViewHandler handler) {
+ super(handler);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -37,7 +37,7 @@
import org.chorem.lima.ui.financialtransaction.DebitColumn;
import org.chorem.lima.ui.financialtransaction.DescriptionColumn;
import org.chorem.lima.ui.financialtransaction.EntryBookColumn;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
import org.chorem.lima.ui.financialtransaction.LetterColumn;
import org.chorem.lima.ui.financialtransaction.VoucherColumn;
@@ -88,15 +88,15 @@
}
protected void initColumns() {
- columns.add(new DateColumn(this));
- columns.add(new EntryBookColumn(this));
- columns.add(new VoucherColumn(this));
- columns.add(new AccountColumn(this));
- columns.add(new DescriptionColumn(this));
- columns.add(new LetterColumn(this));
- columns.add(new DebitColumn(this));
- columns.add(new CreditColumn(this));
- columns.add(new BalanceColumn(this));
+ addColumn(new DateColumn());
+ addColumn(new EntryBookColumn());
+ addColumn(new VoucherColumn());
+ addColumn(new AccountColumn());
+ addColumn(new DescriptionColumn());
+ addColumn(new LetterColumn());
+ addColumn(new DebitColumn());
+ addColumn(new CreditColumn());
+ addColumn(new BalanceColumn());
}
public void setFiscalPeriod(FiscalPeriod fiscalPeriod) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2013-12-31 15:05:26 UTC (rev 3722)
@@ -109,7 +109,9 @@
<FinancialTransactionSearchTableModel
id="financialTransactionSearchTableModel"/>
<FinancialTransactionDefaultTable
- id="financialTransactionSearchTable" rowHeight="22"
+ id="financialTransactionSearchTable"
+ constructorParams='handler'
+ rowHeight="22"
model="{getFinancialTransactionSearchTableModel()}"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
<ListSelectionModel
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,142 +25,20 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
-import org.chorem.lima.ui.common.CellRouteHorizontalAction;
-import org.chorem.lima.ui.common.CellRouteVerticalAction;
-import org.chorem.lima.ui.common.Column;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
-import org.jdesktop.swingx.decorator.ColorHighlighter;
-import org.jdesktop.swingx.decorator.Highlighter;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionDefaultTable;
-import javax.swing.*;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-
/**
* Table des transaction qui ajoute des comportement (keys).
*
* @author ore
* @author Rémi Chapelet
*/
-public class FinancialTransactionUnbalancedTable extends JTable {
+public class FinancialTransactionUnbalancedTable extends FinancialTransactionDefaultTable<FinancialTransactionUnbalancedViewHandler> {
/** serialVersionUID. */
private static final long serialVersionUID = 3133690382049594727L;
- protected final FinancialTransactionUnbalancedViewHandler handler;
-
- private Highlighter colorTransaction;
-
- private ColorHighlighter colorBalance;
-
- public FinancialTransactionUnbalancedTable(final FinancialTransactionUnbalancedViewHandler handler) {
-
- this.handler = handler;
-
- setShowHorizontalLines(true);
- setShowVerticalLines(true);
- setGridColor(new Color(210,210,210));
-
- InputMap inputMap= getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- ActionMap actionMap = getActionMap();
-
- // action on Tab
- Object binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
- actionMap.put(binding, new CellRouteHorizontalAction(this, true));
-
- // action on Shift + Tab
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteHorizontalAction(this, false));
-
- // action on Enter
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0));
- actionMap.put(binding, new CellRouteVerticalAction(this, true));
-
- // action on Shift + Enter
- binding = inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
- actionMap.put(binding, new CellRouteVerticalAction(this, false));
-
- // add action on Ctrl + Shift + Delete
- binding = "delete-transaction";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK + KeyEvent.SHIFT_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.deleteSelectedTransaction();
- }
- });
-
- // add action on Ctrl + N
- binding = "new-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.addEntry();
- }
- });
-
- // add action on Ctrl + Delete
- binding = "delete-entry";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.deleteSelectedEntry();
- }
- });
-
- // add action on Ctrl + B
- binding = "balance";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- handler.balanceTransaction();
- }
- });
-
- addMouseListener(new MyMouseAdapter());
-
+ public FinancialTransactionUnbalancedTable(FinancialTransactionUnbalancedViewHandler handler) {
+ super(handler);
}
-
- @Override
- public TableCellRenderer getCellRenderer(int row, int column) {
- TableCellRenderer renderer;
- FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
- Column columnTable = tableModel.getColumn(column);
- renderer = columnTable.getCellRenderer(row);
- if (renderer == null) {
- renderer = super.getCellRenderer(row, column);
- }
- return renderer;
- }
-
- @Override
- public TableCellEditor getCellEditor(int row, int column) {
- TableCellEditor editor;
- FinancialTransactionTableModel tableModel = (FinancialTransactionTableModel) getModel();
- Column columnTable = tableModel.getColumn(column);
- editor = columnTable.getCellEditor(row);
- if (editor == null) {
- editor = super.getCellEditor(row, column);
- }
- return editor;
- }
-
- private class MyMouseAdapter extends MouseAdapter {
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
- }
-
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedTableModel.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,15 +25,17 @@
package org.chorem.lima.ui.financialtransactionunbalanced;
+import com.google.common.collect.Lists;
+import org.chorem.lima.entity.Entry;
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
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.DebitColumn;
import org.chorem.lima.ui.financialtransaction.DescriptionColumn;
import org.chorem.lima.ui.financialtransaction.EntryBookColumn;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
import org.chorem.lima.ui.financialtransaction.LetterColumn;
import org.chorem.lima.ui.financialtransaction.VoucherColumn;
@@ -56,14 +58,14 @@
protected FiscalPeriod selectedFiscalPeriod;
protected void initColumns() {
- columns.add(new DateColumn(this));
- columns.add(new EntryBookColumn(this));
- columns.add(new VoucherColumn(this));
- columns.add(new AccountColumn(this));
- columns.add(new DescriptionColumn(this));
- columns.add(new DebitColumn(this));
- columns.add(new CreditColumn(this));
- columns.add(new LetterColumn(this));
+ addColumn(new DateColumn());
+ addColumn(new EntryBookColumn());
+ addColumn(new VoucherColumn());
+ addColumn(new AccountColumn());
+ addColumn(new DescriptionColumn());
+ addColumn(new DebitColumn());
+ addColumn(new CreditColumn());
+ addColumn(new LetterColumn());
}
/**
@@ -72,13 +74,18 @@
* @return
*/
protected void refresh() {
- transactions.clear();
+ values.clear();
if (selectedFiscalPeriod != null) {
List<FinancialTransaction> financialTransactions =
financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod);
- transactions.addAll(financialTransactions);
- sortEntries();
+ List<Entry> entries = Lists.newLinkedList();
+
+ for (FinancialTransaction transaction : financialTransactions) {
+ entries.addAll(transaction.getEntry());
+ }
+
+ addAll(entries);
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedView.jaxx 2013-12-31 15:05:26 UTC (rev 3722)
@@ -91,8 +91,9 @@
<JScrollPane>
<FinancialTransactionUnbalancedTableModel
id="financialTransactionUnbalancedTableModel"/>
- <FinancialTransactionDefaultTable
+ <FinancialTransactionUnbalancedTable
id="financialTransactionUnbalancedTable"
+ constructorParams='handler'
rowHeight="22"
selectionModel='{selectionModel}'
model="{getFinancialTransactionUnbalancedTableModel()}"/>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionunbalanced/FinancialTransactionUnbalancedViewHandler.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -146,7 +146,7 @@
cellEditor.cancelCellEditing();
}
- Entry entry = tableModel.getEntryAt(indexSelectedRow);
+ Entry entry = tableModel.get(indexSelectedRow);
//copy + paste the description
Entry newEntry = new EntryImpl();
newEntry.setFinancialTransaction(entry.getFinancialTransaction());
@@ -287,7 +287,7 @@
editor.stopCellEditing();
}
- Entry entry = tableModel.getEntryAt(rowSelected);
+ Entry entry = tableModel.get(rowSelected);
FinancialTransaction transaction = entry.getFinancialTransaction();
BigDecimal credit = transaction.getAmountCredit();
BigDecimal debit = transaction.getAmountDebit();
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/BeginColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/BeginColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/BeginColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,35 @@
+package org.chorem.lima.ui.fiscalperiod;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class BeginColumn extends DefaultColumn<FiscalPeriodTableModel> {
+
+ public BeginColumn() {
+ renderer = new DateLimaTableCellRenderer();
+ }
+
+ @Override
+ public Class<?> getColumnClass() {
+ return Date.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.fiscalperiod.begin");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ FiscalPeriod fiscalPeriod = tableModel.get(row);
+ return fiscalPeriod.getBeginDate();
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EndColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EndColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/EndColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,34 @@
+package org.chorem.lima.ui.fiscalperiod;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.celleditor.DateLimaTableCellRenderer;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import java.util.Date;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class EndColumn extends DefaultColumn<FiscalPeriodTableModel> {
+
+ public EndColumn() {
+ renderer = new DateLimaTableCellRenderer();
+ }
+ @Override
+ public Class<?> getColumnClass() {
+ return Date.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.fiscalperiod.end");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ FiscalPeriod fiscalPeriod = tableModel.get(row);
+ return fiscalPeriod.getEndDate();
+ }
+}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodRenderer.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,28 @@
+package org.chorem.lima.ui.fiscalperiod;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.common.LineRenderer;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FiscalPeriodRenderer extends LineRenderer {
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ if (table.getModel() instanceof FiscalPeriodTableModel) {
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ FiscalPeriod fiscalPeriod = model.get(row);
+ if (!isSelected && fiscalPeriod.getLocked()) {
+ component.setForeground(new Color(222, 0, 0));
+ }
+ }
+ return component;
+ }
+}
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 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -25,15 +25,8 @@
package org.chorem.lima.ui.fiscalperiod;
-import org.chorem.lima.ui.celleditor.FiscalPeriodTableRenderer;
-import org.jdesktop.swingx.JXTable;
+import org.chorem.lima.ui.common.AbstractLimaTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-
/**
* Fiscal period table add support for JXTable.
*
@@ -49,67 +42,13 @@
* Last update : $Date$
* By : $Author$
*/
-public class FiscalPeriodTable extends JXTable
- implements KeyListener, MouseListener {
+public class FiscalPeriodTable extends AbstractLimaTable<FiscalPeriodViewHandler> {
private static final long serialVersionUID = -8462838870024505659L;
- public FiscalPeriodTable() {
- super();
-
- addKeyListener(this);
- addMouseListener(this);
-
+ public FiscalPeriodTable(FiscalPeriodViewHandler handler) {
+ super(handler);
+ lineRenderer = new FiscalPeriodRenderer();
}
- @Override
- public void mouseClicked(MouseEvent e) {
- }
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (rowAtPoint(e.getPoint()) == -1) {
- clearSelection();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
-
- @Override
- public void keyTyped(KeyEvent e) {
- }
-
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
- @Override
- public void keyPressed(KeyEvent e) {
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!isEditing()) {
- clearSelection();
- }
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
-
- @Override
- public TableCellRenderer getCellRenderer(int row, int column) {
- return new FiscalPeriodTableRenderer();
- }
-
}
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 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -27,15 +27,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.common.AbstractLimaTableModel;
-import javax.swing.table.AbstractTableModel;
-import java.text.SimpleDateFormat;
-import java.util.List;
-
-import static org.nuiton.i18n.I18n._;
-
/**
* Modele de Fiscal period (rendu de list)
*
@@ -45,116 +39,17 @@
* Last update : $Date$
* By : $Author$
*/
-public class FiscalPeriodTableModel extends AbstractTableModel {
+public class FiscalPeriodTableModel extends AbstractLimaTableModel<FiscalPeriod> {
/** serialVersionUID. */
private static final long serialVersionUID = 77027335135838258L;
private static final Log log = LogFactory.getLog(FiscalPeriodTableModel.class);
- protected List<FiscalPeriod> fiscalPeriods;
-
- public FiscalPeriodTableModel(List<FiscalPeriod> fiscalPeriods) {
- this.fiscalPeriods = fiscalPeriods;
- }
-
@Override
- public int getRowCount() {
- int result = 0;
- if (fiscalPeriods != null) {
- result = fiscalPeriods.size();
- }
- return result;
+ protected void initColumn() {
+ addColumn(new BeginColumn());
+ addColumn(new EndColumn());
+ addColumn(new StatusColumn());
}
-
- @Override
- public int getColumnCount() {
- return 2;
- }
-
- public FiscalPeriod getFiscalPeriodAt(int row) {
- if (row == -1) {
- return null;
- }
- FiscalPeriod result = fiscalPeriods.get(row);
- return result;
- }
-
- public int getRow(FiscalPeriod period) {
- if (period == null) {
- return -1;
- }
- return fiscalPeriods.indexOf(period);
- }
-
- @Override
- public String getColumnName(int columnIndex) {
-
- String result = "n/a";
-
- switch (columnIndex) {
- case 0:
- result = _("lima.ui.fiscalperiod.fiscalperiod");
- break;
- case 1:
- result = _("lima.ui.fiscalperiod.closure");
- break;
- }
-
- return result;
- }
-
- @Override
- public Object getValueAt(int rowIndex, int columnIndex) {
-
- Object result = "n/a";
-
- FiscalPeriod fiscalPeriod = getFiscalPeriodAt(rowIndex);
-
- if (fiscalPeriod != null) {
- // FIXME echatellier 20120405 i18n problem (hard coded)
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy");
-
- switch (columnIndex) {
- case 0:
- result = simpleDateFormat.
- format(fiscalPeriod.getBeginDate())
- + " - " + simpleDateFormat.
- format(fiscalPeriod.getEndDate());
- break;
- case 1:
- if (fiscalPeriod.getLocked()) {
- result = _("lima.ui.fiscalperiod.closed");
- } else {
- result = _("lima.ui.fiscalperiod.open");
- }
- break;
- }
- }
-
- return result;
- }
-
- public void addFiscalPeriod(FiscalPeriod fiscalPeriod) {
- fiscalPeriods.add(fiscalPeriod);
- int row = fiscalPeriods.indexOf(fiscalPeriod);
- fireTableRowsInserted(row, row);
- }
-
- public void deleteFiscalPeriod(FiscalPeriod fiscalPeriod) {
- int row = fiscalPeriods.indexOf(fiscalPeriod);
- fiscalPeriods.remove(fiscalPeriod);
- fireTableRowsDeleted(row, row);
- }
-
- public void updateFiscalPeriod(FiscalPeriod fiscalPeriod) throws LimaException {
- int row = fiscalPeriods.indexOf(fiscalPeriod);
-
- if (log.isDebugEnabled()) {
- log.debug("Selected row : " + row);
- }
-
- fiscalPeriods.set(row, fiscalPeriod);
- fireTableRowsUpdated(row, row);
- }
}
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 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2013-12-31 15:05:26 UTC (rev 3722)
@@ -70,10 +70,13 @@
<row>
<cell fill="both" weightx="1" weighty="1">
<JScrollPane>
+ <FiscalPeriodTableModel id="fiscalPeriodTableModel" />
<FiscalPeriodTable id="fiscalPeriodTable"
+ constructorParams='handler'
sortable="false"
rowHeight="24"
columnControlVisible="true"
+ model="{fiscalPeriodTableModel}"
selectionModel='{selectionModel}'/>
<ListSelectionModel id="selectionModel"
initializer="new DefaultListSelectionModel()"
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 2013-12-31 15:03:48 UTC (rev 3721)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -128,9 +128,8 @@
public void loadAllFiscalPeriod() {
List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods();
- FiscalPeriodTableModel model = new FiscalPeriodTableModel(periods);
- FiscalPeriodTable table = view.getFiscalPeriodTable();
- table.setModel(model);
+ FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel();
+ tableModel.setValues(periods);
}
/**
@@ -139,7 +138,7 @@
public void addFiscalPeriod() {
FiscalPeriodTable table = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel();
AddPeriod addPeriodDialog = new AddPeriod(view);
addPeriodDialog.setLocationRelativeTo(view);
@@ -161,7 +160,7 @@
if (response == JOptionPane.YES_OPTION) {
fiscalPeriod = fiscalPeriodService.createFiscalPeriod(fiscalPeriod);
- model.addFiscalPeriod(fiscalPeriod);
+ tableModel.addValue(fiscalPeriod);
}
}
}
@@ -172,13 +171,13 @@
public void deleteFiscalPeriod() {
FiscalPeriodTable table = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel();
int selectedRow = table.getSelectedRow();
if (selectedRow >=0 ) {
- FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
+ FiscalPeriod selectedFiscalPeriod = tableModel.get(selectedRow);
if (!selectedFiscalPeriod.isLocked()
&& financialTransactionService.getAllFinancialTransactions(selectedFiscalPeriod).isEmpty()) {
@@ -192,7 +191,7 @@
if (response == JOptionPane.YES_OPTION) {
fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
- model.deleteFiscalPeriod(selectedFiscalPeriod);
+ tableModel.remove(selectedFiscalPeriod);
view.setBlockEnabled(false);
view.setDeleteEnabled(false);
}
@@ -241,13 +240,13 @@
*/
public void blockFiscalPeriod() {
FiscalPeriodTable table = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel();
int selectedRow = table.getSelectedRow();
if (selectedRow >= 0) {
- FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
+ FiscalPeriod selectedFiscalPeriod = tableModel.get(selectedRow);
if (!selectedFiscalPeriod.isLocked()) {
@@ -298,7 +297,7 @@
}
FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, retainedEarnings);
- model.updateFiscalPeriod(fiscalPeriodBlocked);
+ tableModel.fireTableRowsUpdated(selectedRow, selectedRow);
view.setBlockEnabled(false);
view.setDeleteEnabled(false);
@@ -328,9 +327,9 @@
}
FiscalPeriodTable table = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
- if (model.getRowCount() != selectedRow) {
- FiscalPeriod fiscalPeriodAt = model.getFiscalPeriodAt(selectedRow);
+ FiscalPeriodTableModel tableModel = view.getFiscalPeriodTableModel();
+ if (tableModel.getRowCount() != selectedRow) {
+ FiscalPeriod fiscalPeriodAt = tableModel.get(selectedRow);
List<FinancialTransaction> financialTransactionList = financialTransactionService.getAllFinancialTransactions(fiscalPeriodAt);
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/StatusColumn.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/StatusColumn.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/StatusColumn.java 2013-12-31 15:05:26 UTC (rev 3722)
@@ -0,0 +1,33 @@
+package org.chorem.lima.ui.fiscalperiod;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.common.DefaultColumn;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class StatusColumn extends DefaultColumn<FiscalPeriodTableModel> {
+
+ @Override
+ public Class<?> getColumnClass() {
+ return String.class;
+ }
+
+ @Override
+ public String getColumnName() {
+ return _("lima.ui.fiscalperiod.status");
+ }
+
+ @Override
+ public Object getValueAt(int row) {
+ FiscalPeriod fiscalPeriod = tableModel.get(row);
+ String status = _("lima.ui.fiscalperiod.open");
+ if (fiscalPeriod.getLocked()) {
+ status = _("lima.ui.fiscalperiod.closed");
+ }
+ return status;
+ }
+
+}
\ No newline at end of file
1
0
r3721 - in trunk: lima-business/src/main/java/org/chorem/lima/business/utils lima-swing/src/main/java/org/chorem/lima/ui/celleditor lima-swing/src/main/resources lima-swing/src/main/resources/i18n
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:03:48 +0100 (Tue, 31 Dec 2013)
New Revision: 3721
Url: http://chorem.org/projects/lima/repository/revisions/3721
Log:
Factoring code of table and model table.
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateLimaTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties
trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties
trunk/lima-swing/src/main/resources/log4j.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/utils/EntryComparator.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -36,7 +36,14 @@
@Override
public int compare(Entry o1, Entry o2) {
- return o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
+ int result = o1.getFinancialTransaction().getTransactionDate().compareTo(o2.getFinancialTransaction().getTransactionDate());
+ if (result == 0) {
+ result = o1.getFinancialTransaction().getTopiaCreateDate().compareTo(o2.getFinancialTransaction().getTopiaCreateDate());
+ }
+ if (result == 0) {
+ result = o1.getTopiaCreateDate().compareTo(o2.getTopiaCreateDate());
+ }
+ return result;
}
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/AccountTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -29,7 +29,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class AccountTableCellRenderer extends EntryTableCellRenderer {
+public class AccountTableCellRenderer extends DefaultLimaTableCellRenderer {
@Override
public void setValue(Object value) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/BigDecimalTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -33,14 +33,10 @@
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
-public class BigDecimalTableCellRenderer extends EntryTableCellRenderer {
+public class BigDecimalTableCellRenderer extends DefaultLimaTableCellRenderer {
private static final long serialVersionUID = -2499433026151065390L;
- public BigDecimalTableCellRenderer() {
- //
- }
-
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
Copied: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateLimaTableCellRenderer.java (from rev 3719, trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java)
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateLimaTableCellRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateLimaTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -0,0 +1,44 @@
+package org.chorem.lima.ui.celleditor;
+
+/*
+ * #%L
+ * Lima :: Swing
+ * $Id$
+ * $HeadURL$
+ * %%
+ * 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(a)codelutin.com>
+ */
+public class DateLimaTableCellRenderer extends DefaultLimaTableCellRenderer {
+
+ @Override
+ protected void setValue(Object value) {
+ if (value instanceof Date) {
+ DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM);
+ super.setValue(format.format((Date) value));
+ } else {
+ super.setValue(value);
+ }
+ }
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DateTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -1,43 +0,0 @@
-package org.chorem.lima.ui.celleditor;
-
-/*
- * #%L
- * Lima :: Swing
- * $Id$
- * $HeadURL$
- * %%
- * 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(a)codelutin.com>
- */
-public class DateTableCellRenderer extends EntryTableCellRenderer {
-
- protected void setValue(Object value) {
- if (value instanceof Date) {
- DateFormat format = DateFormat.getDateInstance(DateFormat.MEDIUM);
- super.setValue(format.format((Date) value));
- } else {
- super.setValue(value);
- }
- }
-}
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/DefaultLimaTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -0,0 +1,100 @@
+package org.chorem.lima.ui.celleditor;
+
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+import org.chorem.lima.ui.common.TableModelWithGroup;
+import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
+import sun.swing.DefaultLookup;
+
+import javax.swing.*;
+import javax.swing.border.Border;
+import javax.swing.border.EmptyBorder;
+import javax.swing.table.TableCellRenderer;
+import java.awt.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class DefaultLimaTableCellRenderer implements TableCellRenderer {
+
+ private String text = null;
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ //Create a new JLabel to avoid colouring only when row is selected
+ JLabel myCell = new JLabel();
+ myCell.setOpaque(true);
+ myCell.setBorder(new EmptyBorder(1, 1, 1, 1));
+ myCell.setName("Table.entryCellRenderer");
+
+ Color background = Color.WHITE;
+ Color foreground = Color.BLACK;
+
+ if (isSelected) {
+ foreground = table.getSelectionForeground();
+ background = table.getSelectionBackground();
+ } else {
+ Color alternateColor = new Color(204, 207, 223);
+
+ if (table.getModel() instanceof TableModelWithGroup) {
+ TableModelWithGroup model = (TableModelWithGroup) table.getModel();
+ if (model.indexGroupAt(row) % 2 != 0) {
+ background = alternateColor;
+ }
+ } else if (row % 2 != 0) {
+ background = alternateColor;
+ }
+ }
+
+ if (table.isCellEditable(row, column)
+ && (value == null
+ || (value instanceof String) && ((String) value).isEmpty()
+ )
+ ) {
+ background = new Color(255, 198, 209);
+ }
+
+ if (table instanceof FinancialTransactionTable) {
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
+ if (model.getBalanceTransactionInRow(row).signum() != 0) {
+ foreground = new Color(240, 30, 30);
+ }
+ }
+
+ if (hasFocus) {
+ Border border = null;
+ if (isSelected) {
+ //FIXME tchemit-2013-08_02 Do not use sun. classes
+ border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusSelectedCellHighlightBorder");
+ }
+ if (border == null) {
+ //FIXME tchemit-2013-08_02 Do not use sun. classes
+ border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusCellHighlightBorder");
+ }
+ myCell.setBorder(border);
+ if (table.getModel().isCellEditable(row, column)) {
+ background = Color.WHITE;
+ foreground = Color.BLACK;
+ }
+ } else {
+ //FIXME tchemit-2013-08_02 Do not use sun. classes
+ Border border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.cellNoFocusBorder");
+ if (border == null) {
+ border = new EmptyBorder(1, 1, 1, 1);
+ }
+ myCell.setBorder(border);
+ }
+
+ myCell.setBackground(background);
+ myCell.setForeground(foreground);
+ setValue(value);
+
+ myCell.setText(text);
+
+ return myCell;
+ }
+
+ protected void setValue(Object value) {
+ this.text = (value == null) ? "" : value.toString();
+ }
+
+}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryBookTableCellRender.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -29,7 +29,7 @@
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class EntryBookTableCellRender extends EntryTableCellRenderer {
+public class EntryBookTableCellRender extends DefaultLimaTableCellRenderer {
@Override
public void setValue(Object value) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/EntryTableCellRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -24,105 +24,29 @@
* #L%
*/
-import org.chorem.lima.ui.common.TableModelWithGroup;
+import org.chorem.lima.ui.common.FinancialTransactionTableModel;
+import org.chorem.lima.ui.common.LineRenderer;
import org.chorem.lima.ui.financialtransaction.FinancialTransactionTable;
-import org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel;
-import sun.swing.DefaultLookup;
import javax.swing.*;
-import javax.swing.border.Border;
-import javax.swing.border.EmptyBorder;
-import javax.swing.table.TableCellRenderer;
import java.awt.*;
-import java.io.Serializable;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
*/
-public class EntryTableCellRenderer implements TableCellRenderer, Serializable {
+public class EntryTableCellRenderer extends LineRenderer {
- private String text = null;
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- //Create a new JLabel to avoid colouring only when row is selected
-
- JLabel myCell = new JLabel();
- myCell.setOpaque(true);
- myCell.setBorder(new EmptyBorder(1, 1, 1, 1));
- myCell.setName("Table.entryCellRenderer");
-
- Color background = Color.WHITE;
- Color foreground = Color.BLACK;
-
- if (isSelected) {
- foreground = table.getSelectionForeground();
- background = table.getSelectionBackground();
- } else {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- Color alternateColor = DefaultLookup.getColor(myCell, myCell.getUI(), "Table.alternateRowColor");
- if (alternateColor != null) {
-
- if (table.getModel() instanceof TableModelWithGroup) {
- TableModelWithGroup model = (TableModelWithGroup) table.getModel();
- if (model.indexGroupAt(row) % 2 != 0) {
- background = alternateColor;
- }
- } else if (row % 2 == 0) {
- background = alternateColor;
- }
- }
+ if (table instanceof FinancialTransactionTable) {
+ FinancialTransactionTableModel model = (FinancialTransactionTableModel) table.getModel();
+ if (!isSelected && model.getBalanceTransactionInRow(row).signum() != 0) {
+ component.setForeground(new Color(240, 30, 30));
}
-
- if (table.isCellEditable(row, column)
- && (value == null
- || (value instanceof String) && ((String) value).isEmpty()
- )
- ) {
- background = new Color(255, 198, 209);
- }
-
- if (table instanceof FinancialTransactionTable) {
- FinancialTransactionTableModel model = (FinancialTransactionTableModel) ((FinancialTransactionTable)table).getModel();
- if (model.getBalanceTransactionInRow(row).signum() != 0) {
- foreground = new Color(240, 30, 30);
- }
- }
-
- if (hasFocus) {
- Border border = null;
- if (isSelected) {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusSelectedCellHighlightBorder");
- }
- if (border == null) {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.focusCellHighlightBorder");
- }
- myCell.setBorder(border);
- if (table.getModel().isCellEditable(row, column)) {
- background = Color.WHITE;
- foreground = Color.BLACK;
- }
- } else {
- //FIXME tchemit-2013-08_02 Do not use sun. classes
- Border border = DefaultLookup.getBorder(myCell, myCell.getUI(), "Table.cellNoFocusBorder");
- if (border == null) {
- border = new EmptyBorder(1, 1, 1, 1);
- }
- myCell.setBorder(border);
- }
-
- myCell.setBackground(background);
- myCell.setForeground(foreground);
- setValue(value);
-
- myCell.setText(text);
-
- return myCell;
}
- protected void setValue(Object value) {
- this.text = (value == null) ? "" : value.toString();
- }
+ return component;
}
+}
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java 2013-12-31 15:03:48 UTC (rev 3721)
@@ -1,31 +0,0 @@
-package org.chorem.lima.ui.celleditor;
-
-import org.chorem.lima.entity.FiscalPeriod;
-import org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel;
-
-import javax.swing.*;
-import javax.swing.table.DefaultTableCellRenderer;
-import java.awt.*;
-
-/**
- * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
- */
-public class FiscalPeriodTableRenderer extends DefaultTableCellRenderer {
-
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
-
- Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- if (table.getModel() instanceof FiscalPeriodTableModel) {
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
- FiscalPeriod fiscalPeriod = model.getFiscalPeriodAt(row);
- if (!isSelected && fiscalPeriod.getLocked()) {
- component.setForeground(new Color(222, 0, 0));
- }
- }
- return component;
- }
-
-
-}
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 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_en_GB.properties 2013-12-31 15:03:48 UTC (rev 3721)
@@ -320,6 +320,7 @@
lima.ui.fiscalPeriod.buttonnext=
lima.ui.fiscalperiod.addfiscalperiod.morethan12=
lima.ui.fiscalperiod.addfiscalperiodtitle=
+lima.ui.fiscalperiod.begin=
lima.ui.fiscalperiod.block.addretainedearnings=
lima.ui.fiscalperiod.block.confirmation=
lima.ui.fiscalperiod.block.newyear=
@@ -331,9 +332,14 @@
lima.ui.fiscalperiod.closure=
lima.ui.fiscalperiod.delete.confirmation=
lima.ui.fiscalperiod.delete.title=
+lima.ui.fiscalperiod.end=
lima.ui.fiscalperiod.entrybooks.create=
lima.ui.fiscalperiod.fiscalperiod=
+lima.ui.fiscalperiod.fiscalperiod.begin=
+lima.ui.fiscalperiod.fiscalperiod.end=
+lima.ui.fiscalperiod.fiscalperiod.status=
lima.ui.fiscalperiod.open=
+lima.ui.fiscalperiod.status=
lima.ui.home.account=Chart of accounts
lima.ui.home.chartaccounts.create=Create the chart of accounts
lima.ui.home.chartaccounts.modify=Edit the chart of accounts
@@ -403,6 +409,7 @@
lima.ui.lettering.selectEntry=Actual selection
lima.ui.lettering.selectSolde=Balance
lima.ui.mainview.title=Lutin Invoice Monitoring and Accounting
+lima.ui.nonaffect=
lima.ui.opening.accounts=<html><center>Select a default, <br/>import your personnal<br/> or cancel to create your own account chart.</center></html>
lima.ui.opening.close=Close
lima.ui.opening.end=Finish
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 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/resources/i18n/lima-swing_fr_FR.properties 2013-12-31 15:03:48 UTC (rev 3721)
@@ -310,6 +310,7 @@
lima.ui.fiscalPeriod.buttonnext=
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.begin=Début
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?
@@ -321,9 +322,11 @@
lima.ui.fiscalperiod.closure=Cloture
lima.ui.fiscalperiod.delete.confirmation=Ètes vous sûre de vouloir supprimer cette période ? Cette action est irréversible \!
lima.ui.fiscalperiod.delete.title=Suppression de l'exercice
+lima.ui.fiscalperiod.end=Fin
lima.ui.fiscalperiod.entrybooks.create=Création d'un nouveau journal
lima.ui.fiscalperiod.fiscalperiod=Exercice
lima.ui.fiscalperiod.open=Ouvert
+lima.ui.fiscalperiod.status=Statut
lima.ui.home.account=Plan comptable
lima.ui.home.chartaccounts.create=Créer le plan des comptes
lima.ui.home.chartaccounts.modify=Modifier le plan des comptes
@@ -393,6 +396,7 @@
lima.ui.lettering.selectEntry=Sélection courante
lima.ui.lettering.selectSolde=Solde
lima.ui.mainview.title=Lutin Invoice Monitoring and Accounting
+lima.ui.nonaffect=
lima.ui.opening.accounts=<html><center>Veuillez sélectionner un plan par défault, <br/>importer un plan personnalisé<br/> ou annuler pour créer votre propre plan.</center></html>
lima.ui.opening.close=Fermer
lima.ui.opening.end=Terminer
Modified: trunk/lima-swing/src/main/resources/log4j.properties
===================================================================
--- trunk/lima-swing/src/main/resources/log4j.properties 2013-12-31 15:00:00 UTC (rev 3720)
+++ trunk/lima-swing/src/main/resources/log4j.properties 2013-12-31 15:03:48 UTC (rev 3721)
@@ -42,7 +42,7 @@
log4j.logger.org.chorem.lima.ui.lettering.LetteringViewHandler=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LettringSelectionModel=DEBUG
log4j.logger.org.chorem.lima.ui.lettering.LetteringEditModel=DEBUG
-log4j.logger.org.chorem.lima.ui.financialtransaction.FinancialTransactionTableModel=DEBUG
+log4j.logger.org.chorem.lima.ui.common.FinancialTransactionTableModel=DEBUG
log4j.logger.org.chorem.lima.ui.celleditor.BigDecimalTableCellEditor=DEBUG
log4j.logger.org.chorem.lima.business.accountingrules.DefaultAccountingRules=DEBUG
log4j.logger.org.chorem.lima.business.ejb.FinancialTransactionServiceImpl=DEBUG
1
0
r3720 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction
by sbavencoff@users.chorem.org 31 Dec '13
by sbavencoff@users.chorem.org 31 Dec '13
31 Dec '13
Author: sbavencoff
Date: 2013-12-31 16:00:00 +0100 (Tue, 31 Dec 2013)
New Revision: 3720
Url: http://chorem.org/projects/lima/repository/revisions/3720
Log:
Factoring code of table and model table.
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-12-06 16:18:54 UTC (rev 3719)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransaction/FinancialTransactionTableModel.java 2013-12-31 15:00:00 UTC (rev 3720)
@@ -1,352 +0,0 @@
-/*
- * #%L
- * Lima Swing
- *
- * $Id$
- * $HeadURL$
- * %%
- * 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
- * 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%
- */
-
-package org.chorem.lima.ui.financialtransaction;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.chorem.lima.business.api.FinancialTransactionService;
-import org.chorem.lima.business.utils.EntryComparator;
-import org.chorem.lima.business.utils.FinancialTransactionComparator;
-import org.chorem.lima.entity.Entry;
-import org.chorem.lima.entity.EntryImpl;
-import org.chorem.lima.entity.FinancialTransaction;
-import org.chorem.lima.entity.FinancialTransactionImpl;
-import org.chorem.lima.service.LimaServiceFactory;
-import org.chorem.lima.ui.common.Column;
-import org.chorem.lima.ui.common.TableModelWithGroup;
-
-import javax.swing.table.AbstractTableModel;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Basic transaction table model.
- *
- * @author ore
- * @author chatellier
- * @version $Revision$
- */
-public class FinancialTransactionTableModel extends AbstractTableModel implements TableModelWithGroup {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -7495388454688562991L;
-
- protected static final Log log = LogFactory.getLog(FinancialTransactionTableModel.class);
-
- /** Service (just to update setValueAt(). */
- protected FinancialTransactionService financialTransactionService;
-
- protected List<Column> columns;
-
- protected List<Entry> entries;
-
- protected List<FinancialTransaction> transactions;
-
- public FinancialTransactionTableModel() {
- columns = new ArrayList<Column>();
- initColumns();
-
- financialTransactionService =
- LimaServiceFactory.getService(FinancialTransactionService.class);
- entries = new ArrayList<Entry>();
- transactions = new ArrayList<FinancialTransaction>();
- }
-
- protected void initColumns() {
- columns.add(new DateColumn(this));
- columns.add(new VoucherColumn(this));
- columns.add(new AccountColumn(this));
- columns.add(new DescriptionColumn(this));
- columns.add(new DebitColumn(this));
- columns.add(new CreditColumn(this));
- }
-
- public Column getColumn(int column) {
- return columns.get(column);
- }
-
- public void setTransactions(List<FinancialTransaction> transactions) {
- this.transactions.clear();
- this.transactions.addAll(transactions);
- sortEntries();
- }
-
- public void sortEntries() {
- Collections.sort(transactions, new FinancialTransactionComparator());
- entries.clear();
- for (FinancialTransaction transaction : transactions) {
- if (transaction.sizeEntry() > 0) {
- List<Entry> entries = new ArrayList<Entry>(transaction.getEntry());
- Collections.sort(entries, new EntryComparator());
- this.entries.addAll(entries);
- } else {
- Entry entry = new EntryImpl();
- entry.setFinancialTransaction(transaction);
- entry = financialTransactionService.createEntry(entry);
- transaction.addEntry(entry);
- financialTransactionService.updateFinancialTransaction(transaction);
- this.entries.add(entry);
- }
- }
- fireTableDataChanged();
- }
-
- @Override
- public int getColumnCount() {
- return columns.size();
- }
-
- @Override
- public int getRowCount() {
- return entries.size();
- }
-
- @Override
- public Class<?> getColumnClass(int column) {
- Class result = null;
- if (column >= 0 && column < columns.size()) {
- result = columns.get(column).getColumnClass();
- }
- return result;
- }
-
- @Override
- public String getColumnName(int column) {
- String result = "n/a";
- if (column >= 0 && column < columns.size()) {
- result = columns.get(column).getColumnName();
- }
- return result;
- }
-
- @Override
- public Object getValueAt(int row, int column) {
- Object result = null;
- if (column >= 0 && column < columns.size()) {
- result = columns.get(column).getValueAt(row);
- }
- return result;
- }
-
- /**
- * To set cells editable or not
- * different condition for entry or financial transaction
- */
- @Override
- public boolean isCellEditable(int row, int column) {
- boolean result = false;
- if (column >= 0 && column < columns.size()) {
- result = columns.get(column).isCellEditable(row);
- }
- return result;
- }
-
- /** to modifiy financialtransaction or entry */
- @Override
- public void setValueAt(Object value, int row, int column) {
- boolean update = false;
- if (column >= 0 && column < columns.size()) {
- update = columns.get(column).setValueAt(value, row);
- }
- // some modification must update all other
- // first row modification update following rows
- if (update) {
- fireTableCellUpdated(row, column);
- }
- }
-
- public Entry getEntryAt(int row) {
- return entries.get(row);
- }
-
- public FinancialTransaction getTransactionAt(int row) {
- Entry entry = entries.get(row);
- return entry.getFinancialTransaction();
- }
-
- public int indexOf(Entry entry) {
- return entries.indexOf(entry);
- }
-
- public int indexOf(FinancialTransaction transaction) {
- int index = 0;
- Collection<Entry> entriesTransaction = transaction.getEntry();
- for (Entry entry : entries) {
- if (!entriesTransaction.contains(entry)) {
- index++;
- } else {
- break;
- }
- }
- return index;
- }
-
- /**
- * Insert new entry.
- *
- * @param entry entry to insert
- */
- public Entry addEntry(Entry entry) {
- Entry newEntry = null;
- FinancialTransaction transaction = entry.getFinancialTransaction();
- if (transactions.contains(transaction)) {
- newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(transaction);
- newEntry.setVoucher(entry.getVoucher());
- newEntry.setAccount(entry.getAccount());
- newEntry.setDescription(entry.getDescription());
- newEntry.setAmount(entry.getAmount());
- newEntry.setDebit(entry.getDebit());
- newEntry = financialTransactionService.createEntry(newEntry);
-
- transaction.addEntry(newEntry);
- financialTransactionService.updateFinancialTransaction(transaction);
- int row = indexOf(transaction) + transaction.sizeEntry() - 1;
- entries.add(row, newEntry);
- fireTableRowsInserted(row, row);
- }
- return newEntry;
- }
-
- /**
- * Delete selected row in table (could be transaction or entry).
- * <p/>
- * Called by model.
- *
- * @param row
- */
- public void removeTransaction(int row) {
- FinancialTransaction transaction = getTransactionAt(row);
- int firstRow = indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- financialTransactionService.removeFinancialTransaction(transaction);
- entries.removeAll(transaction.getEntry());
- transactions.remove(transaction);
- fireTableRowsDeleted(firstRow, lastRow);
- }
-
- public void removeEntry(int row) {
- Entry entry = getEntryAt(row);
- FinancialTransaction transaction = entry.getFinancialTransaction();
- if (transaction.sizeEntry() > 1) {
- financialTransactionService.removeEntry(entry);
- transaction.removeEntry(entry);
- entries.remove(entry);
- } else {
- financialTransactionService.removeFinancialTransaction(transaction);
- entries.removeAll(transaction.getEntry());
- transactions.remove(transaction);
- }
- fireTableRowsDeleted(row, row);
- }
-
- public FinancialTransaction addTransaction(FinancialTransaction transaction) {
- FinancialTransaction newTransaction = new FinancialTransactionImpl();
- newTransaction.setEntryBook(transaction.getEntryBook());
- newTransaction.setTransactionDate(transaction.getTransactionDate());
- newTransaction = financialTransactionService.createFinancialTransaction(newTransaction);
-
- if (transaction.getEntry() == null || transaction.getEntry().isEmpty()) {
- Entry newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(newTransaction);
- newEntry = financialTransactionService.createEntry(newEntry);
- newTransaction.addEntry(newEntry);
-
- newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(newTransaction);
- newEntry = financialTransactionService.createEntry(newEntry);
- newTransaction.addEntry(newEntry);
- } else {
- for (Entry entry : transaction.getEntry()) {
- Entry newEntry = new EntryImpl();
- newEntry.setFinancialTransaction(newTransaction);
- newEntry.setVoucher(entry.getVoucher());
- newEntry.setAccount(entry.getAccount());
- newEntry.setDescription(entry.getDescription());
- newEntry.setAmount(entry.getAmount());
- newEntry.setDebit(entry.getDebit());
- newEntry = financialTransactionService.createEntry(newEntry);
- newTransaction.addEntry(newEntry);
- }
- financialTransactionService.updateFinancialTransaction(newTransaction);
- }
-
- int indexFirstEntry = entries.size();
- transactions.add(newTransaction);
- entries.addAll(newTransaction.getEntry());
- int indexLastEntry = entries.size() - 1;
- fireTableRowsInserted(indexFirstEntry, indexLastEntry);
- return newTransaction;
- }
-
- public BigDecimal getBalanceTransactionInRow(int row) {
- FinancialTransaction transaction = getTransactionAt(row);
- BigDecimal debit = transaction.getAmountDebit();
- BigDecimal credit = transaction.getAmountCredit();
- BigDecimal balance = debit.subtract(credit);
- return balance;
- }
-
- public int size() {
- int result = 0;
- if (entries != null) {
- result = entries.size();
- }
- return result;
- }
-
-
- @Override
- public int indexGroupAt(int row) {
- FinancialTransaction transaction = getTransactionAt(row);
- int index = transactions.indexOf(transaction);
- return index;
-
- }
-
- public void updateEntry(Entry entry) {
- if (log.isDebugEnabled()) {
- log.debug("Update Entry");
- }
- financialTransactionService.updateEntry(entry);
- }
-
- public void updateTransaction(FinancialTransaction transaction) {
- if (log.isDebugEnabled()) {
- log.debug("Update transaction");
- }
- financialTransactionService.updateFinancialTransaction(transaction);
- }
-
- public void fireTransaction(FinancialTransaction transaction) {
- int firstRow = indexOf(transaction);
- int lastRow = firstRow + transaction.sizeEntry() - 1;
- fireTableRowsUpdated(firstRow, lastRow);
- }
-}
1
0
r3719 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/celleditor java/org/chorem/lima/ui/fiscalperiod resources/icons
by sbavencoff@users.chorem.org 06 Dec '13
by sbavencoff@users.chorem.org 06 Dec '13
06 Dec '13
Author: sbavencoff
Date: 2013-12-06 17:18:54 +0100 (Fri, 06 Dec 2013)
New Revision: 3719
Url: http://chorem.org/projects/lima/repository/revisions/3719
Log:
[Fiscal Period] : move button into toolBar
add shortcuts
add icons
fix error in close or delete when selected row is empty or invalid
Added:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java
trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png
trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-new.png
trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-remove.png
Removed:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodModelUI.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
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java (rev 0)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/celleditor/FiscalPeriodTableRenderer.java 2013-12-06 16:18:54 UTC (rev 3719)
@@ -0,0 +1,31 @@
+package org.chorem.lima.ui.celleditor;
+
+import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.fiscalperiod.FiscalPeriodTableModel;
+
+import javax.swing.*;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.*;
+
+/**
+ * @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
+ */
+public class FiscalPeriodTableRenderer extends DefaultTableCellRenderer {
+
+ public Component getTableCellRendererComponent(JTable table, Object value,
+ boolean isSelected, boolean hasFocus, int row, int column) {
+
+ Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+
+ if (table.getModel() instanceof FiscalPeriodTableModel) {
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ FiscalPeriod fiscalPeriod = model.getFiscalPeriodAt(row);
+ if (!isSelected && fiscalPeriod.getLocked()) {
+ component.setForeground(new Color(222, 0, 0));
+ }
+ }
+ return component;
+ }
+
+
+}
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 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/AddPeriod.jaxx 2013-12-06 16:18:54 UTC (rev 3719)
@@ -31,8 +31,6 @@
<FiscalPeriodViewHandler id='handler' initializer='getContextValue(FiscalPeriodView.class,JAXXUtil.PARENT).getHandler()'/>
- <FiscalPeriodTableModel id="modelFiscalPeriodTable"/>
-
<FiscalPeriod id="period" javaBean="new org.chorem.lima.entity.FiscalPeriodImpl()"/>
<script>
Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodModelUI.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodModelUI.java 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodModelUI.java 2013-12-06 16:18:54 UTC (rev 3719)
@@ -1,66 +0,0 @@
-package org.chorem.lima.ui.fiscalperiod;
-/*
- * #%L
- * Lima :: Swing
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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 org.chorem.lima.entity.FiscalPeriod;
-import org.jdesktop.beans.AbstractSerializableBean;
-
-public class FiscalPeriodModelUI extends AbstractSerializableBean {
-
- private static final long serialVersionUID = 1L;
-
- public static final String BLOCK_ENABLED_PROPERTY = "blockEnabled";
-
- public static final String DELETE_ENABLED_PROPERTY = "deleteEnabled";
-
- protected FiscalPeriod selectedFiscalPeriod;
- protected boolean blockEnabled;
- protected boolean deleteEnabled;
-
- public FiscalPeriodModelUI() {
- }
-
- public boolean isDeleteEnabled() {
- return deleteEnabled;
- }
-
- public boolean isBlockEnabled() {
- return blockEnabled;
- }
-
- public void setBlockEnabled(boolean blockEnabled) {
- Boolean oldValue = isBlockEnabled();
- this.blockEnabled = blockEnabled;
- firePropertyChange(BLOCK_ENABLED_PROPERTY, oldValue, blockEnabled);
- }
-
- public void setDeleteEnabled(boolean deleteEnabled) {
- Boolean oldValue = isDeleteEnabled();
- this.deleteEnabled = deleteEnabled;
- firePropertyChange(DELETE_ENABLED_PROPERTY, oldValue, deleteEnabled);
- }
-
-
-
-}
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 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTable.java 2013-12-06 16:18:54 UTC (rev 3719)
@@ -25,15 +25,10 @@
package org.chorem.lima.ui.fiscalperiod;
-import org.chorem.lima.entity.FiscalPeriod;
+import org.chorem.lima.ui.celleditor.FiscalPeriodTableRenderer;
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 java.awt.Color;
-import java.awt.Component;
+import javax.swing.table.TableCellRenderer;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
@@ -59,37 +54,14 @@
private static final long serialVersionUID = -8462838870024505659L;
- protected FiscalPeriodTableModel model;
+ public FiscalPeriodTable() {
+ super();
- public FiscalPeriodTable(FiscalPeriodTableModel model) {
- super(model);
- this.model = model;
-
addKeyListener(this);
addMouseListener(this);
- // 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 = model.getFiscalPeriodAt(adapter.row);
- return fiscalPeriod.getLocked();
- }
- };
- Highlighter colorTransaction =
- new ColorHighlighter(predicate, null, new Color(222, 0, 0));
- addHighlighter(colorTransaction);
- }
-
@Override
public void mouseClicked(MouseEvent e) {
}
@@ -135,4 +107,9 @@
public void keyReleased(KeyEvent e) {
}
+ @Override
+ public TableCellRenderer getCellRenderer(int row, int column) {
+ return new FiscalPeriodTableRenderer();
+ }
+
}
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 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodTableModel.java 2013-12-06 16:18:54 UTC (rev 3719)
@@ -25,18 +25,17 @@
package org.chorem.lima.ui.fiscalperiod;
-import static org.nuiton.i18n.I18n._;
-
-import java.text.SimpleDateFormat;
-import java.util.List;
-
-import javax.swing.table.AbstractTableModel;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.LimaException;
import org.chorem.lima.entity.FiscalPeriod;
+import javax.swing.table.AbstractTableModel;
+import java.text.SimpleDateFormat;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Modele de Fiscal period (rendu de list)
*
@@ -55,9 +54,8 @@
protected List<FiscalPeriod> fiscalPeriods;
- public void setFiscalPeriods(List<FiscalPeriod> fiscalPeriods) {
+ public FiscalPeriodTableModel(List<FiscalPeriod> fiscalPeriods) {
this.fiscalPeriods = fiscalPeriods;
- fireTableDataChanged();
}
@Override
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 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodView.jaxx 2013-12-06 16:18:54 UTC (rev 3719)
@@ -27,16 +27,15 @@
<import>
javax.swing.ListSelectionModel
- javax.swing.DefaultListSelectionModel
- org.chorem.lima.entity.FiscalPeriod
- org.chorem.lima.entity.FinancialPeriod
+ javax.swing.DefaultListSelectionModel
+ static org.nuiton.i18n.I18n._
</import>
<FiscalPeriodViewHandler id="handler" constructorParams="this"/>
- <FiscalPeriodTableModel id="fiscalPeriodTableModel" />
- <ListSelectionModel id="selectionModel" initializer="new DefaultListSelectionModel()" onValueChanged="handler.onSelectionChanged(event)" selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
- <FiscalPeriodModelUI id='model' javaBean='new FiscalPeriodModelUI()'/>
+ <Boolean id="blockEnabled" javaBean="false"/>
+ <Boolean id="deleteEnabled" javaBean="false"/>
+
<script><![CDATA[
void $afterCompleteSetup() {
getHandler().init();
@@ -44,34 +43,44 @@
]]></script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows="5">
- <JScrollPane>
- <FiscalPeriodTable
- id="fiscalPeriodTable" sortable="false" rowHeight="24"
- constructorParams="getFiscalPeriodTableModel()"
- columnControlVisible="true"
- selectionModel='{selectionModel}'/>
- </JScrollPane>
- </cell>
- </row>
- <row>
<cell fill="horizontal">
- <JButton id="addButton" text="lima.charts.fiscalperiod.add"
- onActionPerformed="getHandler().addFiscalPeriod()"/>
+ <JToolBar floatable="false">
+
+ <JButton id="addButton"
+ toolTipText="{ _("lima.charts.fiscalperiod.add") + " (Ctrl+N)"}"
+ actionIcon='fiscalPeriod-new'
+ onActionPerformed="handler.addFiscalPeriod()"/>
+
+ <JButton id="blockButton"
+ toolTipText="{ _("lima.charts.fiscalperiod.block") + " (Ctrl+C)"}"
+ actionIcon='fiscalPeriod-close'
+ onActionPerformed="handler.blockFiscalPeriod()"
+ enabled="{isBlockEnabled()}"/>
+
+ <JButton id="deleteButton"
+ toolTipText="{ _("lima.charts.fiscalperiod.delete") + " (Del)"}"
+ actionIcon='fiscalPeriod-remove'
+ onActionPerformed="handler.deleteFiscalPeriod()"
+ enabled="{isDeleteEnabled()}"/>
+
+ </JToolBar>
</cell>
</row>
+
<row>
- <cell fill="horizontal">
- <JButton id="blockButton" text="lima.charts.fiscalperiod.block"
- enabled="{model.isBlockEnabled()}"
- onActionPerformed="getHandler().blockFiscalPeriod()"/>
+ <cell fill="both" weightx="1" weighty="1">
+ <JScrollPane>
+ <FiscalPeriodTable id="fiscalPeriodTable"
+ sortable="false"
+ rowHeight="24"
+ columnControlVisible="true"
+ selectionModel='{selectionModel}'/>
+ <ListSelectionModel id="selectionModel"
+ initializer="new DefaultListSelectionModel()"
+ onValueChanged="handler.onSelectionChanged(event)"
+ selectionMode="{ListSelectionModel.SINGLE_SELECTION}"/>
+
+ </JScrollPane>
</cell>
</row>
- <row>
- <cell fill="horizontal">
- <JButton id="deleteButton" text="lima.charts.fiscalperiod.delete"
- enabled="{model.isDeleteEnabled()}"
- onActionPerformed="getHandler().deleteFiscalPeriod()"/>
- </cell>
- </row>
</Table>
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 2013-12-06 13:25:34 UTC (rev 3718)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/fiscalperiod/FiscalPeriodViewHandler.java 2013-12-06 16:18:54 UTC (rev 3719)
@@ -25,16 +25,6 @@
package org.chorem.lima.ui.fiscalperiod;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-
-import javax.swing.DefaultListSelectionModel;
-import javax.swing.JOptionPane;
-import javax.swing.event.ListSelectionEvent;
-
import org.apache.commons.lang3.time.DateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -47,9 +37,18 @@
import org.chorem.lima.entity.FinancialTransaction;
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import org.jdesktop.swingx.JXTable;
import org.nuiton.util.DateUtil;
+import javax.swing.*;
+import javax.swing.event.ListSelectionEvent;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler pour la gestion des exercices (creation/fermeture).
*
@@ -85,6 +84,41 @@
}
public void init() {
+
+ InputMap inputMap = view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = view.getActionMap();
+
+ // add action on Ctrl + N
+ String binding = "new-FiscalPeriod";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addFiscalPeriod();
+ }
+ });
+
+ // add action on Delete
+ binding = "remove-FiscalPeriod";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ deleteFiscalPeriod();
+ }
+ });
+
+ // add action on Ctrl + B
+ binding = "close-FiscalPeriod";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ blockFiscalPeriod();
+ }
+ });
+
+
loadAllFiscalPeriod();
}
@@ -93,7 +127,10 @@
*/
public void loadAllFiscalPeriod() {
List<FiscalPeriod> periods = fiscalPeriodService.getAllFiscalPeriods();
- view.getFiscalPeriodTableModel().setFiscalPeriods(periods);
+
+ FiscalPeriodTableModel model = new FiscalPeriodTableModel(periods);
+ FiscalPeriodTable table = view.getFiscalPeriodTable();
+ table.setModel(model);
}
/**
@@ -101,7 +138,8 @@
*/
public void addFiscalPeriod() {
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTable().getModel();
+ FiscalPeriodTable table = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
AddPeriod addPeriodDialog = new AddPeriod(view);
addPeriodDialog.setLocationRelativeTo(view);
@@ -133,25 +171,33 @@
*/
public void deleteFiscalPeriod() {
- JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = (FiscalPeriodTableModel) view.getFiscalPeriodTable().getModel();
+ FiscalPeriodTable table = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
- //check if the user want to delete the fiscal year
- int response = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.delete.confirmation"),
- _("lima.ui.fiscalperiod.delete.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
+ int selectedRow = table.getSelectedRow();
- int selectedRow = fiscalPeriodeTable.getSelectedRow();
- FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
+ if (selectedRow >=0 ) {
- if (response == JOptionPane.YES_OPTION) {
- fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
+ FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
- model.deleteFiscalPeriod(selectedFiscalPeriod);
- view.getModel().setBlockEnabled(false);
- view.getModel().setDeleteEnabled(false);
- }
+ if (!selectedFiscalPeriod.isLocked()
+ && financialTransactionService.getAllFinancialTransactions(selectedFiscalPeriod).isEmpty()) {
+
+ //check if the user want to delete the fiscal year
+ int response = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.delete.confirmation"),
+ _("lima.ui.fiscalperiod.delete.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE);
+
+ if (response == JOptionPane.YES_OPTION) {
+ fiscalPeriodService.deleteFiscalPeriod(selectedFiscalPeriod);
+
+ model.deleteFiscalPeriod(selectedFiscalPeriod);
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
+ }
+ }
+ }
}
/**
@@ -194,63 +240,70 @@
* after user confirmations
*/
public void blockFiscalPeriod() {
- JXTable fiscalPeriodeTable = view.getFiscalPeriodTable();
- FiscalPeriodTableModel model = view.getFiscalPeriodTableModel();
-
- int selectedRow = fiscalPeriodeTable.getSelectedRow();
- FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
+ FiscalPeriodTable table = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
- //check if the user want to block the fiscal year
- int answerBlock = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.block.confirmation"),
- _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.WARNING_MESSAGE);
-
- if (answerBlock == JOptionPane.YES_OPTION) {
- boolean retainedEarnings = false;
- EntryBook entryBook = null;
+ int selectedRow = table.getSelectedRow();
- //check if the user wants to create a new fiscal year
- int answerCreate = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.block.newyear"),
- _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ if (selectedRow >= 0) {
- // create a new fiscal year
- if (answerCreate == JOptionPane.YES_OPTION) {
- addFiscalPeriod();
+ FiscalPeriod selectedFiscalPeriod = model.getFiscalPeriodAt(selectedRow);
- //report if they are at least one transaction to be report
- if (fiscalPeriodService.isRetainedEarnings(selectedFiscalPeriod)) {
+ if (!selectedFiscalPeriod.isLocked()) {
- //check if the user wants to report datas
- int answerRetainedEarnings = JOptionPane.showConfirmDialog(view,
- _("lima.ui.fiscalperiod.block.addretainedearnings"),
- _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ //check if the user want to block the fiscal year
+ int answerBlock = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.block.confirmation"),
+ _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.WARNING_MESSAGE);
- if (answerRetainedEarnings == JOptionPane.YES_OPTION) {
- retainedEarnings = true;
+ if (answerBlock == JOptionPane.YES_OPTION) {
+ boolean retainedEarnings = false;
+ EntryBook entryBook = null;
- //Sets EntryBook
- EntryBook newEntryBook = new EntryBookImpl();
- RetainedEarningsEntryBookForm entryBookForm =
- new RetainedEarningsEntryBookForm(view);
- entryBookForm.setEntryBook(newEntryBook);
+ //check if the user wants to create a new fiscal year
+ int answerCreate = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.block.newyear"),
+ _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
- // jaxx constructor don't call super() ?
- entryBookForm.setLocationRelativeTo(view);
- entryBookForm.setVisible(true);
- entryBook = entryBookForm.getEntryBook();
+ // create a new fiscal year
+ if (answerCreate == JOptionPane.YES_OPTION) {
+ addFiscalPeriod();
+
+ //report if they are at least one transaction to be report
+ if (fiscalPeriodService.isRetainedEarnings(selectedFiscalPeriod)) {
+
+ //check if the user wants to report datas
+ int answerRetainedEarnings = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.fiscalperiod.block.addretainedearnings"),
+ _("lima.ui.fiscalperiod.block.title"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
+
+ if (answerRetainedEarnings == JOptionPane.YES_OPTION) {
+ retainedEarnings = true;
+
+ //Sets EntryBook
+ EntryBook newEntryBook = new EntryBookImpl();
+ RetainedEarningsEntryBookForm entryBookForm =
+ new RetainedEarningsEntryBookForm(view);
+ entryBookForm.setEntryBook(newEntryBook);
+
+ // jaxx constructor don't call super() ?
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
+ entryBook = entryBookForm.getEntryBook();
+ }
+ }
}
+
+ FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, retainedEarnings);
+ model.updateFiscalPeriod(fiscalPeriodBlocked);
+
+ view.setBlockEnabled(false);
+ view.setDeleteEnabled(false);
}
}
-
- FiscalPeriod fiscalPeriodBlocked = fiscalPeriodService.retainedEarningsAndBlockFiscalPeriod(selectedFiscalPeriod, entryBook, retainedEarnings);
- model.updateFiscalPeriod(fiscalPeriodBlocked);
-
- view.getModel().setBlockEnabled(false);
- view.getModel().setDeleteEnabled(false);
}
}
@@ -274,9 +327,10 @@
selectedRow = listSelectionEvent.getLastIndex();
}
- FiscalPeriodTableModel fiscalPeriodTableModel = view.getFiscalPeriodTableModel();
- if (fiscalPeriodTableModel.getRowCount() != selectedRow) {
- FiscalPeriod fiscalPeriodAt = fiscalPeriodTableModel.getFiscalPeriodAt(selectedRow);
+ FiscalPeriodTable table = view.getFiscalPeriodTable();
+ FiscalPeriodTableModel model = (FiscalPeriodTableModel) table.getModel();
+ if (model.getRowCount() != selectedRow) {
+ FiscalPeriod fiscalPeriodAt = model.getFiscalPeriodAt(selectedRow);
List<FinancialTransaction> financialTransactionList = financialTransactionService.getAllFinancialTransactions(fiscalPeriodAt);
@@ -303,8 +357,8 @@
enableDelete = financialTransactionList.size() <= 0;
}
}
- view.getModel().setBlockEnabled(enableBlock);
- view.getModel().setDeleteEnabled(enableDelete);
+ view.setBlockEnabled(enableBlock);
+ view.setDeleteEnabled(enableDelete);
}
}
}
Added: trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-close.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Copied: trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-new.png (from rev 3718, trunk/lima-swing/src/main/resources/icons/action-entryBook-new.png)
===================================================================
(Binary files differ)
Copied: trunk/lima-swing/src/main/resources/icons/action-fiscalPeriod-remove.png (from rev 3718, trunk/lima-swing/src/main/resources/icons/action-entryBook-remove.png)
===================================================================
(Binary files differ)
1
0
r3718 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook
by sbavencoff@users.chorem.org 06 Dec '13
by sbavencoff@users.chorem.org 06 Dec '13
06 Dec '13
Author: sbavencoff
Date: 2013-12-06 14:25:34 +0100 (Fri, 06 Dec 2013)
New Revision: 3718
Url: http://chorem.org/projects/lima/repository/revisions/3718
Log:
[Entry Book] : fix error in modify or delete when selected row is empty
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-11-22 16:49:26 UTC (rev 3717)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-12-06 13:25:34 UTC (rev 3718)
@@ -180,33 +180,35 @@
EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
int selectedRow = entryBookTable.getSelectedRow();
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
- final EntryBookForm entryBookForm = new EntryBookForm(view);
+ if (selectedRow >= 0) {
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ final EntryBookForm entryBookForm = new EntryBookForm(view);
- InputMap inputMap = entryBookForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
- ActionMap actionMap = entryBookForm.getRootPane().getActionMap();
- String binding = "dispose";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), binding);
- actionMap.put(binding, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- entryBookForm.performCancel();
- }
- });
+ InputMap inputMap = entryBookForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = entryBookForm.getRootPane().getActionMap();
+ String binding = "dispose";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ entryBookForm.performCancel();
+ }
+ });
- entryBookForm.setAddState(false);
- entryBookForm.setEntryBook(selectedEntryBook);
- entryBookForm.setLocationRelativeTo(view);
- entryBookForm.setVisible(true);
+ entryBookForm.setAddState(false);
+ entryBookForm.setEntryBook(selectedEntryBook);
+ entryBookForm.setLocationRelativeTo(view);
+ entryBookForm.setVisible(true);
- // null == cancel action
- selectedEntryBook = entryBookForm.getEntryBook();
- if (selectedEntryBook != null) {
- // service call
- selectedEntryBook = entryBookService.updateEntryBook(selectedEntryBook);
+ // null == cancel action
+ selectedEntryBook = entryBookForm.getEntryBook();
+ if (selectedEntryBook != null) {
+ // service call
+ selectedEntryBook = entryBookService.updateEntryBook(selectedEntryBook);
- // ui refresh
- entryBookTableModel.updateEntryBook(selectedEntryBook);
+ // ui refresh
+ entryBookTableModel.updateEntryBook(selectedEntryBook);
+ }
}
}
@@ -216,21 +218,23 @@
public void deleteEntryBook() {
JXTable entryBookTable = view.getEntryBooksTable();
int selectedRow = entryBookTable.getSelectedRow();
- EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
- EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
+ if (selectedRow >= 0) {
+ EntryBookTableModel entryBookTableModel = (EntryBookTableModel) entryBookTable.getModel();
- int response = JOptionPane.showConfirmDialog(view,
- _("lima.ui.entrybook.deletemessage", selectedEntryBook.getLabel()),
- _("lima.ui.entrybook.deletetitle"), JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE);
+ EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
- if (response == JOptionPane.YES_OPTION) {
+ int response = JOptionPane.showConfirmDialog(view,
+ _("lima.ui.entrybook.deletemessage", selectedEntryBook.getLabel()),
+ _("lima.ui.entrybook.deletetitle"), JOptionPane.YES_NO_OPTION,
+ JOptionPane.QUESTION_MESSAGE);
- entryBookService.removeEntryBook(selectedEntryBook);
- entryBookTableModel.removeEntryBook(selectedEntryBook);
+ if (response == JOptionPane.YES_OPTION) {
+
+ entryBookService.removeEntryBook(selectedEntryBook);
+ entryBookTableModel.removeEntryBook(selectedEntryBook);
+ }
}
-
}
/**
1
0