OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 57 | 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.common.element;
15
 
16
import org.openconcerto.sql.element.BaseSQLComponent;
17
import org.openconcerto.sql.element.SQLComponent;
18
import org.openconcerto.ui.DefaultGridBagConstraints;
180 ilm 19
import org.openconcerto.sql.model.Where;
20
import org.openconcerto.sql.request.ComboSQLRequest;
18 ilm 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.JCheckBox;
28
import javax.swing.JLabel;
29
import javax.swing.JTextField;
30
 
31
public class TitrePersonnelSQLElement extends ComptaSQLConfElement {
32
 
33
    public TitrePersonnelSQLElement() {
34
        super("TITRE_PERSONNEL", "un titre personnel", "titres personnels");
35
    }
36
 
37
    @Override
180 ilm 38
    protected void _initComboRequest(ComboSQLRequest req) {
39
        super._initComboRequest(req);
40
        req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE));
41
    }
42
 
43
    @Override
18 ilm 44
    public boolean isShared() {
45
        return true;
46
    }
47
 
48
    protected List<String> getListFields() {
49
        final List<String> l = new ArrayList<String>();
50
        l.add("CODE");
51
        l.add("NOM");
52
        l.add("SEXE_M");
180 ilm 53
        l.add("OBSOLETE");
18 ilm 54
        return l;
55
    }
56
 
57
    protected List<String> getComboFields() {
58
        final List<String> l = new ArrayList<String>();
59
        l.add("CODE");
60
        return l;
61
    }
62
 
63
    public SQLComponent createComponent() {
64
        return new BaseSQLComponent(this) {
65
 
66
            public void addViews() {
67
                this.setLayout(new GridBagLayout());
68
                final GridBagConstraints c = new DefaultGridBagConstraints();
69
 
70
                // Code
71
                JLabel labelCode = new JLabel("CODE");
72
                JTextField textCode = new JTextField();
73
                this.add(labelCode, c);
74
                c.gridx++;
75
                this.add(textCode, c);
76
 
77
                // Nom
78
                JLabel labelNom = new JLabel("NOM");
79
                JTextField textNom = new JTextField();
80
 
81
                this.add(labelNom, c);
82
                c.gridx++;
83
                this.add(textNom, c);
84
 
85
                // Sexe
86
                JCheckBox sexe = new JCheckBox("Sexe masculin");
87
                c.gridx++;
88
                this.add(sexe, c);
89
 
90
                this.addRequiredSQLObject(textCode, "CODE");
91
                this.addRequiredSQLObject(textNom, "NOM");
92
                this.addRequiredSQLObject(sexe, "SEXE_M");
93
            }
94
        };
95
    }
57 ilm 96
 
97
    @Override
98
    protected String createCode() {
99
        return "civility";
100
    }
18 ilm 101
}