OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 94 | 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.finance.accounting.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;
156 ilm 19
import org.openconcerto.sql.model.Where;
20
import org.openconcerto.sql.request.ComboSQLRequest;
93 ilm 21
import org.openconcerto.sql.sqlobject.ElementComboBox;
19 ilm 22
import org.openconcerto.ui.DefaultGridBagConstraints;
18 ilm 23
 
19 ilm 24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
18 ilm 26
import java.util.ArrayList;
27
import java.util.List;
28
 
93 ilm 29
import javax.swing.JCheckBox;
19 ilm 30
import javax.swing.JLabel;
31
import javax.swing.JTextField;
94 ilm 32
import javax.swing.SwingConstants;
19 ilm 33
 
18 ilm 34
public class PosteAnalytiqueSQLElement extends ComptaSQLConfElement {
35
 
36
    public PosteAnalytiqueSQLElement() {
37
        super("POSTE_ANALYTIQUE", "un poste analytique", "postes analytiques");
38
    }
39
 
40
    protected List<String> getListFields() {
41
        final List<String> list = new ArrayList<String>(2);
93 ilm 42
        list.add("DEFAULT");
18 ilm 43
        list.add("NOM");
44
        list.add("ID_AXE_ANALYTIQUE");
45
        return list;
46
    }
47
 
48
    protected List<String> getComboFields() {
49
        final List<String> list = new ArrayList<String>(2);
50
        list.add("NOM");
51
        list.add("ID_AXE_ANALYTIQUE");
52
        return list;
53
    }
54
 
156 ilm 55
    @Override
56
    protected void _initComboRequest(ComboSQLRequest req) {
57
        super._initComboRequest(req);
58
        req.setWhere(new Where(getTable().getField("OBSOLETE"), "=", Boolean.FALSE));
59
    }
60
 
18 ilm 61
    public SQLComponent createComponent() {
62
        return new BaseSQLComponent(this) {
63
            public void addViews() {
19 ilm 64
                this.setLayout(new GridBagLayout());
65
                GridBagConstraints c = new DefaultGridBagConstraints();
94 ilm 66
                final JLabel labelNom = new JLabel(getLabelFor("NOM"), SwingConstants.RIGHT);
19 ilm 67
                this.add(labelNom, c);
68
                c.gridx++;
69
 
70
                final JTextField obj = new JTextField();
71
                c.weightx = 1;
72
                this.add(obj, c);
73
                this.addRequiredSQLObject(obj, "NOM");
93 ilm 74
 
94 ilm 75
                c.gridx = 0;
76
                c.gridy++;
77
                this.add(new JLabel(getLabelFor("ID_AXE_ANALYTIQUE"), SwingConstants.RIGHT), c);
93 ilm 78
                c.gridx++;
94 ilm 79
                ElementComboBox boxAxe = new ElementComboBox();
80
                this.add(boxAxe, c);
81
                this.addView(boxAxe, "ID_AXE_ANALYTIQUE", REQ);
82
 
83
                c.gridy++;
84
                c.gridx = 0;
93 ilm 85
                c.weightx = 0;
94 ilm 86
                // this.add(new JLabel(getLabelFor("DEFAULT")), c);
93 ilm 87
                c.gridx++;
88
 
94 ilm 89
                JCheckBox box = new JCheckBox(getLabelFor("DEFAULT"));
93 ilm 90
                c.weightx = 1;
91
                this.add(box, c);
92
                this.addRequiredSQLObject(box, "DEFAULT");
93
 
156 ilm 94
                c.gridx++;
95
                JCheckBox boxObs = new JCheckBox(getLabelFor("OBSOLETE"));
96
                c.weightx = 1;
97
                this.add(boxObs, c);
98
                this.addRequiredSQLObject(boxObs, "OBSOLETE");
99
 
18 ilm 100
            }
101
        };
102
    }
57 ilm 103
 
104
    @Override
105
    protected String createCode() {
156 ilm 106
        return createCodeOfPackage() + ".analytic.set";
57 ilm 107
    }
18 ilm 108
}