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
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;
19 ilm 18
import org.openconcerto.sql.sqlobject.ElementComboBox;
18 ilm 19
import org.openconcerto.ui.DefaultGridBagConstraints;
132 ilm 20
import org.openconcerto.utils.ListMap;
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.JLabel;
28
import javax.swing.JTextField;
29
 
30
public class PaysSQLElement extends ComptaSQLConfElement {
31
 
32
    public PaysSQLElement() {
156 ilm 33
        super("PAYS", "un pays", "pays");
18 ilm 34
    }
35
 
36
    protected List<String> getListFields() {
37
        final List<String> l = new ArrayList<String>();
38
        l.add("CODE");
39
        l.add("NOM");
19 ilm 40
        l.add("ID_TARIF");
18 ilm 41
        return l;
42
    }
43
 
44
    protected List<String> getComboFields() {
45
        final List<String> l = new ArrayList<String>();
46
        l.add("NOM");
47
        return l;
48
    }
49
 
93 ilm 50
    @Override
132 ilm 51
    public ListMap<String, String> getShowAs() {
52
        return ListMap.singleton(null, getComboFields());
93 ilm 53
    }
54
 
18 ilm 55
    /*
56
     * (non-Javadoc)
57
     *
58
     * @see org.openconcerto.devis.SQLElement#getComponent()
59
     */
60
    public SQLComponent createComponent() {
61
        return new BaseSQLComponent(this) {
62
            public void addViews() {
63
                this.setLayout(new GridBagLayout());
64
                final GridBagConstraints c = new DefaultGridBagConstraints();
65
                c.gridx = GridBagConstraints.RELATIVE;
66
                final JTextField textNom = new JTextField();
67
                final JTextField textCode = new JTextField();
68
                final JLabel labelNom = new JLabel(getLabelFor("NOM"));
69
                final JLabel labelCode = new JLabel(getLabelFor("CODE"));
19 ilm 70
                final JLabel labelTarif = new JLabel(getLabelFor("ID_TARIF"));
71
                final ElementComboBox comboTarif = new ElementComboBox();
18 ilm 72
                this.add(labelCode, c);
19 ilm 73
                c.weightx = 0.5;
18 ilm 74
                this.add(textCode, c);
19 ilm 75
                c.weightx = 0;
18 ilm 76
                this.add(labelNom, c);
19 ilm 77
                c.weightx = 0.5;
18 ilm 78
                this.add(textNom, c);
19 ilm 79
                c.gridy++;
80
                c.weightx = 0;
81
                this.add(labelTarif, c);
82
                c.weightx = 0.5;
83
                this.add(comboTarif, c);
84
 
85
                final JLabel labelLangue = new JLabel(getLabelFor("ID_LANGUE"));
86
                final ElementComboBox comboLangue = new ElementComboBox();
87
                c.weightx = 0;
88
                this.add(labelLangue, c);
89
                c.weightx = 0.5;
90
                this.add(comboLangue, c);
91
 
18 ilm 92
                this.addSQLObject(textCode, "CODE");
93
                this.addSQLObject(textNom, "NOM");
19 ilm 94
                this.addSQLObject(comboTarif, "ID_TARIF");
95
                this.addSQLObject(comboLangue, "ID_LANGUE");
18 ilm 96
            }
97
        };
98
    }
57 ilm 99
 
100
    @Override
101
    protected String createCode() {
102
        return "country";
103
    }
18 ilm 104
}