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.payroll.element;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.ui.SQLJavaEditor;
|
|
|
17 |
import org.openconcerto.erp.core.humanresources.payroll.component.FormuleTreeNode;
|
|
|
18 |
import org.openconcerto.erp.core.humanresources.payroll.component.VariableTree;
|
|
|
19 |
import org.openconcerto.sql.element.BaseSQLComponent;
|
|
|
20 |
import org.openconcerto.sql.element.ConfSQLElement;
|
|
|
21 |
import org.openconcerto.sql.element.ElementSQLObject;
|
|
|
22 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
23 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
24 |
import org.openconcerto.sql.model.SQLRowAccessor;
|
|
|
25 |
import org.openconcerto.sql.model.SQLSelect;
|
|
|
26 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
27 |
import org.openconcerto.sql.model.Where;
|
|
|
28 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
29 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
30 |
import org.openconcerto.ui.warning.JLabelWarning;
|
|
|
31 |
|
|
|
32 |
import java.awt.GridBagConstraints;
|
|
|
33 |
import java.awt.GridBagLayout;
|
|
|
34 |
import java.awt.Insets;
|
|
|
35 |
import java.awt.event.MouseAdapter;
|
|
|
36 |
import java.awt.event.MouseEvent;
|
|
|
37 |
import java.beans.PropertyChangeEvent;
|
|
|
38 |
import java.beans.PropertyChangeListener;
|
|
|
39 |
import java.util.ArrayList;
|
|
|
40 |
import java.util.List;
|
|
|
41 |
import java.util.Map;
|
|
|
42 |
|
|
|
43 |
import javax.swing.BorderFactory;
|
|
|
44 |
import javax.swing.ButtonGroup;
|
|
|
45 |
import javax.swing.JCheckBox;
|
|
|
46 |
import javax.swing.JLabel;
|
|
|
47 |
import javax.swing.JPanel;
|
|
|
48 |
import javax.swing.JRadioButton;
|
|
|
49 |
import javax.swing.JScrollPane;
|
|
|
50 |
import javax.swing.JSeparator;
|
|
|
51 |
import javax.swing.JSplitPane;
|
|
|
52 |
import javax.swing.JTabbedPane;
|
|
|
53 |
import javax.swing.JTextField;
|
|
|
54 |
import javax.swing.SwingConstants;
|
|
|
55 |
import javax.swing.event.DocumentEvent;
|
|
|
56 |
import javax.swing.event.DocumentListener;
|
|
|
57 |
import javax.swing.tree.TreePath;
|
|
|
58 |
|
|
|
59 |
import org.apache.commons.dbutils.handlers.ArrayListHandler;
|
|
|
60 |
|
|
|
61 |
public class RubriqueBrutSQLElement extends ConfSQLElement {
|
|
|
62 |
|
|
|
63 |
public RubriqueBrutSQLElement() {
|
|
|
64 |
super("RUBRIQUE_BRUT", "une rubrique de brut", "rubriques de brut");
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
protected List<String> getListFields() {
|
|
|
68 |
final List<String> l = new ArrayList<String>();
|
|
|
69 |
l.add("CODE");
|
|
|
70 |
l.add("NOM");
|
|
|
71 |
|
|
|
72 |
l.add("BASE");
|
|
|
73 |
l.add("TAUX");
|
|
|
74 |
l.add("MONTANT");
|
|
|
75 |
l.add("PART_BRUT");
|
|
|
76 |
l.add("PART_CP");
|
|
|
77 |
l.add("IMPOSABLE");
|
|
|
78 |
|
|
|
79 |
return l;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
protected List<String> getComboFields() {
|
|
|
83 |
final List<String> l = new ArrayList<String>();
|
|
|
84 |
l.add("CODE");
|
|
|
85 |
l.add("NOM");
|
|
|
86 |
return l;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
protected List<String> getPrivateFields() {
|
|
|
90 |
final List<String> l = new ArrayList<String>();
|
|
|
91 |
l.add("ID_PERIODE_VALIDITE");
|
|
|
92 |
return l;
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
/*
|
|
|
96 |
* (non-Javadoc)
|
|
|
97 |
*
|
|
|
98 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
99 |
*/
|
|
|
100 |
public SQLComponent createComponent() {
|
|
|
101 |
return new BaseSQLComponent(this) {
|
|
|
102 |
|
|
|
103 |
private JTextField textCode = new JTextField();
|
|
|
104 |
private JTextField textLibelle = new JTextField();
|
|
|
105 |
private SQLJavaEditor formuleBase, formuleTaux, formuleMontant;
|
|
|
106 |
private JLabel labelWarningBadName, labelBadName;
|
|
|
107 |
private boolean validCode;
|
|
|
108 |
|
|
|
109 |
public void addViews() {
|
|
|
110 |
|
|
|
111 |
this.labelWarningBadName = new JLabelWarning();
|
|
|
112 |
this.labelBadName = new JLabel("Code déjà attribué.");
|
|
|
113 |
this.validCode = true;
|
|
|
114 |
|
|
|
115 |
this.setLayout(new GridBagLayout());
|
|
|
116 |
final GridBagConstraints c = new DefaultGridBagConstraints();
|
|
|
117 |
|
|
|
118 |
// Code
|
|
|
119 |
JLabel labelCode = new JLabel(getLabelFor("CODE"));
|
|
|
120 |
labelCode.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
121 |
this.add(labelCode, c);
|
|
|
122 |
|
|
|
123 |
c.gridx++;
|
|
|
124 |
c.weightx = 1;
|
|
|
125 |
this.add(this.textCode, c);
|
|
|
126 |
c.weightx = 0;
|
|
|
127 |
this.textCode.getDocument().addDocumentListener(new DocumentListener() {
|
|
|
128 |
|
|
|
129 |
public void insertUpdate(DocumentEvent e) {
|
|
|
130 |
|
|
|
131 |
isValidCodeName();
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
public void removeUpdate(DocumentEvent e) {
|
|
|
135 |
|
|
|
136 |
isValidCodeName();
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public void changedUpdate(DocumentEvent e) {
|
|
|
140 |
|
|
|
141 |
isValidCodeName();
|
|
|
142 |
}
|
|
|
143 |
});
|
|
|
144 |
|
|
|
145 |
c.gridx++;
|
|
|
146 |
|
|
|
147 |
this.add(this.labelWarningBadName);
|
|
|
148 |
this.labelWarningBadName.setVisible(false);
|
|
|
149 |
c.gridx++;
|
|
|
150 |
this.add(this.labelBadName);
|
|
|
151 |
this.labelBadName.setVisible(false);
|
|
|
152 |
|
|
|
153 |
// Libelle
|
|
|
154 |
c.gridy++;
|
|
|
155 |
c.gridx = 0;
|
|
|
156 |
JLabel labelNom = new JLabel(getLabelFor("NOM"));
|
|
|
157 |
labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
158 |
this.add(labelNom, c);
|
|
|
159 |
|
|
|
160 |
c.gridx++;
|
|
|
161 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
162 |
c.weightx = 1;
|
|
|
163 |
this.add(this.textLibelle, c);
|
|
|
164 |
c.weightx = 0;
|
|
|
165 |
c.gridwidth = 1;
|
|
|
166 |
|
|
|
167 |
/***********************************************************************************
|
|
|
168 |
* PANEL CALCUL
|
|
|
169 |
**********************************************************************************/
|
|
|
170 |
JPanel panelCalcul = new JPanel();
|
|
|
171 |
panelCalcul.setLayout(new GridBagLayout());
|
|
|
172 |
final GridBagConstraints cPanel = new DefaultGridBagConstraints();
|
|
|
173 |
|
|
|
174 |
final VariableTree tree = new VariableTree();
|
|
|
175 |
JScrollPane paneTree = new JScrollPane(tree);
|
|
|
176 |
|
|
|
177 |
cPanel.gridheight = GridBagConstraints.REMAINDER;
|
|
|
178 |
cPanel.weighty = 1;
|
|
|
179 |
cPanel.weightx = 1;
|
|
|
180 |
cPanel.fill = GridBagConstraints.BOTH;
|
|
|
181 |
// panelCalcul.add(paneTree, cPanel);
|
|
|
182 |
|
|
|
183 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
184 |
cPanel.weighty = 0;
|
|
|
185 |
cPanel.weightx = 0;
|
|
|
186 |
cPanel.gridheight = 1;
|
|
|
187 |
|
|
|
188 |
// Formule base
|
|
|
189 |
cPanel.gridx++;
|
|
|
190 |
final Map<String, List<?>> mapTree = VariablePayeSQLElement.getMapTree();
|
|
|
191 |
this.formuleBase = new SQLJavaEditor(mapTree);
|
|
|
192 |
this.formuleBase.setVarAssign("BASE");
|
|
|
193 |
|
|
|
194 |
final JRadioButton radioBase = new JRadioButton(getLabelFor("BASE"));
|
|
|
195 |
panelCalcul.add(radioBase, cPanel);
|
|
|
196 |
cPanel.gridx++;
|
|
|
197 |
panelCalcul.add(this.formuleBase, cPanel);
|
|
|
198 |
|
|
|
199 |
JSeparator sep1 = new JSeparator();
|
|
|
200 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
201 |
cPanel.gridy++;
|
|
|
202 |
cPanel.gridx = 1;
|
|
|
203 |
cPanel.weightx = 1;
|
|
|
204 |
panelCalcul.add(sep1, cPanel);
|
|
|
205 |
cPanel.gridwidth = 1;
|
|
|
206 |
cPanel.weightx = 0;
|
|
|
207 |
|
|
|
208 |
// Formule Taux
|
|
|
209 |
cPanel.gridy++;
|
|
|
210 |
cPanel.gridx = 1;
|
|
|
211 |
|
|
|
212 |
this.formuleTaux = new SQLJavaEditor(mapTree);
|
|
|
213 |
this.formuleTaux.setVarAssign("TAUX");
|
|
|
214 |
final JRadioButton radioTaux = new JRadioButton(getLabelFor("TAUX"));
|
|
|
215 |
panelCalcul.add(radioTaux, cPanel);
|
|
|
216 |
cPanel.gridx++;
|
|
|
217 |
panelCalcul.add(this.formuleTaux, cPanel);
|
|
|
218 |
|
|
|
219 |
JSeparator sep2 = new JSeparator();
|
|
|
220 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
221 |
cPanel.gridy++;
|
|
|
222 |
cPanel.gridx = 1;
|
|
|
223 |
cPanel.weightx = 1;
|
|
|
224 |
panelCalcul.add(sep2, cPanel);
|
|
|
225 |
cPanel.gridwidth = 1;
|
|
|
226 |
cPanel.weightx = 0;
|
|
|
227 |
|
|
|
228 |
// Formule Montant
|
|
|
229 |
cPanel.gridy++;
|
|
|
230 |
cPanel.gridx = 1;
|
|
|
231 |
this.formuleMontant = new SQLJavaEditor(mapTree);
|
|
|
232 |
this.formuleMontant.setVarAssign("MONTANT");
|
|
|
233 |
final JRadioButton radioMontant = new JRadioButton(getLabelFor("MONTANT"));
|
|
|
234 |
panelCalcul.add(radioMontant, cPanel);
|
|
|
235 |
cPanel.gridx++;
|
|
|
236 |
panelCalcul.add(this.formuleMontant, cPanel);
|
|
|
237 |
|
|
|
238 |
JSeparator sep3 = new JSeparator();
|
|
|
239 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
240 |
cPanel.gridy++;
|
|
|
241 |
cPanel.gridx = 1;
|
|
|
242 |
cPanel.weightx = 1;
|
|
|
243 |
panelCalcul.add(sep3, cPanel);
|
|
|
244 |
cPanel.gridwidth = 1;
|
|
|
245 |
cPanel.weightx = 0;
|
|
|
246 |
|
|
|
247 |
// Salarie
|
|
|
248 |
cPanel.gridy++;
|
|
|
249 |
cPanel.gridx = 1;
|
|
|
250 |
JLabel labelSelSal = new JLabel("Salarié");
|
|
|
251 |
labelSelSal.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
252 |
panelCalcul.add(labelSelSal, cPanel);
|
|
|
253 |
|
|
|
254 |
SQLElement eltSal = new SalarieSQLElement();
|
|
|
255 |
final ElementComboBox selSalarie = new ElementComboBox(false);
|
|
|
256 |
|
|
|
257 |
cPanel.gridx++;
|
|
|
258 |
selSalarie.init(eltSal);
|
|
|
259 |
panelCalcul.add(selSalarie, cPanel);
|
|
|
260 |
|
|
|
261 |
ButtonGroup groupRadio = new ButtonGroup();
|
|
|
262 |
groupRadio.add(radioBase);
|
|
|
263 |
groupRadio.add(radioMontant);
|
|
|
264 |
groupRadio.add(radioTaux);
|
|
|
265 |
radioBase.setSelected(true);
|
|
|
266 |
|
|
|
267 |
tree.addMouseListener(new MouseAdapter() {
|
|
|
268 |
|
|
|
269 |
public void mousePressed(MouseEvent e) {
|
|
|
270 |
|
|
|
271 |
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
|
|
272 |
TreePath path = tree.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
|
|
|
273 |
|
|
|
274 |
final Object obj = path.getLastPathComponent();
|
|
|
275 |
|
|
|
276 |
if (obj == null) {
|
|
|
277 |
return;
|
|
|
278 |
} else {
|
|
|
279 |
if (obj instanceof FormuleTreeNode) {
|
|
|
280 |
FormuleTreeNode n = (FormuleTreeNode) obj;
|
|
|
281 |
|
|
|
282 |
if (radioBase.isSelected()) {
|
|
|
283 |
int start = formuleBase.getSelectionStart();
|
|
|
284 |
String tmp = formuleBase.getText();
|
|
|
285 |
|
|
|
286 |
formuleBase.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
287 |
} else {
|
|
|
288 |
|
|
|
289 |
if (radioMontant.isSelected()) {
|
|
|
290 |
int start = formuleMontant.getSelectionStart();
|
|
|
291 |
String tmp = formuleMontant.getText();
|
|
|
292 |
|
|
|
293 |
formuleMontant.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
294 |
} else {
|
|
|
295 |
int start = formuleTaux.getSelectionStart();
|
|
|
296 |
String tmp = formuleTaux.getText();
|
|
|
297 |
|
|
|
298 |
formuleTaux.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
299 |
}
|
|
|
300 |
}
|
|
|
301 |
}
|
|
|
302 |
|
|
|
303 |
}
|
|
|
304 |
}
|
|
|
305 |
}
|
|
|
306 |
});
|
|
|
307 |
|
|
|
308 |
/***********************************************************************************
|
|
|
309 |
* PANEL PROPRIETE
|
|
|
310 |
**********************************************************************************/
|
|
|
311 |
JPanel panelProp = new JPanel();
|
|
|
312 |
panelProp.setLayout(new GridBagLayout());
|
|
|
313 |
cPanel.gridx = 0;
|
|
|
314 |
cPanel.gridy = 0;
|
|
|
315 |
cPanel.weightx = 0;
|
|
|
316 |
cPanel.weighty = 0;
|
|
|
317 |
cPanel.gridwidth = 1;
|
|
|
318 |
cPanel.gridheight = 1;
|
|
|
319 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
320 |
cPanel.anchor = GridBagConstraints.NORTHWEST;
|
|
|
321 |
cPanel.insets = new Insets(2, 2, 1, 2);
|
|
|
322 |
|
|
|
323 |
// Periode d'application
|
|
|
324 |
this.addView("ID_PERIODE_VALIDITE", REQ + ";" + DEC + ";" + SEP);
|
|
|
325 |
ElementSQLObject eltInfosPaye = (ElementSQLObject) this.getView("ID_PERIODE_VALIDITE");
|
|
|
326 |
cPanel.gridy = 0;
|
|
|
327 |
cPanel.gridx = 0;
|
|
|
328 |
cPanel.gridheight = GridBagConstraints.REMAINDER;
|
|
|
329 |
cPanel.weighty = 1;
|
|
|
330 |
cPanel.fill = GridBagConstraints.NONE;
|
|
|
331 |
JPanel panelPeriodeVal = new JPanel();
|
|
|
332 |
panelPeriodeVal.setBorder(BorderFactory.createTitledBorder("Période de validité"));
|
|
|
333 |
panelPeriodeVal.add(eltInfosPaye);
|
|
|
334 |
panelProp.add(panelPeriodeVal, cPanel);
|
|
|
335 |
|
|
|
336 |
cPanel.weightx = 0;
|
|
|
337 |
cPanel.weighty = 0;
|
|
|
338 |
cPanel.gridheight = 1;
|
|
|
339 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
340 |
|
|
|
341 |
// Type
|
|
|
342 |
JLabel labelSelTypeRubrique = new JLabel("Type");
|
|
|
343 |
labelSelTypeRubrique.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
344 |
cPanel.gridx++;
|
|
|
345 |
cPanel.gridheight = 1;
|
|
|
346 |
|
|
|
347 |
cPanel.weightx = 0;
|
|
|
348 |
cPanel.anchor = GridBagConstraints.WEST;
|
|
|
349 |
panelProp.add(labelSelTypeRubrique, cPanel);
|
|
|
350 |
|
|
|
351 |
// SQLElement eltType =
|
|
|
352 |
// Configuration.getInstance().getDirectory().getElement("TYPE_RUBRIQUE_BRUT");
|
|
|
353 |
ElementComboBox comboSelTypeRubrique = new ElementComboBox(false);
|
|
|
354 |
cPanel.gridx++;
|
|
|
355 |
cPanel.weightx = 1;
|
|
|
356 |
panelProp.add(comboSelTypeRubrique, cPanel);
|
|
|
357 |
|
|
|
358 |
// Impression
|
|
|
359 |
JLabel labelSelTypeRubriqueImpression = new JLabel("Impression");
|
|
|
360 |
cPanel.gridy++;
|
|
|
361 |
cPanel.gridx = 1;
|
|
|
362 |
cPanel.weightx = 0;
|
|
|
363 |
panelProp.add(labelSelTypeRubriqueImpression, cPanel);
|
|
|
364 |
|
|
|
365 |
ElementComboBox comboSelTypeImpression = new ElementComboBox(false);
|
|
|
366 |
cPanel.gridx++;
|
|
|
367 |
cPanel.weightx = 1;
|
|
|
368 |
panelProp.add(comboSelTypeImpression, cPanel);
|
|
|
369 |
|
|
|
370 |
// Imposable
|
|
|
371 |
cPanel.gridx = 1;
|
|
|
372 |
cPanel.weightx = 1;
|
|
|
373 |
cPanel.gridy++;
|
|
|
374 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
375 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
376 |
JCheckBox checkImpo = new JCheckBox(getLabelFor("IMPOSABLE"));
|
|
|
377 |
panelProp.add(checkImpo, cPanel);
|
|
|
378 |
|
|
|
379 |
// Participation à la base brute
|
|
|
380 |
cPanel.gridx = 1;
|
|
|
381 |
cPanel.weightx = 1;
|
|
|
382 |
cPanel.gridy++;
|
|
|
383 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
384 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
385 |
JCheckBox checkBrut = new JCheckBox(getLabelFor("PART_BRUT"));
|
|
|
386 |
panelProp.add(checkBrut, cPanel);
|
|
|
387 |
|
|
|
388 |
// Participation aux congés payés
|
|
|
389 |
cPanel.gridx = 1;
|
|
|
390 |
cPanel.weightx = 1;
|
|
|
391 |
cPanel.gridy++;
|
|
|
392 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
393 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
394 |
JCheckBox checkCP = new JCheckBox(getLabelFor("PART_CP"));
|
|
|
395 |
panelProp.add(checkCP, cPanel);
|
|
|
396 |
|
|
|
397 |
// Tabbed Pane
|
|
|
398 |
JTabbedPane tab = new JTabbedPane();
|
|
|
399 |
tab.add("Calcul", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, paneTree, panelCalcul));
|
|
|
400 |
tab.add("Propriétés", panelProp);
|
|
|
401 |
|
|
|
402 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
403 |
c.gridy++;
|
|
|
404 |
c.gridx = 0;
|
|
|
405 |
c.fill = GridBagConstraints.BOTH;
|
|
|
406 |
c.weightx = 1;
|
|
|
407 |
c.weighty = 1;
|
|
|
408 |
this.add(tab, c);
|
|
|
409 |
|
|
|
410 |
this.addRequiredSQLObject(this.textCode, "CODE");
|
|
|
411 |
this.addSQLObject(this.textLibelle, "NOM");
|
|
|
412 |
this.addSQLObject(this.formuleBase, "BASE");
|
|
|
413 |
this.addSQLObject(this.formuleTaux, "TAUX");
|
|
|
414 |
this.addSQLObject(this.formuleMontant, "MONTANT");
|
|
|
415 |
this.addRequiredSQLObject(comboSelTypeRubrique, "ID_TYPE_RUBRIQUE_BRUT");
|
|
|
416 |
this.addRequiredSQLObject(comboSelTypeImpression, "ID_IMPRESSION_RUBRIQUE");
|
|
|
417 |
this.addSQLObject(checkBrut, "PART_BRUT");
|
|
|
418 |
this.addSQLObject(checkCP, "PART_CP");
|
|
|
419 |
this.addSQLObject(checkImpo, "IMPOSABLE");
|
|
|
420 |
|
|
|
421 |
selSalarie.addValueListener(new PropertyChangeListener() {
|
|
|
422 |
|
|
|
423 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
424 |
formuleBase.setSalarieID(selSalarie.getSelectedId());
|
|
|
425 |
formuleTaux.setSalarieID(selSalarie.getSelectedId());
|
|
|
426 |
formuleMontant.setSalarieID(selSalarie.getSelectedId());
|
|
|
427 |
}
|
|
|
428 |
});
|
|
|
429 |
}
|
|
|
430 |
|
|
|
431 |
private void isValidCodeName() {
|
|
|
432 |
System.err.println("Changed valid");
|
|
|
433 |
|
|
|
434 |
// on vérifie que la variable n'existe pas déja
|
|
|
435 |
SQLSelect selAllCodeName = new SQLSelect(getTable().getBase());
|
|
|
436 |
|
|
|
437 |
selAllCodeName.addSelect(getTable().getField("ID"));
|
|
|
438 |
selAllCodeName.setWhere("RUBRIQUE_BRUT.CODE", "=", this.textCode.getText().trim());
|
|
|
439 |
|
|
|
440 |
int idSelected = this.getSelectedID();
|
|
|
441 |
if (idSelected > 1) {
|
|
|
442 |
selAllCodeName.andWhere(new Where(getTable().getField("ID"), "!=", idSelected));
|
|
|
443 |
}
|
|
|
444 |
|
|
|
445 |
String reqAllCodeName = selAllCodeName.asString();
|
|
|
446 |
|
|
|
447 |
Object[] objCodeID = ((List) getTable().getBase().getDataSource().execute(reqAllCodeName, new ArrayListHandler())).toArray();
|
|
|
448 |
|
|
|
449 |
SQLSelect selAllVarName = new SQLSelect(getTable().getBase());
|
|
|
450 |
|
|
|
451 |
SQLTable tableVar = getTable().getBase().getTable("VARIABLE_PAYE");
|
|
|
452 |
selAllVarName.addSelect(tableVar.getField("ID"));
|
|
|
453 |
selAllVarName.setWhere("VARIABLE_PAYE.NOM", "=", this.textCode.getText().trim());
|
|
|
454 |
String reqAllVarName = selAllVarName.asString();
|
|
|
455 |
Object[] objVarID = ((List) getTable().getBase().getDataSource().execute(reqAllVarName, new ArrayListHandler())).toArray();
|
|
|
456 |
|
|
|
457 |
// System.err.println("nb var same " + objVarID.length + " --- nb code same " +
|
|
|
458 |
// objCodeID.length);
|
|
|
459 |
if ((objCodeID.length > 0) || (objVarID.length > 0)) {
|
|
|
460 |
this.labelWarningBadName.setVisible(true);
|
|
|
461 |
this.labelBadName.setVisible(true);
|
|
|
462 |
this.validCode = false;
|
|
|
463 |
} else {
|
|
|
464 |
|
|
|
465 |
List l = VariablePayeSQLElement.getForbiddenVarName();
|
|
|
466 |
for (int i = 0; i < l.size(); i++) {
|
|
|
467 |
if (l.get(i).toString().trim().equals(this.textCode.getText().trim())) {
|
|
|
468 |
this.labelWarningBadName.setVisible(true);
|
|
|
469 |
this.labelBadName.setVisible(true);
|
|
|
470 |
this.validCode = false;
|
|
|
471 |
return;
|
|
|
472 |
}
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
this.labelWarningBadName.setVisible(false);
|
|
|
476 |
this.labelBadName.setVisible(false);
|
|
|
477 |
this.validCode = true;
|
|
|
478 |
}
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
public synchronized boolean isValidated() {
|
|
|
482 |
return super.isValidated() && this.validCode;
|
|
|
483 |
}
|
|
|
484 |
|
|
|
485 |
@Override
|
|
|
486 |
public void select(SQLRowAccessor r) {
|
|
|
487 |
super.select(r);
|
|
|
488 |
isValidCodeName();
|
|
|
489 |
}
|
|
|
490 |
};
|
|
|
491 |
}
|
|
|
492 |
}
|