OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 63 | 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
 /*
15
 * Créé le 30 mars 2012
16
 */
17
package org.openconcerto.erp.core.humanresources.employe.element;
18
 
63 ilm 19
import org.openconcerto.erp.core.common.element.ComptaSQLConfElement;
61 ilm 20
import org.openconcerto.erp.core.humanresources.employe.panel.ObjectifEditPanel;
21
import org.openconcerto.sql.element.BaseSQLComponent;
22
import org.openconcerto.sql.element.SQLElement;
23
import org.openconcerto.sql.model.SQLRowAccessor;
24
import org.openconcerto.sql.sqlobject.ElementComboBox;
25
import org.openconcerto.ui.DefaultGridBagConstraints;
26
import org.openconcerto.ui.FormLayouter;
27
import org.openconcerto.utils.text.SimpleDocumentListener;
28
 
29
import java.awt.GridBagConstraints;
30
import java.awt.GridBagLayout;
31
 
32
import javax.swing.JLabel;
33
import javax.swing.JPanel;
34
import javax.swing.JTabbedPane;
35
import javax.swing.JTextField;
36
import javax.swing.SwingConstants;
37
import javax.swing.event.DocumentEvent;
38
import javax.swing.event.DocumentListener;
39
 
40
public class CommercialSQLComponent extends BaseSQLComponent {
41
 
80 ilm 42
    private JTextField textInitiale;
43
    private JTextField textPrenom, textNom;
44
    private ObjectifEditPanel objectifPanel = new ObjectifEditPanel(getSelectedID());
61 ilm 45
 
46
    DocumentListener listener = new SimpleDocumentListener() {
47
 
48
        @Override
49
        public void update(DocumentEvent e) {
50
            updateInititale();
51
        }
52
    };
53
 
54
    public CommercialSQLComponent(SQLElement elt) {
55
        super(elt);
56
    }
57
 
58
    @Override
59
    public void select(SQLRowAccessor r) {
60
        super.select(r);
61
        if (r == null) {
62
            objectifPanel.setIdCommercial(-1);
63
        } else {
64
            objectifPanel.setIdCommercial(r.getID());
65
        }
66
    }
67
 
68
    private void updateInititale() {
69
        String s = "";
70
        if (this.textPrenom.getText().trim().length() > 0) {
71
            s += this.textPrenom.getText().trim().charAt(0);
72
        }
73
        if (this.textNom.getText().trim().length() > 0) {
74
            s += this.textNom.getText().trim().charAt(0);
75
        }
76
        this.textInitiale.setText(s);
77
    }
78
 
79
    private final JTabbedPane pane = new JTabbedPane();
80
 
81
    public void addViews() {
82
        this.setLayout(new GridBagLayout());
83
 
84
        GridBagConstraints c = new DefaultGridBagConstraints();
85
        JPanel panelInfos = new JPanel(new GridBagLayout());
86
        // Titre personnel
87
        final JLabel label = new JLabel(getLabelFor("ID_TITRE_PERSONNEL"));
88
        label.setHorizontalAlignment(SwingConstants.RIGHT);
89
        panelInfos.add(label, c);
90
        ElementComboBox selTitre = new ElementComboBox(false, 6);
91
 
92
        c.gridx++;
93
        c.fill = GridBagConstraints.NONE;
94
        c.gridwidth = GridBagConstraints.REMAINDER;
95
        panelInfos.add(selTitre, c);
96
 
97
        // Nom
98
        c.gridx = 0;
99
        c.gridy++;
100
        c.gridwidth = 1;
101
        c.fill = GridBagConstraints.HORIZONTAL;
102
        final JLabel label2 = new JLabel(getLabelFor("NOM"));
103
        label2.setHorizontalAlignment(SwingConstants.RIGHT);
104
        panelInfos.add(label2, c);
105
        this.textNom = new JTextField(21);
106
        c.gridx++;
107
        c.weightx = 1;
108
        panelInfos.add(this.textNom, c);
109
        this.textNom.getDocument().addDocumentListener(this.listener);
110
 
111
        // Prenom
112
        c.gridx++;
113
        c.weightx = 0;
114
        final JLabel label3 = new JLabel(getLabelFor("PRENOM"));
115
        label3.setHorizontalAlignment(SwingConstants.RIGHT);
116
        panelInfos.add(label3, c);
117
        this.textPrenom = new JTextField(21);
118
        c.gridx++;
119
        c.weightx = 1;
120
        panelInfos.add(this.textPrenom, c);
121
        this.textPrenom.getDocument().addDocumentListener(this.listener);
122
 
123
        // // Initiales
124
        c.gridx = 0;
125
        c.gridy++;
126
        c.weightx = 0;
127
        final JLabel label4 = new JLabel("Initiales");
128
        label4.setHorizontalAlignment(SwingConstants.RIGHT);
129
        panelInfos.add(label4, c);
130
        c.gridx++;
131
        c.weightx = 1;
132
        c.fill = GridBagConstraints.NONE;
133
        this.textInitiale = new JTextField(4);
134
        this.textInitiale.setEditable(false);
135
        panelInfos.add(this.textInitiale, c);
136
        c.fill = GridBagConstraints.HORIZONTAL;
137
 
138
        // Fonction
139
        c.gridx++;
140
        c.weightx = 0;
141
        final JLabel label5 = new JLabel(getLabelFor("FONCTION"));
142
        label5.setHorizontalAlignment(SwingConstants.RIGHT);
143
        panelInfos.add(label5, c);
144
        JTextField textFonction = new JTextField();
145
        c.gridx++;
146
        c.weightx = 1;
147
        panelInfos.add(textFonction, c);
148
 
149
        // Tel Standard
150
        c.gridx = 0;
151
        c.gridy++;
152
        c.weightx = 0;
153
        final JLabel label6 = new JLabel(getLabelFor("TEL_STANDARD"));
154
        label6.setHorizontalAlignment(SwingConstants.RIGHT);
155
        panelInfos.add(label6, c);
156
        c.gridx++;
157
        c.weightx = 1;
158
        JTextField textTel = new JTextField();
159
        panelInfos.add(textTel, c);
160
 
161
        // Tel direct
162
        c.gridx++;
163
        c.weightx = 0;
164
        final JLabel label7 = new JLabel(getLabelFor("TEL_DIRECT"));
165
        label7.setHorizontalAlignment(SwingConstants.RIGHT);
166
        panelInfos.add(label7, c);
167
        JTextField textTelD = new JTextField();
168
        c.gridx++;
169
        c.weightx = 1;
170
        panelInfos.add(textTelD, c);
171
 
172
        // Tel Mobile
173
        c.gridx = 0;
174
        c.gridy++;
175
        c.weightx = 0;
176
        final JLabel label8 = new JLabel(getLabelFor("TEL_MOBILE"));
177
        label8.setHorizontalAlignment(SwingConstants.RIGHT);
178
        panelInfos.add(label8, c);
179
        c.gridx++;
180
        c.weightx = 1;
181
        JTextField textTelM = new JTextField();
182
        panelInfos.add(textTelM, c);
183
 
184
        // Tel Perso
185
        c.gridx++;
186
        c.weightx = 0;
187
        final JLabel label9 = new JLabel(getLabelFor("TEL_PERSONEL"));
188
        label9.setHorizontalAlignment(SwingConstants.RIGHT);
189
        panelInfos.add(label9, c);
190
        JTextField textTelP = new JTextField();
191
        c.gridx++;
192
        c.weightx = 1;
193
        panelInfos.add(textTelP, c);
194
 
195
        // Tel Fax
196
        c.gridx = 0;
197
        c.gridy++;
198
        c.weightx = 0;
199
        final JLabel label10 = new JLabel(getLabelFor("FAX"));
200
        label10.setHorizontalAlignment(SwingConstants.RIGHT);
201
        panelInfos.add(label10, c);
202
        c.gridx++;
203
        c.weightx = 1;
204
        JTextField textFax = new JTextField();
205
        panelInfos.add(textFax, c);
206
 
207
        // Tel Email
208
        c.gridx++;
209
        c.weightx = 0;
210
        final JLabel label11 = new JLabel(getLabelFor("EMAIL"));
211
        label11.setHorizontalAlignment(SwingConstants.RIGHT);
212
        panelInfos.add(label11, c);
213
        JTextField textMail = new JTextField();
214
        c.gridx++;
215
        c.weightx = 1;
216
        panelInfos.add(textMail, c);
217
 
218
        // Modules
219
        c.gridx = 0;
220
        c.gridy++;
221
        c.gridwidth = GridBagConstraints.REMAINDER;
63 ilm 222
        final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
61 ilm 223
        addP.setOpaque(false);
224
        this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
225
        panelInfos.add(addP, c);
226
 
227
        // User
228
 
229
        c.gridx = 0;
230
        c.gridy++;
231
        c.gridwidth = 1;
232
        c.weightx = 0;
233
        final JLabel labelUser = new JLabel(getLabelFor("ID_USER_COMMON"));
234
        labelUser.setHorizontalAlignment(SwingConstants.RIGHT);
235
        panelInfos.add(labelUser, c);
236
        c.gridx++;
237
        c.weightx = 1;
238
 
239
        c.gridwidth = GridBagConstraints.REMAINDER;
240
        ElementComboBox comboUser = new ElementComboBox(true, 25);
241
        panelInfos.add(comboUser, c);
242
 
243
        c.weighty = 1;
244
        c.gridy++;
245
        JPanel panelLayouter = new JPanel();
246
        panelLayouter.setOpaque(false);
247
        panelInfos.add(panelLayouter, c);
248
 
249
        GridBagConstraints cFull = new DefaultGridBagConstraints();
250
        cFull.weightx = 1;
251
        cFull.weighty = 1;
252
        cFull.fill = GridBagConstraints.BOTH;
253
 
254
        if (getMode() == Mode.MODIFICATION) {
255
            pane.add("Informations", panelInfos);
256
 
257
            pane.add("Objectifs", objectifPanel);
258
            panelInfos.setOpaque(false);
259
            this.add(pane, cFull);
260
        } else {
261
            this.add(panelInfos, cFull);
262
        }
263
 
264
        this.addRequiredSQLObject(selTitre, "ID_TITRE_PERSONNEL");
265
        selTitre.setButtonsVisible(false);
266
        this.addRequiredSQLObject(this.textNom, "NOM");
267
        this.addRequiredSQLObject(this.textPrenom, "PRENOM");
268
 
269
        this.addSQLObject(textFonction, "FONCTION");
270
 
271
        this.addSQLObject(comboUser, "ID_USER_COMMON");
272
 
273
        this.addSQLObject(textTel, "TEL_STANDARD");
274
        this.addSQLObject(textTelD, "TEL_DIRECT");
275
 
276
        this.addSQLObject(textTelM, "TEL_MOBILE");
277
        this.addSQLObject(textTelP, "TEL_PERSONEL");
278
 
279
        this.addSQLObject(textFax, "FAX");
280
        this.addSQLObject(textMail, "EMAIL");
281
 
282
        // Locks
283
        DefaultGridBagConstraints.lockMinimumSize(this.textInitiale);
284
        DefaultGridBagConstraints.lockMinimumSize(selTitre);
285
 
286
    }
287
 
288
    public JTabbedPane getModificationTabbedPane() {
289
        return this.pane;
290
    }
291
}