OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | 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
 
142 ilm 16
import org.openconcerto.erp.config.DsnBrutCode;
156 ilm 17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
142 ilm 18
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
156 ilm 20
import org.openconcerto.sql.model.DBRoot;
142 ilm 21
import org.openconcerto.ui.DefaultGridBagConstraints;
22
import org.openconcerto.ui.component.ComboLockedMode;
23
import org.openconcerto.ui.component.ITextCombo;
24
 
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.util.ArrayList;
28
import java.util.Arrays;
29
import java.util.List;
30
 
31
import javax.swing.JLabel;
32
import javax.swing.JTextField;
33
 
156 ilm 34
public class CodeTypeRubriqueBrutSQLElement extends ComptaSQLConfElement {
142 ilm 35
 
156 ilm 36
    public CodeTypeRubriqueBrutSQLElement(final DBRoot root) {
37
        super(root.getTable("CODE_TYPE_RUBRIQUE_BRUT"), "un code rubrique de brut", "codes rubrique de brut");
132 ilm 38
    }
39
 
142 ilm 40
    protected List<String> getListFields() {
41
        final List<String> list = new ArrayList<String>(3);
42
        list.add("CODE");
43
        list.add("TYPE");
44
        list.add("NOM");
45
        return list;
46
    }
47
 
48
    protected List<String> getComboFields() {
49
        final List<String> list = new ArrayList<String>(3);
50
        list.add("CODE");
51
        list.add("TYPE");
52
        list.add("NOM");
53
        return list;
54
    }
55
 
56
    public SQLComponent createComponent() {
57
        return new BaseSQLComponent(this) {
58
 
59
            public void addViews() {
60
                this.setLayout(new GridBagLayout());
61
                final GridBagConstraints c = new DefaultGridBagConstraints();
62
 
63
                // Code
64
                final JLabel labelCode = new JLabel("Code");
65
                this.add(labelCode, c);
66
                c.gridx++;
67
                c.weightx = 1;
68
                final JTextField textCode = new JTextField();
69
                this.add(textCode, c);
70
 
71
                // Nom
72
                c.gridx++;
73
                c.weightx = 0;
74
                final JLabel labelNom = new JLabel("Libellé");
75
                this.add(labelNom, c);
76
                c.gridx++;
77
                c.weightx = 1;
78
                final JTextField textNom = new JTextField();
79
                this.add(textNom, c);
80
 
81
                // Type
82
                ITextCombo comboType = new ITextCombo(ComboLockedMode.LOCKED);
83
                comboType.initCache(Arrays.asList(DsnBrutCode.DsnTypeCodeBrut.PRIME.getName(), DsnBrutCode.DsnTypeCodeBrut.AUTRE.getName(), DsnBrutCode.DsnTypeCodeBrut.REMUNERATION.getName()));
84
                c.gridx++;
85
                c.weightx = 0;
86
                final JLabel labelType = new JLabel("Type");
87
                this.add(labelType, c);
88
                c.gridx++;
89
                c.weightx = 1;
90
                this.add(comboType, c);
91
 
92
                this.addRequiredSQLObject(comboType, "TYPE");
93
                this.addRequiredSQLObject(textNom, "NOM");
94
                this.addRequiredSQLObject(textCode, "CODE");
95
            }
96
        };
97
    }
98
 
132 ilm 99
    @Override
100
    protected String createCode() {
101
        return "humanresources.rubriquebrut.code";
102
    }
103
}