OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Rev 73 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
18 ilm 1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
7
 * only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
8
 * copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
9
 * language governing permissions and limitations under the License.
10
 *
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
13
 
14
 package org.openconcerto.erp.core.sales.invoice.ui;
15
 
16
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
17
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
18
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.element.SQLElement;
21
import org.openconcerto.sql.model.SQLRow;
22
import org.openconcerto.sql.model.SQLTable;
23
import org.openconcerto.sql.model.Where;
24
import org.openconcerto.sql.view.EditFrame;
25
import org.openconcerto.sql.view.ListeAddPanel;
19 ilm 26
import org.openconcerto.sql.view.list.IListe;
18 ilm 27
import org.openconcerto.sql.view.list.SQLTableModelColumn;
28
import org.openconcerto.sql.view.list.SQLTableModelColumnPath;
19 ilm 29
import org.openconcerto.sql.view.list.SQLTableModelSource;
18 ilm 30
 
31
import java.awt.event.ActionEvent;
32
 
33
import javax.swing.JButton;
34
import javax.swing.JTable;
35
import javax.swing.SwingUtilities;
36
 
19 ilm 37
public class ListPanelEcheancesClients extends ListeAddPanel {
18 ilm 38
 
39
    // TODO Ajouter une légende dans liste echeance panel pour les couleurs du renderer
40
 
41
    private EditFrame editFrame;
42
    private boolean showRegCompta = false;
43
 
44
    public ListPanelEcheancesClients() {
19 ilm 45
        this(Configuration.getInstance().getDirectory().getElement("ECHEANCE_CLIENT"));
46
    }
18 ilm 47
 
19 ilm 48
    private ListPanelEcheancesClients(final SQLElement elem) {
49
        super(elem, new IListe(elem.getTableSource(true)));
18 ilm 50
        setListe();
51
    }
52
 
53
    public JTable getJTable() {
54
 
55
        return this.getListe().getJTable();
56
    }
57
 
58
    public void setShowRegCompta(boolean b) {
59
        this.showRegCompta = b;
60
        setListe();
61
    }
62
 
63
    protected void handleAction(JButton source, ActionEvent e) {
64
        if (source == this.buttonModifier) {
65
 
66
            if (this.editFrame == null) {
67
                this.editFrame = new EditFrame(this.element, EditFrame.MODIFICATION);
68
            }
19 ilm 69
            this.editFrame.selectionId(this.getListe().getSelectedId());
18 ilm 70
            this.editFrame.pack();
71
            this.editFrame.setVisible(true);
72
 
73
            SQLRow ecritureRow = new EcritureSQLElement().getTable().getRow(this.getListe().getSelectedId());
74
 
75
            MouvementSQLElement.showSource(ecritureRow.getInt("ID_MOUVEMENT"));
76
 
77
        } else {
78
 
79
            super.handleAction(source, e);
80
        }
81
    }
82
 
83
    private void setListe() {
84
        SwingUtilities.invokeLater(new Runnable() {
85
            @Override
86
            public void run() {
87
 
19 ilm 88
                final SQLTable elementEchT = getListe().getSource().getPrimaryTable();
89
                Where wNotRegle = new Where(elementEchT.getField("REGLE"), "=", Boolean.FALSE);
18 ilm 90
                if (!showRegCompta) {
19 ilm 91
                    wNotRegle = wNotRegle.and(new Where(elementEchT.getField("REG_COMPTA"), "=", Boolean.FALSE));
18 ilm 92
                }
19 ilm 93
                getListe().getRequest().setWhere(wNotRegle);
18 ilm 94
 
95
                // this.buttonAjouter.setVisible(false);
96
                final ListEcheanceClientRenderer rend = new ListEcheanceClientRenderer();
97
                for (int i = 0; i < ListPanelEcheancesClients.this.getListe().getJTable().getColumnCount(); i++) {
98
                    if (ListPanelEcheancesClients.this.getListe().getJTable().getColumnClass(i) != Boolean.class) {
99
 
100
                        ListPanelEcheancesClients.this.getListe().getJTable().getColumnModel().getColumn(i).setCellRenderer(rend);
101
                    }
102
                }
103
                // this.getListe().setSQLEditable(false);
104
                ListPanelEcheancesClients.this.buttonAjouter.setVisible(false);
105
                ListPanelEcheancesClients.this.buttonEffacer.setVisible(false);
106
                ListPanelEcheancesClients.this.buttonModifier.setVisible(false);
107
 
19 ilm 108
                final SQLTableModelSource src = ListPanelEcheancesClients.this.getListe().getSource();
18 ilm 109
 
110
                ListPanelEcheancesClients.this.getListe().setSQLEditable(true);
111
 
112
                for (SQLTableModelColumn column : src.getColumns()) {
113
                    if (column.getClass().isAssignableFrom(SQLTableModelColumnPath.class)) {
114
                        ((SQLTableModelColumnPath) column).setEditable(false);
115
                    }
116
                }
117
 
118
                ((SQLTableModelColumnPath) src.getColumns(getElement().getTable().getField("INFOS")).iterator().next()).setEditable(true);
119
 
120
            }
121
        });
122
    }
123
 
124
    @Override
125
    public SQLComponent getModifComp() {
126
        // TODO Auto-generated method stub
127
        return null;
128
    }
129
}