OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 132 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
132 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.humanresources.payroll.element;
15
 
156 ilm 16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
132 ilm 17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
156 ilm 19
import org.openconcerto.sql.model.SQLTable;
132 ilm 20
import org.openconcerto.ui.DefaultGridBagConstraints;
21
 
22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.util.ArrayList;
25
import java.util.List;
26
 
27
import javax.swing.JLabel;
28
import javax.swing.JTextField;
29
 
156 ilm 30
public abstract class AbstractCodeCommonSQLElement extends ComptaSQLConfElement {
132 ilm 31
 
156 ilm 32
    public AbstractCodeCommonSQLElement(final SQLTable table, final String singular, final String plural) {
33
        super(table, singular, plural);
132 ilm 34
    }
35
 
36
    protected List<String> getListFields() {
37
        final List<String> list = new ArrayList<String>(2);
38
        list.add("CODE");
39
        list.add("NOM");
40
        return list;
41
    }
42
 
43
    protected List<String> getComboFields() {
44
        final List<String> list = new ArrayList<String>(2);
45
        list.add("CODE");
46
        list.add("NOM");
47
        return list;
48
    }
49
 
50
    public SQLComponent createComponent() {
51
        return new BaseSQLComponent(this) {
52
 
53
            public void addViews() {
54
                this.setLayout(new GridBagLayout());
55
                final GridBagConstraints c = new DefaultGridBagConstraints();
56
 
57
                // Code
58
                final JLabel labelCode = new JLabel("Code");
59
                this.add(labelCode, c);
60
                c.gridx++;
61
                c.weightx = 1;
62
                final JTextField textCode = new JTextField();
63
                this.add(textCode, c);
64
 
65
                // Nom
66
                c.gridx++;
67
                c.weightx = 0;
68
                final JLabel labelNom = new JLabel("Libellé");
69
                this.add(labelNom, c);
70
                c.gridx++;
71
                c.weightx = 1;
72
                final JTextField textNom = new JTextField();
73
                this.add(textNom, c);
74
 
75
                this.addRequiredSQLObject(textNom, "NOM");
76
                this.addRequiredSQLObject(textCode, "CODE");
77
            }
78
        };
79
    }
80
 
81
}