OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 149 | 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.finance.payment.ui;
15
 
16
import org.openconcerto.erp.core.common.ui.DeviseCellEditor;
17
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
18
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.element.SQLElement;
149 ilm 20
import org.openconcerto.sql.model.SQLRowValues;
18 ilm 21
import org.openconcerto.sql.view.list.KeyTableCellRenderer;
22
import org.openconcerto.sql.view.list.RowValuesTable;
23
import org.openconcerto.sql.view.list.RowValuesTableModel;
24
import org.openconcerto.sql.view.list.RowValuesTableRenderer;
25
import org.openconcerto.sql.view.list.SQLTableElement;
26
import org.openconcerto.ui.DefaultGridBagConstraints;
27
import org.openconcerto.ui.table.TimestampTableCellEditor;
28
 
29
import java.awt.GridBagConstraints;
30
import java.awt.GridBagLayout;
31
import java.sql.Timestamp;
32
import java.util.List;
33
import java.util.Vector;
34
 
35
import javax.swing.DefaultCellEditor;
36
import javax.swing.JPanel;
37
import javax.swing.JScrollPane;
38
import javax.swing.JTextField;
39
import javax.swing.ToolTipManager;
40
 
41
public class EncaisseMontantTable extends JPanel {
42
    protected RowValuesTable table;
43
    protected SQLTableElement montant;
44
    protected RowValuesTableModel model;
93 ilm 45
 
18 ilm 46
    SQLTableElement montantRegle;
47
    SQLTableElement montantARegler;
48
 
49
    public EncaisseMontantTable() {
50
        init();
51
        uiInit();
52
    }
53
 
54
    /**
55
     *
56
     */
57
    protected void init() {
58
 
59
        final SQLElement e = getSQLElement();
60
 
61
        final List<SQLTableElement> list = new Vector<SQLTableElement>();
62
 
63
        final SQLTableElement tableElement_Mvt = new SQLTableElement(e.getTable().getField("ID_MOUVEMENT_ECHEANCE"), Integer.class, new DefaultCellEditor(new JTextField()));
64
        tableElement_Mvt.setRenderer(new KeyTableCellRenderer(Configuration.getInstance().getDirectory().getElement("MOUVEMENT")));
177 ilm 65
        tableElement_Mvt.setEditable(false);
18 ilm 66
        list.add(tableElement_Mvt);
67
 
68
        // Date
69
        final SQLTableElement dateElement = new SQLTableElement(e.getTable().getField("DATE"), Timestamp.class, new TimestampTableCellEditor());
177 ilm 70
        dateElement.setEditable(false);
18 ilm 71
        list.add(dateElement);
72
 
73
        // Total HT
74
        montantARegler = new SQLTableElement(e.getTable().getField("MONTANT_A_REGLER"), Long.class, new DeviseCellEditor());
75
        montantARegler.setRenderer(new DeviseNiceTableCellRenderer());
177 ilm 76
        montantARegler.setEditable(false);
18 ilm 77
        list.add(montantARegler);
78
 
79
        // Total HT
80
        this.montantRegle = new SQLTableElement(e.getTable().getField("MONTANT_REGLE"), Long.class, new DeviseCellEditor());
81
        this.montantRegle.setRenderer(new DeviseNiceTableCellRenderer());
82
        list.add(this.montantRegle);
83
 
73 ilm 84
        this.model = new RowValuesTableModel(e, list, e.getTable().getField("MONTANT_REGLE"), false);
18 ilm 85
 
86
        this.table = new RowValuesTable(this.model, null, true);
87
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
88
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
89
 
90
        // Calcul automatique du total TTC
91
        // montantARegler.addModificationListener(this.montantRegle);
92
        // this.montantRegle.setModifier(new CellDynamicModifier() {
93
        // @Override
94
        // public Object computeValueFrom(SQLRowValues row) {
95
        // return row.getObject("MONTANT_A_REGLER");
96
        // }
97
        // });
98
 
99
    }
100
 
101
    /**
102
     *
103
     */
104
    protected void uiInit() {
105
        // Ui init
106
        this.setLayout(new GridBagLayout());
107
        final GridBagConstraints c = new DefaultGridBagConstraints();
108
        c.weightx = 1;
109
 
110
        c.fill = GridBagConstraints.BOTH;
111
        c.weighty = 1;
112
 
113
        this.add(new JScrollPane(this.table), c);
114
        this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
115
    }
116
 
117
    public SQLElement getSQLElement() {
118
        return Configuration.getInstance().getDirectory().getElement("ENCAISSER_MONTANT_ELEMENT");
119
    }
120
 
121
    public void updateField(String field, int id) {
122
        this.table.updateField(field, id);
123
    }
124
 
125
    public RowValuesTable getRowValuesTable() {
126
        return this.table;
127
    }
128
 
129
    public void insertFrom(String field, int id) {
130
        this.table.insertFrom(field, id);
131
    }
132
 
149 ilm 133
    public void insertFrom(SQLRowValues rowVals) {
134
        this.table.insertFrom(rowVals);
135
    }
136
 
18 ilm 137
    public RowValuesTableModel getModel() {
138
        return this.table.getRowValuesTableModel();
139
    }
140
 
141
    public SQLTableElement getMontantElement() {
142
        return this.montantRegle;
143
    }
144
 
145
    public SQLTableElement getMontantAReglerElement() {
146
        return this.montantARegler;
147
    }
148
 
149
    public void refreshTable() {
150
        this.table.repaint();
151
    }
152
 
153
}