From echatellier@users.chorem.org Fri Apr 9 18:12:23 2010 From: echatellier@users.chorem.org To: lima-commits@list.chorem.org Subject: [Lima-commits] r2841 - trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction Date: Fri, 09 Apr 2010 18:12:23 +0200 Message-ID: <20100409161223.3F17815919@nuiton.codelutin.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7394427501591489299==" --===============7394427501591489299== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Author: echatellier Date: 2010-04-09 18:12:23 +0200 (Fri, 09 Apr 2010) New Revision: 2841 Log: Migration of transaction and lettering UI. Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionH= elper.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionV= iewHandler.java Removed: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVie= wImpl.java Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWidg= etImpl.java trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVie= w.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTransa= ctionView.jaxx trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/TransactionV= iew.jaxx Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Crite= riaWidgetImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWid= getImpl.java 2010-04-09 16:10:45 UTC (rev 2840) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/CriteriaWid= getImpl.java 2010-04-09 16:12:23 UTC (rev 2841) @@ -23,13 +23,13 @@ import org.apache.commons.logging.LogFactory; import org.chorem.lima.LimaContext; import static org.nuiton.i18n.I18n._; -import org.chorem.lima.combobox.JWideComboBox; -import org.chorem.lima.combobox.model.AccountComboBoxModel; import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer; import org.chorem.lima.dto.AccountDTO; import org.chorem.lima.item.Item; import org.chorem.lima.service.util.ServiceHelper; -import org.chorem.lima.util.AccountToStringConverter; +import org.chorem.lima.ui.transaction.autocomplete.AccountToStringConverter; +import org.chorem.lima.ui.transaction.model.AccountComboBoxModel; +import org.chorem.lima.widgets.JWideComboBox; import org.jdesktop.swingx.JXDatePicker; import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; =20 Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Lette= ringView.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVi= ew.jaxx 2010-04-09 16:10:45 UTC (rev 2840) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVi= ew.jaxx 2010-04-09 16:12:23 UTC (rev 2841) @@ -15,95 +15,86 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ##% --> =20 - +
- + - -
- - - - - - - - - - +
- + - - + + - - + + - + - + - + - + - +
- +
- + - + - + - +
@@ -111,18 +102,21 @@ - - + + + - + - + \ No newline at end of file Deleted: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Letter= ingViewImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVi= ewImpl.java 2010-04-09 16:10:45 UTC (rev 2840) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/LetteringVi= ewImpl.java 2010-04-09 16:12:23 UTC (rev 2841) @@ -1,127 +0,0 @@ -/** - * *##% Lima Main - * Copyright (C) 2008 CodeLutin - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * . ##%* - */ - -package org.chorem.lima.ui.transaction; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.chorem.lima.LimaContext; -import org.chorem.lima.combobox.JWideComboBox; -import org.chorem.lima.combobox.model.AccountComboBoxModel; -import org.chorem.lima.combobox.renderer.AccountComboBoxRenderer; -import org.chorem.lima.combobox.renderer.PeriodComboBoxRenderer; -import org.chorem.lima.dto.AccountDTO; -import org.chorem.lima.dto.PeriodDTO; -import org.chorem.lima.service.util.ServiceHelper; -import org.chorem.lima.util.AccountToStringConverter; -import org.nuiton.util.Resource; -import org.jdesktop.swingx.JXTable; -import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator; - -import javax.swing.*; -import java.awt.*; -import java.util.List; -import java.util.Vector; - -import jaxx.runtime.JAXXContext; - -/** - * @author ore - */ -public class LetteringViewImpl extends LetteringView { - - =20 - - /** - * log - */ - private static final Log log =3D LogFactory.getLog(LetteringViewImpl.cla= ss); - private final JWideComboBox accountComboBox; - - /** - * @param parentContext - */ - public LetteringViewImpl(JAXXContext parentContext) { - super(parentContext); - - /** Calling services */ - List accounts =3D ServiceHelper.getAllFlatAccount( - LimaContext.getContext().getDataManager().getAccountModel().= getData()); - /** Creating accounting model */ - Vector v1 =3D new Vector(accounts); - AccountComboBoxModel model =3D new AccountComboBoxModel(v1); - accountComboBox =3D new JWideComboBox(); - accountComboBox.setPreferredSize(new Dimension(200, 25)); - accountComboBox.setModel(model); - LimaContext.getContext().getDataManager().getAccountModel().addPrope= rtyChangeListener(model); - accountComboBox.setRenderer(AccountComboBoxRenderer.getInstance()); - accountPanel.add(accountComboBox); - - /** AutoCompletion */ - AutoCompleteDecorator.decorate(accountComboBox, AccountToStringConve= rter.getInstance()); - - Icon forwardIcon =3D Resource.getIcon("toolbarButtonGraphics/navigat= ion/Forward24.gif"); - Icon backIcon =3D Resource.getIcon("toolbarButtonGraphics/navigation= /Back24.gif"); - nextButton.setIcon(forwardIcon); - precedentButton.setIcon(backIcon); - - /** Creating period model */ - List periodes =3D LimaContext.getContext().getNeogiaFacto= ry().getPeriodService().getAllPeriod( - LimaContext.getContext().getNeogiaFactory().getStatusService= ().getAllStatus() - ); - Vector v2 =3D new Vector(); - for (PeriodDTO period : periodes) { - v2.addElement(period); - v2.addAll(period.getChildren()); - } - JWideComboBox sinceComboBox =3D new JWideComboBox(v2); - sinceComboBox.setRenderer(PeriodComboBoxRenderer.getInstance()); - sinceComboBox.setPreferredSize(new Dimension(200, 25)); - sincePanel.add(sinceComboBox); - - JWideComboBox toComboBox =3D new JWideComboBox(v2); - toComboBox.setRenderer(PeriodComboBoxRenderer.getInstance()); - toComboBox.setPreferredSize(new Dimension(200, 25)); - toPanel.add(toComboBox); - - JXTable table =3D new JXTable(); - tablePanel.setViewportView(table); - } - - /** - * - */ - @Override - protected void nextAccount() { - if (!(accountComboBox.getSelectedIndex() =3D=3D accountComboBox.getM= odel().getSize() - 1)) { - accountComboBox.setSelectedIndex(accountComboBox.getSelectedInde= x() + 1); - } - - } - - /** - * - */ - @Override - protected void precedentAccount() { - if (!(accountComboBox.getSelectedIndex() =3D=3D 0)) { - accountComboBox.setSelectedIndex(accountComboBox.getSelectedInde= x() - 1); - } - } -} Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Searc= hTransactionView.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTrans= actionView.jaxx 2010-04-09 16:10:45 UTC (rev 2840) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/SearchTrans= actionView.jaxx 2010-04-09 16:12:23 UTC (rev 2841) @@ -28,7 +28,7 @@ - + @@ -49,10 +49,10 @@ - + - +
Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transact= ionHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= Helper.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= Helper.java 2010-04-09 16:12:23 UTC (rev 2841) @@ -0,0 +1,79 @@ +/* *##% Lima Main + * Copyright (C) 2008 - 2010 CodeLutin + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * . ##%* + */ + +package org.chorem.lima.ui.transaction; + +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.Transaction; + +/** + * TODO add comment here. + *=20 + * @author chatellier + * @version $Revision$ + *=20 + * Last update : $Date$ + * By : $Author$ + */ +public class TransactionHelper { + + /** + * Get total credit for a transaction. + *=20 + * @param transaction transaction to get credit + * @return total credit + */ + public static double getCredit(Transaction transaction) { + double credit =3D 0; + for (Entry entry : transaction.getEntry()) { + // TODO EC-20100407 voir si le modele correspond (amount, credit= ,debit) + if (!entry.getDebit()) { + credit +=3D entry.getAmount(); + } + } + return credit; + } + + /** + * Get total debit for a transaction. + *=20 + * @param transaction transaction to get debit + * @return total debit + */ + public static double getDebit(Transaction transaction) { + double debit =3D 0; + for (Entry entry : transaction.getEntry()) { + // TODO EC-20100407 voir si le modele correspond (amount, credit= ,debit) + if (entry.getDebit()) { + debit +=3D entry.getAmount(); + } + } + return debit; + } + + /** + * Return true if transaction is balanced (credit =3D=3D debit). + *=20 + * @param transaction transaction to test + * @return {@code true} if transaction is balanced + */ + public static boolean isBalanced(Transaction transaction) { + boolean balanced =3D getDebit(transaction) =3D=3D getCredit(transact= ion); + return balanced; + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transa= ction/TransactionHelper.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Trans= actionView.jaxx =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= View.jaxx 2010-04-09 16:10:45 UTC (rev 2840) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= View.jaxx 2010-04-09 16:12:23 UTC (rev 2841) @@ -16,11 +16,15 @@ ##% --> =20 + + + + - + @@ -46,26 +50,34 @@ - + + + highlighters=3D"{org.jdesktop.swingx.decorator.Highlight= erFactory.createAlternateStriping(Color.WHITE,new Color(250,250,250))}" /> + - + - + - +
\ No newline at end of file Added: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transact= ionViewHandler.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= ViewHandler.java (rev 0) +++ trunk/lima-swing/src/main/java/org/chorem/lima/ui/transaction/Transaction= ViewHandler.java 2010-04-09 16:12:23 UTC (rev 2841) @@ -0,0 +1,112 @@ +/* *##% 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, US= A. + * ##%*/ + +package org.chorem.lima.ui.transaction; + +import static org.nuiton.i18n.I18n._; + +import javax.swing.JOptionPane; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.entity.Entry; +import org.chorem.lima.entity.Transaction; +import org.chorem.lima.table.model.TransactionTableModel; +import org.chorem.lima.ui.transaction.table.TransactionTable; + +/** + * Handler associated with account view. + *=20 + * @author chatellier + * @version $Revision$ + *=20 + * Last update : $Date$ + * By : $Author$ + */ +public class TransactionViewHandler { + + /** log. */ + private static final Log log =3D LogFactory.getLog(TransactionViewHandle= r.class); + + protected TransactionView view; + + protected TransactionViewHandler(TransactionView view) { + this.view =3D view; + } + + public void addEmptyTransaction() { + =20 + } + =20 + public void removeTransaction() { + =20 + } + =20 + public void addEmptyEntry() { + =20 + } + =20 + /** + * Delete selected row in table (could be transaction or entry). + *=20 + * Called by model. + */ + public void deleteSelectedRow() { + + TransactionTable table =3D (TransactionTable)view.getTransactionTabl= e(); + TransactionTableModel model =3D table.getModel(); + + int indexSelectedRow =3D table.getSelectedRow(); + if (indexSelectedRow !=3D -1) { + + Object selectedValue =3D model.getElementAt(indexSelectedRow); + + String message =3D null; + if (selectedValue instanceof Transaction) { + message =3D _("lima.question.remove.transaction"); + } + else { + message =3D _("lima.question.remove.entry"); + } + + int response =3D JOptionPane.showConfirmDialog(view, message, + _("lima.transaction.confirmdelete"), JOptionPane.YES_NO_= OPTION); + + if (response =3D=3D JOptionPane.YES_OPTION) { + + if (selectedValue instanceof Transaction) { + // TODO EC-20100409 implements this + if (log.isWarnEnabled()) { + log.warn("TODO implement Transaction deletion"); + } + } + else if (selectedValue instanceof Entry) { + // TODO EC-20100409 implements this + if (log.isWarnEnabled()) { + log.warn("TODO implement Entry deletion"); + } + } + } + } + else { + if (log.isWarnEnabled()) { + log.warn("Call delete selected row without selection"); + } + } + } +} Property changes on: trunk/lima-swing/src/main/java/org/chorem/lima/ui/transa= ction/TransactionViewHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL --===============7394427501591489299==--