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
142 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.sales.product.element;
15
 
156 ilm 16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
142 ilm 17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
156 ilm 19
import org.openconcerto.sql.model.DBRoot;
142 ilm 20
import org.openconcerto.sql.sqlobject.ElementComboBox;
21
import org.openconcerto.ui.DefaultGridBagConstraints;
22
import org.openconcerto.utils.ListMap;
23
 
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.util.ArrayList;
27
import java.util.List;
28
 
29
import javax.swing.JLabel;
30
import javax.swing.JTextField;
31
 
156 ilm 32
public class EcoContributionSQLElement extends ComptaSQLConfElement {
142 ilm 33
 
156 ilm 34
    public EcoContributionSQLElement(final DBRoot root) {
35
        super(root.getTable("ECO_CONTRIBUTION"));
142 ilm 36
    }
37
 
156 ilm 38
    @Override
39
    protected String createCode() {
40
        return this.createCodeOfPackage() + ".ewaste-tax";
41
    }
42
 
142 ilm 43
    protected List<String> getListFields() {
44
        final List<String> list = new ArrayList<String>(2);
45
        list.add("ID_FAMILLE_ECO_CONTRIBUTION");
46
        list.add("CODE");
47
        list.add("NOM");
48
        list.add("TAUX");
49
        return list;
50
    }
51
 
52
    protected List<String> getComboFields() {
53
        final List<String> list = new ArrayList<String>(2);
54
        list.add("CODE");
55
        list.add("NOM");
56
        list.add("TAUX");
57
        return list;
58
    }
59
 
60
    @Override
61
    public ListMap<String, String> getShowAs() {
62
        return ListMap.singleton(null, "CODE", "NOM");
63
 
64
    }
65
 
66
    public SQLComponent createComponent() {
67
        return new BaseSQLComponent(this) {
68
 
69
            public void addViews() {
70
                this.setLayout(new GridBagLayout());
71
                final GridBagConstraints c = new DefaultGridBagConstraints();
72
 
73
                // Code
74
                final JLabel labelCode = new JLabel(getLabelFor("CODE"));
75
                c.weightx = 0;
76
                this.add(labelCode, c);
77
                c.gridx++;
78
                c.weightx = 1;
79
                final JTextField textCode = new JTextField();
80
                this.add(textCode, c);
81
 
82
                // Nom
83
                c.gridx++;
84
                c.weightx = 0;
85
                final JLabel labelNom = new JLabel(getLabelFor("NOM"));
86
                this.add(labelNom, c);
87
                c.gridx++;
88
                c.weightx = 1;
89
                final JTextField textNom = new JTextField();
90
                this.add(textNom, c);
91
 
92
                // Famille
93
                c.gridy++;
94
                c.gridx = 0;
95
                c.weightx = 0;
96
                final JLabel labelFamille = new JLabel(getLabelFor("ID_FAMILLE_ECO_CONTRIBUTION"));
97
                this.add(labelFamille, c);
98
                c.gridx++;
99
                c.weightx = 1;
100
                ElementComboBox combo = new ElementComboBox();
101
                this.add(combo, c);
102
 
103
                // Taux
104
                c.gridx++;
105
                c.weightx = 0;
106
                final JLabel labelTaux = new JLabel(getLabelFor("TAUX"));
107
                this.add(labelTaux, c);
108
                c.gridx++;
109
                c.weightx = 1;
110
                final JTextField textTaux = new JTextField();
111
                this.add(textTaux, c);
112
 
113
                this.addRequiredSQLObject(textTaux, "TAUX");
114
                this.addSQLObject(combo, "ID_FAMILLE_ECO_CONTRIBUTION");
115
                this.addRequiredSQLObject(textNom, "NOM");
116
                this.addRequiredSQLObject(textCode, "CODE");
117
            }
118
        };
119
    }
120
}