OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 144 | 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.humanresources.payroll.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
144 ilm 17
import org.openconcerto.sql.element.BaseSQLComponent;
18 ilm 18
import org.openconcerto.sql.element.SQLComponent;
144 ilm 19
import org.openconcerto.ui.DefaultGridBagConstraints;
18 ilm 20
 
144 ilm 21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
18 ilm 23
import java.util.ArrayList;
91 ilm 24
import java.util.Collections;
18 ilm 25
import java.util.List;
26
 
144 ilm 27
import javax.swing.JLabel;
18 ilm 28
import javax.swing.JTextField;
29
 
30
public class VariableSalarieSQLElement extends ComptaSQLConfElement {
31
 
32
    public VariableSalarieSQLElement() {
33
        super("VARIABLE_SALARIE", "une variable salarié", "variables salariés");
34
    }
35
 
36
    protected List<String> getListFields() {
37
 
38
        final List<String> l = new ArrayList<String>();
39
 
40
        for (org.openconcerto.sql.model.SQLField sqlField : this.getTable().getContentFields()) {
41
 
42
            String field = sqlField.getName();
43
            if (!field.equalsIgnoreCase("ID_USER_COMMON_CREATE") && !field.equalsIgnoreCase("ID_USER_COMMON_MODIFY") && !field.equalsIgnoreCase("MODIFICATION_DATE")
156 ilm 44
                    && !field.equalsIgnoreCase("CREATION_DATE") && !field.endsWith("_DEFAULT_VAL") && !field.endsWith("_CUMUL_VAL")) {
18 ilm 45
                l.add(field);
46
            }
47
        }
91 ilm 48
        Collections.sort(l);
18 ilm 49
        return l;
50
    }
51
 
52
    protected List<String> getComboFields() {
53
        final List<String> l = new ArrayList<String>();
54
        l.add("HEURE_110");
55
        return l;
56
    }
57
 
132 ilm 58
    @Override
59
    public boolean isPrivate() {
60
        return true;
61
    }
62
 
18 ilm 63
    /*
64
     * (non-Javadoc)
65
     *
66
     * @see org.openconcerto.devis.SQLElement#getComponent()
67
     */
68
    public SQLComponent createComponent() {
144 ilm 69
        return new BaseSQLComponent(this) {
18 ilm 70
            public void addViews() {
71
 
144 ilm 72
                this.setLayout(new GridBagLayout());
73
 
74
                GridBagConstraints c = new DefaultGridBagConstraints();
75
                c.gridx = GridBagConstraints.RELATIVE;
76
                this.add(new JLabel("Nom de la variable"), c);
77
                this.add(new JLabel("Valeur période courante"), c);
78
                this.add(new JLabel("Valeur d'initialisation par défaut(prochain bulletin)"), c);
156 ilm 79
                this.add(new JLabel("Cumuls"), c);
144 ilm 80
 
18 ilm 81
                final List<String> listFields = getListFields();
82
 
144 ilm 83
                for (String fieldName : listFields) {
18 ilm 84
 
144 ilm 85
                    c.gridy++;
86
                    this.add(new JLabel(getLabelFor(fieldName)), c);
87
                    final JTextField textFieldVal = new JTextField(15);
88
                    this.add(textFieldVal, c);
89
                    this.addView(textFieldVal, fieldName);
90
                    if (getTable().contains(fieldName + "_DEFAULT_VAL")) {
91
                        final JTextField textFieldValDef = new JTextField(15);
92
                        this.add(textFieldValDef, c);
93
                        this.addView(textFieldValDef, fieldName + "_DEFAULT_VAL");
94
 
18 ilm 95
                    }
156 ilm 96
                    if (getTable().contains(fieldName + "_CUMUL_VAL")) {
97
                        final JTextField textFieldValDef = new JTextField(15);
98
                        this.add(textFieldValDef, c);
99
                        this.addView(textFieldValDef, fieldName + "_CUMUL_VAL");
18 ilm 100
 
156 ilm 101
                    }
102
 
144 ilm 103
                    // if (pos % 2 == 0) {
104
                    // this.addSQLObject(new JTextField(15), i, "left");
105
                    // } else {
106
                    // this.addSQLObject(new JTextField(15), i, "right");
107
                    // }
108
 
18 ilm 109
                }
110
            }
111
        };
112
    }
57 ilm 113
 
114
    @Override
115
    protected String createCode() {
156 ilm 116
        return createCodeOfPackage() + ".employe.variable";
57 ilm 117
    }
18 ilm 118
}