OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 28 | Go to most recent revision | Details | 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.humanresources.employe.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
import org.openconcerto.sql.sqlobject.ElementComboBox;
20
import org.openconcerto.ui.DefaultGridBagConstraints;
21
import org.openconcerto.utils.text.SimpleDocumentListener;
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.JPanel;
30
import javax.swing.JTextField;
31
import javax.swing.SwingConstants;
32
import javax.swing.event.DocumentEvent;
33
import javax.swing.event.DocumentListener;
34
 
35
public class CommercialSQLElement extends ComptaSQLConfElement {
36
 
37
    public CommercialSQLElement() {
38
        super("COMMERCIAL", "un commercial", "commerciaux");
39
    }
40
 
41
    public CommercialSQLElement(String tableName, String singular, String plural) {
42
        super(tableName, singular, plural);
43
    }
44
 
45
    protected List<String> getListFields() {
46
        final List<String> l = new ArrayList<String>();
47
        l.add("NOM");
48
        l.add("PRENOM");
49
        l.add("FONCTION");
50
        l.add("TEL_STANDARD");
51
        l.add("TEL_DIRECT");
52
        return l;
53
    }
54
 
55
    protected List<String> getComboFields() {
56
        final List<String> l = new ArrayList<String>();
57
        l.add("NOM");
58
        l.add("PRENOM");
59
        l.add("FONCTION");
60
 
61
        return l;
62
    }
63
 
64
    /*
65
     * (non-Javadoc)
66
     *
67
     * @see org.openconcerto.devis.SQLElement#getComponent()
68
     */
69
    public SQLComponent createComponent() {
70
        return new BaseSQLComponent(this) {
71
 
72
            JTextField textInitiale;
73
            JTextField textPrenom, textNom;
74
 
75
            DocumentListener listener = new SimpleDocumentListener() {
76
 
77
                @Override
78
                public void update(DocumentEvent e) {
79
                    updateInititale();
80
                }
81
            };
82
 
83
            private void updateInititale() {
84
                String s = "";
85
                if (this.textPrenom.getText().trim().length() > 0) {
86
                    s += this.textPrenom.getText().trim().charAt(0);
87
                }
88
                if (this.textNom.getText().trim().length() > 0) {
89
                    s += this.textNom.getText().trim().charAt(0);
90
                }
91
                this.textInitiale.setText(s);
92
            }
93
 
94
            public void addViews() {
95
                this.setLayout(new GridBagLayout());
96
 
97
                GridBagConstraints c = new DefaultGridBagConstraints();
98
 
99
                // Titre personnel
100
                final JLabel label = new JLabel(getLabelFor("ID_TITRE_PERSONNEL"));
101
                label.setHorizontalAlignment(SwingConstants.RIGHT);
102
                this.add(label, c);
103
                ElementComboBox selTitre = new ElementComboBox(false, 6);
104
 
105
                c.gridx++;
106
                c.fill = GridBagConstraints.NONE;
107
                c.gridwidth = GridBagConstraints.REMAINDER;
108
                this.add(selTitre, c);
109
 
110
                // Nom
111
                c.gridx = 0;
112
                c.gridy++;
113
                c.gridwidth = 1;
114
                c.fill = GridBagConstraints.HORIZONTAL;
115
                final JLabel label2 = new JLabel(getLabelFor("NOM"));
116
                label2.setHorizontalAlignment(SwingConstants.RIGHT);
117
                this.add(label2, c);
118
                this.textNom = new JTextField(21);
119
                c.gridx++;
120
                c.weightx = 1;
121
                this.add(this.textNom, c);
122
                this.textNom.getDocument().addDocumentListener(this.listener);
123
 
124
                // Prenom
125
                c.gridx++;
126
                c.weightx = 0;
127
                final JLabel label3 = new JLabel(getLabelFor("PRENOM"));
128
                label3.setHorizontalAlignment(SwingConstants.RIGHT);
129
                this.add(label3, c);
130
                this.textPrenom = new JTextField(21);
131
                c.gridx++;
132
                c.weightx = 1;
133
                this.add(this.textPrenom, c);
134
                this.textPrenom.getDocument().addDocumentListener(this.listener);
135
 
136
                // // Initiales
137
                c.gridx = 0;
138
                c.gridy++;
139
                c.weightx = 0;
140
                final JLabel label4 = new JLabel("Initiales");
141
                label4.setHorizontalAlignment(SwingConstants.RIGHT);
142
                this.add(label4, c);
143
                c.gridx++;
144
                c.weightx = 1;
145
                c.fill = GridBagConstraints.NONE;
146
                this.textInitiale = new JTextField(2);
147
                this.textInitiale.setEditable(false);
148
                this.add(this.textInitiale, c);
149
                c.fill = GridBagConstraints.HORIZONTAL;
150
 
151
                // Fonction
152
                c.gridx++;
153
                c.weightx = 0;
154
                final JLabel label5 = new JLabel(getLabelFor("FONCTION"));
155
                label5.setHorizontalAlignment(SwingConstants.RIGHT);
156
                this.add(label5, c);
157
                JTextField textFonction = new JTextField();
158
                c.gridx++;
159
                c.weightx = 1;
160
                this.add(textFonction, c);
161
 
162
                // Tel Standard
163
                c.gridx = 0;
164
                c.gridy++;
165
                c.weightx = 0;
166
                final JLabel label6 = new JLabel(getLabelFor("TEL_STANDARD"));
167
                label6.setHorizontalAlignment(SwingConstants.RIGHT);
168
                this.add(label6, c);
169
                c.gridx++;
170
                c.weightx = 1;
171
                JTextField textTel = new JTextField();
172
                this.add(textTel, c);
173
 
174
                // Tel direct
175
                c.gridx++;
176
                c.weightx = 0;
177
                final JLabel label7 = new JLabel(getLabelFor("TEL_DIRECT"));
178
                label7.setHorizontalAlignment(SwingConstants.RIGHT);
179
                this.add(label7, c);
180
                JTextField textTelD = new JTextField();
181
                c.gridx++;
182
                c.weightx = 1;
183
                this.add(textTelD, c);
184
 
185
                // Tel Mobile
186
                c.gridx = 0;
187
                c.gridy++;
188
                c.weightx = 0;
189
                final JLabel label8 = new JLabel(getLabelFor("TEL_MOBILE"));
190
                label8.setHorizontalAlignment(SwingConstants.RIGHT);
191
                this.add(label8, c);
192
                c.gridx++;
193
                c.weightx = 1;
194
                JTextField textTelM = new JTextField();
195
                this.add(textTelM, c);
196
 
197
                // Tel Perso
198
                c.gridx++;
199
                c.weightx = 0;
200
                final JLabel label9 = new JLabel(getLabelFor("TEL_PERSONEL"));
201
                label9.setHorizontalAlignment(SwingConstants.RIGHT);
202
                this.add(label9, c);
203
                JTextField textTelP = new JTextField();
204
                c.gridx++;
205
                c.weightx = 1;
206
                this.add(textTelP, c);
207
 
208
                // Tel Fax
209
                c.gridx = 0;
210
                c.gridy++;
211
                c.weightx = 0;
212
                final JLabel label10 = new JLabel(getLabelFor("FAX"));
213
                label10.setHorizontalAlignment(SwingConstants.RIGHT);
214
                this.add(label10, c);
215
                c.gridx++;
216
                c.weightx = 1;
217
                JTextField textFax = new JTextField();
218
                this.add(textFax, c);
219
 
220
                // Tel Email
221
                c.gridx++;
222
                c.weightx = 0;
223
                final JLabel label11 = new JLabel(getLabelFor("EMAIL"));
224
                label11.setHorizontalAlignment(SwingConstants.RIGHT);
225
                this.add(label11, c);
226
                JTextField textMail = new JTextField();
227
                c.gridx++;
228
                c.weightx = 1;
229
                this.add(textMail, c);
230
 
231
                // User
232
 
233
                c.gridx = 0;
234
                c.gridy++;
235
                c.weightx = 0;
236
                final JLabel labelUser = new JLabel(getLabelFor("ID_USER_COMMON"));
237
                labelUser.setHorizontalAlignment(SwingConstants.RIGHT);
238
                this.add(labelUser, c);
239
                c.gridx++;
240
                c.weightx = 1;
241
 
242
                c.gridwidth = GridBagConstraints.REMAINDER;
243
                ElementComboBox comboUser = new ElementComboBox(true, 25);
244
                this.add(comboUser, c);
245
 
246
                c.weighty = 1;
247
                c.gridy++;
248
                this.add(new JPanel(), c);
249
 
250
                this.addRequiredSQLObject(selTitre, "ID_TITRE_PERSONNEL");
251
                selTitre.setButtonsVisible(false);
252
                this.addRequiredSQLObject(this.textNom, "NOM");
253
                this.addRequiredSQLObject(this.textPrenom, "PRENOM");
254
 
255
                this.addSQLObject(textFonction, "FONCTION");
256
 
257
                this.addSQLObject(comboUser, "ID_USER_COMMON");
258
 
259
                this.addSQLObject(textTel, "TEL_STANDARD");
260
                this.addSQLObject(textTelD, "TEL_DIRECT");
261
 
262
                this.addSQLObject(textTelM, "TEL_MOBILE");
263
                this.addSQLObject(textTelP, "TEL_PERSONEL");
264
 
265
                this.addSQLObject(textFax, "FAX");
266
                this.addSQLObject(textMail, "EMAIL");
267
 
268
                // Locks
269
                DefaultGridBagConstraints.lockMinimumSize(this.textInitiale);
270
                DefaultGridBagConstraints.lockMinimumSize(selTitre);
271
 
272
            }
273
        };
274
    }
275
}