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.sales.price.element;
15
 
16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
19 ilm 19
import org.openconcerto.sql.sqlobject.ElementComboBox;
18 ilm 20
import org.openconcerto.ui.DefaultGridBagConstraints;
132 ilm 21
import org.openconcerto.utils.ListMap;
18 ilm 22
 
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.util.ArrayList;
26
import java.util.List;
27
 
28
import javax.swing.JLabel;
29
import javax.swing.JTextField;
30
 
31
public class TarifSQLElement extends ComptaSQLConfElement {
32
 
33
    public TarifSQLElement() {
34
        super("TARIF", "un tarif", "tarifs");
35
    }
36
 
37
    @Override
38
    public boolean isShared() {
39
        return true;
40
    }
41
 
42
    protected List<String> getListFields() {
43
        final List<String> l = new ArrayList<String>();
44
        l.add("NOM");
45
        return l;
46
    }
47
 
48
    protected List<String> getComboFields() {
49
        final List<String> l = new ArrayList<String>();
50
        l.add("NOM");
51
        return l;
52
    }
53
 
19 ilm 54
    @Override
132 ilm 55
    public ListMap<String, String> getShowAs() {
56
        final ListMap<String, String> map = new ListMap<String, String>();
57
        map.putCollection(null, "NOM");
19 ilm 58
        return map;
59
    }
60
 
18 ilm 61
    public SQLComponent createComponent() {
62
        return new BaseSQLComponent(this) {
63
 
64
            public void addViews() {
65
                this.setLayout(new GridBagLayout());
66
                final GridBagConstraints c = new DefaultGridBagConstraints();
67
 
68
                // Nom
21 ilm 69
                final JLabel labelNom = new JLabel(getLabelFor("NOM"));
70
                final JTextField textNom = new JTextField();
18 ilm 71
 
72
                this.add(labelNom, c);
73
                c.gridx++;
74
                c.weightx = 1;
75
                this.add(textNom, c);
76
 
19 ilm 77
                // Devise
21 ilm 78
                final JLabel labelDevise = new JLabel(getLabelFor("ID_DEVISE"));
79
                final ElementComboBox boxDevise = new ElementComboBox();
80
                c.gridx = 0;
81
                c.gridy++;
19 ilm 82
                c.weightx = 0;
83
                this.add(labelDevise, c);
84
                c.gridx++;
85
                c.weightx = 1;
86
                this.add(boxDevise, c);
87
 
88
                // Devise
21 ilm 89
                final JLabel labelTaxe = new JLabel(getLabelFor("ID_TAXE"));
90
                final ElementComboBox boxTaxe = new ElementComboBox();
91
                c.gridx = 0;
92
                c.gridy++;
19 ilm 93
                c.weightx = 0;
94
                this.add(labelTaxe, c);
95
                c.gridx++;
96
                c.weightx = 1;
97
                this.add(boxTaxe, c);
98
 
18 ilm 99
                this.addRequiredSQLObject(textNom, "NOM");
19 ilm 100
                this.addSQLObject(boxDevise, "ID_DEVISE");
101
                this.addSQLObject(boxTaxe, "ID_TAXE");
18 ilm 102
 
103
            }
104
        };
105
    }
156 ilm 106
 
107
    @Override
108
    protected String createCodeSuffix() {
109
        return ".list";
110
    }
111
 
18 ilm 112
}