OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
156 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;
20
import org.openconcerto.sql.model.SQLRowValues;
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 DepotChequeTable extends JPanel {
42
    protected RowValuesTable table;
43
    protected SQLTableElement montant;
44
    protected RowValuesTableModel model;
45
 
46
    public DepotChequeTable() {
47
        init();
48
        uiInit();
49
    }
50
 
51
    /**
52
     *
53
     */
54
    protected void init() {
55
 
56
        final SQLElement e = getSQLElement();
57
 
58
        final List<SQLTableElement> list = new Vector<SQLTableElement>();
59
 
60
        final SQLTableElement tableElement_Chq = new SQLTableElement(e.getTable().getField("ID_CHEQUE_A_ENCAISSER"), Integer.class, new DefaultCellEditor(new JTextField()));
61
        tableElement_Chq.setRenderer(new KeyTableCellRenderer(e.getForeignElement("ID_CHEQUE_A_ENCAISSER")));
62
        list.add(tableElement_Chq);
63
 
64
        final SQLTableElement tableElement_Client = new SQLTableElement(e.getTable().getField("ID_CLIENT"), Integer.class, new DefaultCellEditor(new JTextField()));
65
        tableElement_Client.setRenderer(new KeyTableCellRenderer(e.getForeignElement("ID_CLIENT")));
66
        list.add(tableElement_Client);
67
 
68
        // Tiers
69
        final SQLTableElement tiersElement = new SQLTableElement(e.getTable().getField("TIERS"));
70
        list.add(tiersElement);
71
 
72
        // Date
73
        final SQLTableElement numeroElement = new SQLTableElement(e.getTable().getField("NUMERO"));
74
        list.add(numeroElement);
75
 
76
        // Date
77
        final SQLTableElement banqueElement = new SQLTableElement(e.getTable().getField("BANQUE"));
78
        list.add(banqueElement);
79
 
80
        // Date
81
        final SQLTableElement pieceElement = new SQLTableElement(e.getTable().getField("PIECE"));
82
        list.add(pieceElement);
83
 
84
        // Date
85
        final SQLTableElement dateElement = new SQLTableElement(e.getTable().getField("DATE"), Timestamp.class, new TimestampTableCellEditor());
86
        list.add(dateElement);
87
 
88
        // Total HT
89
        this.montant = new SQLTableElement(e.getTable().getField("MONTANT"), Long.class, new DeviseCellEditor());
90
        this.montant.setRenderer(new DeviseNiceTableCellRenderer());
91
        list.add(this.montant);
92
 
93
        this.model = new RowValuesTableModel(e, list, e.getTable().getField("MONTANT"), false);
94
 
95
        this.table = new RowValuesTable(this.model, null, true);
96
 
97
        this.table.setEditable(false);
98
 
99
        ToolTipManager.sharedInstance().unregisterComponent(this.table);
100
        ToolTipManager.sharedInstance().unregisterComponent(this.table.getTableHeader());
101
 
102
    }
103
 
104
    /**
105
     *
106
     */
107
    protected void uiInit() {
108
        // Ui init
109
        this.setLayout(new GridBagLayout());
110
        final GridBagConstraints c = new DefaultGridBagConstraints();
111
        c.weightx = 1;
112
 
113
        c.fill = GridBagConstraints.BOTH;
114
        c.weighty = 1;
115
 
116
        this.add(new JScrollPane(this.table), c);
117
        this.table.setDefaultRenderer(Long.class, new RowValuesTableRenderer());
118
    }
119
 
120
    public SQLElement getSQLElement() {
121
        return Configuration.getInstance().getDirectory().getElement("DEPOT_CHEQUE_ELEMENT");
122
    }
123
 
124
    public void updateField(String field, int id) {
125
        this.table.updateField(field, id);
126
    }
127
 
128
    public RowValuesTable getRowValuesTable() {
129
        return this.table;
130
    }
131
 
132
    public void insertFrom(String field, int id) {
133
        this.table.insertFrom(field, id);
134
    }
135
 
136
    public void insertFrom(SQLRowValues rowVals) {
137
        this.table.insertFrom(rowVals);
138
    }
139
 
140
    public RowValuesTableModel getModel() {
141
        return this.table.getRowValuesTableModel();
142
    }
143
 
144
    public SQLTableElement getMontantElement() {
145
        return this.montant;
146
    }
147
 
148
    public void refreshTable() {
149
        this.table.repaint();
150
    }
151
 
152
}