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.ConfSQLElement;
|
|
|
20 |
import org.openconcerto.sql.element.ElementSQLObject;
|
|
|
21 |
import org.openconcerto.sql.element.SQLComponent;
|
|
|
22 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
23 |
import org.openconcerto.sql.sqlobject.ElementComboBox;
|
|
|
24 |
import org.openconcerto.ui.DefaultGridBagConstraints;
|
|
|
25 |
|
|
|
26 |
import java.awt.GridBagConstraints;
|
|
|
27 |
import java.awt.GridBagLayout;
|
|
|
28 |
import java.awt.Insets;
|
|
|
29 |
import java.awt.event.MouseAdapter;
|
|
|
30 |
import java.awt.event.MouseEvent;
|
|
|
31 |
import java.beans.PropertyChangeEvent;
|
|
|
32 |
import java.beans.PropertyChangeListener;
|
|
|
33 |
import java.util.ArrayList;
|
|
|
34 |
import java.util.List;
|
|
|
35 |
import java.util.Map;
|
|
|
36 |
|
|
|
37 |
import javax.swing.BorderFactory;
|
|
|
38 |
import javax.swing.ButtonGroup;
|
|
|
39 |
import javax.swing.JCheckBox;
|
|
|
40 |
import javax.swing.JLabel;
|
|
|
41 |
import javax.swing.JPanel;
|
|
|
42 |
import javax.swing.JRadioButton;
|
|
|
43 |
import javax.swing.JScrollPane;
|
|
|
44 |
import javax.swing.JSeparator;
|
|
|
45 |
import javax.swing.JSplitPane;
|
|
|
46 |
import javax.swing.JTabbedPane;
|
|
|
47 |
import javax.swing.SwingConstants;
|
|
|
48 |
import javax.swing.tree.TreePath;
|
|
|
49 |
|
|
|
50 |
public class RubriqueBrutSQLElement extends ConfSQLElement {
|
|
|
51 |
|
|
|
52 |
public RubriqueBrutSQLElement() {
|
|
|
53 |
super("RUBRIQUE_BRUT", "une rubrique de brut", "rubriques de brut");
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
protected List<String> getListFields() {
|
|
|
57 |
final List<String> l = new ArrayList<String>();
|
|
|
58 |
l.add("CODE");
|
|
|
59 |
l.add("NOM");
|
|
|
60 |
|
|
|
61 |
l.add("BASE");
|
|
|
62 |
l.add("TAUX");
|
|
|
63 |
l.add("MONTANT");
|
|
|
64 |
l.add("PART_BRUT");
|
|
|
65 |
l.add("PART_CP");
|
|
|
66 |
l.add("IMPOSABLE");
|
|
|
67 |
|
|
|
68 |
return l;
|
|
|
69 |
}
|
|
|
70 |
|
|
|
71 |
protected List<String> getComboFields() {
|
|
|
72 |
final List<String> l = new ArrayList<String>();
|
|
|
73 |
l.add("CODE");
|
|
|
74 |
l.add("NOM");
|
|
|
75 |
return l;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
protected List<String> getPrivateFields() {
|
|
|
79 |
final List<String> l = new ArrayList<String>();
|
|
|
80 |
l.add("ID_PERIODE_VALIDITE");
|
|
|
81 |
return l;
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
/*
|
|
|
85 |
* (non-Javadoc)
|
|
|
86 |
*
|
|
|
87 |
* @see org.openconcerto.devis.SQLElement#getComponent()
|
|
|
88 |
*/
|
|
|
89 |
public SQLComponent createComponent() {
|
21 |
ilm |
90 |
return new RubriqueSQLComponent(this) {
|
18 |
ilm |
91 |
|
|
|
92 |
private SQLJavaEditor formuleBase, formuleTaux, formuleMontant;
|
|
|
93 |
|
21 |
ilm |
94 |
@Override
|
|
|
95 |
protected void addViews(GridBagConstraints c) {
|
18 |
ilm |
96 |
c.weightx = 0;
|
|
|
97 |
c.gridwidth = 1;
|
|
|
98 |
|
|
|
99 |
/***********************************************************************************
|
|
|
100 |
* PANEL CALCUL
|
|
|
101 |
**********************************************************************************/
|
|
|
102 |
JPanel panelCalcul = new JPanel();
|
|
|
103 |
panelCalcul.setLayout(new GridBagLayout());
|
|
|
104 |
final GridBagConstraints cPanel = new DefaultGridBagConstraints();
|
|
|
105 |
|
|
|
106 |
final VariableTree tree = new VariableTree();
|
|
|
107 |
JScrollPane paneTree = new JScrollPane(tree);
|
|
|
108 |
|
|
|
109 |
cPanel.gridheight = GridBagConstraints.REMAINDER;
|
|
|
110 |
cPanel.weighty = 1;
|
|
|
111 |
cPanel.weightx = 1;
|
|
|
112 |
cPanel.fill = GridBagConstraints.BOTH;
|
|
|
113 |
// panelCalcul.add(paneTree, cPanel);
|
|
|
114 |
|
|
|
115 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
116 |
cPanel.weighty = 0;
|
|
|
117 |
cPanel.weightx = 0;
|
|
|
118 |
cPanel.gridheight = 1;
|
|
|
119 |
|
|
|
120 |
// Formule base
|
|
|
121 |
cPanel.gridx++;
|
|
|
122 |
final Map<String, List<?>> mapTree = VariablePayeSQLElement.getMapTree();
|
|
|
123 |
this.formuleBase = new SQLJavaEditor(mapTree);
|
|
|
124 |
this.formuleBase.setVarAssign("BASE");
|
|
|
125 |
|
|
|
126 |
final JRadioButton radioBase = new JRadioButton(getLabelFor("BASE"));
|
|
|
127 |
panelCalcul.add(radioBase, cPanel);
|
|
|
128 |
cPanel.gridx++;
|
|
|
129 |
panelCalcul.add(this.formuleBase, cPanel);
|
|
|
130 |
|
|
|
131 |
JSeparator sep1 = new JSeparator();
|
|
|
132 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
133 |
cPanel.gridy++;
|
|
|
134 |
cPanel.gridx = 1;
|
|
|
135 |
cPanel.weightx = 1;
|
|
|
136 |
panelCalcul.add(sep1, cPanel);
|
|
|
137 |
cPanel.gridwidth = 1;
|
|
|
138 |
cPanel.weightx = 0;
|
|
|
139 |
|
|
|
140 |
// Formule Taux
|
|
|
141 |
cPanel.gridy++;
|
|
|
142 |
cPanel.gridx = 1;
|
|
|
143 |
|
|
|
144 |
this.formuleTaux = new SQLJavaEditor(mapTree);
|
|
|
145 |
this.formuleTaux.setVarAssign("TAUX");
|
|
|
146 |
final JRadioButton radioTaux = new JRadioButton(getLabelFor("TAUX"));
|
|
|
147 |
panelCalcul.add(radioTaux, cPanel);
|
|
|
148 |
cPanel.gridx++;
|
|
|
149 |
panelCalcul.add(this.formuleTaux, cPanel);
|
|
|
150 |
|
|
|
151 |
JSeparator sep2 = new JSeparator();
|
|
|
152 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
153 |
cPanel.gridy++;
|
|
|
154 |
cPanel.gridx = 1;
|
|
|
155 |
cPanel.weightx = 1;
|
|
|
156 |
panelCalcul.add(sep2, cPanel);
|
|
|
157 |
cPanel.gridwidth = 1;
|
|
|
158 |
cPanel.weightx = 0;
|
|
|
159 |
|
|
|
160 |
// Formule Montant
|
|
|
161 |
cPanel.gridy++;
|
|
|
162 |
cPanel.gridx = 1;
|
|
|
163 |
this.formuleMontant = new SQLJavaEditor(mapTree);
|
|
|
164 |
this.formuleMontant.setVarAssign("MONTANT");
|
|
|
165 |
final JRadioButton radioMontant = new JRadioButton(getLabelFor("MONTANT"));
|
|
|
166 |
panelCalcul.add(radioMontant, cPanel);
|
|
|
167 |
cPanel.gridx++;
|
|
|
168 |
panelCalcul.add(this.formuleMontant, cPanel);
|
|
|
169 |
|
|
|
170 |
JSeparator sep3 = new JSeparator();
|
|
|
171 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
172 |
cPanel.gridy++;
|
|
|
173 |
cPanel.gridx = 1;
|
|
|
174 |
cPanel.weightx = 1;
|
|
|
175 |
panelCalcul.add(sep3, cPanel);
|
|
|
176 |
cPanel.gridwidth = 1;
|
|
|
177 |
cPanel.weightx = 0;
|
|
|
178 |
|
|
|
179 |
// Salarie
|
|
|
180 |
cPanel.gridy++;
|
|
|
181 |
cPanel.gridx = 1;
|
|
|
182 |
JLabel labelSelSal = new JLabel("Salarié");
|
|
|
183 |
labelSelSal.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
184 |
panelCalcul.add(labelSelSal, cPanel);
|
|
|
185 |
|
|
|
186 |
SQLElement eltSal = new SalarieSQLElement();
|
|
|
187 |
final ElementComboBox selSalarie = new ElementComboBox(false);
|
|
|
188 |
|
|
|
189 |
cPanel.gridx++;
|
|
|
190 |
selSalarie.init(eltSal);
|
|
|
191 |
panelCalcul.add(selSalarie, cPanel);
|
|
|
192 |
|
|
|
193 |
ButtonGroup groupRadio = new ButtonGroup();
|
|
|
194 |
groupRadio.add(radioBase);
|
|
|
195 |
groupRadio.add(radioMontant);
|
|
|
196 |
groupRadio.add(radioTaux);
|
|
|
197 |
radioBase.setSelected(true);
|
|
|
198 |
|
|
|
199 |
tree.addMouseListener(new MouseAdapter() {
|
|
|
200 |
|
|
|
201 |
public void mousePressed(MouseEvent e) {
|
|
|
202 |
|
|
|
203 |
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
|
|
204 |
TreePath path = tree.getClosestPathForLocation(e.getPoint().x, e.getPoint().y);
|
|
|
205 |
|
|
|
206 |
final Object obj = path.getLastPathComponent();
|
|
|
207 |
|
|
|
208 |
if (obj == null) {
|
|
|
209 |
return;
|
|
|
210 |
} else {
|
|
|
211 |
if (obj instanceof FormuleTreeNode) {
|
|
|
212 |
FormuleTreeNode n = (FormuleTreeNode) obj;
|
|
|
213 |
|
|
|
214 |
if (radioBase.isSelected()) {
|
|
|
215 |
int start = formuleBase.getSelectionStart();
|
|
|
216 |
String tmp = formuleBase.getText();
|
|
|
217 |
|
|
|
218 |
formuleBase.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
219 |
} else {
|
|
|
220 |
|
|
|
221 |
if (radioMontant.isSelected()) {
|
|
|
222 |
int start = formuleMontant.getSelectionStart();
|
|
|
223 |
String tmp = formuleMontant.getText();
|
|
|
224 |
|
|
|
225 |
formuleMontant.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
226 |
} else {
|
|
|
227 |
int start = formuleTaux.getSelectionStart();
|
|
|
228 |
String tmp = formuleTaux.getText();
|
|
|
229 |
|
|
|
230 |
formuleTaux.setText(tmp.substring(0, start) + n.getTextValue() + tmp.substring(start, tmp.length()));
|
|
|
231 |
}
|
|
|
232 |
}
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
}
|
|
|
236 |
}
|
|
|
237 |
}
|
|
|
238 |
});
|
|
|
239 |
|
|
|
240 |
/***********************************************************************************
|
|
|
241 |
* PANEL PROPRIETE
|
|
|
242 |
**********************************************************************************/
|
|
|
243 |
JPanel panelProp = new JPanel();
|
|
|
244 |
panelProp.setLayout(new GridBagLayout());
|
|
|
245 |
cPanel.gridx = 0;
|
|
|
246 |
cPanel.gridy = 0;
|
|
|
247 |
cPanel.weightx = 0;
|
|
|
248 |
cPanel.weighty = 0;
|
|
|
249 |
cPanel.gridwidth = 1;
|
|
|
250 |
cPanel.gridheight = 1;
|
|
|
251 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
252 |
cPanel.anchor = GridBagConstraints.NORTHWEST;
|
|
|
253 |
cPanel.insets = new Insets(2, 2, 1, 2);
|
|
|
254 |
|
|
|
255 |
// Periode d'application
|
|
|
256 |
this.addView("ID_PERIODE_VALIDITE", REQ + ";" + DEC + ";" + SEP);
|
|
|
257 |
ElementSQLObject eltInfosPaye = (ElementSQLObject) this.getView("ID_PERIODE_VALIDITE");
|
|
|
258 |
cPanel.gridy = 0;
|
|
|
259 |
cPanel.gridx = 0;
|
|
|
260 |
cPanel.gridheight = GridBagConstraints.REMAINDER;
|
|
|
261 |
cPanel.weighty = 1;
|
|
|
262 |
cPanel.fill = GridBagConstraints.NONE;
|
|
|
263 |
JPanel panelPeriodeVal = new JPanel();
|
|
|
264 |
panelPeriodeVal.setBorder(BorderFactory.createTitledBorder("Période de validité"));
|
|
|
265 |
panelPeriodeVal.add(eltInfosPaye);
|
|
|
266 |
panelProp.add(panelPeriodeVal, cPanel);
|
|
|
267 |
|
|
|
268 |
cPanel.weightx = 0;
|
|
|
269 |
cPanel.weighty = 0;
|
|
|
270 |
cPanel.gridheight = 1;
|
|
|
271 |
cPanel.fill = GridBagConstraints.HORIZONTAL;
|
|
|
272 |
|
|
|
273 |
// Type
|
|
|
274 |
JLabel labelSelTypeRubrique = new JLabel("Type");
|
|
|
275 |
labelSelTypeRubrique.setHorizontalAlignment(SwingConstants.RIGHT);
|
|
|
276 |
cPanel.gridx++;
|
|
|
277 |
cPanel.gridheight = 1;
|
|
|
278 |
|
|
|
279 |
cPanel.weightx = 0;
|
|
|
280 |
cPanel.anchor = GridBagConstraints.WEST;
|
|
|
281 |
panelProp.add(labelSelTypeRubrique, cPanel);
|
|
|
282 |
|
|
|
283 |
// SQLElement eltType =
|
|
|
284 |
// Configuration.getInstance().getDirectory().getElement("TYPE_RUBRIQUE_BRUT");
|
|
|
285 |
ElementComboBox comboSelTypeRubrique = new ElementComboBox(false);
|
|
|
286 |
cPanel.gridx++;
|
|
|
287 |
cPanel.weightx = 1;
|
|
|
288 |
panelProp.add(comboSelTypeRubrique, cPanel);
|
|
|
289 |
|
|
|
290 |
// Impression
|
|
|
291 |
JLabel labelSelTypeRubriqueImpression = new JLabel("Impression");
|
|
|
292 |
cPanel.gridy++;
|
|
|
293 |
cPanel.gridx = 1;
|
|
|
294 |
cPanel.weightx = 0;
|
|
|
295 |
panelProp.add(labelSelTypeRubriqueImpression, cPanel);
|
|
|
296 |
|
|
|
297 |
ElementComboBox comboSelTypeImpression = new ElementComboBox(false);
|
|
|
298 |
cPanel.gridx++;
|
|
|
299 |
cPanel.weightx = 1;
|
|
|
300 |
panelProp.add(comboSelTypeImpression, cPanel);
|
|
|
301 |
|
|
|
302 |
// Imposable
|
|
|
303 |
cPanel.gridx = 1;
|
|
|
304 |
cPanel.weightx = 1;
|
|
|
305 |
cPanel.gridy++;
|
|
|
306 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
307 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
308 |
JCheckBox checkImpo = new JCheckBox(getLabelFor("IMPOSABLE"));
|
|
|
309 |
panelProp.add(checkImpo, cPanel);
|
|
|
310 |
|
|
|
311 |
// Participation à la base brute
|
|
|
312 |
cPanel.gridx = 1;
|
|
|
313 |
cPanel.weightx = 1;
|
|
|
314 |
cPanel.gridy++;
|
|
|
315 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
316 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
317 |
JCheckBox checkBrut = new JCheckBox(getLabelFor("PART_BRUT"));
|
|
|
318 |
panelProp.add(checkBrut, cPanel);
|
|
|
319 |
|
|
|
320 |
// Participation aux congés payés
|
|
|
321 |
cPanel.gridx = 1;
|
|
|
322 |
cPanel.weightx = 1;
|
|
|
323 |
cPanel.gridy++;
|
|
|
324 |
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
325 |
cPanel.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
326 |
JCheckBox checkCP = new JCheckBox(getLabelFor("PART_CP"));
|
|
|
327 |
panelProp.add(checkCP, cPanel);
|
|
|
328 |
|
|
|
329 |
// Tabbed Pane
|
|
|
330 |
JTabbedPane tab = new JTabbedPane();
|
|
|
331 |
tab.add("Calcul", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, paneTree, panelCalcul));
|
|
|
332 |
tab.add("Propriétés", panelProp);
|
|
|
333 |
|
|
|
334 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
|
|
335 |
c.gridx = 0;
|
|
|
336 |
c.fill = GridBagConstraints.BOTH;
|
|
|
337 |
c.weightx = 1;
|
|
|
338 |
c.weighty = 1;
|
|
|
339 |
this.add(tab, c);
|
|
|
340 |
|
|
|
341 |
this.addSQLObject(this.formuleBase, "BASE");
|
|
|
342 |
this.addSQLObject(this.formuleTaux, "TAUX");
|
|
|
343 |
this.addSQLObject(this.formuleMontant, "MONTANT");
|
|
|
344 |
this.addRequiredSQLObject(comboSelTypeRubrique, "ID_TYPE_RUBRIQUE_BRUT");
|
|
|
345 |
this.addRequiredSQLObject(comboSelTypeImpression, "ID_IMPRESSION_RUBRIQUE");
|
|
|
346 |
this.addSQLObject(checkBrut, "PART_BRUT");
|
|
|
347 |
this.addSQLObject(checkCP, "PART_CP");
|
|
|
348 |
this.addSQLObject(checkImpo, "IMPOSABLE");
|
|
|
349 |
|
|
|
350 |
selSalarie.addValueListener(new PropertyChangeListener() {
|
|
|
351 |
|
|
|
352 |
public void propertyChange(PropertyChangeEvent evt) {
|
|
|
353 |
formuleBase.setSalarieID(selSalarie.getSelectedId());
|
|
|
354 |
formuleTaux.setSalarieID(selSalarie.getSelectedId());
|
|
|
355 |
formuleMontant.setSalarieID(selSalarie.getSelectedId());
|
|
|
356 |
}
|
|
|
357 |
});
|
|
|
358 |
}
|
|
|
359 |
};
|
|
|
360 |
}
|
|
|
361 |
}
|