OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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