OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
61 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
 
132 ilm 16
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
17
import org.openconcerto.sql.element.BaseSQLComponent;
18
import org.openconcerto.sql.element.SQLComponent;
19
import org.openconcerto.ui.DefaultGridBagConstraints;
20
import org.openconcerto.utils.ListMap;
21
 
61 ilm 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 UniteVenteArticleSQLElement extends ComptaSQLConfElement {
31
 
32
    public static final int A_LA_PIECE = 2;
177 ilm 33
    public static final int M2 = 4;
61 ilm 34
 
35
    public UniteVenteArticleSQLElement() {
36
        super("UNITE_VENTE", "une unité de vente", "unité de vente");
37
    }
38
 
39
    protected List<String> getListFields() {
40
        final List<String> l = new ArrayList<String>();
41
        l.add("CODE");
42
        l.add("NOM");
43
        return l;
44
    }
45
 
46
    protected List<String> getComboFields() {
47
        final List<String> l = new ArrayList<String>();
48
        l.add("NOM");
49
        return l;
50
    }
51
 
94 ilm 52
    @Override
132 ilm 53
    public ListMap<String, String> getShowAs() {
54
        return ListMap.singleton(null, "NOM");
94 ilm 55
    }
56
 
61 ilm 57
    /*
58
     * (non-Javadoc)
59
     *
60
     * @see org.openconcerto.devis.SQLElement#getComponent()
61
     */
62
    public SQLComponent createComponent() {
63
        return new BaseSQLComponent(this) {
64
 
65
            public void addViews() {
66
 
67
                this.setLayout(new GridBagLayout());
68
                GridBagConstraints c = new DefaultGridBagConstraints();
69
 
70
                // Nom
71
                JLabel labelCode = new JLabel(getLabelFor("CODE"));
72
                JTextField textCode = new JTextField(25);
73
 
74
                this.add(labelCode, c);
75
                c.gridx++;
76
                DefaultGridBagConstraints.lockMinimumSize(textCode);
77
                this.add(textCode, c);
78
 
79
                // Nom
80
                c.gridy++;
81
                c.gridx = 0;
82
                JLabel labelNom = new JLabel(getLabelFor("NOM"));
83
                JTextField textNom = new JTextField(50);
84
 
85
                this.add(labelNom, c);
86
                c.gridx++;
87
                DefaultGridBagConstraints.lockMinimumSize(textNom);
88
                this.add(textNom, c);
89
 
90
                this.addRequiredSQLObject(textCode, "CODE");
91
                this.addRequiredSQLObject(textNom, "NOM");
92
            }
93
        };
94
    }
95
 
96
    @Override
97
    protected String createCode() {
156 ilm 98
        return createCodeOfPackage() + ".unit";
61 ilm 99
    }
100
}