OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 174 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 174 Rev 180
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
3
 * 
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
4
 * Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
5
 * 
5
 * 
6
 * The contents of this file are subject to the terms of the GNU General Public License Version 3
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
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
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.
9
 * language governing permissions and limitations under the License.
10
 * 
10
 * 
11
 * When distributing the software, include this License Header Notice in each file.
11
 * When distributing the software, include this License Header Notice in each file.
12
 */
12
 */
13
 
13
 
14
 package org.openconcerto.erp.core.humanresources.payroll.ui;
14
 package org.openconcerto.erp.core.humanresources.payroll.ui;
15
 
15
 
16
import org.openconcerto.erp.model.EditionFichePayeModel;
16
import org.openconcerto.erp.model.EditionFichePayeModel;
17
import org.openconcerto.erp.preferences.DefaultNXProps;
17
import org.openconcerto.erp.preferences.DefaultNXProps;
18
import org.openconcerto.sql.Configuration;
18
import org.openconcerto.sql.Configuration;
19
import org.openconcerto.sql.element.SQLElement;
19
import org.openconcerto.sql.element.SQLElement;
20
import org.openconcerto.sql.sqlobject.ElementComboBox;
20
import org.openconcerto.sql.sqlobject.ElementComboBox;
21
import org.openconcerto.sql.view.EditFrame;
21
import org.openconcerto.sql.view.EditFrame;
22
import org.openconcerto.sql.view.EditPanel;
22
import org.openconcerto.sql.view.EditPanel;
23
import org.openconcerto.ui.JDate;
23
import org.openconcerto.ui.JDate;
24
import org.openconcerto.ui.preferences.DefaultProps;
24
import org.openconcerto.ui.preferences.DefaultProps;
25
import org.openconcerto.utils.ExceptionHandler;
25
import org.openconcerto.utils.ExceptionHandler;
26
import org.openconcerto.utils.TableSorter;
26
import org.openconcerto.utils.TableSorter;
27
 
27
 
28
import java.awt.GridBagConstraints;
28
import java.awt.GridBagConstraints;
29
import java.awt.GridBagLayout;
29
import java.awt.GridBagLayout;
30
import java.awt.Insets;
30
import java.awt.Insets;
31
import java.awt.event.ActionEvent;
31
import java.awt.event.ActionEvent;
32
import java.awt.event.ActionListener;
32
import java.awt.event.ActionListener;
33
import java.awt.event.MouseEvent;
33
import java.awt.event.MouseEvent;
34
import java.awt.event.MouseListener;
34
import java.awt.event.MouseListener;
35
import java.beans.PropertyChangeEvent;
35
import java.beans.PropertyChangeEvent;
36
import java.beans.PropertyChangeListener;
36
import java.beans.PropertyChangeListener;
37
import java.util.ArrayList;
37
import java.util.ArrayList;
38
import java.util.Calendar;
38
import java.util.Calendar;
39
import java.util.Date;
39
import java.util.Date;
40
import java.util.List;
40
import java.util.List;
41
 
41
 
42
import javax.swing.AbstractAction;
42
import javax.swing.AbstractAction;
43
import javax.swing.BorderFactory;
43
import javax.swing.BorderFactory;
44
import javax.swing.JButton;
44
import javax.swing.JButton;
45
import javax.swing.JFrame;
45
import javax.swing.JFrame;
46
import javax.swing.JLabel;
46
import javax.swing.JLabel;
47
import javax.swing.JOptionPane;
47
import javax.swing.JOptionPane;
48
import javax.swing.JPanel;
48
import javax.swing.JPanel;
49
import javax.swing.JPopupMenu;
49
import javax.swing.JPopupMenu;
50
import javax.swing.JProgressBar;
50
import javax.swing.JProgressBar;
51
import javax.swing.JScrollPane;
51
import javax.swing.JScrollPane;
52
import javax.swing.JSpinner;
52
import javax.swing.JSpinner;
53
import javax.swing.JTable;
53
import javax.swing.JTable;
54
import javax.swing.SpinnerModel;
54
import javax.swing.SpinnerModel;
55
import javax.swing.SpinnerNumberModel;
55
import javax.swing.SpinnerNumberModel;
56
import javax.swing.SwingConstants;
56
import javax.swing.SwingConstants;
57
import javax.swing.SwingUtilities;
57
import javax.swing.SwingUtilities;
58
import javax.swing.event.ChangeEvent;
58
import javax.swing.event.ChangeEvent;
59
import javax.swing.event.ChangeListener;
59
import javax.swing.event.ChangeListener;
60
 
60
 
61
public class EditionFichePayePanel extends JPanel implements MouseListener {
61
public class EditionFichePayePanel extends JPanel implements MouseListener {
62
 
62
 
63
    private final DefaultProps props = DefaultNXProps.getInstance();
63
    private final DefaultProps props = DefaultNXProps.getInstance();
64
    private final JProgressBar bar = new JProgressBar();
64
    private final JProgressBar bar = new JProgressBar();
65
    private final JLabel labelEtatEdition = new JLabel();
65
    private final JLabel labelEtatEdition = new JLabel();
66
    private final EditionFichePayeModel model = new EditionFichePayeModel(bar, labelEtatEdition);
66
    private final EditionFichePayeModel model = new EditionFichePayeModel(bar, labelEtatEdition);
67
    private final JTable table;
67
    private final JTable table;
68
    private EditFrame frameModifySal = null;
68
    private EditFrame frameModifySal = null;
69
 
69
 
70
    public EditionFichePayePanel() {
70
    public EditionFichePayePanel() {
71
        super(new GridBagLayout());
71
        super(new GridBagLayout());
72
 
72
 
73
        GridBagConstraints c = new GridBagConstraints();
73
        GridBagConstraints c = new GridBagConstraints();
74
        c.gridx = 0;
74
        c.gridx = 0;
75
        c.gridy = 0;
75
        c.gridy = 0;
76
        c.gridwidth = 1;
76
        c.gridwidth = 1;
77
        c.gridheight = 1;
77
        c.gridheight = 1;
78
        c.weightx = 0;
78
        c.weightx = 0;
79
        c.weighty = 0;
79
        c.weighty = 0;
80
        c.anchor = GridBagConstraints.WEST;
80
        c.anchor = GridBagConstraints.WEST;
81
        c.fill = GridBagConstraints.HORIZONTAL;
81
        c.fill = GridBagConstraints.HORIZONTAL;
82
        c.insets = new Insets(2, 2, 1, 2);
82
        c.insets = new Insets(2, 2, 1, 2);
83
 
83
 
84
        // Période de travail
84
        // Période de travail
85
        JPanel panelPeriode = new JPanel();
85
        JPanel panelPeriode = new JPanel();
86
        panelPeriode.setBorder(BorderFactory.createTitledBorder("Période de travail"));
86
        panelPeriode.setBorder(BorderFactory.createTitledBorder("Période de travail"));
87
 
87
 
88
        SQLElement eltMois = Configuration.getInstance().getDirectory().getElement("MOIS");
88
        SQLElement eltMois = Configuration.getInstance().getDirectory().getElement("MOIS");
89
        JLabel labelMois = new JLabel("Mois");
89
        JLabel labelMois = new JLabel("Mois");
90
        final ElementComboBox selMois = new ElementComboBox(false, 25);
90
        final ElementComboBox selMois = new ElementComboBox(false, 25);
91
        selMois.init(eltMois);
91
        selMois.init(eltMois);
92
        selMois.setButtonsVisible(false);
92
        selMois.setButtonsVisible(false);
93
 
93
 
94
        // on remet les anciennes valeurs
94
        // on remet les anciennes valeurs
95
        int valMois = props.getIntProperty("MoisEditionPaye");
95
        int valMois = props.getIntProperty("MoisEditionPaye");
96
        if (valMois > 1) {
96
        if (valMois > 1) {
97
            selMois.setValue(valMois);
97
            selMois.setValue(valMois);
98
        }
98
        }
99
 
99
 
100
        JLabel labelAnnee = new JLabel("Année");
100
        JLabel labelAnnee = new JLabel("Année");
101
        // final JTextField textAnnee = new JTextField(4);
101
        // final JTextField textAnnee = new JTextField(4);
102
        Calendar cal = Calendar.getInstance();
102
        Calendar cal = Calendar.getInstance();
103
        SpinnerModel modelSpinner = new SpinnerNumberModel(cal.get(Calendar.YEAR), // initial value
103
        SpinnerModel modelSpinner = new SpinnerNumberModel(cal.get(Calendar.YEAR), // initial value
104
                cal.get(Calendar.YEAR) - 100, // min
104
                cal.get(Calendar.YEAR) - 100, // min
105
                cal.get(Calendar.YEAR) + 100, // max
105
                cal.get(Calendar.YEAR) + 100, // max
106
                1);
106
                1);
107
        final JSpinner textAnnee = new JSpinner(modelSpinner);
107
        final JSpinner textAnnee = new JSpinner(modelSpinner);
108
 
108
 
109
        String valYear = props.getStringProperty("AnneeEditionPaye");
109
        String valYear = props.getStringProperty("AnneeEditionPaye");
110
        if (valYear != null && valYear.trim().length() > 0) {
110
        if (valYear != null && valYear.trim().length() > 0) {
111
            textAnnee.setValue(Integer.valueOf(valYear));
111
            textAnnee.setValue(Integer.valueOf(valYear));
112
        }
112
        }
113
        panelPeriode.add(labelMois);
113
        panelPeriode.add(labelMois);
114
        panelPeriode.add(selMois);
114
        panelPeriode.add(selMois);
115
        panelPeriode.add(labelAnnee);
115
        panelPeriode.add(labelAnnee);
116
        panelPeriode.add(textAnnee);
116
        panelPeriode.add(textAnnee);
117
 
117
 
118
        JLabel periodeDeb = new JLabel("Correspondant à la période du");
118
        JLabel periodeDeb = new JLabel("Correspondant à la période du");
119
        JLabel periodeFin = new JLabel("au");
119
        JLabel periodeFin = new JLabel("au");
120
        final JDate dateDeb = new JDate();
120
        final JDate dateDeb = new JDate();
121
        final JDate dateFin = new JDate();
121
        final JDate dateFin = new JDate();
122
 
122
 
123
        panelPeriode.add(periodeDeb);
123
        panelPeriode.add(periodeDeb);
124
        panelPeriode.add(dateDeb);
124
        panelPeriode.add(dateDeb);
125
        panelPeriode.add(periodeFin);
125
        panelPeriode.add(periodeFin);
126
        panelPeriode.add(dateFin);
126
        panelPeriode.add(dateFin);
127
 
127
 
128
        c.gridwidth = GridBagConstraints.REMAINDER;
128
        c.gridwidth = GridBagConstraints.REMAINDER;
129
        c.weightx = 1;
129
        c.weightx = 1;
130
        this.add(panelPeriode, c);
130
        this.add(panelPeriode, c);
131
 
131
 
132
        // Liste des salariés
132
        // Liste des salariés
133
        c.gridy++;
133
        c.gridy++;
134
        TableSorter s = new TableSorter(this.model);
134
        TableSorter s = new TableSorter(this.model);
135
        this.table = new JTable(s);
135
        this.table = new JTable(s);
136
        s.setTableHeader(this.table.getTableHeader());
136
        s.setTableHeader(this.table.getTableHeader());
137
        // this.table = new JTable(this.model);
137
        // this.table = new JTable(this.model);
138
        this.table.addMouseListener(this);
138
        this.table.addMouseListener(this);
139
        c.fill = GridBagConstraints.BOTH;
139
        c.fill = GridBagConstraints.BOTH;
140
        c.weighty = 1;
140
        c.weighty = 1;
141
        this.add(new JScrollPane(this.table), c);
141
        this.add(new JScrollPane(this.table), c);
142
 
142
 
143
        // Label Etat
143
        // Label Etat
144
        c.gridx = 0;
144
        c.gridx = 0;
145
        c.gridy++;
145
        c.gridy++;
146
        c.gridwidth = GridBagConstraints.REMAINDER;
146
        c.gridwidth = GridBagConstraints.REMAINDER;
147
        c.fill = GridBagConstraints.HORIZONTAL;
147
        c.fill = GridBagConstraints.HORIZONTAL;
148
        c.weighty = 0;
148
        c.weighty = 0;
149
        c.weightx = 1;
149
        c.weightx = 1;
150
        this.labelEtatEdition.setHorizontalAlignment(SwingConstants.CENTER);
150
        this.labelEtatEdition.setHorizontalAlignment(SwingConstants.CENTER);
151
        this.add(this.labelEtatEdition, c);
151
        this.add(this.labelEtatEdition, c);
152
 
152
 
153
        // Progress Bar
153
        // Progress Bar
154
        c.gridwidth = GridBagConstraints.REMAINDER;
154
        c.gridwidth = GridBagConstraints.REMAINDER;
155
        c.fill = GridBagConstraints.HORIZONTAL;
155
        c.fill = GridBagConstraints.HORIZONTAL;
156
        c.gridy++;
156
        c.gridy++;
157
        c.weighty = 0;
157
        c.weighty = 0;
158
        this.add(this.bar, c);
158
        this.add(this.bar, c);
159
 
159
 
160
        // Button
160
        // Button
161
        final JButton buttonValid = new JButton("Valider");
161
        final JButton buttonValid = new JButton("Valider");
162
        final JButton buttonFermer = new JButton("Fermer");
162
        final JButton buttonFermer = new JButton("Fermer");
163
 
163
 
164
        PropertyChangeListener dateListener = new PropertyChangeListener() {
164
        PropertyChangeListener dateListener = new PropertyChangeListener() {
165
 
165
 
166
            @Override
166
            @Override
167
            public void propertyChange(PropertyChangeEvent evt) {
167
            public void propertyChange(PropertyChangeEvent evt) {
168
                buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null && dateDeb.getValue().compareTo(dateFin.getValue()) <= 0);
168
                buttonValid.setEnabled(dateDeb.getValue() != null && dateFin.getValue() != null && dateDeb.getValue().compareTo(dateFin.getValue()) <= 0);
169
                model.setDateLimit(dateDeb.getValue());
169
                model.setDateLimit(dateDeb.getValue());
170
            }
170
            }
171
        };
171
        };
172
        dateDeb.addValueListener(dateListener);
172
        dateDeb.addValueListener(dateListener);
173
        dateFin.addValueListener(dateListener);
173
        dateFin.addValueListener(dateListener);
174
 
174
 
175
        c.gridy++;
175
        c.gridy++;
176
        c.gridwidth = 1;
176
        c.gridwidth = 1;
177
        c.anchor = GridBagConstraints.EAST;
177
        c.anchor = GridBagConstraints.EAST;
178
        c.weightx = 1;
178
        c.weightx = 1;
179
        c.fill = GridBagConstraints.NONE;
179
        c.fill = GridBagConstraints.NONE;
180
        this.add(buttonValid, c);
180
        this.add(buttonValid, c);
181
        c.weightx = 0;
181
        c.weightx = 0;
182
        c.gridx++;
182
        c.gridx++;
183
        this.add(buttonFermer, c);
183
        this.add(buttonFermer, c);
184
 
184
 
185
        buttonFermer.addActionListener(new ActionListener() {
185
        buttonFermer.addActionListener(new ActionListener() {
186
            public void actionPerformed(ActionEvent e) {
186
            public void actionPerformed(ActionEvent e) {
187
                ((JFrame) SwingUtilities.getRoot(EditionFichePayePanel.this)).dispose();
187
                ((JFrame) SwingUtilities.getRoot(EditionFichePayePanel.this)).dispose();
188
            }
188
            }
189
        });
189
        });
190
 
190
 
191
        buttonValid.addActionListener(new ActionListener() {
191
        buttonValid.addActionListener(new ActionListener() {
192
            public void actionPerformed(ActionEvent e) {
192
            public void actionPerformed(ActionEvent e) {
193
                try {
193
                try {
194
                    // Sauvegarde des valeurs
194
                    // Sauvegarde des valeurs
195
                    props.setProperty("MoisEditionPaye", String.valueOf(selMois.getSelectedId()));
195
                    props.setProperty("MoisEditionPaye", String.valueOf(selMois.getSelectedId()));
196
                    // props.setProperty("AnneeEditionPaye", textAnnee.getText());
196
                    // props.setProperty("AnneeEditionPaye", textAnnee.getText());
197
                    props.store();
197
                    props.store();
198
 
198
 
199
                    final Date dateStart = dateDeb.getDate();
199
                    final Date dateStart = dateDeb.getDate();
200
 
200
 
201
                    if (dateStart == null) {
201
                    if (dateStart == null) {
202
                        JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de début manquante.");
202
                        JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de début manquante.");
203
                        return;
203
                        return;
204
                    }
204
                    }
205
                    java.sql.Date du = new java.sql.Date(dateStart.getTime());
205
                    java.sql.Date du = new java.sql.Date(dateStart.getTime());
206
                    final Date dateEnd = dateFin.getDate();
206
                    final Date dateEnd = dateFin.getDate();
207
                    if (dateEnd == null) {
207
                    if (dateEnd == null) {
208
                        JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de fin manquante.");
208
                        JOptionPane.showMessageDialog(EditionFichePayePanel.this, "Date de fin manquante.");
209
                        return;
209
                        return;
210
                    }
210
                    }
211
                    java.sql.Date au = new java.sql.Date(dateEnd.getTime());
211
                    java.sql.Date au = new java.sql.Date(dateEnd.getTime());
212
 
212
 
213
                    // model.validationFiche(textAnnee.getText(), selMois.getSelectedId(), du, au);
213
                    // model.validationFiche(textAnnee.getText(), selMois.getSelectedId(), du, au);
214
                    model.validationFiche(textAnnee.getValue().toString(), selMois.getSelectedId(), du, au);
214
                    model.validationFiche(textAnnee.getValue().toString(), selMois.getSelectedId(), du, au);
215
                } catch (Exception ex) {
215
                } catch (Exception ex) {
216
                    ExceptionHandler.handle("Impossible de valider la paye", ex);
216
                    ExceptionHandler.handle("Impossible de valider la paye", ex);
217
                }
217
                }
218
            }
218
            }
219
        });
219
        });
220
 
220
 
221
        selMois.addValueListener(new PropertyChangeListener() {
221
        selMois.addValueListener(new PropertyChangeListener() {
222
 
222
 
223
            public void propertyChange(PropertyChangeEvent evt) {
223
            public void propertyChange(PropertyChangeEvent evt) {
224
                if (selMois.getSelectedId() > 1 && textAnnee.getValue() != null) {
224
                if (selMois.getSelectedId() > 1 && textAnnee.getValue() != null) {
225
                    Calendar cal = Calendar.getInstance();
225
                    Calendar cal = Calendar.getInstance();
226
                    cal.set(Calendar.DAY_OF_MONTH, 1);
226
                    cal.set(Calendar.DAY_OF_MONTH, 1);
227
                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
227
                    cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
228
                    cal.set(Calendar.YEAR, Integer.valueOf(textAnnee.getValue().toString()).intValue());
228
                    cal.set(Calendar.YEAR, Integer.valueOf(textAnnee.getValue().toString()).intValue());
229
                    dateDeb.setValue(cal.getTime());
229
                    dateDeb.setValue(cal.getTime());
230
                    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
230
                    cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
231
                    dateFin.setValue(cal.getTime());
231
                    dateFin.setValue(cal.getTime());
232
                }
232
                }
233
            }
233
            }
234
        });
234
        });
235
 
235
 
236
        textAnnee.addChangeListener(new ChangeListener() {
236
        textAnnee.addChangeListener(new ChangeListener() {
237
            public void stateChanged(ChangeEvent e) {
237
            public void stateChanged(ChangeEvent e) {
238
 
238
 
239
                Calendar cal = Calendar.getInstance();
239
                Calendar cal = Calendar.getInstance();
240
                cal.set(Calendar.DAY_OF_MONTH, 1);
240
                cal.set(Calendar.DAY_OF_MONTH, 1);
241
                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
241
                cal.set(Calendar.MONTH, selMois.getSelectedId() - 2);
242
                cal.set(Calendar.YEAR, Integer.valueOf(textAnnee.getValue().toString()).intValue());
242
                cal.set(Calendar.YEAR, Integer.valueOf(textAnnee.getValue().toString()).intValue());
243
                dateDeb.setValue(cal.getTime());
243
                dateDeb.setValue(cal.getTime());
244
                cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
244
                cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
245
                dateFin.setValue(cal.getTime());
245
                dateFin.setValue(cal.getTime());
246
            }
246
            }
247
        });
247
        });
248
 
248
 
249
    }
249
    }
250
 
250
 
251
    public void mouseClicked(MouseEvent e) {
251
    public void mouseClicked(MouseEvent e) {
252
    }
252
    }
253
 
253
 
254
    public void mouseEntered(MouseEvent e) {
254
    public void mouseEntered(MouseEvent e) {
255
    }
255
    }
256
 
256
 
257
    public void mouseExited(MouseEvent e) {
257
    public void mouseExited(MouseEvent e) {
258
    }
258
    }
259
 
259
 
260
    public void mousePressed(final MouseEvent e) {
260
    public void mousePressed(final MouseEvent e) {
261
 
261
 
262
        int row = table.rowAtPoint(e.getPoint());
262
        int row = ((TableSorter) table.getModel()).modelIndex(table.rowAtPoint(e.getPoint()));
263
        final int idSal = model.getIdSalAtRow(row);
263
        final int idSal = model.getIdSalAtRow(row);
264
 
264
 
265
        if (e.getButton() == MouseEvent.BUTTON3) {
265
        if (e.getButton() == MouseEvent.BUTTON3) {
266
            JPopupMenu menuDroit = new JPopupMenu();
266
            JPopupMenu menuDroit = new JPopupMenu();
267
            menuDroit.add(new AbstractAction("Modifier") {
267
            menuDroit.add(new AbstractAction("Modifier") {
268
                public void actionPerformed(ActionEvent e) {
268
                public void actionPerformed(ActionEvent e) {
269
                    if (frameModifySal == null) {
269
                    if (frameModifySal == null) {
270
                        SQLElement elt = Configuration.getInstance().getDirectory().getElement("SALARIE");
270
                        SQLElement elt = Configuration.getInstance().getDirectory().getElement("SALARIE");
271
                        frameModifySal = new EditFrame(elt, EditPanel.MODIFICATION);
271
                        frameModifySal = new EditFrame(elt, EditPanel.MODIFICATION);
272
                    }
272
                    }
273
 
273
 
274
                    frameModifySal.selectionId(idSal, 1);
274
                    frameModifySal.selectionId(idSal, 1);
275
                    frameModifySal.pack();
275
                    frameModifySal.pack();
276
                    frameModifySal.setVisible(true);
276
                    frameModifySal.setVisible(true);
277
                }
277
                }
278
            });
278
            });
279
 
279
 
280
            menuDroit.add(new AbstractAction("Marquer tout \"A créer\"") {
280
            menuDroit.add(new AbstractAction("Marquer tout \"A créer\"") {
281
 
281
 
282
                public void actionPerformed(ActionEvent e) {
282
                public void actionPerformed(ActionEvent e) {
283
                    int rows = table.getModel().getRowCount();
283
                    int rows = table.getModel().getRowCount();
284
                    for (int i = 0; i < rows; i++) {
284
                    for (int i = 0; i < rows; i++) {
285
                        table.getModel().setValueAt(Boolean.TRUE, i, 0);
285
                        table.getModel().setValueAt(Boolean.TRUE, i, 0);
286
                    }
286
                    }
287
                    model.fireTableDataChanged();
287
                    model.fireTableDataChanged();
288
                }
288
                }
289
            });
289
            });
290
 
290
 
291
            menuDroit.add(new AbstractAction("Désélectionner tout \"A créer\"") {
291
            menuDroit.add(new AbstractAction("Désélectionner tout \"A créer\"") {
292
 
292
 
293
                public void actionPerformed(ActionEvent e) {
293
                public void actionPerformed(ActionEvent e) {
294
                    int rows = table.getModel().getRowCount();
294
                    int rows = table.getModel().getRowCount();
295
                    for (int i = 0; i < rows; i++) {
295
                    for (int i = 0; i < rows; i++) {
296
                        table.getModel().setValueAt(Boolean.FALSE, i, 0);
296
                        table.getModel().setValueAt(Boolean.FALSE, i, 0);
297
                    }
297
                    }
298
                    model.fireTableDataChanged();
298
                    model.fireTableDataChanged();
299
                }
299
                }
300
            });
300
            });
301
 
301
 
302
            menuDroit.add(new AbstractAction("Marquer la sélection \"A créer\"") {
302
            menuDroit.add(new AbstractAction("Marquer la sélection \"A créer\"") {
303
 
303
 
304
                public void actionPerformed(ActionEvent e) {
304
                public void actionPerformed(ActionEvent e) {
305
                    int[] selectedRows = table.getSelectedRows();
305
                    int[] selectedRows = table.getSelectedRows();
306
 
306
 
307
                    List<Integer> l = new ArrayList<>(selectedRows.length);
307
                    List<Integer> l = new ArrayList<>(selectedRows.length);
308
                    for (int i : selectedRows) {
308
                    for (int i : selectedRows) {
309
                        l.add(i);
309
                        l.add(i);
310
                    }
310
                    }
311
                    int rows = table.getModel().getRowCount();
311
                    int rows = table.getModel().getRowCount();
312
                    for (int i = 0; i < rows; i++) {
312
                    for (int i = 0; i < rows; i++) {
313
                        table.setValueAt(l.contains(i), i, 0);
313
                        table.setValueAt(l.contains(i), i, 0);
314
                    }
314
                    }
315
                    model.fireTableDataChanged();
315
                    model.fireTableDataChanged();
316
                }
316
                }
317
            });
317
            });
318
 
318
 
319
            menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
319
            menuDroit.show(e.getComponent(), e.getPoint().x, e.getPoint().y);
320
        }
320
        }
321
    }
321
    }
322
 
322
 
323
    public void mouseReleased(MouseEvent e) {
323
    public void mouseReleased(MouseEvent e) {
324
    }
324
    }
325
}
325
}