Author: rchapelet Date: 2009-08-24 15:25:49 +0200 (Mon, 24 Aug 2009) New Revision: 2683 Added: trunk/lima-main/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java trunk/lima-main/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java Modified: trunk/lima-main/src/main/java/org/chorem/lima/bilan/Bilan.java trunk/lima-main/src/main/java/org/chorem/lima/table/BilanActifJXTable.java trunk/lima-main/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java trunk/lima-main/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanView.jaxx trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanViewImpl.java trunk/lima-main/src/main/java/org/chorem/lima/ui/ResultViewImpl.java Log: Mise en page du bilan & compte de r?\195?\169sultat Modified: trunk/lima-main/src/main/java/org/chorem/lima/bilan/Bilan.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/bilan/Bilan.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/bilan/Bilan.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -23,7 +23,6 @@ import org.chorem.lima.dto.BilanDTO; import org.chorem.lima.dto.BalanceDTO; import org.chorem.lima.dto.util.DTOHelper; -import org.chorem.lima.util.Util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -39,6 +38,7 @@ private List<Bilan> listBilan; private String numberAccount; private String position = ""; + private Bilan bilanMaster = null; public Bilan () { @@ -122,7 +122,12 @@ { if (bilan != null) { + // Ajout à la liste listBilan.add(bilan); + // Ajout du bilan père + bilan.setBilanMaster(this); + // Ajout du total au(x) bilan(s) père(s) + addTotalMasterBilan (bilan, bilan.getTotal()); } } @@ -134,8 +139,7 @@ public void add (Bilan bilan, String total) { if (bilan != null) - { - this.setTotal(DTOHelper.AddNumbersString(this.getTotal(), total)); + { add(bilan); } } @@ -188,10 +192,30 @@ return this.position; } + public Bilan getBilanMaster () + { + return bilanMaster; + } + + public void setBilanMaster (Bilan bilan) + { + bilanMaster = bilan; + } + public void addTotal (String number) { this.setTotal(DTOHelper.AddNumbersString(this.getTotal(), number)); } + public void addTotalMasterBilan (Bilan bilan,String total) + { + // Tant que un bilan possède un bilan père, on ajoute le total à ce dernier + Bilan bilanSearch = bilan.getBilanMaster(); + while ( bilanSearch!=null ) + { + bilanSearch.setTotal(DTOHelper.AddNumbersString(bilanSearch.getTotal(), total)); + bilanSearch = bilanSearch.getBilanMaster(); + } + } } \ No newline at end of file Modified: trunk/lima-main/src/main/java/org/chorem/lima/table/BilanActifJXTable.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/BilanActifJXTable.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/BilanActifJXTable.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -21,16 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.table.model.BilanActifTableModel; +import org.chorem.lima.table.renderer.BilanActifTableCellRenderer; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; -import javax.swing.*; -import javax.swing.table.TableColumnModel; -import javax.swing.table.TableModel; import java.awt.*; /** @@ -41,7 +38,7 @@ /** * log */ - private static final Log log = LogFactory.getLog(TransactionJXTable.class); + private static final Log log = LogFactory.getLog(BilanActifJXTable.class); private ColorHighlighter colorTitle; /** @@ -56,7 +53,14 @@ setColumnControlVisible(true); addColorTitle(); - + addColorTotal(); + + // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) + BilanActifTableCellRenderer bilanTableCellRenderer = new BilanActifTableCellRenderer(); + for (int i = 0; i < getModel().getColumnCount(); i++) { + getColumnModel().getColumn(i).setCellRenderer(bilanTableCellRenderer); + } + } @@ -75,9 +79,26 @@ }; colorTitle = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null); addHighlighter(colorTitle); + } + public void addColorTotal() { + HighlightPredicate predicate = new HighlightPredicate() { + + @Override + public boolean isHighlighted(Component arg0, ComponentAdapter adapter) { + boolean result = false; + if ( getModel().getElement(adapter.row).getPosition().equalsIgnoreCase("total") ) + { + result = true; + } + return result; + } + }; + colorTitle = new ColorHighlighter(predicate, new Color(140,150,217), null,null,null); + addHighlighter(colorTitle); } + @Override public BilanActifTableModel getModel() { return (BilanActifTableModel) this.dataModel; Modified: trunk/lima-main/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/BilanPassifJXTable.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -21,16 +21,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.table.model.BilanPassifTableModel; +import org.chorem.lima.table.renderer.BilanPassifTableCellRenderer; import org.jdesktop.swingx.JXTable; import org.jdesktop.swingx.decorator.ColorHighlighter; import org.jdesktop.swingx.decorator.ComponentAdapter; import org.jdesktop.swingx.decorator.HighlightPredicate; -import javax.swing.*; -import javax.swing.table.TableColumnModel; -import javax.swing.table.TableModel; import java.awt.*; /** @@ -41,7 +38,7 @@ /** * log */ - private static final Log log = LogFactory.getLog(TransactionJXTable.class); + private static final Log log = LogFactory.getLog(BilanPassifJXTable.class); private ColorHighlighter colorTitle; /** @@ -56,7 +53,14 @@ setColumnControlVisible(true); addColorTitle(); + addColorTotal(); + // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) + BilanPassifTableCellRenderer bilanTableCellRenderer = new BilanPassifTableCellRenderer(); + for (int i = 0; i < getModel().getColumnCount(); i++) { + getColumnModel().getColumn(i).setCellRenderer(bilanTableCellRenderer); + } + } @@ -78,6 +82,23 @@ } + public void addColorTotal() { + HighlightPredicate predicate = new HighlightPredicate() { + + @Override + public boolean isHighlighted(Component arg0, ComponentAdapter adapter) { + boolean result = false; + if ( getModel().getElement(adapter.row).getPosition().equalsIgnoreCase("total") ) + { + result = true; + } + return result; + } + }; + colorTitle = new ColorHighlighter(predicate, new Color(140,150,217), null,null,null); + addHighlighter(colorTitle); + } + @Override public BilanPassifTableModel getModel() { return (BilanPassifTableModel) this.dataModel; Added: trunk/lima-main/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java (rev 0) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/ResultChargesJXTable.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -0,0 +1,92 @@ +/** + * *##% Lima Main + * Copyright (C) 2009 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 + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.table; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.table.model.ResultChargesTableModel; +import org.chorem.lima.table.renderer.ResultTableCellRenderer; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; + +import java.awt.*; + +/** + * @author Rémi Chapelet + */ +public class ResultChargesJXTable extends JXTable { + + /** + * log + */ + private static final Log log = LogFactory.getLog(ResultChargesJXTable.class); + private ColorHighlighter colorTitle; + + /** + * @param model + * @param columnModel + */ + public ResultChargesJXTable(ResultChargesTableModel model) { + super(model); + + /** Design de la table */ + setRowHeight(24); + setColumnControlVisible(true); + + addColorTitle(); + + // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) + ResultTableCellRenderer resultTableCellRenderer = new ResultTableCellRenderer(); + for (int i = 0; i < getModel().getColumnCount(); i++) { + getColumnModel().getColumn(i).setCellRenderer(resultTableCellRenderer); + } + + } + + + public void addColorTitle() { + HighlightPredicate predicate = new HighlightPredicate() { + + @Override + public boolean isHighlighted(Component arg0, ComponentAdapter adapter) { + boolean result = false; + if ( getModel().getElement(adapter.row).getPosition().equalsIgnoreCase("title") ) + { + result = true; + } + return result; + } + }; + colorTitle = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null); + addHighlighter(colorTitle); + } + + + + + @Override + public ResultChargesTableModel getModel() { + return (ResultChargesTableModel) this.dataModel; + } + + +} Added: trunk/lima-main/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java (rev 0) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/ResultProduitsJXTable.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -0,0 +1,92 @@ +/** + * *##% Lima Main + * Copyright (C) 2009 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 + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.table; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.chorem.lima.table.model.ResultProduitsTableModel; +import org.chorem.lima.table.renderer.ResultTableCellRenderer; +import org.jdesktop.swingx.JXTable; +import org.jdesktop.swingx.decorator.ColorHighlighter; +import org.jdesktop.swingx.decorator.ComponentAdapter; +import org.jdesktop.swingx.decorator.HighlightPredicate; + +import java.awt.*; + +/** + * @author Rémi Chapelet + */ +public class ResultProduitsJXTable extends JXTable { + + /** + * log + */ + private static final Log log = LogFactory.getLog(ResultProduitsJXTable.class); + private ColorHighlighter colorTitle; + + /** + * @param model + * @param columnModel + */ + public ResultProduitsJXTable(ResultProduitsTableModel model) { + super(model); + + /** Design de la table */ + setRowHeight(24); + setColumnControlVisible(true); + + addColorTitle(); + + // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) + ResultTableCellRenderer resultTableCellRenderer = new ResultTableCellRenderer(); + for (int i = 0; i < getModel().getColumnCount(); i++) { + getColumnModel().getColumn(i).setCellRenderer(resultTableCellRenderer); + } + + } + + + public void addColorTitle() { + HighlightPredicate predicate = new HighlightPredicate() { + + @Override + public boolean isHighlighted(Component arg0, ComponentAdapter adapter) { + boolean result = false; + if ( getModel().getElement(adapter.row).getPosition().equalsIgnoreCase("title") ) + { + result = true; + } + return result; + } + }; + colorTitle = new ColorHighlighter(predicate, new Color(222,222,222), null,null,null); + addHighlighter(colorTitle); + } + + + + + @Override + public ResultProduitsTableModel getModel() { + return (ResultProduitsTableModel) this.dataModel; + } + + +} Modified: trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultChargesTableModel.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -119,4 +119,9 @@ return false; } + public BalanceDTO getElement (int row) + { + return data.get(row); + } + } Modified: trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/model/ResultProduitsTableModel.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -119,4 +119,9 @@ return false; } + public BalanceDTO getElement (int row) + { + return data.get(row); + } + } Modified: trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BalanceTableCellRenderer.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -19,13 +19,16 @@ package org.chorem.lima.table.renderer; -import org.chorem.lima.dto.util.DTOHelper; -import org.chorem.lima.table.TransactionJXTable; import javax.swing.table.*; import javax.swing.*; import java.awt.*; +/** + * Permet de modifier l'apparence du tableau pour la balance + * @author Rémi Chapelet + */ + public class BalanceTableCellRenderer extends DefaultTableCellRenderer { @Override Added: trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java (rev 0) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanActifTableCellRenderer.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -0,0 +1,80 @@ +/** + * *##% Lima-Callao + * Copyright (C) 2009 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 + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.table.renderer; + +import org.chorem.lima.bilan.Bilan; +import org.chorem.lima.table.BilanActifJXTable; +import javax.swing.table.*; +import javax.swing.*; +import java.awt.*; + + +/** + * Permet de modifier l'apparence du tableau pour le bilan à l'actif + * @author Rémi Chapelet + */ + +public class BilanActifTableCellRenderer extends DefaultTableCellRenderer { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) + { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, + row, column); + + // Récupère la JXTable du bilan actif + BilanActifJXTable bilanActifJXTable = (BilanActifJXTable) table; + // Récupère le bilan de la ligne + Bilan bilan = bilanActifJXTable.getModel().getElement(row); + // Si le bilan est un soustotal, alors la ligne est en gras + if (bilan.getPosition().equalsIgnoreCase("soustotal")) + { + setFont(new Font("Verdana", Font.BOLD, 12)); + } + + if (bilan.getPosition().equalsIgnoreCase("total")) + { + setFont(new Font("Verdana", Font.BOLD, 13)); + } + + // Alignement des cellules + switch (column) { + case 0: + this.setHorizontalAlignment(JLabel.LEFT); + break; + case 1: + this.setHorizontalAlignment(JLabel.RIGHT); + break; + case 2: + this.setHorizontalAlignment(JLabel.RIGHT); + break; + case 3: + this.setHorizontalAlignment(JLabel.RIGHT); + break; + case 4: + this.setHorizontalAlignment(JLabel.RIGHT); + break; + } + + return this; + } + +} Added: trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java (rev 0) +++ trunk/lima-main/src/main/java/org/chorem/lima/table/renderer/BilanPassifTableCellRenderer.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -0,0 +1,71 @@ +/** + * *##% Lima-Callao + * Copyright (C) 2009 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 + * <http://www.gnu.org/licenses/lgpl-3.0.html>. ##%* + */ + +package org.chorem.lima.table.renderer; + +import org.chorem.lima.bilan.Bilan; +import org.chorem.lima.table.BilanPassifJXTable; +import javax.swing.table.*; +import javax.swing.*; +import java.awt.*; + + +/** + * Permet de modifier l'apparence du tableau pour le bilan au passif + * @author Rémi Chapelet + */ + +public class BilanPassifTableCellRenderer extends DefaultTableCellRenderer { + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, + boolean isSelected, boolean hasFocus, int row, int column) + { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, + row, column); + + // Récupère la JXTable du bilan actif + BilanPassifJXTable bilanPassifJXTable = (BilanPassifJXTable) table; + // Récupère le bilan de la ligne + Bilan bilan = bilanPassifJXTable.getModel().getElement(row); + // Si le bilan est un soustotal, alors la ligne est en gras + if (bilan.getPosition().equalsIgnoreCase("soustotal")) + { + setFont(new Font("Verdana", Font.BOLD, 12)); + } + + if (bilan.getPosition().equalsIgnoreCase("total")) + { + setFont(new Font("Verdana", Font.BOLD, 13)); + } + + // Alignement des cellules + switch (column) { + case 0: + this.setHorizontalAlignment(JLabel.LEFT); + break; + case 1: + this.setHorizontalAlignment(JLabel.RIGHT); + break; + } + + return this; + } + +} Modified: trunk/lima-main/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/ui/BalanceViewImpl.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -28,7 +28,6 @@ import org.chorem.lima.Main; import org.chorem.lima.table.model.BalanceTableModel; import org.chorem.lima.table.renderer.BalanceTableCellRenderer; -import org.chorem.lima.util.Util; import static org.nuiton.i18n.I18n._; import org.jdesktop.swingx.JXTable; Modified: trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanView.jaxx =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanView.jaxx 2009-08-24 13:25:49 UTC (rev 2683) @@ -17,19 +17,13 @@ </row> <!-- Affichage du bilan (actif et passif) --> - <row weighty="6" anchor="center" fill="both"> - <cell weightx="60"> + <row weightx="1.0" weighty="1.0" anchor="center" fill="both"> + <cell weightx="0.5"> <JScrollPane id="tabActif" /> </cell> - <cell weightx="100"> + <cell weightx="0.5"> <JScrollPane id="tabPassif" /> </cell> </row> - <!-- Affichage du résultat --> - <row columns="2"> - <cell> - <JLabel /> - </cell> - </row> </Table> \ No newline at end of file Modified: trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanViewImpl.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/ui/BilanViewImpl.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -31,10 +31,7 @@ import org.chorem.lima.table.BilanPassifJXTable; import org.chorem.lima.table.model.BilanActifTableModel; import org.chorem.lima.table.model.BilanPassifTableModel; -import org.chorem.lima.util.Util; -import org.jdesktop.swingx.decorator.HighlighterFactory; -import org.jdesktop.swingx.JXTable; import java.awt.event.*; import javax.swing.*; import java.util.Hashtable; @@ -43,6 +40,9 @@ import java.util.Vector; /** + * Cette classe permet de calculer le bilan. Elle utilise la balance et + * le compte de résultat. + * * @author Rémi Chapelet */ public class BilanViewImpl extends BilanView { @@ -66,7 +66,7 @@ modelBilanActif = new BilanActifTableModel(new LinkedList<Bilan>()); modelBilanPassif = new BilanPassifTableModel(new LinkedList<Bilan>()); - // Charge les produits et charges + // Chargement du bilan updateBilan(); /** ACTIF */ @@ -91,38 +91,79 @@ } + /** + * Permet de calculer le bilan + */ public void updateBilan () { log.debug("Update bilan :"); // Chargement de la balance List<BalanceDTO> ListbalanceDTO = balance.createBalance((PeriodDTO) comboBoxPeriod.getSelectedItem()); + /** + * Cette partie consiste à créer les catégories du bilan + */ /** ACTIF */ Hashtable<String,Bilan> actifTab = new Hashtable<String,Bilan>(); - actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel","0",null)); - actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel","0",null)); - actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier","0",null)); - actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours","0",null)); - actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés","0",null)); - actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances","0",null)); - actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP","0",null)); - actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités","0",null)); - actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA","0",null)); + actifTab.put("ACTIF", new Bilan("TOTAL (1) + (2)","total",null)); + actifTab.put("ACTIF_IMMOBILISE", new Bilan("ACTIF IMMOBILISE","title",null)); + actifTab.put("ACTIF_IMMOBILISE_INCORPOREL", new Bilan("Immobilisé incorporel","",null)); + actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL")); + actifTab.put("ACTIF_IMMOBILISE_CORPOREL", new Bilan("Immobilisé corporel","",null)); + actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL")); + actifTab.put("ACTIF_IMMOBILISE_FINANCIER", new Bilan("Immobilisé financier","",null)); + actifTab.get("ACTIF_IMMOBILISE").add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER")); + actifTab.put("ACTIF_CIRCULANT", new Bilan("ACTIF CIRCULANT","title",null)); + actifTab.put("ACTIF_CIRCULANT_STOCK", new Bilan("stocks et en-cours","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_STOCK")); + actifTab.put("ACTIF_CIRCULANT_AVANCES", new Bilan("av. et ac. versés","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_AVANCES")); + actifTab.put("ACTIF_CIRCULANT_CREANCES", new Bilan("Créances","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CREANCES")); + actifTab.put("ACTIF_CIRCULANT_VMP", new Bilan("VMP","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_VMP")); + actifTab.put("ACTIF_CIRCULANT_DISPONIBILITE", new Bilan("Disponibilités","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE")); + actifTab.put("ACTIF_CIRCULANT_CCA", new Bilan("CCA","",null)); + actifTab.get("ACTIF_CIRCULANT").add(actifTab.get("ACTIF_CIRCULANT_CCA")); + actifTab.get("ACTIF").add(actifTab.get("ACTIF_IMMOBILISE")); + actifTab.get("ACTIF").add(actifTab.get("ACTIF_CIRCULANT")); /** PASSIF */ Hashtable<String,Bilan> passifTab = new Hashtable<String,Bilan>(); - passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital","0",null)); - passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves","0",null)); - passifTab.put("PASSIF_CP_RAN", new Bilan("RAN","0",null)); - passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat","0",null)); - passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement","0",null)); - passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées","0",null)); - passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions","0",null)); - passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts","0",null)); - passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus","0",null)); - passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs","0",null)); - passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales","0",null)); - passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations","0",null)); - passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes","0",null)); - passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA","0",null)); + passifTab.put("PASSIF", new Bilan("TOTAL (1) + (2) + (3)","total",null)); + passifTab.put("PASSIF_CAPITAUX", new Bilan("CAPITAUX PROPRES","title",null)); + passifTab.put("PASSIF_CP_CAPITAL", new Bilan("Capital","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_CAPITAL")); + passifTab.put("PASSIF_CP_RESERVES", new Bilan("Réserves","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESERVES")); + passifTab.put("PASSIF_CP_RAN", new Bilan("RAN","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RAN")); + passifTab.put("PASSIF_CP_RESULTAT", new Bilan("Résultat","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_RESULTAT")); + passifTab.put("PASSIF_CP_SUBVENTION", new Bilan("Subventions d'investissement","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_SUBVENTION")); + passifTab.put("PASSIF_CP_PROVISION", new Bilan("Provisions réglementées","",null)); + passifTab.get("PASSIF_CAPITAUX").add(passifTab.get("PASSIF_CP_PROVISION")); + passifTab.put("PASSIF_PR_PROVISIONS", new Bilan("PROVISIONS","title",null)); + passifTab.put("PASSIF_PROVISIONS", new Bilan("Provisions","",null)); + passifTab.get("PASSIF_PR_PROVISIONS").add(passifTab.get("PASSIF_PROVISIONS")); + passifTab.put("PASSIF_DETTES", new Bilan("DETTES","title",null)); + passifTab.put("PASSIF_DETTES_EMPRUNTS", new Bilan("Emprunts","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_EMPRUNTS")); + passifTab.put("PASSIF_DETTES_AVANCES", new Bilan("av. et ac. reçus","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AVANCES")); + passifTab.put("PASSIF_DETTES_FOURNISSEURS", new Bilan("Fournisseurs","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FOURNISSEURS")); + passifTab.put("PASSIF_DETTES_FISCALES", new Bilan("Fiscales/sociales","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_FISCALES")); + passifTab.put("PASSIF_DETTES_IMMOBILISATIONS", new Bilan("Immobilisations","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS")); + passifTab.put("PASSIF_DETTES_AUTRES_DETTES", new Bilan("Autres dettes","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES")); + passifTab.put("PASSIF_DETTES_PCA", new Bilan("PCA","",null)); + passifTab.get("PASSIF_DETTES").add(passifTab.get("PASSIF_DETTES_PCA")); + passifTab.get("PASSIF").add(passifTab.get("PASSIF_CAPITAUX")); + passifTab.get("PASSIF").add(passifTab.get("PASSIF_CP_PROVISION")); + passifTab.get("PASSIF").add(passifTab.get("PASSIF_DETTES")); /** * Vérifie chaque numéro de compte (balance) pour déterminer sa position @@ -130,9 +171,11 @@ * Chaque catégorie est un objet bilan, et possède à son tour des bilans * correspondants aux comptes. * Cette boucle ne prend pas en compte les amortissement et provisions. - * Ces comptes sont mis dans une liste à part, pour être listés une seconde fois. + * Ces comptes sont mis dans une liste à part, pour être traités une seconde fois. */ + // Liste amort/prov à traiter apres Hashtable<String,List<BalanceDTO>> provisionMap = new Hashtable<String,List<BalanceDTO>>(); + // Pour chaque balance for ( BalanceDTO balanceDTO : ListbalanceDTO) { /** @@ -325,36 +368,38 @@ */ /** ACTIF */ List<Bilan> listActif = new LinkedList<Bilan>(); - listActif.add(new Bilan("ACTIF_IMMOBILISE","title",null)); + listActif.add(actifTab.get("ACTIF_IMMOBILISE")); listActif.add(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL")); listActif.add(actifTab.get("ACTIF_IMMOBILISE_CORPOREL")); listActif.add(actifTab.get("ACTIF_IMMOBILISE_FINANCIER")); - String total = DTOHelper.AddNumbersString(DTOHelper.AddNumbersString(actifTab.get("ACTIF_IMMOBILISE_INCORPOREL").getTotal(),actifTab.get("ACTIF_IMMOBILISE_CORPOREL").getTotal()),actifTab.get("ACTIF_IMMOBILISE_FINANCIER").getTotal()); - listActif.add(new Bilan("SOUS-TOTAL (1)","soustotal",total,"0")); - listActif.add(new Bilan("ACTIF_CIRCULANT","title",null)); + listActif.add(new Bilan("SOUS-TOTAL (1)","soustotal",actifTab.get("ACTIF_IMMOBILISE").getTotal(),"0")); + listActif.add(actifTab.get("ACTIF_CIRCULANT")); listActif.add(actifTab.get("ACTIF_CIRCULANT_STOCK")); listActif.add(actifTab.get("ACTIF_CIRCULANT_AVANCES")); listActif.add(actifTab.get("ACTIF_CIRCULANT_CREANCES")); listActif.add(actifTab.get("ACTIF_CIRCULANT_VMP")); listActif.add(actifTab.get("ACTIF_CIRCULANT_DISPONIBILITE")); listActif.add(actifTab.get("ACTIF_CIRCULANT_CCA")); - //listActif.add(new Bilan("SOUS-TOTAL (1)","soustotal",actifTab.get("ACTIF_CIRCULANT").getTotal(),"0")); - + listActif.add(new Bilan("SOUS-TOTAL (2)","soustotal",actifTab.get("ACTIF_CIRCULANT").getTotal(),"0")); + listActif.add(actifTab.get("ACTIF")); + // Création du modèle à partir de la liste précédement créée modelBilanActif.setData(listActif); modelBilanActif.fireTableDataChanged(); /** PASSIF */ List<Bilan> listPassif = new LinkedList<Bilan>(); - listPassif.add(new Bilan("CAPITAUX PROPRES","title",null)); + listPassif.add(passifTab.get("PASSIF_CAPITAUX")); listPassif.add(passifTab.get("PASSIF_CP_CAPITAL")); listPassif.add(passifTab.get("PASSIF_CP_RESERVES")); listPassif.add(passifTab.get("PASSIF_CP_RAN")); listPassif.add(passifTab.get("PASSIF_CP_SUBVENTION")); listPassif.add(passifTab.get("PASSIF_CP_PROVISION")); - listPassif.add(new Bilan("PROVISIONS","title",null)); + listPassif.add(new Bilan("SOUS-TOTAL (1)","soustotal",passifTab.get("PASSIF_CAPITAUX").getTotal(),"0")); + listPassif.add(passifTab.get("PASSIF_PR_PROVISIONS")); listPassif.add(passifTab.get("PASSIF_PROVISIONS")); - listPassif.add(new Bilan("DETTES","title",null)); + listPassif.add(new Bilan("SOUS-TOTAL (2)","soustotal",passifTab.get("PASSIF_PR_PROVISIONS").getTotal(),"0")); + listPassif.add(passifTab.get("PASSIF_DETTES")); listPassif.add(passifTab.get("PASSIF_DETTES_EMPRUNTS")); listPassif.add(passifTab.get("PASSIF_DETTES_AVANCES")); listPassif.add(passifTab.get("PASSIF_DETTES_FOURNISSEURS")); @@ -362,6 +407,8 @@ listPassif.add(passifTab.get("PASSIF_DETTES_IMMOBILISATIONS")); listPassif.add(passifTab.get("PASSIF_DETTES_AUTRES_DETTES")); listPassif.add(passifTab.get("PASSIF_DETTES_PCA")); + listPassif.add(new Bilan("SOUS-TOTAL (3)","soustotal",passifTab.get("PASSIF_DETTES").getTotal(),"0")); + listPassif.add(passifTab.get("PASSIF")); // Création du modèle à partir de la liste précédement créée modelBilanPassif.setData(listPassif); Modified: trunk/lima-main/src/main/java/org/chorem/lima/ui/ResultViewImpl.java =================================================================== --- trunk/lima-main/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2009-08-21 16:29:50 UTC (rev 2682) +++ trunk/lima-main/src/main/java/org/chorem/lima/ui/ResultViewImpl.java 2009-08-24 13:25:49 UTC (rev 2683) @@ -26,6 +26,8 @@ import org.chorem.lima.dto.PeriodDTO; import org.chorem.lima.dto.util.DTOHelper; import org.chorem.lima.Main; +import org.chorem.lima.table.ResultChargesJXTable; +import org.chorem.lima.table.ResultProduitsJXTable; import org.chorem.lima.table.model.ResultChargesTableModel; import org.chorem.lima.table.model.ResultProduitsTableModel; import org.chorem.lima.table.renderer.ResultTableCellRenderer; @@ -113,17 +115,7 @@ * CHARGES */ // Création du tableau avec le modèle - tableCharge = new JXTable(modelResultCharges); - /** Design de la table */ - tableCharge.setRowHeight(24); - // Permet d'alterner les couleurs des lignes pour le tableau - tableCharge.setHighlighters(HighlighterFactory.createAlternateStriping()); - tableCharge.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - tableCharge.setColumnControlVisible(true); - // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) - for (int i = 0; i < tableCharge.getModel().getColumnCount(); i++) { - tableCharge.getColumnModel().getColumn(i).setCellRenderer(new ResultTableCellRenderer()); - } + tableCharge = new ResultChargesJXTable(modelResultCharges); // Ajout du tableau tabCharge.setViewportView(tableCharge); @@ -131,17 +123,7 @@ * PRODUITS */ // Création du tableau avec le modèle - tableProduit = new JXTable(modelResultProduits); - /** Design de la table */ - tableProduit.setRowHeight(24); - // Permet d'alterner les couleurs des lignes pour le tableau - tableProduit.setHighlighters(HighlighterFactory.createAlternateStriping()); - tableProduit.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - tableProduit.setColumnControlVisible(true); - // On associe pour chaque colonne l'affichage des cellules (centré, alignement, etc) - for (int i = 0; i < tableProduit.getModel().getColumnCount(); i++) { - tableProduit.getColumnModel().getColumn(i).setCellRenderer(new ResultTableCellRenderer()); - } + tableProduit = new ResultProduitsJXTable(modelResultProduits); // Ajout du tableau tabProduit.setViewportView(tableProduit); @@ -320,16 +302,16 @@ */ // CHARGES List<BalanceDTO> listCharges = new LinkedList<BalanceDTO>(); - BalanceDTO titleExploitation = new BalanceDTO("Exploitation","title","0","0","",null); + BalanceDTO titleExploitation = new BalanceDTO("Exploitation","title","0","0","title",null); listCharges.add(titleExploitation); listCharges.addAll(chargeTab.get("exploitation")); - BalanceDTO titleFinancier = new BalanceDTO("Financiers","title","0","0","",null); + BalanceDTO titleFinancier = new BalanceDTO("Financiers","title","0","0","title",null); listCharges.add(titleFinancier); listCharges.addAll(chargeTab.get("financier")); - BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles","title","0","0","",null); + BalanceDTO titleExceptionnel = new BalanceDTO("Exceptionnelles","title","0","0","title",null); listCharges.add(titleExceptionnel); listCharges.addAll(chargeTab.get("exceptionnel")); - BalanceDTO titleAutre = new BalanceDTO("Autres","title","0","0","",null); + BalanceDTO titleAutre = new BalanceDTO("Autres","title","0","0","title",null); listCharges.add(titleAutre); listCharges.addAll(chargeTab.get("autres")); // Création du modèle à partir de la liste précédement créée @@ -338,13 +320,13 @@ // PRODUITS List<BalanceDTO> listProduits = new LinkedList<BalanceDTO>(); - titleExploitation = new BalanceDTO("Exploitation","title","0","0","",null); + titleExploitation = new BalanceDTO("Exploitation","title","0","0","title",null); listProduits.add(titleExploitation); listProduits.addAll(produitTab.get("exploitation")); - titleFinancier = new BalanceDTO("Financiers","title","0","0","",null); + titleFinancier = new BalanceDTO("Financiers","title","0","0","title",null); listProduits.add(titleFinancier); listProduits.addAll(produitTab.get("financier")); - titleExceptionnel = new BalanceDTO("Exceptionnelles","title","0","0","",null); + titleExceptionnel = new BalanceDTO("Exceptionnelles","title","0","0","title",null); listProduits.add(titleExceptionnel); listProduits.addAll(produitTab.get("exceptionnel")); // Création du modèle à partir de la liste précédement créée