Author: jpepin Date: 2010-08-18 16:47:44 +0200 (Wed, 18 Aug 2010) New Revision: 3006 Url: http://chorem.org/repositories/revision/lima/3006 Log: Ajout vue recherches d'?\195?\169critures. Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAccountsEnum.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,60 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.enums; + +import static org.nuiton.i18n.I18n._; + + +public enum ComboBoxAccountsEnum { + + ACCOUNT(_("lima.enum.comboboxaccount.account")), + ACCOUNT_LIST(_("lima.enum.comboboxaccount.accountlist")); + + private final String description; + + private ComboBoxAccountsEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxAccountsEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxAccountsEnum[] enums = ComboBoxAccountsEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxAccountsEnum valueOfDescription(String description){ + ComboBoxAccountsEnum value = null; + + for (ComboBoxAccountsEnum enums : ComboBoxAccountsEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxAmountEnum.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,61 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.enums; + +import static org.nuiton.i18n.I18n._; + + +public enum ComboBoxAmountEnum { + + BOTH(_("lima.enum.comboboxamount.both")), + DEBIT(_("lima.enum.comboboxamount.debit")), + CREDIT(_("lima.enum.comboboxamount.credit")); + + private final String description; + + private ComboBoxAmountEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxAmountEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxAmountEnum[] enums = ComboBoxAmountEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxAmountEnum valueOfDescription(String description){ + ComboBoxAmountEnum value = null; + + for (ComboBoxAmountEnum enums : ComboBoxAmountEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxOperatorsEnum.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,61 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.enums; + +import static org.nuiton.i18n.I18n._; + + +public enum ComboBoxOperatorsEnum { + + EQUAL(_("lima.enum.comboboxoperator.equal")), + SUPERIOR(_("lima.enum.comboboxoperator.superior")), + INFERIOR(_("lima.enum.comboboxoperator.inferior"));; + + private final String description; + + private ComboBoxOperatorsEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxOperatorsEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxOperatorsEnum[] enums = ComboBoxOperatorsEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxOperatorsEnum valueOfDescription(String description){ + ComboBoxOperatorsEnum value = null; + + for (ComboBoxOperatorsEnum enums : ComboBoxOperatorsEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/enums/ComboBoxPeriodEnum.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,62 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.enums; + +import static org.nuiton.i18n.I18n._; + + +public enum ComboBoxPeriodEnum { + + DATE(_("lima.enum.comboboxperiod.date")), + PERIOD(_("lima.enum.comboboxperiod.period")), + FISCAL_PERIOD(_("lima.enum.comboboxperiod.fiscalperiod")), + FINANCIAL_PERIOD(_("lima.enum.comboboxperiod.financialperiod")); + + private final String description; + + private ComboBoxPeriodEnum(String description) { + this.description = description; + } + + public String getDescription() { + return this.description; + } + + public static String[] descriptions(){ + int nbElts = ComboBoxPeriodEnum.values().length; + String[] descriptions = new String[nbElts]; + ComboBoxPeriodEnum[] enums = ComboBoxPeriodEnum.values(); + for (int i = 0; i < nbElts; i++) { + descriptions[i] = enums[i].getDescription(); + } + return descriptions; + } + + public static ComboBoxPeriodEnum valueOfDescription(String description){ + ComboBoxPeriodEnum value = null; + + for (ComboBoxPeriodEnum enums : ComboBoxPeriodEnum.values()) { + if (description.equals(enums.description)){ + value = enums; + break; + } + } + return value; + } +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-17 15:34:26 UTC (rev 3005) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainView.jaxx 2010-08-18 14:47:44 UTC (rev 3006) @@ -157,6 +157,8 @@ actionIcon='entries-balanced'/> <JMenuItem text="lima.entries.searchunbalancedtransaction" onActionPerformed='getHandler().showTransactionUnbalancedView(this)' actionIcon='entries-unbalanced'/> + <JMenuItem text="lima.entries.searchtransaction" onActionPerformed='getHandler().showTransactionSearchView(this)' + actionIcon='entries-search'/> <JMenuItem text="lima.entries.lettering" onActionPerformed='getHandler().showLetteringView(this)' actionIcon='lettering'/> </JMenu> Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-17 15:34:26 UTC (rev 3005) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/MainViewHandler.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -42,6 +42,7 @@ import org.chorem.lima.ui.financialstatementchart.FinancialStatementChartView; import org.chorem.lima.ui.financialstatementreport.FinancialStatementReportView; import org.chorem.lima.ui.financialtransaction.FinancialTransactionView; +import org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchView; import org.chorem.lima.ui.financialtransactionunbalanced.FinancialTransactionUnbalancedView; import org.chorem.lima.ui.home.HomeView; import org.chorem.lima.ui.identity.IdentityForm; @@ -380,6 +381,12 @@ mainView.showTab(_("lima.entries.searchunbalancedtransaction"), searchResultView); } + public void showTransactionSearchView(JAXXContext rootContext) { + MainView mainView = getUI(rootContext); + FinancialTransactionSearchView searchView = new FinancialTransactionSearchView(mainView); + mainView.showTab(_("lima.entries.searchtransaction"), searchView); + } + public void showBalanceView(JAXXContext rootContext) { MainView mainView = getUI(rootContext); BalanceView balanceView = new BalanceView(mainView); Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchComboBox.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,90 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.JComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Account; +import org.chorem.lima.ui.accountsreports.AccountRenderer; +import org.chorem.lima.ui.combobox.AccountComboBoxModel; +import org.chorem.lima.util.AccountToString; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + +public class AccountSearchComboBox extends JComboBox implements KeyListener, ActionListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(AccountSearchComboBox.class); + + protected FinancialTransactionSearchViewHandler handler; + + public AccountSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + AccountComboBoxModel accountComboBoxModel = new AccountComboBoxModel(); + AccountRenderer accountRenderer = new AccountRenderer(); + setModel(accountComboBoxModel); + setRenderer(accountRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, AccountToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } + + + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + //handler.setAccount((Account) this.getSelectedItem()); + } + } + + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof Account){ + //handler.setAccount((Account) this.getSelectedItem()); + } + + // delegate popup list menu + if ( e.getKeyChar() == KeyEvent.VK_ENTER ) + { + firePopupMenuCanceled(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/AccountSearchPanel.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,54 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import javax.swing.JPanel; +import javax.swing.JTextField; +import org.chorem.lima.enums.ComboBoxAccountsEnum; + +public class AccountSearchPanel extends JPanel { + + protected FinancialTransactionSearchViewHandler handler; + + public AccountSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + refresh(ComboBoxAccountsEnum.ACCOUNT); + } + + static final long serialVersionUID = 1L; + + public void refresh(ComboBoxAccountsEnum comboBoxAccountsEnum){ + + switch (comboBoxAccountsEnum) { + case ACCOUNT: + AccountSearchComboBox accountComboBox = new AccountSearchComboBox(handler); + this.removeAll(); + this.add(accountComboBox); + break; + + case ACCOUNT_LIST: + JTextField accountsList = new JTextField(16); + this.removeAll(); + this.add(accountsList); + break; + } + + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/EntryBookSearchComboBox.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,89 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.JComboBox; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.combobox.EntryBookComboBoxModel; +import org.chorem.lima.ui.combobox.EntryBookRenderer; +import org.chorem.lima.util.EntryBookToString; +import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; + +public class EntryBookSearchComboBox extends JComboBox implements KeyListener, ActionListener { + + private static final long serialVersionUID = 1L; + + private static final Log log = + LogFactory.getLog(EntryBookSearchComboBox.class); + + protected FinancialTransactionSearchViewHandler handler; + + public EntryBookSearchComboBox(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + EntryBookComboBoxModel entryBookComboBoxModel = new EntryBookComboBoxModel(); + EntryBookRenderer entryBookRenderer = new EntryBookRenderer(); + setModel(entryBookComboBoxModel); + setRenderer(entryBookRenderer); + setEditable(true); + AutoCompleteDecorator.decorate(this, EntryBookToString.getInstance()); + this.getEditor().getEditorComponent().addKeyListener(this); + this.addActionListener(this); + } + + + + @Override + public void actionPerformed(ActionEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + //handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + } + + + @Override + public void keyPressed(KeyEvent e) { + + } + + @Override + public void keyReleased(KeyEvent e) { + Object object = this.getSelectedItem(); + if (object instanceof EntryBook){ + //handler.setEntryBook((EntryBook) this.getSelectedItem()); + } + // delegate popup list menu + if ( e.getKeyChar() == KeyEvent.VK_ENTER ) + { + firePopupMenuCanceled(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } + +} Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,154 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import java.awt.Color; +import java.awt.Component; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.math.BigDecimal; +import java.util.Date; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.ui.celleditor.AccountTableCellEditor; +import org.chorem.lima.ui.celleditor.DateTableCellEditor; +import org.chorem.lima.ui.celleditor.EntryBookTableCellEditor; +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; + + +/** + * Table des transaction qui ajoute des comportement (keys). + * + * @author ore + * @author Rémi Chapelet + */ +public class FinancialTransactionSearchTable extends JXTable implements KeyListener { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3133690382049594727L; + + protected FinancialTransactionSearchViewHandler handler; + + private Highlighter colorTransaction; + + private ColorHighlighter colorBalance; + + /** + */ + public FinancialTransactionSearchTable(FinancialTransactionSearchViewHandler handler) { + + this.handler = handler; + + addKeyListener(this); + + //Get new date editor + setDefaultEditor(Date.class, new DateTableCellEditor()); + //Get new entry book editor + setDefaultEditor(EntryBook.class, new EntryBookTableCellEditor()); + //Get new account editor + setDefaultEditor(Account.class, new AccountTableCellEditor()); + + //highlight financial financial transactions + addColorTransaction(); + // highlight unbalanced financial transactions + addColorNonBalancedTransaction(); + } + + /** + * Cette méthode permet de colorer toutes les transactions dans le tableau + * afin de bien distinguer les transactions et entrées comptables. + * On récupère la première cellule, on vérifie que c'est une date + */ + protected void addColorTransaction() { + if (colorTransaction != null) { + removeHighlighter(colorTransaction); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + return adapter.getValueAt(adapter.row, 0) instanceof Date; + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(222,222,222), null); + addHighlighter(colorTransaction); + } + + + + /** + * Permet de surligner une transaction dans le tableau lorsque + * cette dernière n'est pas équilibrée. + * On récupère la dernière cellule de la ligne + * et on vérifie si la valeur est différente de 0 + */ + protected void addColorNonBalancedTransaction() { + if (colorBalance != null) { + removeHighlighter(colorBalance); + } + HighlightPredicate predicate = new HighlightPredicate() { + @Override + public boolean isHighlighted(Component renderer, + ComponentAdapter adapter) { + boolean isHighlighted = false; + Object value = adapter.getValueAt(adapter.row, 8); + if (value instanceof BigDecimal) { + BigDecimal currentBalance = (BigDecimal) value; + if (currentBalance.doubleValue() != 0) { + isHighlighted = true; + } + } + return isHighlighted; + } + }; + colorTransaction = + new ColorHighlighter(predicate, new Color(255, 198, 209), null); + addHighlighter(colorTransaction); + } + + /** + * for each action combination key are think + * for extend keyboard and laptop keyboard + */ + @Override + public void keyPressed(KeyEvent e) { + + } + + /* + * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent) + */ + @Override + public void keyTyped(KeyEvent e) { + + } + + /* + * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent) + */ + @Override + public void keyReleased(KeyEvent e) { + + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTable.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,467 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import static org.nuiton.i18n.I18n._; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import javax.swing.table.AbstractTableModel; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.business.FinancialTransactionServiceMonitorable; +import org.chorem.lima.business.LimaException; +import org.chorem.lima.business.ejbinterface.FinancialTransactionService; +import org.chorem.lima.business.utils.EntryComparator; +import org.chorem.lima.entity.Account; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.EntryBook; +import org.chorem.lima.entity.EntryImpl; +import org.chorem.lima.entity.FinancialTransaction; +import org.chorem.lima.entity.FiscalPeriod; +import org.chorem.lima.service.LimaServiceFactory; +import org.chorem.lima.util.DialogHelper; +import org.chorem.lima.util.ErrorHelper; + +/** + * Basic transaction table model. + * + * Le modele est filtré sur {@link #selectedEntryBook} et + * {@link #selectedFinancialPeriod} (montée en charge !). + * + * @author ore + * @author chatellier + * @version $Revision: 2897 $ + * + * Last update : $Date: 2010-05-14 13:22:26 +0200 (ven. 14 mai 2010) $ + * By : $Author: jpepin $ + */ +public class FinancialTransactionSearchTableModel extends AbstractTableModel { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3914954536809622358L; + + /** log. */ + private static final Log log = LogFactory + .getLog(FinancialTransactionSearchTableModel.class); + + /** Transaction service. */ + protected final FinancialTransactionService financialTransactionService; + + /** selected financial period */ + protected FiscalPeriod selectedFiscalPeriod; + + /** data cache */ + protected List<Object> cacheDataList; + + /** collection + + + /** + * Model constructor. + * + * Just init service proxies. + */ + public FinancialTransactionSearchTableModel() { + /* Services */ + financialTransactionService = + LimaServiceFactory.getInstance().getService( + FinancialTransactionServiceMonitorable.class); + } + + /** + * Le model est une combinaison de Transaction/Entries. + * + * + * @return + */ + protected List<Object> getDataList() { + List<Object> results = new ArrayList<Object>(); + if(selectedFiscalPeriod != null){ + try { + Set<FinancialTransaction> financialtransactions = + financialTransactionService.getAllInexactFinancialTransactions(selectedFiscalPeriod); + for (FinancialTransaction financialtransaction : financialtransactions) { + results.add(financialtransaction); + List<Entry> entries = (List<Entry>) financialtransaction.getEntry(); + Collections.sort(entries, new EntryComparator()); + results.addAll(entries); + } + } + catch (LimaException eee) { + if (log.isErrorEnabled()) { + log.debug("Can't update model", eee); + } + + ErrorHelper.showErrorDialog("Can't get transaction list", eee); + } + } + + return results; + } + + public void refresh(){ + cacheDataList = getDataList(); + fireTableDataChanged(); + } + + @Override + public int getColumnCount() { + return 9; + } + + @Override + public Class<?> getColumnClass(int column) { + + Class<?> result = null; + + switch (column) { + case 0: + result = Date.class; + break; + case 1: + result = EntryBook.class; + break; + case 2: + result = String.class; + break; + case 3: + result = Account.class; + break; + case 4: + result = String.class; + break; + case 5: + result = String.class; + break; + case 6: + result = BigDecimal.class; + break; + case 7: + result = BigDecimal.class; + break; + case 8: + result = BigDecimal.class; + break; + } + + return result; + } + + @Override + public String getColumnName(int column) { + String result = "n/a"; + + switch (column) { + case 0: + result = _("lima.table.date"); + break; + case 1: + result = _("lima.table.entrybook"); + break; + case 2: + result = _("lima.table.voucher"); + break; + case 3: + result = _("lima.table.account"); + break; + case 4: + result = _("lima.table.description"); + break; + case 5: + result = _("lima.table.position"); + break; + case 6: + result = _("lima.table.debit"); + break; + case 7: + result = _("lima.table.credit"); + break; + case 8: + result = _("lima.table.balance"); + break; + } + + return result; + } + + @Override + public int getRowCount() { + int result = 0; + + // just prevent too much result + if (cacheDataList != null) { + result = cacheDataList.size(); + } + + return result; + } + + @Override + public Object getValueAt(int row, int column) { + Object result = null; + + // just prevent too much result + if (cacheDataList != null) { + result = cacheDataList.get(row); + + if (result instanceof FinancialTransaction) { + FinancialTransaction currentRow = (FinancialTransaction)result; + BigDecimal amountDebit = currentRow.getAmountDebit(); + BigDecimal amountCredit = currentRow.getAmountCredit(); + + switch (column) { + case 0: + result = currentRow.getTransactionDate(); + break; + case 1: + if (currentRow.getEntryBook() != null){ + result = currentRow.getEntryBook().getCode(); + } + else { + result = null; + } + break; + case 2: + result = null; //entrybook + break; + case 3: + result = null; // account + break; + case 4: + result = null; // description + break; + case 5 : + result = null; // position + break; + case 6: + result = amountDebit; + break; + case 7: + result = amountCredit; + break; + case 8: + result = amountDebit.subtract(amountCredit); + break; + } + } + else if (result instanceof Entry) { + Entry currentEntry = (Entry)result; + switch (column) { + case 0: + result = null; // date + break; + case 1 : // entry book + result = null; + break; + case 2: + result = currentEntry.getVoucher(); + break; + case 3: // account + if (currentEntry.getAccount() != null){ + result = currentEntry.getAccount().getAccountNumber(); + } + else { + result = null; + } + break; + case 4: + result = currentEntry.getDescription(); + break; + case 5 : + result = currentEntry.getPosition(); + break; + case 6: + result = currentEntry.getDebit() ? currentEntry.getAmount() : 0; + break; + case 7: + result = currentEntry.getDebit() ? 0 : currentEntry.getAmount(); + break; + case 8: + result = null; // balance + break; + } + + } + } + + return result; + } + + public void setFiscalPeriod(FiscalPeriod fiscalPeriod){ + selectedFiscalPeriod = fiscalPeriod; + } + + /** + * To set cells editable or not + * different condition for entry or financial transaction + */ + @Override + public boolean isCellEditable(int rowIndex, int columnIndex) { + boolean editableCell=false; + Object currentRow = cacheDataList.get(rowIndex); + // cells editable for the entry row, all cells exclude the date + if ((currentRow instanceof Entry) && !((columnIndex==0) || (columnIndex==1))) { + editableCell=true; + } + // cells editable for the financialtransaction row, no cells exclude the date + if ((currentRow instanceof FinancialTransaction) && ((columnIndex==0) || (columnIndex==1))){ + editableCell=true; + } + return editableCell; + } + + + /** + * @throws LimaException + */ + public void addEmptyEntry(Object value, int row) throws LimaException { + FinancialTransaction currentTransaction = null; + Object currentRow = cacheDataList.get(row); + Entry entry = new EntryImpl(); + entry.setAmount(new BigDecimal(0)); + //check if current row is a transaction or an entry + if (currentRow instanceof FinancialTransaction) { + currentTransaction = (FinancialTransaction)currentRow; + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + //get back the parent transaction of the entry + currentTransaction = currentEntry.getFinancialTransaction(); + } + //create it + entry.setFinancialTransaction(currentTransaction); + financialTransactionService.createEntry(entry); + //on recharge la liste + refresh(); + } + + /** + * to modifiy financialtransaction or entry + */ + @Override + public void setValueAt(Object value, int row, int column) { + int financialTransactionRow=0; + // just prevent too much result + if (selectedFiscalPeriod != null) { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof FinancialTransaction) { + FinancialTransaction currentFinancialTransaction = + (FinancialTransaction)currentRow; + switch (column) { + case 0: + //update + currentFinancialTransaction.setTransactionDate((Date)value); + break; + case 1 : + currentFinancialTransaction.setEntryBook((EntryBook)value); + break; + } + // notify service for modification + try { + financialTransactionService. + updateFinancialTransaction(currentFinancialTransaction); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't update financial transaction", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(((FinancialTransaction) currentRow)); + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + switch (column) { + case 2 : + currentEntry.setVoucher((String)value); + break; + case 3: + currentEntry.setAccount((Account)value); + break; + case 4: + currentEntry.setDescription((String)value); + break; + case 5 : + currentEntry.setPosition((String)value); + break; + case 6: + currentEntry.setAmount((BigDecimal)value); + currentEntry.setDebit(true); + break; + case 7: + currentEntry.setAmount((BigDecimal)value); + currentEntry.setDebit(false); + break; + } + try { + financialTransactionService.updateEntry(currentEntry); + } catch (LimaException eee) { + if (log.isDebugEnabled()){ + log.debug("Can't update entry", eee); + } + DialogHelper.showMessageDialog(eee.getMessage()); + } + //update the financial transaction in entire + financialTransactionRow = + cacheDataList.indexOf(((Entry) currentRow). + getFinancialTransaction()); + } + //on recharge la liste + //TODO PEPIN 20100607 Get financial transaction of cachedatelist on replace it + fireTableRowsUpdated(financialTransactionRow, getRowCount()-1); + } + } + + public Object getElementAt(int row){ + + Object currentRow = cacheDataList.get(row); + return currentRow; + } + + + /** + * Delete selected row in table (could be transaction or entry). + * + * Called by model. + * @param Object, int + * @throws LimaException + */ + public void removeObject(Object object, int row) throws LimaException { + Object currentRow = cacheDataList.get(row); + if (currentRow instanceof FinancialTransaction) { + FinancialTransaction currentTransaction = + (FinancialTransaction)currentRow; + financialTransactionService.removeFinancialTransaction(currentTransaction); + } + else if (currentRow instanceof Entry) { + Entry currentEntry = (Entry)currentRow; + financialTransactionService.removeEntry(currentEntry); + } + //on recharge la liste + refresh(); + } + +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchTableModel.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,87 @@ +<!-- ##% Lima Swing + Copyright (C) 2008 - 2010 CodeLutin + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + ##% --> + +<Table> + <FinancialTransactionSearchViewHandler id="handler" javaBean="new FinancialTransactionSearchViewHandler(this)" /> + <Boolean id="selectedRow" javaBean="false" /> + <script> + <![CDATA[ + import org.chorem.lima.enums.ComboBoxPeriodEnum; + import org.chorem.lima.enums.ComboBoxAccountsEnum; + import org.chorem.lima.enums.ComboBoxAmountEnum; + import org.chorem.lima.enums.ComboBoxOperatorsEnum; + + AccountSearchPanel accountSearchPanel = new AccountSearchPanel(handler); + PeriodSearchPanel periodSearchPanel = new PeriodSearchPanel(handler); + + void $afterCompleteSetup() { + } + + ]]> + </script> + + <row> + <cell><Table><row> + <cell anchor="west"><JComboBox id="periodComboBox" javaBean="new JComboBox(ComboBoxPeriodEnum.descriptions())" + onActionPerformed="periodSearchPanel.refresh(ComboBoxPeriodEnum.valueOfDescription((String) periodComboBox.getSelectedItem())); + validate(); repaint()"/></cell> + <cell><PeriodSearchPanel javaBean="periodSearchPanel"/></cell> + </row></Table></cell> + </row> + <row> + <cell><Table><row> + <cell><JLabel text="lima.table.voucher"/></cell> + <cell><JTextField id='voucher'/></cell> + <cell><JLabel text="lima.table.description"/></cell> + <cell><JTextField id='description'/></cell> + <cell><JLabel text="lima.table.letter"/></cell> + <cell><JTextField id='letter'/></cell> + </row></Table></cell> + </row> + <row> + <cell><Table><row> + <cell><JComboBox id="accountComboBox" javaBean="new JComboBox(ComboBoxAccountsEnum.descriptions())" + onActionPerformed="accountSearchPanel.refresh(ComboBoxAccountsEnum.valueOfDescription((String) accountComboBox.getSelectedItem())); + validate(); repaint()"/></cell> + <cell><AccountSearchPanel javaBean="accountSearchPanel"/></cell> + <cell anchor='east'><JLabel text="lima.table.entrybook"/></cell> + <cell anchor='west'><EntryBookSearchComboBox javaBean="new EntryBookSearchComboBox(handler)"/></cell> + </row></Table></cell> + </row> + <row> + <cell><Table><row> + <cell><JLabel text="lima.amount"/></cell> + <cell><JComboBox id="amountComboBox" javaBean="new JComboBox(ComboBoxAmountEnum.descriptions())"/></cell> + <cell><JComboBox id="operatorComboBox" javaBean="new JComboBox(ComboBoxOperatorsEnum.descriptions())"/></cell> + <cell><JTextField id='amount'/></cell> + </row></Table></cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1"> + <JScrollPane> + <org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTableModel + id="financialTransactionSearchTableModel" /> + <org.chorem.lima.ui.financialtransactionsearch.FinancialTransactionSearchTable + id="financialTransactionSearchTable" sortable="false" rowHeight="22" + constructorParams="getHandler()" model="{getFinancialTransactionSearchTableModel()}" + selectionMode="{ListSelectionModel.SINGLE_SELECTION}" /> + <javax.swing.ListSelectionModel javaBean="getFinancialTransactionSearchTable().getSelectionModel()" + onValueChanged="setSelectedRow(financialTransactionSearchTable.getSelectedRow() != -1)"/> + </JScrollPane> + </cell> + </row> +</Table> \ No newline at end of file Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchView.jaxx ___________________________________________________________________ Added: svn:executable + * Added: 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 (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,60 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import static org.nuiton.i18n.I18n._; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; + +/** + * Handler associated with financial transaction view. + * + * @author chatellier + * @version $Revision: 2901 $ + * + * Last update : $Date: 2010-05-19 12:52:43 +0200 (mer. 19 mai 2010) $ + * By : $Author: jpepin $ + */ +public class FinancialTransactionSearchViewHandler { + + /** log. */ + private static final Log log = + LogFactory.getLog(FinancialTransactionSearchViewHandler.class); + + protected FinancialTransactionSearchView view; + + protected FinancialTransactionSearchTable table; + + protected FinancialTransactionSearchTableModel tableModel; + + protected FiscalPeriodComboBoxModel comboBoxModel; + + + protected FinancialTransactionSearchViewHandler(FinancialTransactionSearchView view) { + this.view = view; + + } + + public void refresh(){ + tableModel = view.getFinancialTransactionSearchTableModel(); + tableModel.refresh(); + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/FinancialTransactionSearchViewHandler.java ___________________________________________________________________ Added: svn:executable + * Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/financialtransactionsearch/PeriodSearchPanel.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -0,0 +1,111 @@ +/* *##% Lima Swing + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * ##%*/ + +package org.chorem.lima.ui.financialtransactionsearch; + +import java.util.Calendar; +import java.util.Date; +import static org.nuiton.i18n.I18n._; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.apache.commons.lang.time.DateUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.enums.ComboBoxPeriodEnum; +import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxModel; +import org.chorem.lima.ui.combobox.FinancialPeriodComboBoxRenderer; +import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxModel; +import org.chorem.lima.ui.combobox.FiscalPeriodComboBoxRenderer; +import org.jdesktop.swingx.JXDatePicker; + +public class PeriodSearchPanel extends JPanel { + + private static final Log log = + LogFactory.getLog(PeriodSearchPanel.class); + + protected FinancialTransactionSearchViewHandler handler; + + public PeriodSearchPanel(FinancialTransactionSearchViewHandler handler) { + this.handler = handler; + refresh(ComboBoxPeriodEnum.DATE); + } + + static final long serialVersionUID = 1L; + + public void refresh(ComboBoxPeriodEnum comboBoxPeriodEnum){ + + switch (comboBoxPeriodEnum) { + case DATE: + Calendar calendar = Calendar.getInstance(); + Date date = calendar.getTime(); + date = DateUtils.truncate(date, Calendar.DATE); + JXDatePicker datePicker = new JXDatePicker(date); + this.removeAll(); + this.add(datePicker); + break; + + case PERIOD: + // get begin date + Calendar calendarBegin = Calendar.getInstance(); + // set begindate to JAN 1 - 0:00.000 of this years + Date beginDate = calendarBegin.getTime(); + beginDate = DateUtils.truncate(beginDate, Calendar.YEAR); + //handler().setBeginDate(beginDate); + + // get end date + Calendar calendarEnd = Calendar.getInstance(); + Date endDate = calendarEnd.getTime(); + //handler().setEndDate(endDate); + JLabel beginDateLabel = new JLabel(_("lima.period.begindate")); + JXDatePicker beginDatePicker = new JXDatePicker(beginDate); + JLabel endDateLabel = new JLabel(_("lima.period.enddate")); + JXDatePicker endDatePicker = new JXDatePicker(endDate); + this.removeAll(); + this.add(beginDateLabel); + this.add(beginDatePicker); + this.add(endDateLabel); + this.add(endDatePicker); + break; + + case FISCAL_PERIOD: + FiscalPeriodComboBoxModel fiscalModel = new FiscalPeriodComboBoxModel(); + FiscalPeriodComboBoxRenderer fiscalRenderer = new FiscalPeriodComboBoxRenderer(); + JComboBox fiscalPeriod = new JComboBox(fiscalModel); + fiscalPeriod.setRenderer(fiscalRenderer); + fiscalPeriod.setEditable(false); + //fiscalPeriod.actionPerformed(handler.); + this.removeAll(); + this.add(fiscalPeriod); + break; + + case FINANCIAL_PERIOD: + FinancialPeriodComboBoxModel financialModel = new FinancialPeriodComboBoxModel(); + FinancialPeriodComboBoxRenderer financialRenderer = new FinancialPeriodComboBoxRenderer(); + JComboBox financialPeriod = new JComboBox(financialModel); + financialPeriod.setRenderer(financialRenderer); + financialPeriod.setEditable(false); + this.removeAll(); + this.add(financialPeriod); + break; + } + + } + +} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java =================================================================== --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-08-17 15:34:26 UTC (rev 3005) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/opening/OpeningViewHandler.java 2010-08-18 14:47:44 UTC (rev 3006) @@ -20,12 +20,10 @@ import static org.nuiton.i18n.I18n._; import java.awt.Color; - import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.border.Border; import javax.swing.border.EmptyBorder; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.chorem.lima.business.FiscalPeriodServiceMonitorable; Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-17 15:34:26 UTC (rev 3005) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-en_GB.properties 2010-08-18 14:47:44 UTC (rev 3006) @@ -79,6 +79,7 @@ lima.entries=Entries lima.entries.addtransaction= lima.entries.lettering= +lima.entries.searchtransaction= lima.entries.searchunbalancedtransaction= lima.entrybook=Entry Book lima.entrybook.add=Add Entry Book @@ -90,6 +91,18 @@ lima.entrybook.type3= lima.entrybook.type4= lima.entrybook.type5= +lima.enum.comboboxaccount.account= +lima.enum.comboboxaccount.accountlist= +lima.enum.comboboxamount.both= +lima.enum.comboboxamount.credit= +lima.enum.comboboxamount.debit= +lima.enum.comboboxoperator.equal= +lima.enum.comboboxoperator.inferior= +lima.enum.comboboxoperator.superior= +lima.enum.comboboxperiod.date= +lima.enum.comboboxperiod.financialperiod= +lima.enum.comboboxperiod.fiscalperiod= +lima.enum.comboboxperiod.period= lima.error=Error lima.error.errorpane.htmlmessage=<html><body><b>An application error happened</b>\:<br/>%s</body></html> lima.error.errorpane.title=Lima error @@ -218,6 +231,7 @@ lima.table.fiscalperiod= lima.table.grossamount= lima.table.label= +lima.table.letter= lima.table.move.credit= lima.table.move.debit= lima.table.netamount= Modified: trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties =================================================================== --- trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-17 15:34:26 UTC (rev 3005) +++ trunk/lima-swing/src/main/resources/i18n/lima-swing-fr_FR.properties 2010-08-18 14:47:44 UTC (rev 3006) @@ -74,6 +74,7 @@ lima.entries=Traitement lima.entries.addtransaction=Saisir des \u00E9critures lima.entries.lettering=Ajouter une lettre +lima.entries.searchtransaction=Rechercher des \u00E9critures lima.entries.searchunbalancedtransaction=Entr\u00E9es incorrect lima.entrybook=Journal lima.entrybook.add=Ajouter un journal @@ -85,6 +86,18 @@ lima.entrybook.type3=Tr\u00E9sorerie lima.entrybook.type4=G\u00E9n\u00E9ral lima.entrybook.type5=Situation +lima.enum.comboboxaccount.account=Compte +lima.enum.comboboxaccount.accountlist=Liste de compte +lima.enum.comboboxamount.both=Les deux +lima.enum.comboboxamount.credit=Cr\u00E9dit +lima.enum.comboboxamount.debit=D\u00E9bit +lima.enum.comboboxoperator.equal=\u00C9gal +lima.enum.comboboxoperator.inferior=Inf\u00E9rieur +lima.enum.comboboxoperator.superior=Sup\u00E9rieur +lima.enum.comboboxperiod.date=Date +lima.enum.comboboxperiod.financialperiod=P\u00E9riode Financi\u00E8re +lima.enum.comboboxperiod.fiscalperiod=Exercice +lima.enum.comboboxperiod.period=P\u00E9riode lima.error=Erreur lima.error.errorpane.htmlmessage=<html><body><b>Une erreur s'est produite</b>\:<br/>%s</body></html> lima.error.errorpane.title=Lima erreur @@ -205,6 +218,7 @@ lima.table.fiscalperiod=Exercice lima.table.grossamount=Brut lima.table.label=Libell\u00E9 +lima.table.letter=Lettre lima.table.move.credit=Mouvement au cr\u00E9dit lima.table.move.debit=Mouvement au d\u00E9bit lima.table.netamount=Net