OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

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

Rev Author Line No. Line
43 ilm 1
/*
2
 * Créé le 1 sept. 2011
3
 */
4
package org.openconcerto.modules.badge;
5
 
6
import java.awt.GridBagConstraints;
7
import java.awt.GridBagLayout;
8
import java.awt.Insets;
9
import java.util.ArrayList;
10
import java.util.List;
11
 
12
import javax.swing.JCheckBox;
13
import javax.swing.JLabel;
14
import javax.swing.JTextField;
15
import javax.swing.SwingConstants;
16
 
17
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
18
import org.openconcerto.sql.element.BaseSQLComponent;
19
import org.openconcerto.sql.element.SQLComponent;
20
import org.openconcerto.sql.model.SQLRowValues;
21
import org.openconcerto.sql.sqlobject.ElementComboBox;
22
import org.openconcerto.ui.DefaultGridBagConstraints;
23
import org.openconcerto.ui.JDate;
24
import org.openconcerto.ui.TitledSeparator;
25
import org.openconcerto.ui.component.ITextArea;
118 ilm 26
import org.openconcerto.utils.ListMap;
43 ilm 27
 
28
public class AdherentSQLElement extends ComptaSQLConfElement {
29
    public AdherentSQLElement() {
30
        super("ADHERENT", "un adhérent", "adhérents");
31
    }
32
 
33
    @Override
153 ilm 34
    public boolean isPrivate() {
35
        return true;
36
    }
37
 
38
    @Override
43 ilm 39
    protected List<String> getListFields() {
40
        final List<String> l = new ArrayList<String>();
41
        l.add("ID_PLAGE_HORAIRE");
42
        l.add("DATE_VALIDITE_INSCRIPTION");
43
        l.add("NUMERO_CARTE");
44
        l.add("ACTIF");
45
        return l;
46
    }
47
 
48
    @Override
49
    protected List<String> getComboFields() {
50
        final List<String> l = new ArrayList<String>();
153 ilm 51
        l.add("NUMERO_CARTE");
43 ilm 52
        return l;
53
    }
54
 
55
    @Override
118 ilm 56
    public ListMap<String, String> getShowAs() {
57
        return ListMap.singleton(null, getComboFields());
43 ilm 58
    }
59
 
60
    @Override
61
    public SQLComponent createComponent() {
62
        return new BaseSQLComponent(this) {
63
 
64
            private JLabel getJLabelFor(String field) {
65
                JLabel label = new JLabel(getLabelFor(field));
66
                label.setHorizontalAlignment(SwingConstants.RIGHT);
67
                return label;
68
            }
69
 
70
            @Override
71
            protected SQLRowValues createDefaults() {
72
                SQLRowValues rowVals = new SQLRowValues(getTable());
73
                rowVals.put("ACTIF", Boolean.TRUE);
74
                return rowVals;
75
            }
76
 
77
            @Override
78
            protected void addViews() {
79
                GridBagConstraints c = new DefaultGridBagConstraints();
80
                this.setLayout(new GridBagLayout());
81
 
82
                c.weightx = 1;
83
                c.gridwidth = GridBagConstraints.REMAINDER;
84
                c.insets = new Insets(15, 3, 2, 2);
85
                this.add(new TitledSeparator("Gestion des entrées", true), c);
86
 
87
                JDate dateInscr = new JDate();
88
                c.gridwidth = 1;
89
                c.gridy++;
90
                c.weightx = 0;
91
                c.insets = DefaultGridBagConstraints.getDefaultInsets();
92
                this.add(getJLabelFor("DATE_VALIDITE_INSCRIPTION"), c);
93
 
94
                c.gridx++;
95
                this.add(dateInscr, c);
96
                this.addView(dateInscr, "DATE_VALIDITE_INSCRIPTION");
97
 
98
                c.gridwidth = 1;
99
                c.gridx++;
100
                c.weightx = 0;
101
                this.add(getJLabelFor("NUMERO_CARTE"), c);
102
 
103
                c.gridx++;
104
                JTextField fieldCarte = new JTextField();
105
                this.add(fieldCarte, c);
106
                this.addView(fieldCarte, "NUMERO_CARTE");
107
 
108
                ElementComboBox boxPlage = new ElementComboBox();
109
                c.gridy++;
110
                c.gridx = 0;
111
                c.weightx = 0;
112
                c.gridwidth = 1;
113
                this.add(getJLabelFor("ID_PLAGE_HORAIRE"), c);
114
                c.gridx++;
115
                // c.weightx = 1;
116
                this.add(boxPlage, c);
117
                this.addView(boxPlage, "ID_PLAGE_HORAIRE");
118
 
119
                c.gridy++;
120
                c.gridx = 0;
121
                c.weightx = 0;
122
                c.gridwidth = GridBagConstraints.REMAINDER;
123
                JCheckBox boxActif = new JCheckBox(getLabelFor("ACTIF"));
124
                this.add(boxActif, c);
125
                this.addView(boxActif, "ACTIF");
126
                c.gridy++;
127
                c.gridx = 0;
128
                c.gridwidth = GridBagConstraints.REMAINDER;
129
                JCheckBox boxAdmin = new JCheckBox(getLabelFor("ADMIN"));
130
                this.add(boxAdmin, c);
131
                this.addView(boxAdmin, "ADMIN");
132
 
133
                c.gridy++;
134
                c.gridx = 0;
135
                c.gridwidth = GridBagConstraints.REMAINDER;
136
                c.insets = new Insets(15, 3, 2, 2);
137
                this.add(new TitledSeparator("Informations complémentaires", true), c);
138
 
139
                c.gridy++;
140
                c.weighty = 1;
141
                c.fill = GridBagConstraints.BOTH;
142
                c.insets = DefaultGridBagConstraints.getDefaultInsets();
143
                ITextArea infos = new ITextArea();
144
                this.add(infos, c);
145
                this.addView(infos, "INFOS");
146
            }
147
        };
148
    }
149
}