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
- 1853 discussions
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
r3717 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/entrybook resources/icons
by sbavencoff@users.chorem.org 22 Nov '13
by sbavencoff@users.chorem.org 22 Nov '13
22 Nov '13
Author: sbavencoff
Date: 2013-11-22 17:49:26 +0100 (Fri, 22 Nov 2013)
New Revision: 3717
Url: http://chorem.org/projects/lima/repository/revisions/3717
Log:
[Entry Book] : move button into toolBar
add shortcuts
add icons
Added:
trunk/lima-swing/src/main/resources/icons/action-entryBook-edit.png
trunk/lima-swing/src/main/resources/icons/action-entryBook-import.png
trunk/lima-swing/src/main/resources/icons/action-entryBook-new.png
trunk/lima-swing/src/main/resources/icons/action-entryBook-remove.png
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx
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/EntryBookForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2013-11-22 16:48:35 UTC (rev 3716)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookForm.jaxx 2013-11-22 16:49:26 UTC (rev 3717)
@@ -49,7 +49,7 @@
<JLabel text="lima.ui.entrybook.code"/>
</cell>
<cell>
- <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}" editable='{isAddState()}' />
+ <JTextField id="entryBookCodeField" text="{getEntryBook().getCode()}" enabled='{isAddState()}' />
<Document javaBean="getEntryBookCodeField().getDocument()"
onInsertUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'
onRemoveUpdate='getEntryBook().setCode(getEntryBookCodeField().getText())'/>
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-11-22 16:48:35 UTC (rev 3716)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookView.jaxx 2013-11-22 16:49:26 UTC (rev 3717)
@@ -41,7 +41,37 @@
]]></script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
+ <cell fill="horizontal">
+ <JToolBar floatable="false">
+
+ <JButton id="addButton"
+ toolTipText="{ _("lima.ui.entrybook.add") + " (Ctrl+N)"}"
+ actionIcon='entryBook-new'
+ onActionPerformed="handler.addEntryBook()"/>
+
+ <JButton id="updateButton"
+ toolTipText="{ _("lima.ui.entrybook.update") + " (Ctrl+M)"}"
+ actionIcon='entryBook-edit'
+ onActionPerformed="handler.updateEntryBook()"
+ enabled="{isSelectedRow()}"/>
+
+ <JButton id="removeButton"
+ toolTipText="{ _("lima.ui.entrybook.remove") + " (Del)"}"
+ actionIcon='entryBook-remove'
+ onActionPerformed="handler.deleteEntryBook()"
+ enabled="{isSelectedRow()}"/>
+
+ <JButton id="importButton"
+ actionIcon='entryBook-import'
+ toolTipText="lima.ui.importexport.import"
+ onActionPerformed="handler.importEntryBooks()"/>
+
+ </JToolBar>
+ </cell>
+ </row>
+
+ <row>
+ <cell fill="both" weightx="1" weighty="1">
<JScrollPane>
<EntryBookTable id="entryBooksTable" rowHeight="24"
constructorParams="getHandler()"
@@ -52,29 +82,5 @@
onValueChanged="setSelectedRow(entryBooksTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
- <cell fill="horizontal">
- <JButton id="addButton" text="lima.ui.entrybook.add"
- onActionPerformed="getHandler().addEntryBook()"/>
- </cell>
</row>
- <row>
- <cell fill="horizontal">
- <JButton id="updateButton" text="lima.ui.entrybook.update"
- enabled="{isSelectedRow()}"
- onActionPerformed="getHandler().updateEntryBook()"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal">
- <JButton id="removeButton" text="lima.ui.entrybook.remove"
- enabled="{isSelectedRow()}"
- onActionPerformed="getHandler().deleteEntryBook()"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" anchor="north" weighty="1">
- <JButton id="importButton" text="lima.ui.importexport.import"
- onActionPerformed="getHandler().importEntryBooks()"/>
- </cell>
- </row>
</Table>
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:48:35 UTC (rev 3716)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/entrybook/EntryBookViewHandler.java 2013-11-22 16:49:26 UTC (rev 3717)
@@ -25,12 +25,6 @@
package org.chorem.lima.ui.entrybook;
-import static org.nuiton.i18n.I18n._;
-
-import java.util.List;
-
-import javax.swing.JOptionPane;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ServiceListener;
@@ -44,6 +38,15 @@
import org.chorem.lima.ui.importexport.ImportExport;
import org.jdesktop.swingx.JXTable;
+import javax.swing.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler for entry book view.
*
@@ -68,6 +71,51 @@
}
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-entryBook";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ addEntryBook();
+ }
+ });
+
+ // add action on Delete
+ binding = "remove-entryBook";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ deleteEntryBook();
+ }
+ });
+
+ // add action on Ctrl + M
+ binding = "modify-entryBook";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateEntryBook();
+ }
+ });
+
+ EntryBookTable table = view.getEntryBooksTable();
+
+ table.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2 ) {
+ updateEntryBook();
+ }
+ }
+ });
+
loadAllEntryBooks();
}
@@ -92,7 +140,19 @@
public void addEntryBook() {
EntryBook newEntryBook = new EntryBookImpl();
- EntryBookForm entryBookForm = new EntryBookForm(view);
+ 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();
+ }
+ });
+
entryBookForm.setEntryBook(newEntryBook);
entryBookForm.setLocationRelativeTo(view);
entryBookForm.setVisible(true);
@@ -121,7 +181,19 @@
int selectedRow = entryBookTable.getSelectedRow();
EntryBook selectedEntryBook = entryBookTableModel.getEntryBookAtRow(selectedRow);
- EntryBookForm entryBookForm = new EntryBookForm(view);
+ 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();
+ }
+ });
+
entryBookForm.setAddState(false);
entryBookForm.setEntryBook(selectedEntryBook);
entryBookForm.setLocationRelativeTo(view);
@@ -169,7 +241,19 @@
*/
public void importEntryBooks() {
- EntryBookImportForm form = new EntryBookImportForm(view);
+ final EntryBookImportForm form = new EntryBookImportForm(view);
+
+ InputMap inputMap = form.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = form.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) {
+ form.performCancel();
+ }
+ });
+
form.setLocationRelativeTo(view);
form.setVisible(true);
Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-edit.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-edit.png)
===================================================================
(Binary files differ)
Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-import.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-import.png)
===================================================================
(Binary files differ)
Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-new.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-new.png)
===================================================================
(Binary files differ)
Copied: trunk/lima-swing/src/main/resources/icons/action-entryBook-remove.png (from rev 3714, trunk/lima-swing/src/main/resources/icons/action-account-remove.png)
===================================================================
(Binary files differ)
1
0
r3716 - in trunk/lima-business/src/main: java/org/chorem/lima/business/ejb resources/i18n
by sbavencoff@users.chorem.org 22 Nov '13
by sbavencoff@users.chorem.org 22 Nov '13
22 Nov '13
Author: sbavencoff
Date: 2013-11-22 17:48:35 +0100 (Fri, 22 Nov 2013)
New Revision: 3716
Url: http://chorem.org/projects/lima/repository/revisions/3716
Log:
[Entry Book] : fix check if entry already exist
fix error message
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2013-11-22 16:39:28 UTC (rev 3715)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/ejb/EntryBookServiceImpl.java 2013-11-22 16:48:35 UTC (rev 3716)
@@ -68,11 +68,11 @@
// check if entrybook with is name already exist
EntryBookDAO entryBookDAO = getDaoHelper().getEntryBookDAO();
EntryBook existingEntryBook =
- entryBookDAO.findByLabel(entryBook.getCode());
+ entryBookDAO.findByCode(entryBook.getCode());
if (existingEntryBook != null) {
throw new LimaBusinessException(
_("lima-business.entrybook.entrybookalreadyexist",
- entryBook.getLabel()));
+ entryBook.getCode()));
}
// creation du EntryBook
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2013-11-22 16:39:28 UTC (rev 3715)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2013-11-22 16:48:35 UTC (rev 3716)
@@ -64,7 +64,7 @@
lima-business.document.vatnumber=VAT N°
lima-business.document.voucher=Voucher
lima-business.document.zipcode=
-lima-business.entrybook.entrybookalreadyexist=An EntryBook already exists with this label \: %s
+lima-business.entrybook.entrybookalreadyexist=An EntryBook already exists with this code \: %s
lima-business.financialstatement.check.nothing=Not found \: %s - %s \n
lima-business.financialstatement.check.warn=Warning this function is just an help.\n Many accounts must no calculate on Financial statement.\n Some account marked not found is normally.\n\n
lima-business.financialtransaction.retainedearnings.description=Retained earnings
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2013-11-22 16:39:28 UTC (rev 3715)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2013-11-22 16:48:35 UTC (rev 3716)
@@ -66,7 +66,7 @@
lima-business.document.vatnumber=N° TVA
lima-business.document.voucher=Pièce comptable
lima-business.document.zipcode=Code postal
-lima-business.entrybook.entrybookalreadyexist=Un journal existe déjà avec ce libellé \: %s
+lima-business.entrybook.entrybookalreadyexist=Un journal existe déjà avec ce code \: %s
lima-business.financialstatement.check.nothing=Introuvable \: %s - %s \n
lima-business.financialstatement.check.warn=Attention cette fonctionnalité n'est qu'une aide utilisateur.\n Certains comptes ne doivent pas être présent au bilan et compte de résultat.\n Il est donc normal que des comptes sont marqués comme introuvable.\n\n
lima-business.financialtransaction.retainedearnings.description=Report à nouveau
1
0
r3715 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/account
by sbavencoff@users.chorem.org 22 Nov '13
by sbavencoff@users.chorem.org 22 Nov '13
22 Nov '13
Author: sbavencoff
Date: 2013-11-22 17:39:28 +0100 (Fri, 22 Nov 2013)
New Revision: 3715
Url: http://chorem.org/projects/lima/repository/revisions/3715
Log:
[Account Plan] : fix shortcuts
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 15:35:03 UTC (rev 3714)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 16:39:28 UTC (rev 3715)
@@ -127,7 +127,7 @@
// add action on Ctrl + N
String binding = "new-account";
- inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding);
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK), binding);
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
1
0
r3714 - in trunk/lima-swing/src/main: java/org/chorem/lima/ui/account resources/icons
by sbavencoff@users.chorem.org 22 Nov '13
by sbavencoff@users.chorem.org 22 Nov '13
22 Nov '13
Author: sbavencoff
Date: 2013-11-22 16:35:03 +0100 (Fri, 22 Nov 2013)
New Revision: 3714
Url: http://chorem.org/projects/lima/repository/revisions/3714
Log:
[Account Plan] : move button into toolBar
add shortcuts
add icons
Added:
trunk/lima-swing/src/main/resources/icons/action-account-edit.png
trunk/lima-swing/src/main/resources/icons/action-account-import.png
trunk/lima-swing/src/main/resources/icons/action-account-new.png
trunk/lima-swing/src/main/resources/icons/action-account-remove.png
Modified:
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2013-11-22 15:33:11 UTC (rev 3713)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountView.jaxx 2013-11-22 15:35:03 UTC (rev 3714)
@@ -41,7 +41,37 @@
]]></script>
<row>
- <cell fill="both" weightx="1" weighty="1" rows='4'>
+ <cell fill="horizontal">
+ <JToolBar floatable="false">
+
+ <JButton id="addButton"
+ toolTipText="{ _("lima.ui.account.addaccount") + " (Ctrl+N)"}"
+ actionIcon='account-new'
+ onActionPerformed="handler.addAccount()"/>
+
+ <JButton id="updateButton"
+ toolTipText="{ _("lima.ui.common.update") + " (Ctrl+M)"}"
+ actionIcon='account-edit'
+ onActionPerformed="handler.updateAccount()"
+ enabled="{isSelectedRow()}"/>
+
+ <JButton id="removeButton"
+ toolTipText="{ _("lima.ui.common.remove") + " (Del)"}"
+ actionIcon='account-remove'
+ onActionPerformed="handler.removeAccount()"
+ enabled="{isSelectedRow()}"/>
+
+ <JButton id="importButton"
+ actionIcon='account-import'
+ toolTipText="lima.ui.importexport.import"
+ onActionPerformed="handler.importAccountsChart()"/>
+
+ </JToolBar>
+ </cell>
+ </row>
+
+ <row>
+ <cell fill="both" weightx="1" weighty="1">
<JScrollPane>
<JXTreeTable id="accountsTreeTable"
selectionMode="{ListSelectionModel.SINGLE_SELECTION}"
@@ -51,29 +81,5 @@
onValueChanged="setSelectedRow(accountsTreeTable.getSelectedRow() != -1)"/>
</JScrollPane>
</cell>
- <cell fill="horizontal">
- <JButton id="addButton" text="lima.ui.account.addaccount"
- onActionPerformed="handler.addAccount()"/>
- </cell>
</row>
- <row>
- <cell fill="horizontal">
- <JButton id="updateButton" text="lima.ui.common.update"
- onActionPerformed="handler.updateAccount()"
- enabled="{isSelectedRow()}"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal">
- <JButton id="removeButton" text="lima.ui.common.remove"
- onActionPerformed="handler.removeAccount()"
- enabled="{isSelectedRow()}"/>
- </cell>
- </row>
- <row>
- <cell fill="horizontal" anchor="north" weighty="1">
- <JButton id="importButton" text="lima.ui.importexport.import"
- onActionPerformed="handler.importAccountsChart()"/>
- </cell>
- </row>
</Table>
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 15:33:11 UTC (rev 3713)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/AccountViewHandler.java 2013-11-22 15:35:03 UTC (rev 3714)
@@ -25,25 +25,6 @@
package org.chorem.lima.ui.account;
-import static org.nuiton.i18n.I18n._;
-
-import java.awt.event.KeyAdapter;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import javax.swing.JOptionPane;
-import javax.swing.tree.TreePath;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.chorem.lima.business.ServiceListener;
@@ -60,6 +41,25 @@
import org.jdesktop.swingx.treetable.MutableTreeTableNode;
import org.jdesktop.swingx.treetable.TreeTableNode;
+import javax.swing.*;
+import javax.swing.tree.TreePath;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import static org.nuiton.i18n.I18n._;
+
/**
* Handler associated with account view.
*
@@ -119,22 +119,42 @@
*/
public void init() {
JXTreeTable table = view.getAccountsTreeTable();
- table.addKeyListener(new KeyAdapter() {
- /**
- * for each action combination key are think
- * for extend keyboard and laptop keyboard
- */
+
+ //To block reaction of the dual key 'ctrl+a' (Selection of all lines)
+ InputMap inputMap = view.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = view.getActionMap();
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK), "none");
+
+ // add action on Ctrl + N
+ String binding = "new-account";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
@Override
- public void keyPressed(KeyEvent e) {
- JXTreeTable source = (JXTreeTable) e.getSource();
- // clear row selection with the key: escape
- if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- if (!source.isEditing()) {
- source.clearSelection();
- }
- }
+ public void actionPerformed(ActionEvent e) {
+ addAccount();
}
});
+
+ // add action on Delete
+ binding = "remove-account";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ removeAccount();
+ }
+ });
+
+ // add action on Ctrl + M
+ binding = "modify-account";
+ inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_DOWN_MASK), binding);
+ actionMap.put(binding, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ updateAccount();
+ }
+ });
+
table.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
@@ -143,6 +163,13 @@
source.clearSelection();
}
}
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ if (e.getClickCount() == 2 ) {
+ updateAccount();
+ }
+ }
});
loadAllAccounts();
@@ -193,7 +220,19 @@
* Display add account view
*/
public void addAccount() {
- AccountForm accountForm = new AccountForm(view);
+ final AccountForm accountForm = new AccountForm(view);
+
+ InputMap inputMap = accountForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = accountForm.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) {
+ accountForm.dispose();
+ }
+ });
+
accountForm.setLocationRelativeTo(view);
accountForm.setVisible(true);
}
@@ -288,7 +327,20 @@
Account selectedAccount = (Account)lastPathComponent.getUserObject();
// display edit form
- UpdateAccountForm accountForm = new UpdateAccountForm(view);
+ final UpdateAccountForm accountForm = new UpdateAccountForm(view);
+
+ InputMap inputMap = accountForm.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = accountForm.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) {
+ accountForm.dispose();
+ }
+ });
+
+
accountForm.setAccount(selectedAccount);
accountForm.setLocationRelativeTo(view);
accountForm.setVisible(true);
@@ -355,7 +407,19 @@
public void importAccountsChart() {
- AccountImportForm form = new AccountImportForm(view);
+ final AccountImportForm form = new AccountImportForm(view);
+
+ InputMap inputMap = form.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
+ ActionMap actionMap = form.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) {
+ form.performCancel();
+ }
+ });
+
form.setLocationRelativeTo(view);
form.setVisible(true);
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2013-11-22 15:33:11 UTC (rev 3713)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/account/UpdateAccountForm.jaxx 2013-11-22 15:35:03 UTC (rev 3714)
@@ -48,7 +48,8 @@
<JLabel text="lima.ui.account.number" labelFor='{numberTextField}'/>
</cell>
<cell fill="horizontal">
- <JTextField id="numberTextField" editable='{false}'
+ <JTextField id="numberTextField"
+ enabled="false"
text="{getAccount().getAccountNumber()}"/>
</cell>
</row>
Added: trunk/lima-swing/src/main/resources/icons/action-account-edit.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-edit.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-account-import.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-import.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-account-new.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-new.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/lima-swing/src/main/resources/icons/action-account-remove.png
===================================================================
(Binary files differ)
Property changes on: trunk/lima-swing/src/main/resources/icons/action-account-remove.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r3713 - in trunk/lima-business/src/main: java/org/chorem/lima/business/accountingrules resources/i18n
by sbavencoff@users.chorem.org 22 Nov '13
by sbavencoff@users.chorem.org 22 Nov '13
22 Nov '13
Author: sbavencoff
Date: 2013-11-22 16:33:11 +0100 (Fri, 22 Nov 2013)
New Revision: 3713
Url: http://chorem.org/projects/lima/repository/revisions/3713
Log:
[Account Plan] fixes : check account number and error message
Modified:
trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
Modified: trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java
===================================================================
--- trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2013-10-28 08:11:44 UTC (rev 3712)
+++ trunk/lima-business/src/main/java/org/chorem/lima/business/accountingrules/FranceAccountingRules.java 2013-11-22 15:33:11 UTC (rev 3713)
@@ -74,7 +74,7 @@
}
// Check root account starts with 1 to 8
- if (accountNumber.length() == 1 && !accountNumber.matches("[1-8]")) {
+ if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
throw new LimaBusinessException(_("lima-business.franceaccountingrules.accountstartnumbererror",
account.getAccountNumber()));
}
@@ -94,7 +94,7 @@
}
// Check root account starts with 1 to 8
- if (accountNumber.length() == 1 && accountNumber.matches("[1-8]")) {
+ if (accountNumber.length() >= 1 && !accountNumber.substring(0, 1).matches("[1-8]")) {
throw new LimaBusinessException(_("lima-business.franceaccountingrules.accountstartnumbererror",
account.getAccountNumber()));
}
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2013-10-28 08:11:44 UTC (rev 3712)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_en_GB.properties 2013-11-22 15:33:11 UTC (rev 3713)
@@ -73,7 +73,7 @@
lima-business.fiscalperiod.newfinancialperioderror=Can't set financial period on the following fiscal year
lima-business.fiscalperiod.previousfiscalperiodalreadyblocked=The last financial period from the fiscal period is blocked
lima-business.franceaccountingrules.accountnumbernotnumeric=Account Number is not numeric \: %s
-lima-business.franceaccountingrules.accountstartnumbererror=Master account is not a digit between 1 to 8 \: %d
+lima-business.franceaccountingrules.accountstartnumbererror=Master account is not a digit between 1 to 8 \: %s
lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=The previous financial periods for this entrybook must be blocked before this
lima-business.franceaccountingrules.antefiscalperiodnotblocked=The ante fiscal period is not locked
lima-business.franceaccountingrules.fiscalperiodnotempty=The fiscal period is not empty \!
Modified: trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties
===================================================================
--- trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2013-10-28 08:11:44 UTC (rev 3712)
+++ trunk/lima-business/src/main/resources/i18n/lima-business_fr_FR.properties 2013-11-22 15:33:11 UTC (rev 3713)
@@ -74,8 +74,8 @@
lima-business.fiscalperiod.fiscalperiodalreadyblocked=La période fiscale est déjà bloquée
lima-business.fiscalperiod.newfinancialperioderror=Impossible de définir la période financière sur la période fiscale suivante
lima-business.fiscalperiod.previousfiscalperiodalreadyblocked=La dernière période financière de la période fiscale est bloquée
-lima-business.franceaccountingrules.accountnumbernotnumeric=Le numéro de copte n'est pas numéric \: %s
-lima-business.franceaccountingrules.accountstartnumbererror=Le numéro du copte général n'est pas compris entre 1 et 8 \: %d
+lima-business.franceaccountingrules.accountnumbernotnumeric=Le numéro de compte n'est pas numérique \: %s
+lima-business.franceaccountingrules.accountstartnumbererror=Le numéro du compte général n'est pas compris entre 1 et 8 \: %s
lima-business.franceaccountingrules.antefinancialperiodnotblockedentrybook=Les périodes financières précédentes pour ce journal doivent être bloquées avant
lima-business.franceaccountingrules.antefiscalperiodnotblocked=La période fiscale précédente n'est pas bloquée
lima-business.franceaccountingrules.fiscalperiodnotempty=La période fiscale à supprimer n'est pas vide \!
1
0
28 Oct '13
Author: dcosse
Date: 2013-10-28 09:11:44 +0100 (Mon, 28 Oct 2013)
New Revision: 3712
Url: http://chorem.org/projects/lima/repository/revisions/3712
Log:
fixes #955 correction d un bug sur l'application de filtres sur les ?\195?\169critures
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java
trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java
trunk/lima-swing/src/main/resources/icons/action-choose-entry.png
trunk/lima-swing/src/main/resources/icons/action-un-lettering.png
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/Filter/FilterGenerator.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.Clause.AndClause;
import org.chorem.lima.Clause.BooleanClause;
import org.chorem.lima.Clause.Clause;
@@ -75,134 +76,146 @@
@Override
public void visitFinancialTransactionCondition(FinancialTransactionCondition condition) {
-
- filter = new FinancialTransactionFilter();
- for (Condition subCondition : condition.getConditions()) {
- subCondition.accept(this);
- }
- if (clauses.size() == 1 ) {
- filter.setClause(clauses.get(0));
- } else if (clauses.size() > 1) {
- if (condition.isAllConditions()) {
- AndClause clause = new AndClause();
- clause.addAll(clauses);
- filter.setClause(clause);
- } else {
- OrClause clause = new OrClause();
- clause.addAll(clauses);
- filter.setClause(clause);
+ if (condition != null && condition.getConditions() != null) {
+ filter = new FinancialTransactionFilter();
+ for (Condition subCondition : condition.getConditions()) {
+ if (subCondition.validCondition()) {
+ subCondition.accept(this);
+ }
}
- }
+ if (clauses.size() == 1 ) {
+ filter.setClause(clauses.get(0));
+ } else if (clauses.size() > 1) {
+ if (condition.isAllConditions()) {
+ AndClause clause = new AndClause();
+ clause.addAll(clauses);
+ filter.setClause(clause);
+ } else {
+ OrClause clause = new OrClause();
+ clause.addAll(clauses);
+ filter.setClause(clause);
+ }
+ }
- if (entryClauses.size() == 1 ) {
- entryFilter.setClause(entryClauses.get(0));
- } else if (entryClauses.size() > 1) {
- if (condition.isAllConditions()) {
- AndClause clause = new AndClause();
- clause.addAll(entryClauses);
- entryFilter.setClause(clause);
- } else {
- OrClause clause = new OrClause();
- clause.addAll(entryClauses);
- entryFilter.setClause(clause);
+ if (entryClauses.size() == 1 ) {
+ entryFilter.setClause(entryClauses.get(0));
+ } else if (entryClauses.size() > 1) {
+ if (condition.isAllConditions()) {
+ AndClause clause = new AndClause();
+ clause.addAll(entryClauses);
+ entryFilter.setClause(clause);
+ } else {
+ OrClause clause = new OrClause();
+ clause.addAll(entryClauses);
+ entryFilter.setClause(clause);
+ }
}
}
}
@Override
public void visitDateCondition(DateCondition condition) {
- DateClause dateClause = getFilter().newTransactionDateClause();
- switch (condition.getOperand()) {
- case SAME:
- dateClause.setOperand(DateClause.Operand.SAME);
- break;
- case AFTER:
- dateClause.setOperand(DateClause.Operand.AFTER);
- break;
- case PREVIOUS:
- dateClause.setOperand(DateClause.Operand.PREVIOUS);
- break;
- case DIFFERENT:
- dateClause.setOperand(DateClause.Operand.DIFFERENT);
- break;
+ if (condition != null && condition.getOperand() != null) {
+ DateClause dateClause = getFilter().newTransactionDateClause();
+ switch (condition.getOperand()) {
+ case SAME:
+ dateClause.setOperand(DateClause.Operand.SAME);
+ break;
+ case AFTER:
+ dateClause.setOperand(DateClause.Operand.AFTER);
+ break;
+ case PREVIOUS:
+ dateClause.setOperand(DateClause.Operand.PREVIOUS);
+ break;
+ case DIFFERENT:
+ dateClause.setOperand(DateClause.Operand.DIFFERENT);
+ break;
+ }
+ dateClause.setValue(condition.getDate());
+ clauses.add(dateClause);
}
- dateClause.setValue(condition.getDate());
- clauses.add(dateClause);
}
@Override
public void visitDateIntervalCondition(DateIntervalCondition condition) {
- AndClause andClause = new AndClause();
+ if (condition != null && condition.getBeginDate() != null && condition.getEndDate() != null) {
+ AndClause andClause = new AndClause();
- DateClause beginDateClause = getFilter().newTransactionDateClause();
- beginDateClause.setOperand(DateClause.Operand.AFTER);
- beginDateClause.setValue(condition.getBeginDate());
- andClause.add(beginDateClause);
+ DateClause beginDateClause = getFilter().newTransactionDateClause();
+ beginDateClause.setOperand(DateClause.Operand.AFTER);
+ beginDateClause.setValue(condition.getBeginDate());
+ andClause.add(beginDateClause);
- DateClause endDateClause = getFilter().newTransactionDateClause();
- endDateClause.setOperand(DateClause.Operand.PREVIOUS);
- endDateClause.setValue(condition.getEndDate());
- andClause.add(endDateClause);
+ DateClause endDateClause = getFilter().newTransactionDateClause();
+ endDateClause.setOperand(DateClause.Operand.PREVIOUS);
+ endDateClause.setValue(condition.getEndDate());
+ andClause.add(endDateClause);
- clauses.add(andClause);
+ clauses.add(andClause);
+ }
}
@Override
public void visitEntryBookCondition(EntryBookCondition condition) {
-
- SetClause setClause = getFilter().newEntryBookSetClause();
- setClause.addAll(condition.getEntryBooks());
- clauses.add(setClause);
+ if (condition != null && condition.getEntryBooks() != null) {
+ SetClause setClause = getFilter().newEntryBookSetClause();
+ setClause.addAll(condition.getEntryBooks());
+ clauses.add(setClause);
+ }
}
@Override
public void visitFinancialPeriodCondition(FinancialPeriodCondition condition) {
- OrClause orClause = new OrClause();
- for (FinancialPeriod period : condition.getFinancialPeriods()) {
- AndClause andClause = new AndClause();
+ if (condition != null && condition.getFinancialPeriods() != null) {
+ OrClause orClause = new OrClause();
+ for (FinancialPeriod period : condition.getFinancialPeriods()) {
+ AndClause andClause = new AndClause();
- DateClause beginDateClause = getFilter().newTransactionDateClause();
- beginDateClause.setOperand(DateClause.Operand.AFTER);
- beginDateClause.setValue(period.getBeginDate());
- andClause.add(beginDateClause);
+ DateClause beginDateClause = getFilter().newTransactionDateClause();
+ beginDateClause.setOperand(DateClause.Operand.AFTER);
+ beginDateClause.setValue(period.getBeginDate());
+ andClause.add(beginDateClause);
- DateClause endDateClause = getFilter().newTransactionDateClause();
- endDateClause.setOperand(DateClause.Operand.PREVIOUS);
- endDateClause.setValue(period.getEndDate());
- andClause.add(endDateClause);
+ DateClause endDateClause = getFilter().newTransactionDateClause();
+ endDateClause.setOperand(DateClause.Operand.PREVIOUS);
+ endDateClause.setValue(period.getEndDate());
+ andClause.add(endDateClause);
- orClause.add(andClause);
+ orClause.add(andClause);
+ }
+ if (orClause.size() == 1) {
+ clauses.add(orClause.get(0));
+ } else {
+ clauses.add(orClause);
+ }
}
- if (orClause.size() == 1) {
- clauses.add(orClause.get(0));
- } else {
- clauses.add(orClause);
- }
}
@Override
public void visitFiscalPeriodCondition(FiscalPeriodCondition condition) {
- OrClause orClause = new OrClause();
- for (FiscalPeriod period : condition.getFiscalPeriods()) {
- AndClause andClause = new AndClause();
+ if (condition != null && condition.getFiscalPeriods()!=null) {
+ OrClause orClause = new OrClause();
+ for (FiscalPeriod period : condition.getFiscalPeriods()) {
+ AndClause andClause = new AndClause();
- DateClause beginDateClause = getFilter().newTransactionDateClause();
- beginDateClause.setOperand(DateClause.Operand.AFTER);
- beginDateClause.setValue(period.getBeginDate());
- andClause.add(beginDateClause);
+ DateClause beginDateClause = getFilter().newTransactionDateClause();
+ beginDateClause.setOperand(DateClause.Operand.AFTER);
+ beginDateClause.setValue(period.getBeginDate());
+ andClause.add(beginDateClause);
- DateClause endDateClause = getFilter().newTransactionDateClause();
- endDateClause.setOperand(DateClause.Operand.PREVIOUS);
- endDateClause.setValue(period.getEndDate());
- andClause.add(endDateClause);
+ DateClause endDateClause = getFilter().newTransactionDateClause();
+ endDateClause.setOperand(DateClause.Operand.PREVIOUS);
+ endDateClause.setValue(period.getEndDate());
+ andClause.add(endDateClause);
- orClause.add(andClause);
+ orClause.add(andClause);
+ }
+ if (orClause.size() == 1) {
+ clauses.add(orClause.get(0));
+ } else {
+ clauses.add(orClause);
+ }
}
- if (orClause.size() == 1) {
- clauses.add(orClause.get(0));
- } else {
- clauses.add(orClause);
- }
}
protected EntryFilter getEntryFilter() {
@@ -239,18 +252,22 @@
@Override
public void visitDescriptionCondition(DescriptionCondition descriptionCondition) {
- getEntryFilter();
- StringClause stringClause = entryFilter.newDescriptionClause();
+ if (descriptionCondition != null
+ && descriptionCondition.getOperand() != null
+ && StringUtils.isNotBlank(descriptionCondition.getValue())) {
+ getEntryFilter();
+ StringClause stringClause = entryFilter.newDescriptionClause();
- AbstractStringCondition.Operand operand = descriptionCondition.getOperand();
- StringClause.Operand stringClauseOperand = getStringClauseOperand(operand);
- stringClause.setOperand(stringClauseOperand);
+ AbstractStringCondition.Operand operand = descriptionCondition.getOperand();
+ StringClause.Operand stringClauseOperand = getStringClauseOperand(operand);
+ stringClause.setOperand(stringClauseOperand);
- stringClause.setValue(descriptionCondition.getValue());
+ stringClause.setValue(descriptionCondition.getValue());
- stringClause.setSensitiveCase(descriptionCondition.isSensitiveCase());
+ stringClause.setSensitiveCase(descriptionCondition.isSensitiveCase());
- entryClauses.add(stringClause);
+ entryClauses.add(stringClause);
+ }
}
@Override
@@ -262,7 +279,8 @@
StringClause.Operand stringClauseOperand = getStringClauseOperand(operand);
stringClause.setOperand(stringClauseOperand);
- stringClause.setValue(voucherCondition.getValue());
+ String value = voucherCondition.getValue() == null ? "*" : voucherCondition.getValue();
+ stringClause.setValue(value);
stringClause.setSensitiveCase(voucherCondition.isSensitiveCase());
@@ -271,102 +289,120 @@
@Override
public void visitLetteringCondition(LetteringCondition letteringCondition) {
- getEntryFilter();
- StringClause stringClause = entryFilter.newLetteringClause();
+ if (letteringCondition != null
+ && letteringCondition.getOperand() != null
+ && StringUtils.isNotBlank(letteringCondition.getValue())){
+ getEntryFilter();
+ StringClause stringClause = entryFilter.newLetteringClause();
- AbstractStringCondition.Operand operand = letteringCondition.getOperand();
- StringClause.Operand stringClauseOperand = getStringClauseOperand(operand);
- stringClause.setOperand(stringClauseOperand);
+ AbstractStringCondition.Operand operand = letteringCondition.getOperand();
+ StringClause.Operand stringClauseOperand = getStringClauseOperand(operand);
+ stringClause.setOperand(stringClauseOperand);
- stringClause.setValue(letteringCondition.getValue());
+ stringClause.setValue(letteringCondition.getValue());
- stringClause.setSensitiveCase(letteringCondition.isSensitiveCase());
+ stringClause.setSensitiveCase(letteringCondition.isSensitiveCase());
- entryClauses.add(stringClause);
+ entryClauses.add(stringClause);
+ }
+
}
@Override
public void visitAccountCondition(AccountCondition accountCondition) {
- getEntryFilter();
- SubFilterClause subFilterClause = entryFilter.newAccountFilterClause();
- AccountFilter accountFilter = (AccountFilter) subFilterClause.getSubFilter();
- StringClause stringClause = accountFilter.newAccountNumberClause();
- stringClause.setOperand(StringClause.Operand.BEGIN);
- Account account = accountCondition.getAccount();
- stringClause.setValue(account.getAccountNumber());
+ if (accountCondition != null
+ && accountCondition.getAccount() != null
+ && accountCondition.getAccount().getAccountNumber() != null){
+ getEntryFilter();
+ SubFilterClause subFilterClause = entryFilter.newAccountFilterClause();
+ AccountFilter accountFilter = (AccountFilter) subFilterClause.getSubFilter();
+ StringClause stringClause = accountFilter.newAccountNumberClause();
+ stringClause.setOperand(StringClause.Operand.BEGIN);
+ Account account = accountCondition.getAccount();
+ stringClause.setValue(account.getAccountNumber());
- accountFilter.setClause(stringClause);
- entryClauses.add(subFilterClause);
+ accountFilter.setClause(stringClause);
+ entryClauses.add(subFilterClause);
+ }
}
protected NumberClause.Operand getNumberClauseOperand(AbstractBigDecimalCondition.Operand operand) {
- NumberClause.Operand result;
- switch (operand) {
- case NOT_EQUAL:
- result = NumberClause.Operand.NOT_EQUAL;
- break;
- case LOWER:
- result = NumberClause.Operand.LOWER;
- break;
- case LOWER_OR_EQUAL:
- result = NumberClause.Operand.LOWER_OR_EQUAL;
- break;
- case UPPER:
- result = NumberClause.Operand.UPPER;
- break;
- case UPPER_OR_EQUAL:
- result = NumberClause.Operand.UPPER_OR_EQUAL;
- break;
- case EQUAL:
- default:
- result = NumberClause.Operand.EQUAL;
- break;
+ NumberClause.Operand result = NumberClause.Operand.EQUAL;
+ if (operand != null) {
+ switch (operand) {
+ case NOT_EQUAL:
+ result = NumberClause.Operand.NOT_EQUAL;
+ break;
+ case LOWER:
+ result = NumberClause.Operand.LOWER;
+ break;
+ case LOWER_OR_EQUAL:
+ result = NumberClause.Operand.LOWER_OR_EQUAL;
+ break;
+ case UPPER:
+ result = NumberClause.Operand.UPPER;
+ break;
+ case UPPER_OR_EQUAL:
+ result = NumberClause.Operand.UPPER_OR_EQUAL;
+ break;
+ case EQUAL:
+ default:
+ result = NumberClause.Operand.EQUAL;
+ break;
+ }
}
return result;
}
@Override
public void visitDebitCondition(DebitCondition debitCondition) {
- getEntryFilter();
+ if (debitCondition != null
+ && debitCondition.getOperand() != null
+ && debitCondition.getValue() != null){
+ getEntryFilter();
- BooleanClause debitClause = entryFilter.newDebitClause();
+ BooleanClause debitClause = entryFilter.newDebitClause();
- NumberClause amountClause = entryFilter.newAmountClause();
+ NumberClause amountClause = entryFilter.newAmountClause();
- AbstractBigDecimalCondition.Operand operand = debitCondition.getOperand();
- NumberClause.Operand clauseOperand = getNumberClauseOperand(operand);
- amountClause.setOperand(clauseOperand);
+ AbstractBigDecimalCondition.Operand operand = debitCondition.getOperand();
+ NumberClause.Operand clauseOperand = getNumberClauseOperand(operand);
+ amountClause.setOperand(clauseOperand);
- amountClause.setValue(debitCondition.getValue());
+ amountClause.setValue(debitCondition.getValue());
- AndClause andClause = new AndClause();
- andClause.add(debitClause);
- andClause.add(amountClause);
+ AndClause andClause = new AndClause();
+ andClause.add(debitClause);
+ andClause.add(amountClause);
- entryClauses.add(andClause);
+ entryClauses.add(andClause);
+ }
}
@Override
public void visitCreditCondition(CreditCondition creditCondition) {
- getEntryFilter();
+ if (creditCondition != null && creditCondition.getOperand() != null && creditCondition.getValue() != null) {
+ getEntryFilter();
- BooleanClause debitClause = entryFilter.newDebitClause();
- NotClause creditClause = new NotClause();
- creditClause.setClause(debitClause);
+ BooleanClause debitClause = entryFilter.newDebitClause();
+ NotClause creditClause = new NotClause();
+ creditClause.setClause(debitClause);
- NumberClause amountClause = entryFilter.newAmountClause();
+ NumberClause amountClause = entryFilter.newAmountClause();
- AbstractBigDecimalCondition.Operand operand = creditCondition.getOperand();
- NumberClause.Operand clauseOperand = getNumberClauseOperand(operand);
- amountClause.setOperand(clauseOperand);
+ AbstractBigDecimalCondition.Operand operand = creditCondition.getOperand();
+ NumberClause.Operand clauseOperand = getNumberClauseOperand(operand);
+ amountClause.setOperand(clauseOperand);
- amountClause.setValue(creditCondition.getValue());
+ amountClause.setValue(creditCondition.getValue());
- AndClause andClause = new AndClause();
- andClause.add(creditClause);
- andClause.add(amountClause);
+ AndClause andClause = new AndClause();
+ andClause.add(creditClause);
+ andClause.add(amountClause);
- entryClauses.add(andClause);
+ entryClauses.add(andClause);
+ }
+
}
public FinancialTransactionFilter getFilter() {
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/AccountCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -44,6 +44,11 @@
}
@Override
+ public boolean validCondition() {
+ return account != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitAccountCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/Condition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -29,5 +29,12 @@
*/
public interface Condition {
+ /**
+ * Accept the condition if there is benefice to execute it
+ * @return true if the condition is valid
+ */
+ public boolean validCondition();
+
public void accept(VisitorCondition v);
+
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/CreditCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -30,6 +30,11 @@
public class CreditCondition extends AbstractBigDecimalCondition {
@Override
+ public boolean validCondition() {
+ return value != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitCreditCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -59,6 +59,11 @@
}
@Override
+ public boolean validCondition() {
+ return date != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitDateCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DateIntervalCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -53,6 +53,11 @@
}
@Override
+ public boolean validCondition() {
+ return beginDate != null && endDate != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitDateIntervalCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DebitCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -30,6 +30,11 @@
public class DebitCondition extends AbstractBigDecimalCondition {
@Override
+ public boolean validCondition() {
+ return value != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitDebitCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/DescriptionCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -24,6 +24,8 @@
* #L%
*/
+import org.apache.commons.lang3.StringUtils;
+
import java.io.Serializable;
/**
@@ -32,6 +34,11 @@
public class DescriptionCondition extends AbstractStringCondition implements Serializable {
@Override
+ public boolean validCondition() {
+ return StringUtils.isNotBlank(value);
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitDescriptionCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/EntryBookCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -45,6 +45,11 @@
}
@Override
+ public boolean validCondition() {
+ return entryBooks != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitEntryBookCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialPeriodCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -45,6 +45,11 @@
}
@Override
+ public boolean validCondition() {
+ return financialPeriods != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitFinancialPeriodCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FinancialTransactionCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -58,6 +58,11 @@
}
@Override
+ public boolean validCondition() {
+ return true;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitFinancialTransactionCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/FiscalPeriodCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -48,6 +48,11 @@
}
@Override
+ public boolean validCondition() {
+ return fiscalPeriods != null;
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitFiscalPeriodCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/LetteringCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -24,6 +24,8 @@
* #L%
*/
+import org.apache.commons.lang3.StringUtils;
+
import java.io.Serializable;
/**
@@ -31,6 +33,11 @@
*/
public class LetteringCondition extends AbstractStringCondition implements Serializable {
@Override
+ public boolean validCondition() {
+ return StringUtils.isNotBlank(value);
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitLetteringCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/beans/VoucherCondition.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -24,6 +24,8 @@
* #L%
*/
+import org.apache.commons.lang3.StringUtils;
+
import java.io.Serializable;
/**
@@ -32,6 +34,11 @@
public class VoucherCondition extends AbstractStringCondition implements Serializable {
@Override
+ public boolean validCondition() {
+ return StringUtils.isNotBlank(value);
+ }
+
+ @Override
public void accept(VisitorCondition v) {
v.visitVoucherCondition(this);
}
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/GeneratorHQuery.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -24,6 +24,7 @@
* #L%
*/
+import org.apache.commons.lang3.StringUtils;
import org.chorem.lima.Clause.AndClause;
import org.chorem.lima.Clause.BooleanClause;
import org.chorem.lima.Clause.Clause;
@@ -166,25 +167,30 @@
@Override
public void visitDateClause(DateClause dateClause) {
- String parameter = addParameter(dateClause.getValue());
- Filter filter = filterStack.peek();
- String alias = aliasMap.get(filter);
- String operand = " = " ;
- switch (dateClause.getOperand()) {
- case SAME:
- operand = " = ";
- break;
- case PREVIOUS:
- operand = " <= ";
- break;
- case AFTER:
- operand = " >= ";
- break;
- case DIFFERENT:
- operand = " != ";
- break;
+ if (dateClause != null
+ && dateClause.getValue() != null) {
+ String parameter = addParameter(dateClause.getValue());
+ Filter filter = filterStack.peek();
+ String alias = aliasMap.get(filter);
+ String operand = " = " ;
+ switch (dateClause.getOperand()) {
+ case SAME:
+ operand = " = ";
+ break;
+ case PREVIOUS:
+ operand = " <= ";
+ break;
+ case AFTER:
+ operand = " >= ";
+ break;
+ case DIFFERENT:
+ operand = " != ";
+ break;
+ }
+ whereClause += alias + "." + dateClause.getProperty() + operand + ":" + parameter;
+ } else {
+ whereClause += "1 = 1";
}
- whereClause += alias + "." + dateClause.getProperty() + operand + ":" + parameter;
}
@Override
@@ -212,31 +218,35 @@
@Override
public void visitNumberClause(NumberClause numberClause) {
- String parameter = addParameter(numberClause.getValue());
- Filter filter = filterStack.peek();
- String alias = aliasMap.get(filter);
- String operand = " = " ;
- switch (numberClause.getOperand()) {
- case EQUAL:
- operand = " = ";
- break;
- case NOT_EQUAL:
- operand = " != ";
- break;
- case LOWER:
- operand = " < ";
- break;
- case LOWER_OR_EQUAL:
- operand = " <= ";
- break;
- case UPPER:
- operand = " > ";
- break;
- case UPPER_OR_EQUAL:
- operand = " >= ";
- break;
+ if (numberClause != null && numberClause.getValue() != null) {
+ String parameter = addParameter(numberClause.getValue());
+ String operand = " = " ;
+ Filter filter = filterStack.peek();
+ String alias = aliasMap.get(filter);
+ switch (numberClause.getOperand()) {
+ case EQUAL:
+ operand = " = ";
+ break;
+ case NOT_EQUAL:
+ operand = " != ";
+ break;
+ case LOWER:
+ operand = " < ";
+ break;
+ case LOWER_OR_EQUAL:
+ operand = " <= ";
+ break;
+ case UPPER:
+ operand = " > ";
+ break;
+ case UPPER_OR_EQUAL:
+ operand = " >= ";
+ break;
+ }
+ whereClause += alias + "." + numberClause.getProperty() + operand + ":" + parameter;
+ } else {
+ whereClause += "1 = 1";
}
- whereClause += alias + "." + numberClause.getProperty() + operand + ":" + parameter;
}
@Override
@@ -291,37 +301,39 @@
@Override
public void visitStringClause(StringClause stringClause) {
- Filter filter = filterStack.peek();
- String alias = aliasMap.get(filter);
- String operand = " = " ;
String value = stringClause.getValue();
- switch (stringClause.getOperand()) {
- case EQUAL:
- operand = " = ";
- value = stringClause.getValue();
- break;
- case NOT_EQUAL:
- operand = " != ";
- value = stringClause.getValue();
- break;
- case BEGIN:
- operand = " LIKE ";
- value = stringClause.getValue() + "%";
- break;
- case ENDING:
- operand = " LIKE ";
- value = "%" + stringClause.getValue();
- break;
- case CONTAIN:
- operand = " LIKE ";
- value = "%" + stringClause.getValue()+ "%";
- break;
+ if (StringUtils.isNotBlank(value)) {
+ Filter filter = filterStack.peek();
+ String alias = aliasMap.get(filter);
+ String operand = " = " ;
+ switch (stringClause.getOperand()) {
+ case EQUAL:
+ operand = " = ";
+ value = stringClause.getValue();
+ break;
+ case NOT_EQUAL:
+ operand = " != ";
+ value = stringClause.getValue();
+ break;
+ case BEGIN:
+ operand = " LIKE ";
+ value = stringClause.getValue() + "%";
+ break;
+ case ENDING:
+ operand = " LIKE ";
+ value = "%" + stringClause.getValue();
+ break;
+ case CONTAIN:
+ operand = " LIKE ";
+ value = "%" + stringClause.getValue()+ "%";
+ break;
+ }
+ if (stringClause.isSensitiveCase()) {
+ whereClause += alias + "." + stringClause.getProperty() + operand + "'" + value + "'";
+ } else {
+ whereClause += "lower(" + alias + "." + stringClause.getProperty() + ")" + operand + "'" + value.toLowerCase() + "'";
+ }
}
- if (stringClause.isSensitiveCase()) {
- whereClause += alias + "." + stringClause.getProperty() + operand + "'" + value + "'";
- } else {
- whereClause += "lower(" + alias + "." + stringClause.getProperty() + ")" + operand + "'" + value.toLowerCase() + "'";
- }
}
@Override
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionHandler.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -35,6 +35,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
+import java.awt.event.KeyEvent;
/**
* @author Sylvain Bavencoff <bavencoff(a)codelutin.com>
@@ -64,7 +65,7 @@
condition.setValue(text);
}
- public void setText(ActionEvent event) {
+ public void setText(KeyEvent event) {
String text = view.getTextField().getText();
setText(text);
}
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/Filter/StringCondition/StringConditionView.jaxx 2013-10-28 08:11:44 UTC (rev 3712)
@@ -55,7 +55,7 @@
<cell>
<JTextField id="textField"
text="{handler.getText()}"
- onActionPerformed="handler.setText(event)" />
+ onKeyReleased="handler.setText(event)" />
</cell>
<cell weightx="1" anchor="west">
<JCheckBox id="sensitiveCaseCheckBox"
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -157,8 +157,8 @@
public void refresh() {
FinancialTransactionDefaultTable table = view.getFinancialTransactionSearchTable();
table.exit();
- FinancialTransactionConditionView ConditionView = view.getFinancialTransactionConditionView();
- FinancialTransactionConditionHandler conditionHandler = ConditionView.getHandler();
+ FinancialTransactionConditionView conditionView = view.getFinancialTransactionConditionView();
+ FinancialTransactionConditionHandler conditionHandler = conditionView.getHandler();
FinancialTransactionCondition condition= conditionHandler.getFilter();
tableModel = view.getFinancialTransactionSearchTableModel();
if (tableModel != null) {
Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java
===================================================================
--- trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java 2013-10-11 15:17:27 UTC (rev 3711)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java 2013-10-28 08:11:44 UTC (rev 3712)
@@ -1,5 +1,29 @@
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 static org.nuiton.i18n.I18n._;
/**
Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/TypeEntry.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Property changes on: trunk/lima-swing/src/main/resources/icons/action-choose-entry.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Property changes on: trunk/lima-swing/src/main/resources/icons/action-un-lettering.png
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r3711 - in trunk: lima-callao/src/main/java/org/chorem/lima/entity lima-swing/src/main/java/org/chorem/lima/ui/lettering
by Bavencoff@users.chorem.org 11 Oct '13
by Bavencoff@users.chorem.org 11 Oct '13
11 Oct '13
Author: Bavencoff
Date: 2013-10-11 17:17:27 +0200 (Fri, 11 Oct 2013)
New Revision: 3711
Url: http://chorem.org/projects/lima/repository/revisions/3711
Log:
[lettrage] change lettring/un lettring filter
Modified:
trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.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/LetteringView.jaxx
trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java
Modified: trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java
===================================================================
--- trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2013-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-callao/src/main/java/org/chorem/lima/entity/EntryDAOImpl.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -197,12 +197,11 @@
" where E.financialTransaction = F" +
" and E.account.accountNumber like :account ";
- if (filter.getDisplayLettered() || filter.getDisplayUnlettred()){
- if (filter.getDisplayUnlettred()){
- query += " and E.lettering is null";
- }else {
- query += " and E.lettering is not null";
- }
+
+ if (!filter.getDisplayLettered() && filter.getDisplayUnlettred()){
+ query += " and E.lettering is null";
+ } else if (filter.getDisplayLettered() && !filter.getDisplayUnlettred()){
+ query += " and E.lettering is not null";
}
query += " and E.financialTransaction.transactionDate between :beginDate and :endDate " +
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-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringTable.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -70,7 +70,7 @@
actionMap.put(binding, new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
- handler.addLetter();
+ handler.addLetter();
}
});
@@ -94,7 +94,18 @@
}
});
+ // 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());
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-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringView.jaxx 2013-10-11 15:17:27 UTC (rev 3711)
@@ -32,14 +32,11 @@
org.chorem.lima.entity.Account
javax.swing.ListSelectionModel
org.jdesktop.swingx.JXDatePicker
- org.chorem.lima.beans.LetteringFilter
- org.chorem.lima.beans.LetteringFilterImpl
</import>
<LetteringViewHandler id="handler" constructorParams="this"/>
<LetteringTableModel id="tableModel"/>
- <LetteringFilterImpl id='filterModel' initializer='new LetteringFilterImpl()'/>
<LetteringEditModel id='editModel'/>
<LettringSelectionModel id='lettringSelectionModel' constructorParams=' tableModel'
@@ -84,7 +81,7 @@
model="{accountComboBoxModel}"
toolTipText="lima.ui.lettering.account"
renderer="{new org.chorem.lima.ui.common.AccountListRenderer()}"
- onItemStateChanged="filterModel.setAccount((Account)accountComboBoxModel.getSelectedItem())" />
+ onItemStateChanged="handler.setAccount((Account)accountComboBoxModel.getSelectedItem())" />
<JButton id="back" actionIcon="previous"
toolTipText="lima.ui.account.buttonback"
onActionPerformed="handler.back(accountComboBox)"/>
@@ -97,12 +94,12 @@
<JLabel text="lima.ui.lettering.beginFinancialPeriod"
labelFor='{pickerDebut}'/>
<JXDatePicker id="pickerDebut"
- onActionPerformed="filterModel.setDateStart(pickerDebut.getDate())"/>
+ onActionPerformed="handler.setDateStart(pickerDebut.getDate())"/>
<JLabel text="lima.ui.lettering.endFinancialPeriod"
labelFor="{pickerFin}"/>
<JXDatePicker id="pickerFin"
- onActionPerformed="filterModel.setDateEnd(pickerFin.getDate())"/>
+ onActionPerformed="handler.setDateEnd(pickerFin.getDate())"/>
<JToolBar.Separator/>
@@ -112,7 +109,7 @@
genericType='TypeEntry'
constructorParams='TypeEntry.class'
toolTipText="lima.ui.lettering.entry"
- onItemStateChanged="filterModel.setDisplayLettered(lettredEntryComboBox.getSelectedItem().isLettered()) ; filterModel.setDisplayUnlettred(lettredEntryComboBox.getSelectedItem().isNoLettered()) " />
+ onItemStateChanged="handler.setTypeEntry(lettredEntryComboBox.getSelectedItem())" />
<JToolBar.Separator/>
@@ -165,4 +162,4 @@
</JScrollPane>
</cell>
</row>
-</Table>
\ No newline at end of file
+</Table>
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-10-11 13:56:17 UTC (rev 3710)
+++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/lettering/LetteringViewHandler.java 2013-10-11 15:17:27 UTC (rev 3711)
@@ -40,9 +40,7 @@
import org.chorem.lima.entity.FiscalPeriod;
import org.chorem.lima.service.LimaServiceFactory;
-import javax.swing.JComboBox;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
+import javax.swing.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
@@ -78,6 +76,7 @@
protected BigDecimal solde = BigDecimal.ZERO;
protected LettringSelectionModel lettringSelectionModel;
protected LetteringEditModel editModel;
+
protected enum ButtonMode {DELETTRED, LETTRED, EQUALIZED, ALL}
private static final Log log = LogFactory.getLog(LetteringViewHandler.class);
@@ -94,18 +93,10 @@
* Init all combo box in view.
*/
public void init() {
- filter = view.getFilterModel();
+ filter = new LetteringFilterImpl();
editModel = view.getEditModel();
lettringSelectionModel = view.getLettringSelectionModel();
loadComboAndRows();
-
- filter.addPropertyChangeListener(new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- updateAllEntries();
- }
- });
}
public void balanceAndActions() {
@@ -302,9 +293,30 @@
return null;
}
+ public void setDateStart(Date date) {
+ filter.setDateStart(date);
+ updateAllEntries();
+ }
+
+ public void setDateEnd(Date date) {
+ filter.setDateEnd(date);
+ updateAllEntries();
+ }
+
+ public void setAccount(Account account) {
+ filter.setAccount(account);
+ updateAllEntries();
+ }
+
+ public void setTypeEntry(TypeEntry typeEntry) {
+ filter.setDisplayLettered(typeEntry.isLettered());
+ filter.setDisplayUnlettred(typeEntry.isNoLettered());
+ updateAllEntries();
+ }
+
public void updateAllEntries() {
- if (isFilterValid()) {
+ if (filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) {
List<Entry> entries = findAllEntries(filter);
List<String> journalEntrees = new ArrayList<String>();
@@ -356,19 +368,6 @@
}
}
- /**To test if the filter contain an account and a period
- * @return true if filter is valid
- * */
- protected boolean isFilterValid() {
- boolean valid = false;
-
- if (filter.getAccount() != null && filter.getDateStart() != null && filter.getDateEnd() != null) {
- valid = true;
- }
-
- return valid;
- }
-
/**
* Select previous value in combo box.
*
1
0