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