OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 156 | Rev 182 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 156 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.finance.accounting.ui;
14
 package org.openconcerto.erp.core.finance.accounting.ui;
15
 
15
 
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
16
import org.openconcerto.erp.config.ComptaPropsConfiguration;
-
 
17
import org.openconcerto.erp.core.common.ui.DeviseField;
17
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
18
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
18
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
19
import org.openconcerto.erp.core.finance.accounting.element.ComptePCESQLElement;
19
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.EcritureSQLElement;
20
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
21
import org.openconcerto.erp.core.finance.accounting.element.MouvementSQLElement;
21
import org.openconcerto.erp.core.finance.accounting.model.PointageModel;
22
import org.openconcerto.erp.core.finance.accounting.model.PointageModel;
22
import org.openconcerto.erp.model.ISQLCompteSelector;
23
import org.openconcerto.erp.model.ISQLCompteSelector;
23
import org.openconcerto.erp.rights.ComptaUserRight;
24
import org.openconcerto.erp.rights.ComptaUserRight;
24
import org.openconcerto.sql.Configuration;
25
import org.openconcerto.sql.Configuration;
25
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.element.SQLElement;
26
import org.openconcerto.sql.element.SQLElementDirectory;
27
import org.openconcerto.sql.element.SQLElementDirectory;
27
import org.openconcerto.sql.model.SQLBase;
28
import org.openconcerto.sql.model.SQLBase;
28
import org.openconcerto.sql.model.SQLRow;
29
import org.openconcerto.sql.model.SQLRow;
29
import org.openconcerto.sql.model.SQLRowValues;
30
import org.openconcerto.sql.model.SQLRowValues;
30
import org.openconcerto.sql.model.SQLSystem;
31
import org.openconcerto.sql.model.SQLSystem;
31
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.model.SQLTable;
32
import org.openconcerto.sql.model.Where;
33
import org.openconcerto.sql.model.Where;
33
import org.openconcerto.sql.request.ComboSQLRequest;
34
import org.openconcerto.sql.request.ComboSQLRequest;
34
import org.openconcerto.sql.users.rights.UserRightsManager;
35
import org.openconcerto.sql.users.rights.UserRightsManager;
35
import org.openconcerto.sql.view.list.IListe;
36
import org.openconcerto.sql.view.list.IListe;
36
import org.openconcerto.ui.DefaultGridBagConstraints;
37
import org.openconcerto.ui.DefaultGridBagConstraints;
37
import org.openconcerto.ui.FontUtils;
38
import org.openconcerto.ui.FontUtils;
38
import org.openconcerto.ui.JDate;
39
import org.openconcerto.ui.JDate;
39
import org.openconcerto.ui.TitledSeparator;
40
import org.openconcerto.ui.TitledSeparator;
40
import org.openconcerto.ui.warning.JLabelWarning;
41
import org.openconcerto.ui.warning.JLabelWarning;
41
import org.openconcerto.utils.text.SimpleDocumentListener;
42
import org.openconcerto.utils.text.SimpleDocumentListener;
42
 
43
 
43
import java.awt.Color;
44
import java.awt.Color;
44
import java.awt.Dimension;
45
import java.awt.Dimension;
45
import java.awt.GridBagConstraints;
46
import java.awt.GridBagConstraints;
46
import java.awt.GridBagLayout;
47
import java.awt.GridBagLayout;
47
import java.awt.Insets;
48
import java.awt.Insets;
48
import java.awt.Window;
49
import java.awt.Window;
49
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionEvent;
50
import java.awt.event.ActionListener;
51
import java.awt.event.ActionListener;
51
import java.awt.event.KeyAdapter;
52
import java.awt.event.KeyAdapter;
52
import java.awt.event.KeyEvent;
53
import java.awt.event.KeyEvent;
53
import java.awt.event.MouseAdapter;
54
import java.awt.event.MouseAdapter;
54
import java.awt.event.MouseEvent;
55
import java.awt.event.MouseEvent;
55
import java.beans.PropertyChangeEvent;
56
import java.beans.PropertyChangeEvent;
56
import java.beans.PropertyChangeListener;
57
import java.beans.PropertyChangeListener;
57
import java.sql.SQLException;
58
import java.sql.SQLException;
58
import java.util.Date;
59
import java.util.Date;
59
import java.util.concurrent.ExecutionException;
60
import java.util.concurrent.ExecutionException;
60
 
61
 
61
import javax.swing.AbstractAction;
62
import javax.swing.AbstractAction;
62
import javax.swing.BorderFactory;
63
import javax.swing.BorderFactory;
63
import javax.swing.ButtonGroup;
64
import javax.swing.ButtonGroup;
64
import javax.swing.JButton;
65
import javax.swing.JButton;
65
import javax.swing.JCheckBox;
66
import javax.swing.JCheckBox;
66
import javax.swing.JLabel;
67
import javax.swing.JLabel;
67
import javax.swing.JPanel;
68
import javax.swing.JPanel;
68
import javax.swing.JPopupMenu;
69
import javax.swing.JPopupMenu;
69
import javax.swing.JRadioButton;
70
import javax.swing.JRadioButton;
70
import javax.swing.JScrollPane;
71
import javax.swing.JScrollPane;
71
import javax.swing.JTable;
72
import javax.swing.JTable;
72
import javax.swing.JTextField;
73
import javax.swing.JTextField;
73
import javax.swing.SwingConstants;
74
import javax.swing.SwingConstants;
74
import javax.swing.SwingUtilities;
75
import javax.swing.SwingUtilities;
75
import javax.swing.SwingWorker;
76
import javax.swing.SwingWorker;
76
import javax.swing.event.DocumentEvent;
77
import javax.swing.event.DocumentEvent;
77
import javax.swing.event.DocumentListener;
-
 
78
import javax.swing.event.TableModelEvent;
78
import javax.swing.event.TableModelEvent;
79
import javax.swing.event.TableModelListener;
79
import javax.swing.event.TableModelListener;
80
 
80
 
81
public class PointagePanel extends JPanel {
81
public class PointagePanel extends JPanel {
82
 
82
 
83
    private ListPanelEcritures ecriturePanel;
83
    private ListPanelEcritures ecriturePanel;
84
    private JTextField codePointage;
84
    private JTextField codePointage;
85
    private ISQLCompteSelector selCompte;
85
    private ISQLCompteSelector selCompte;
86
    private final JDate datePointee;
86
    private final JDate datePointee;
87
    private JCheckBox boxValidEcriture;
87
    private JCheckBox boxValidEcriture;
88
    private JPanel warningPanel;
88
    private JPanel warningPanel;
-
 
89
    private final DeviseField fieldSoldeD = new DeviseField(15);
-
 
90
    private final DeviseField fieldSoldeA = new DeviseField(15);
-
 
91
    private final DeviseField fieldEcart = new DeviseField(15);
89
 
92
 
90
    private final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
93
    private final SQLBase base = ((ComptaPropsConfiguration) Configuration.getInstance()).getSQLBaseSociete();
91
    private final SQLTable tableEcr = this.base.getTable("ECRITURE");
94
    private final SQLTable tableEcr = this.base.getTable("ECRITURE");
92
    private final SQLTable tableCpt = this.base.getTable("COMPTE_PCE");
95
    private final SQLTable tableCpt = this.base.getTable("COMPTE_PCE");
93
 
96
 
94
    private final static int allEcriture = 0;
97
    private final static int allEcriture = 0;
95
    private final static int ecriturePointee = 1;
98
    private final static int ecriturePointee = 1;
96
    private final static int ecritureNotPointee = 2;
99
    private final static int ecritureNotPointee = 2;
97
 
100
 
98
    private int modeSelect;
101
    private int modeSelect;
99
    private PointageModel model;
102
    private PointageModel model;
100
    private JButton buttonPointer;
103
    private JButton buttonPointer;
101
    private JDate dateFin, dateDeb;
104
    private JDate dateFin, dateDeb;
102
 
105
 
103
    public PointagePanel() {
106
    public PointagePanel() {
104
        this.setLayout(new GridBagLayout());
107
        this.setLayout(new GridBagLayout());
105
        final GridBagConstraints c = new DefaultGridBagConstraints();
108
        final GridBagConstraints c = new DefaultGridBagConstraints();
106
        final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
109
        final SQLElementDirectory directory = Configuration.getInstance().getDirectory();
107
        this.modeSelect = allEcriture;
110
        this.modeSelect = allEcriture;
108
 
111
 
109
        // Selection du compte à pointer
112
        // Selection du compte à pointer
110
        // TODO Ajouter selection d'un Journal
113
        // TODO Ajouter selection d'un Journal
111
 
114
 
112
        JLabel labelPointageCompte = new JLabel("Pointage du compte");
115
        JLabel labelPointageCompte = new JLabel("Pointage du compte");
113
        labelPointageCompte.setHorizontalAlignment(SwingConstants.RIGHT);
116
        labelPointageCompte.setHorizontalAlignment(SwingConstants.RIGHT);
114
        this.add(labelPointageCompte, c);
117
        this.add(labelPointageCompte, c);
115
 
118
 
116
        this.selCompte = new ISQLCompteSelector();
119
        this.selCompte = new ISQLCompteSelector();
117
        SQLElement eltCpt = directory.getElement("COMPTE_PCE");
120
        SQLElement eltCpt = directory.getElement("COMPTE_PCE");
118
        final ComboSQLRequest createComboRequest = eltCpt.createComboRequest();
121
        final ComboSQLRequest createComboRequest = eltCpt.createComboRequest();
119
        String function = "REGEXP";
122
        String function = "REGEXP";
120
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
123
        if (Configuration.getInstance().getBase().getServer().getSQLSystem() == SQLSystem.POSTGRESQL) {
121
            function = "~";
124
            function = "~";
122
        }
125
        }
123
        createComboRequest.setWhere(new Where(eltCpt.getTable().getField("NUMERO"), function, "^5.*$"));
126
        createComboRequest.setWhere(new Where(eltCpt.getTable().getField("NUMERO"), function, "^5.*$"));
124
        this.selCompte.init(eltCpt, createComboRequest);
127
        this.selCompte.init(eltCpt, createComboRequest);
125
        new SwingWorker<Integer, Object>() {
128
        new SwingWorker<Integer, Object>() {
126
 
129
 
127
            @Override
130
            @Override
128
            protected Integer doInBackground() throws Exception {
131
            protected Integer doInBackground() throws Exception {
129
 
132
 
130
                return ComptePCESQLElement.getId("5");
133
                return ComptePCESQLElement.getId("5");
131
            }
134
            }
132
 
135
 
133
            @Override
136
            @Override
134
            protected void done() {
137
            protected void done() {
135
                try {
138
                try {
136
                    PointagePanel.this.selCompte.setValue(get());
139
                    PointagePanel.this.selCompte.setValue(get());
137
                } catch (InterruptedException e) {
140
                } catch (InterruptedException e) {
138
                    // TODO Auto-generated catch block
141
                    // TODO Auto-generated catch block
139
                    e.printStackTrace();
142
                    e.printStackTrace();
140
                } catch (ExecutionException e) {
143
                } catch (ExecutionException e) {
141
                    // TODO Auto-generated catch block
144
                    // TODO Auto-generated catch block
142
                    e.printStackTrace();
145
                    e.printStackTrace();
143
                }
146
                }
144
            }
147
            }
145
        }.execute();
148
        }.execute();
146
 
149
 
147
        // c.fill = GridBagConstraints.NONE;
150
        // c.fill = GridBagConstraints.NONE;
148
        c.weightx = 1;
151
        c.weightx = 1;
149
        c.gridx++;
152
        c.gridx++;
150
        c.gridwidth = GridBagConstraints.REMAINDER;
153
        c.gridwidth = GridBagConstraints.REMAINDER;
151
        this.add(this.selCompte, c);
154
        this.add(this.selCompte, c);
152
 
155
 
153
        // Gestion du pointage
156
        // Gestion du pointage
154
        c.insets = new Insets(2, 2, 1, 2);
157
        c.insets = new Insets(2, 2, 1, 2);
155
        TitledSeparator sepGestionPointage = new TitledSeparator("Gestion du pointage");
158
        TitledSeparator sepGestionPointage = new TitledSeparator("Gestion du pointage");
156
        c.fill = GridBagConstraints.HORIZONTAL;
159
        c.fill = GridBagConstraints.HORIZONTAL;
157
        c.gridy++;
160
        c.gridy++;
158
        c.gridx = 0;
161
        c.gridx = 0;
159
        this.add(sepGestionPointage, c);
162
        this.add(sepGestionPointage, c);
160
 
163
 
161
        // Panel Selection du mode d'affichage des ecritures
164
        // Panel Selection du mode d'affichage des ecritures
162
 
165
 
163
        c.gridy++;
166
        c.gridy++;
164
        c.gridx = 0;
167
        c.gridx = 0;
165
        c.gridwidth = 1;
168
        c.gridwidth = 1;
166
        c.gridheight = 1;
169
        c.gridheight = 1;
167
        c.weightx = 0;
170
        c.weightx = 0;
168
 
171
 
169
        // Numero de releve
172
        // Numero de releve
170
        // c.anchor = GridBagConstraints.EAST;
173
        // c.anchor = GridBagConstraints.EAST;
171
        JLabel labelReleve = new JLabel("N° de relevé");
174
        JLabel labelReleve = new JLabel("N° de relevé");
172
        labelReleve.setHorizontalAlignment(SwingConstants.RIGHT);
175
        labelReleve.setHorizontalAlignment(SwingConstants.RIGHT);
173
        this.add(labelReleve, c);
176
        this.add(labelReleve, c);
174
 
177
 
175
        this.codePointage = new JTextField(10);
178
        this.codePointage = new JTextField(10);
176
        c.gridx++;
179
        c.gridx++;
177
        c.weightx = 0;
180
        c.weightx = 0;
178
        c.fill = GridBagConstraints.NONE;
181
        c.fill = GridBagConstraints.NONE;
179
        c.anchor = GridBagConstraints.WEST;
182
        c.anchor = GridBagConstraints.WEST;
180
        this.add(this.codePointage, c);
183
        this.add(this.codePointage, c);
181
 
184
 
182
        // Warning si aucun code rentré
185
        // Warning si aucun code rentré
183
        c.gridx++;
186
        c.gridx++;
184
        c.fill = GridBagConstraints.HORIZONTAL;
187
        c.fill = GridBagConstraints.HORIZONTAL;
185
        createPanelWarning();
188
        createPanelWarning();
186
        c.gridwidth = 1;
189
        c.gridwidth = 1;
187
        c.weightx = 1;
190
        c.weightx = 1;
188
        this.add(this.warningPanel, c);
191
        this.add(this.warningPanel, c);
189
 
192
 
190
        // Date de pointage
193
        // Date de pointage
191
        // MAYBE si date invalide grisée le bouton pointer
194
        // MAYBE si date invalide grisée le bouton pointer
192
        JLabel labelDate = new JLabel("Date de pointage");
195
        JLabel labelDate = new JLabel("Date de pointage");
193
        labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
196
        labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
194
        c.gridx = 0;
197
        c.gridx = 0;
195
        c.gridy++;
198
        c.gridy++;
196
        c.gridwidth = 1;
199
        c.gridwidth = 1;
197
        c.weightx = 0;
200
        c.weightx = 0;
198
        this.add(labelDate, c);
201
        this.add(labelDate, c);
199
 
202
 
200
        this.datePointee = new JDate(true);
203
        this.datePointee = new JDate(true);
201
        c.fill = GridBagConstraints.NONE;
204
        c.fill = GridBagConstraints.NONE;
202
        c.weightx = 1;
205
        c.weightx = 1;
203
        c.gridx++;
206
        c.gridx++;
204
        c.gridwidth = 1;
207
        c.gridwidth = 1;
205
        this.add(this.datePointee, c);
208
        this.add(this.datePointee, c);
206
 
209
 
-
 
210
        JPanel panelCheckValue = new JPanel(new GridBagLayout());
-
 
211
        GridBagConstraints cCheck = new DefaultGridBagConstraints();
-
 
212
        JLabel labelSoldeD = new JLabel("Solde de départ");
-
 
213
        labelSoldeD.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
214
        cCheck.gridwidth = 1;
-
 
215
        cCheck.weightx = 0;
-
 
216
        panelCheckValue.add(labelSoldeD, cCheck);
-
 
217
 
-
 
218
        cCheck.fill = GridBagConstraints.NONE;
-
 
219
        cCheck.weightx = 1;
-
 
220
        cCheck.gridx++;
-
 
221
        cCheck.gridwidth = 1;
-
 
222
        panelCheckValue.add(this.fieldSoldeD, cCheck);
-
 
223
 
-
 
224
        JLabel labelSoldeA = new JLabel("Solde d'arrivée");
-
 
225
        labelSoldeA.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
226
        cCheck.gridx++;
-
 
227
 
-
 
228
        cCheck.gridwidth = 1;
-
 
229
        cCheck.weightx = 0;
-
 
230
        panelCheckValue.add(labelSoldeA, cCheck);
-
 
231
        cCheck.fill = GridBagConstraints.NONE;
-
 
232
        cCheck.weightx = 1;
-
 
233
        cCheck.gridx++;
-
 
234
        cCheck.gridwidth = 1;
-
 
235
        panelCheckValue.add(this.fieldSoldeA, cCheck);
-
 
236
 
-
 
237
        JLabel labelEcart = new JLabel("Ecart pointage");
-
 
238
        labelEcart.setHorizontalAlignment(SwingConstants.RIGHT);
-
 
239
        cCheck.gridx++;
-
 
240
        cCheck.gridwidth = 1;
-
 
241
        cCheck.weightx = 0;
-
 
242
        panelCheckValue.add(labelEcart, cCheck);
-
 
243
 
-
 
244
        cCheck.fill = GridBagConstraints.NONE;
-
 
245
        cCheck.weightx = 1;
-
 
246
        cCheck.gridx++;
-
 
247
        cCheck.gridwidth = 1;
-
 
248
        this.fieldEcart.setEditable(false);
-
 
249
        panelCheckValue.add(this.fieldEcart, cCheck);
-
 
250
 
-
 
251
        c.gridx++;
-
 
252
        c.gridwidth = 3;
-
 
253
        c.weightx = 1;
-
 
254
        this.add(panelCheckValue, c);
-
 
255
        this.fieldSoldeA.getDocument().addDocumentListener(new SimpleDocumentListener() {
-
 
256
 
-
 
257
            @Override
-
 
258
            public void update(DocumentEvent e) {
-
 
259
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
-
 
260
            }
-
 
261
        });
-
 
262
 
-
 
263
        this.fieldSoldeD.getDocument().addDocumentListener(new SimpleDocumentListener() {
-
 
264
 
-
 
265
            @Override
-
 
266
            public void update(DocumentEvent e) {
-
 
267
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
-
 
268
            }
-
 
269
        });
-
 
270
 
207
        TitledSeparator sepPeriode = new TitledSeparator("Filtre ");
271
        TitledSeparator sepPeriode = new TitledSeparator("Filtre ");
208
        c.gridy++;
272
        c.gridy++;
209
        c.gridx = 0;
273
        c.gridx = 0;
210
        c.anchor = GridBagConstraints.WEST;
274
        c.anchor = GridBagConstraints.WEST;
211
        c.gridwidth = GridBagConstraints.REMAINDER;
275
        c.gridwidth = GridBagConstraints.REMAINDER;
212
        c.fill = GridBagConstraints.HORIZONTAL;
276
        c.fill = GridBagConstraints.HORIZONTAL;
213
        this.add(sepPeriode, c);
277
        this.add(sepPeriode, c);
214
 
278
 
215
        JPanel panelSelectEcritures = createPanelSelectionEcritures();
279
        JPanel panelSelectEcritures = createPanelSelectionEcritures();
216
        c.gridy++;
280
        c.gridy++;
217
        c.weightx = 0;
281
        c.weightx = 0;
218
        c.gridwidth = 1;
282
        c.gridwidth = 1;
219
        c.gridx = 0;
283
        c.gridx = 0;
220
        final JLabel labelEcr = new JLabel("Ecritures");
284
        final JLabel labelEcr = new JLabel("Ecritures");
221
        labelEcr.setHorizontalAlignment(SwingConstants.RIGHT);
285
        labelEcr.setHorizontalAlignment(SwingConstants.RIGHT);
222
        this.add(labelEcr, c);
286
        this.add(labelEcr, c);
223
        c.gridx++;
287
        c.gridx++;
224
        c.fill = GridBagConstraints.NONE;
288
        c.fill = GridBagConstraints.NONE;
225
        c.gridwidth = GridBagConstraints.REMAINDER;
289
        c.gridwidth = GridBagConstraints.REMAINDER;
226
        c.weightx = 1;
290
        c.weightx = 1;
227
        this.add(panelSelectEcritures, c);
291
        this.add(panelSelectEcritures, c);
228
        c.fill = GridBagConstraints.HORIZONTAL;
292
        c.fill = GridBagConstraints.HORIZONTAL;
229
 
293
 
230
        c.gridy++;
294
        c.gridy++;
231
        c.gridx = 0;
295
        c.gridx = 0;
232
        c.weightx = 0;
296
        c.weightx = 0;
233
        JPanel panelPeriode = new JPanel();
297
        JPanel panelPeriode = new JPanel();
234
        // Date de début
298
        // Date de début
235
        this.dateDeb = new JDate();
299
        this.dateDeb = new JDate();
236
        final JLabel periodLabel = new JLabel("Période du ");
300
        final JLabel periodLabel = new JLabel("Période du ");
237
        periodLabel.setHorizontalAlignment(SwingConstants.RIGHT);
301
        periodLabel.setHorizontalAlignment(SwingConstants.RIGHT);
238
        c.gridwidth = 1;
302
        c.gridwidth = 1;
239
        this.add(periodLabel, c);
303
        this.add(periodLabel, c);
240
 
304
 
241
        c.gridx++;
305
        c.gridx++;
242
 
306
 
243
        panelPeriode.add(this.dateDeb);
307
        panelPeriode.add(this.dateDeb);
244
        this.dateDeb.addValueListener(new PropertyChangeListener() {
308
        this.dateDeb.addValueListener(new PropertyChangeListener() {
245
            public void propertyChange(PropertyChangeEvent evt) {
309
            public void propertyChange(PropertyChangeEvent evt) {
246
                changeListRequest();
310
                changeListRequest();
247
                PointagePanel.this.model.updateTotauxCompte();
311
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
248
            }
312
            }
249
        });
313
        });
250
 
314
 
251
        // Date de fin
315
        // Date de fin
252
        this.dateFin = new JDate(true);
316
        this.dateFin = new JDate(true);
253
        panelPeriode.add(new JLabel("au"));
317
        panelPeriode.add(new JLabel("au"));
254
        this.dateFin.addValueListener(new PropertyChangeListener() {
318
        this.dateFin.addValueListener(new PropertyChangeListener() {
255
            public void propertyChange(PropertyChangeEvent evt) {
319
            public void propertyChange(PropertyChangeEvent evt) {
256
                changeListRequest();
320
                changeListRequest();
257
                PointagePanel.this.model.updateTotauxCompte();
321
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
258
            }
322
            }
259
        });
323
        });
260
 
324
 
261
        panelPeriode.add(this.dateFin);
325
        panelPeriode.add(this.dateFin);
262
 
326
 
263
        c.weightx = 1;
327
        c.weightx = 1;
264
        c.fill = GridBagConstraints.NONE;
328
        c.fill = GridBagConstraints.NONE;
265
        c.gridwidth = GridBagConstraints.REMAINDER;
329
        c.gridwidth = GridBagConstraints.REMAINDER;
266
        this.add(panelPeriode, c);
330
        this.add(panelPeriode, c);
267
 
331
 
268
        TitledSeparator sepEcriture = new TitledSeparator("Ecritures ");
332
        TitledSeparator sepEcriture = new TitledSeparator("Ecritures ");
269
        c.gridy++;
333
        c.gridy++;
270
        c.gridx = 0;
334
        c.gridx = 0;
271
        c.gridwidth = GridBagConstraints.REMAINDER;
335
        c.gridwidth = GridBagConstraints.REMAINDER;
272
        c.fill = GridBagConstraints.HORIZONTAL;
336
        c.fill = GridBagConstraints.HORIZONTAL;
273
        this.add(sepEcriture, c);
337
        this.add(sepEcriture, c);
274
 
338
 
275
        // Liste des ecritures
339
        // Liste des ecritures
276
        final EcritureSQLElement ecritureElem = directory.getElement(EcritureSQLElement.class);
340
        final EcritureSQLElement ecritureElem = directory.getElement(EcritureSQLElement.class);
277
        this.ecriturePanel = new ListPanelEcritures(ecritureElem, new IListe(ecritureElem.createPointageTableSource()));
341
        this.ecriturePanel = new ListPanelEcritures(ecritureElem, new IListe(ecritureElem.createPointageTableSource()));
278
        this.ecriturePanel.setShowReadOnlyFrameOnDoubleClick(false);
342
        this.ecriturePanel.setShowReadOnlyFrameOnDoubleClick(false);
279
        c.gridx = 0;
343
        c.gridx = 0;
280
        c.gridy++;
344
        c.gridy++;
281
        c.weighty = 1;
345
        c.weighty = 1;
282
        c.weightx = 1;
346
        c.weightx = 1;
283
        c.fill = GridBagConstraints.BOTH;
347
        c.fill = GridBagConstraints.BOTH;
284
        c.gridwidth = GridBagConstraints.REMAINDER;
348
        c.gridwidth = GridBagConstraints.REMAINDER;
285
        this.ecriturePanel.getListe().setPreferredSize(new Dimension(this.ecriturePanel.getListe().getPreferredSize().width, 200));
349
        this.ecriturePanel.getListe().setPreferredSize(new Dimension(this.ecriturePanel.getListe().getPreferredSize().width, 200));
286
        this.add(this.ecriturePanel, c);
350
        this.add(this.ecriturePanel, c);
287
 
351
 
288
        // JTable Totaux
352
        // JTable Totaux
289
        c.gridy++;
353
        c.gridy++;
290
        c.gridx = 0;
354
        c.gridx = 0;
291
        c.weighty = 0;
355
        c.weighty = 0;
292
        c.weightx = 1;
356
        c.weightx = 1;
293
        c.fill = GridBagConstraints.BOTH;
357
        c.fill = GridBagConstraints.BOTH;
294
        c.gridwidth = 4;
358
        c.gridwidth = 4;
295
        c.gridheight = 3;
359
        c.gridheight = 3;
296
        this.model = new PointageModel(this.selCompte.getSelectedId(), this);
360
        this.model = new PointageModel(this.selCompte.getSelectedId(), this);
297
        JTable table = new JTable(this.model);
361
        JTable table = new JTable(this.model);
298
        table.setRowHeight(FontUtils.getPreferredRowHeight(table));
362
        table.setRowHeight(FontUtils.getPreferredRowHeight(table));
299
        // AlternateTableCellRenderer.setAllColumns(table);
363
        // AlternateTableCellRenderer.setAllColumns(table);
300
        final DeviseNiceTableCellRenderer cellRenderer = new DeviseNiceTableCellRenderer();
364
        final DeviseNiceTableCellRenderer cellRenderer = new DeviseNiceTableCellRenderer();
301
        for (int i = 0; i < table.getColumnCount(); i++) {
365
        for (int i = 0; i < table.getColumnCount(); i++) {
302
            // if (table.getColumnClass(i) == Long.class || table.getColumnClass(i) ==
366
            // if (table.getColumnClass(i) == Long.class || table.getColumnClass(i) ==
303
            // BigInteger.class) {
367
            // BigInteger.class) {
304
 
368
 
305
            table.getColumnModel().getColumn(i).setCellRenderer(cellRenderer);
369
            table.getColumnModel().getColumn(i).setCellRenderer(cellRenderer);
306
            // }else{
370
            // }else{
307
            //
371
            //
308
            // }
372
            // }
309
        }
373
        }
310
        JScrollPane sPane = new JScrollPane(table);
374
        JScrollPane sPane = new JScrollPane(table);
311
 
375
 
312
        // TODO Gerer la taille des colonnes
376
        // TODO Gerer la taille des colonnes
313
        Dimension d = new Dimension(table.getPreferredSize().width, table.getPreferredSize().height + table.getTableHeader().getPreferredSize().height + 4);
377
        Dimension d = new Dimension(table.getPreferredSize().width, table.getPreferredSize().height + table.getTableHeader().getPreferredSize().height + 4);
314
        sPane.setPreferredSize(d);
378
        sPane.setPreferredSize(d);
315
        this.add(sPane, c);
379
        this.add(sPane, c);
316
 
380
 
317
        // Legende
381
        // Legende
318
        c.gridx += 4;
382
        c.gridx += 4;
319
        c.gridwidth = 1;
383
        c.gridwidth = 1;
320
        c.anchor = GridBagConstraints.WEST;
384
        c.anchor = GridBagConstraints.WEST;
321
        c.fill = GridBagConstraints.NONE;
385
        c.fill = GridBagConstraints.NONE;
322
        c.weightx = 0;
386
        c.weightx = 0;
323
        this.add(createPanelLegende(), c);
387
        this.add(createPanelLegende(), c);
324
 
388
 
325
        // Validation des ecritures pointées
389
        // Validation des ecritures pointées
326
        this.boxValidEcriture = new JCheckBox("Valider les écritures pointées");
390
        this.boxValidEcriture = new JCheckBox("Valider les écritures pointées");
327
        c.gridx++;
391
        c.gridx++;
328
        c.gridheight = 1;
392
        c.gridheight = 1;
329
        c.gridwidth = GridBagConstraints.REMAINDER;
393
        c.gridwidth = GridBagConstraints.REMAINDER;
330
        this.add(this.boxValidEcriture, c);
394
        this.add(this.boxValidEcriture, c);
331
 
395
 
332
        // Bouton Pointer
396
        // Bouton Pointer
333
        c.anchor = GridBagConstraints.SOUTHEAST;
397
        c.anchor = GridBagConstraints.SOUTHEAST;
334
        this.buttonPointer = new JButton("Pointer");
398
        this.buttonPointer = new JButton("Pointer");
335
        c.gridwidth = 1;
399
        c.gridwidth = 1;
336
        c.gridheight = 1;
400
        c.gridheight = 1;
337
        c.weightx = 0;
401
        c.weightx = 0;
338
        c.gridx = 5;
402
        c.gridx = 5;
339
        c.gridy++;
403
        c.gridy++;
340
        c.fill = GridBagConstraints.NONE;
404
        c.fill = GridBagConstraints.NONE;
341
 
405
 
342
        this.add(this.buttonPointer, c);
406
        this.add(this.buttonPointer, c);
343
 
407
 
344
        // Bouton Depointer
408
        // Bouton Depointer
345
        JButton buttonDepointer = new JButton("Dépointer");
409
        JButton buttonDepointer = new JButton("Dépointer");
346
        c.gridx++;
410
        c.gridx++;
347
        c.weightx = 0;
411
        c.weightx = 0;
348
        this.add(buttonDepointer, c);
412
        this.add(buttonDepointer, c);
349
 
413
 
350
        c.gridwidth = GridBagConstraints.REMAINDER;
414
        c.gridwidth = GridBagConstraints.REMAINDER;
351
        c.gridheight = 1;
415
        c.gridheight = 1;
352
        c.weightx = 0;
416
        c.weightx = 0;
353
        c.gridx = 5;
417
        c.gridx = 5;
354
        c.gridy++;
418
        c.gridy++;
355
        c.fill = GridBagConstraints.NONE;
419
        c.fill = GridBagConstraints.NONE;
356
        c.anchor = GridBagConstraints.EAST;
420
        c.anchor = GridBagConstraints.EAST;
357
        JButton buttonClose = new JButton("Fermer");
421
        JButton buttonClose = new JButton("Fermer");
358
        buttonClose.addActionListener(new ActionListener() {
422
        buttonClose.addActionListener(new ActionListener() {
359
 
423
 
360
            @Override
424
            @Override
361
            public void actionPerformed(ActionEvent e) {
425
            public void actionPerformed(ActionEvent e) {
362
                ((Window) SwingUtilities.getRoot(PointagePanel.this)).dispose();
426
                ((Window) SwingUtilities.getRoot(PointagePanel.this)).dispose();
363
            }
427
            }
364
        });
428
        });
365
        this.add(buttonClose, c);
429
        this.add(buttonClose, c);
366
        this.buttonPointer.addActionListener(new ActionListener() {
430
        this.buttonPointer.addActionListener(new ActionListener() {
367
            public void actionPerformed(ActionEvent e) {
431
            public void actionPerformed(ActionEvent e) {
368
 
432
 
369
                int[] rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
433
                int[] rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
370
 
434
 
371
                for (int i = 0; i < rowIndex.length; i++) {
435
                for (int i = 0; i < rowIndex.length; i++) {
372
                    System.err.println("Action pointage sur " + i);
436
                    System.err.println("Action pointage sur " + i);
373
                    actionPointage(rowIndex[i]);
437
                    actionPointage(rowIndex[i]);
374
                }
438
                }
375
            }
439
            }
376
        });
440
        });
377
 
441
 
378
        buttonDepointer.addActionListener(new ActionListener() {
442
        buttonDepointer.addActionListener(new ActionListener() {
379
            public void actionPerformed(ActionEvent e) {
443
            public void actionPerformed(ActionEvent e) {
380
 
444
 
381
                int[] rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
445
                int[] rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
382
 
446
 
383
                for (int i = 0; i < rowIndex.length; i++) {
447
                for (int i = 0; i < rowIndex.length; i++) {
384
                    System.err.println("Action depointage sur " + i);
448
                    System.err.println("Action depointage sur " + i);
385
                    actionDepointage(rowIndex[i]);
449
                    actionDepointage(rowIndex[i]);
386
                }
450
                }
387
            }
451
            }
388
        });
452
        });
389
 
453
 
390
        // Changement de compte
454
        // Changement de compte
391
        this.selCompte.addValueListener(new PropertyChangeListener() {
455
        this.selCompte.addValueListener(new PropertyChangeListener() {
392
            public void propertyChange(PropertyChangeEvent evt) {
456
            public void propertyChange(PropertyChangeEvent evt) {
393
 
457
 
394
                changeListRequest();
458
                changeListRequest();
395
            };
459
            };
396
        });
460
        });
397
 
461
 
398
        // Action Souris sur la IListe
462
        // Action Souris sur la IListe
399
        this.ecriturePanel.getListe().getJTable().addMouseListener(new MouseAdapter() {
463
        this.ecriturePanel.getListe().getJTable().addMouseListener(new MouseAdapter() {
400
 
464
 
401
            @Override
465
            @Override
402
            public void mouseReleased(MouseEvent e) {
466
            public void mouseReleased(MouseEvent e) {
403
                // ATTN never modify an IListe on mousePressed otherwise the selection is incoherent
467
                // ATTN never modify an IListe on mousePressed otherwise the selection is incoherent
404
                // (see IListe.iterateSelectedRows())
468
                // (see IListe.iterateSelectedRows())
405
                if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) {
469
                if ((e.getClickCount() == 2) && (e.getButton() == MouseEvent.BUTTON1)) {
406
 
470
 
407
                    int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(e.getPoint());
471
                    int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(e.getPoint());
408
                    int id = PointagePanel.this.ecriturePanel.getListe().idFromIndex(rowIndex);
472
                    int id = PointagePanel.this.ecriturePanel.getListe().idFromIndex(rowIndex);
409
 
473
 
410
                    SQLRow row = PointagePanel.this.tableEcr.getRow(id);
474
                    SQLRow row = PointagePanel.this.tableEcr.getRow(id);
411
                    if (row.getString("POINTEE").trim().length() == 0) {
475
                    if (row.getString("POINTEE").trim().length() == 0) {
412
                        actionPointage(rowIndex);
476
                        actionPointage(rowIndex);
413
                    } else {
477
                    } else {
414
                        actionDepointage(rowIndex);
478
                        actionDepointage(rowIndex);
415
                    }
479
                    }
416
                }
480
                }
417
 
481
 
418
                if (e.getButton() == MouseEvent.BUTTON3) {
482
                if (e.getButton() == MouseEvent.BUTTON3) {
419
                    actionMenuDroit(e);
483
                    actionMenuDroit(e);
420
                }
484
                }
421
 
485
 
422
                int[] selectedRows = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
486
                int[] selectedRows = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
423
                int[] idRows = new int[selectedRows.length];
487
                int[] idRows = new int[selectedRows.length];
424
                for (int i = 0; i < idRows.length; i++) {
488
                for (int i = 0; i < idRows.length; i++) {
425
                    idRows[i] = PointagePanel.this.ecriturePanel.getListe().idFromIndex(selectedRows[i]);
489
                    idRows[i] = PointagePanel.this.ecriturePanel.getListe().idFromIndex(selectedRows[i]);
426
                }
490
                }
427
 
491
 
428
                PointagePanel.this.model.updateSelection(idRows);
492
                PointagePanel.this.model.updateSelection(idRows);
429
            }
493
            }
430
        });
494
        });
431
 
495
 
432
        // action sur la IListe
496
        // action sur la IListe
433
        this.ecriturePanel.getListe().getJTable().addKeyListener(new KeyAdapter() {
497
        this.ecriturePanel.getListe().getJTable().addKeyListener(new KeyAdapter() {
434
            @Override
498
            @Override
435
            public void keyReleased(KeyEvent e) {
499
            public void keyReleased(KeyEvent e) {
436
                int[] selectedRows = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
500
                int[] selectedRows = PointagePanel.this.ecriturePanel.getListe().getJTable().getSelectedRows();
437
                int[] idRows = new int[selectedRows.length];
501
                int[] idRows = new int[selectedRows.length];
438
                for (int i = 0; i < idRows.length; i++) {
502
                for (int i = 0; i < idRows.length; i++) {
439
                    idRows[i] = PointagePanel.this.ecriturePanel.getListe().idFromIndex(selectedRows[i]);
503
                    idRows[i] = PointagePanel.this.ecriturePanel.getListe().idFromIndex(selectedRows[i]);
440
                }
504
                }
441
 
505
 
442
                PointagePanel.this.model.updateSelection(idRows);
506
                PointagePanel.this.model.updateSelection(idRows);
443
            }
507
            }
444
        });
508
        });
445
 
509
 
446
        this.ecriturePanel.getListe().addListener(new TableModelListener() {
510
        this.ecriturePanel.getListe().addListener(new TableModelListener() {
447
            @Override
511
            @Override
448
            public void tableChanged(TableModelEvent e) {
512
            public void tableChanged(TableModelEvent e) {
449
                PointagePanel.this.model.updateTotauxCompte();
513
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
450
            }
514
            }
451
        });
515
        });
452
 
516
 
453
        // Gestion du code de releve
517
        // Gestion du code de releve
454
        this.codePointage.getDocument().addDocumentListener(new SimpleDocumentListener() {
518
        this.codePointage.getDocument().addDocumentListener(new SimpleDocumentListener() {
455
 
519
 
456
            @Override
520
            @Override
457
            public void update(DocumentEvent e) {
521
            public void update(DocumentEvent e) {
458
                PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0));
522
                PointagePanel.this.warningPanel.setVisible((PointagePanel.this.codePointage.getText().trim().length() == 0));
459
                PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0));
523
                PointagePanel.this.buttonPointer.setEnabled((PointagePanel.this.codePointage.getText().trim().length() != 0));
460
                PointagePanel.this.model.updateTotauxCompte();
524
                PointagePanel.this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
461
            }
525
            }
462
        });
526
        });
463
 
527
 
464
        changeListRequest();
528
        changeListRequest();
465
        this.warningPanel.setVisible((this.codePointage.getText().trim().length() == 0));
529
        this.warningPanel.setVisible((this.codePointage.getText().trim().length() == 0));
466
        this.buttonPointer.setEnabled((this.codePointage.getText().trim().length() != 0));
530
        this.buttonPointer.setEnabled((this.codePointage.getText().trim().length() != 0));
467
    }
531
    }
468
 
532
 
469
    /* Menu clic Droit */
533
    /* Menu clic Droit */
470
    private void actionMenuDroit(final MouseEvent mE) {
534
    private void actionMenuDroit(final MouseEvent mE) {
471
        JPopupMenu menu = new JPopupMenu();
535
        JPopupMenu menu = new JPopupMenu();
472
 
536
 
473
        menu.add(new AbstractAction("Voir la source") {
537
        menu.add(new AbstractAction("Voir la source") {
474
            public void actionPerformed(ActionEvent e) {
538
            public void actionPerformed(ActionEvent e) {
475
 
539
 
476
                int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
540
                int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
477
                int id = PointagePanel.this.ecriturePanel.getListe().idFromIndex(rowIndex);
541
                int id = PointagePanel.this.ecriturePanel.getListe().idFromIndex(rowIndex);
478
 
542
 
479
                SQLTable ecriture = PointagePanel.this.base.getTable("ECRITURE");
543
                SQLTable ecriture = PointagePanel.this.base.getTable("ECRITURE");
480
                SQLRow rowEcr = ecriture.getRow(id);
544
                SQLRow rowEcr = ecriture.getRow(id);
481
 
545
 
482
                MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
546
                MouvementSQLElement.showSource(rowEcr.getInt("ID_MOUVEMENT"));
483
            }
547
            }
484
        });
548
        });
485
 
549
 
486
        if (this.codePointage.getText().trim().length() != 0) {
550
        if (this.codePointage.getText().trim().length() != 0) {
487
            menu.add(new AbstractAction("Pointer") {
551
            menu.add(new AbstractAction("Pointer") {
488
                public void actionPerformed(ActionEvent e) {
552
                public void actionPerformed(ActionEvent e) {
489
 
553
 
490
                    int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
554
                    int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
491
                    actionPointage(rowIndex);
555
                    actionPointage(rowIndex);
492
                }
556
                }
493
            });
557
            });
494
        }
558
        }
495
 
559
 
496
        menu.add(new AbstractAction("Dépointer") {
560
        menu.add(new AbstractAction("Dépointer") {
497
            public void actionPerformed(ActionEvent e) {
561
            public void actionPerformed(ActionEvent e) {
498
 
562
 
499
                int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
563
                int rowIndex = PointagePanel.this.ecriturePanel.getListe().getJTable().rowAtPoint(mE.getPoint());
500
                actionDepointage(rowIndex);
564
                actionDepointage(rowIndex);
501
            }
565
            }
502
        });
566
        });
503
 
567
 
504
        menu.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y);
568
        menu.show(mE.getComponent(), mE.getPoint().x, mE.getPoint().y);
505
    }
569
    }
506
 
570
 
507
    public Date getDateDeb() {
571
    public Date getDateDeb() {
508
        return this.dateDeb.getValue();
572
        return this.dateDeb.getValue();
509
    }
573
    }
510
 
574
 
511
    public Date getDateFin() {
575
    public Date getDateFin() {
512
        return this.dateFin.getDate();
576
        return this.dateFin.getDate();
513
    }
577
    }
514
 
578
 
515
    public String getCodePointage() {
579
    public String getCodePointage() {
516
        return this.codePointage.getText();
580
        return this.codePointage.getText();
517
    }
581
    }
518
 
582
 
519
    /* Panel Warning no numero releve */
583
    /* Panel Warning no numero releve */
520
    private void createPanelWarning() {
584
    private void createPanelWarning() {
521
 
585
 
522
        this.warningPanel = new JPanel();
586
        this.warningPanel = new JPanel();
523
        this.warningPanel.setLayout(new GridBagLayout());
587
        this.warningPanel.setLayout(new GridBagLayout());
524
        // this.warningPanel.setBorder(BorderFactory.createTitledBorder("Warning"));
588
        // this.warningPanel.setBorder(BorderFactory.createTitledBorder("Warning"));
525
 
589
 
526
        GridBagConstraints c = new GridBagConstraints();
590
        GridBagConstraints c = new GridBagConstraints();
527
        c.anchor = GridBagConstraints.WEST;
591
        c.anchor = GridBagConstraints.WEST;
528
        c.fill = GridBagConstraints.NONE;
592
        c.fill = GridBagConstraints.NONE;
529
        c.gridheight = 1;
593
        c.gridheight = 1;
530
        c.gridwidth = 1;
594
        c.gridwidth = 1;
531
        c.gridx = 0;
595
        c.gridx = 0;
532
        c.gridy = 0;
596
        c.gridy = 0;
533
        c.weightx = 0;
597
        c.weightx = 0;
534
        c.weighty = 0;
598
        c.weighty = 0;
535
 
599
 
536
        final JLabel warningNoCodeImg = new JLabelWarning();
600
        final JLabel warningNoCodeImg = new JLabelWarning();
537
        // warningNoCodeImg.setHorizontalAlignment(SwingConstants.RIGHT);
601
        // warningNoCodeImg.setHorizontalAlignment(SwingConstants.RIGHT);
538
        this.warningPanel.add(warningNoCodeImg, c);
602
        this.warningPanel.add(warningNoCodeImg, c);
539
        final JLabel warningNoCodeText = new JLabel("Impossible de pointer tant que le numéro de relevé n'est pas saisi!");
603
        final JLabel warningNoCodeText = new JLabel("Impossible de pointer tant que le numéro de relevé n'est pas saisi!");
540
        c.gridx++;
604
        c.gridx++;
541
        this.warningPanel.add(warningNoCodeText, c);
605
        this.warningPanel.add(warningNoCodeText, c);
542
    }
606
    }
543
 
607
 
544
    // Pointe la ligne passée en parametre
608
    // Pointe la ligne passée en parametre
545
    private void actionPointage(int rowIndex) {
609
    private void actionPointage(int rowIndex) {
546
        String codePoint = this.codePointage.getText().trim();
610
        String codePoint = this.codePointage.getText().trim();
547
 
611
 
548
        int id = this.ecriturePanel.getListe().idFromIndex(rowIndex);
612
        int id = this.ecriturePanel.getListe().idFromIndex(rowIndex);
549
 
613
 
550
        SQLRow row = this.tableEcr.getRow(id);
614
        SQLRow row = this.tableEcr.getRow(id);
551
        SQLRowValues rowVals = new SQLRowValues(this.tableEcr);
615
        SQLRowValues rowVals = new SQLRowValues(this.tableEcr);
552
 
616
 
553
        // Pointage
617
        // Pointage
554
        // On pointe ou repointe la ligne avec la date et le numero de releve saisis
618
        // On pointe ou repointe la ligne avec la date et le numero de releve saisis
555
        if ((!this.datePointee.isEmpty()) && (codePoint.length() > 0)) {
619
        if ((!this.datePointee.isEmpty()) && (codePoint.length() > 0)) {
556
 
620
 
557
            // Si la ligne est en brouillard on valide le mouvement associé
621
            // Si la ligne est en brouillard on valide le mouvement associé
558
            if (this.boxValidEcriture.isSelected() && (!row.getBoolean("VALIDE"))) {
622
            if (this.boxValidEcriture.isSelected() && (!row.getBoolean("VALIDE"))) {
559
                EcritureSQLElement.validationEcritures(row.getInt("ID_MOUVEMENT"));
623
                EcritureSQLElement.validationEcritures(row.getInt("ID_MOUVEMENT"));
560
            }
624
            }
561
 
625
 
562
            rowVals.put("POINTEE", codePoint);
626
            rowVals.put("POINTEE", codePoint);
563
            rowVals.put("DATE_POINTEE", new java.sql.Date(this.datePointee.getDate().getTime()));
627
            rowVals.put("DATE_POINTEE", new java.sql.Date(this.datePointee.getDate().getTime()));
564
 
628
 
565
            try {
629
            try {
566
                rowVals.update(id);
630
                rowVals.update(id);
567
            } catch (SQLException e1) {
631
            } catch (SQLException e1) {
568
 
632
 
569
                e1.printStackTrace();
633
                e1.printStackTrace();
570
            }
634
            }
571
        }
635
        }
572
        this.model.updateTotauxCompte();
636
        this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
573
    }
637
    }
574
 
638
 
575
    public ListPanelEcritures getEcriturePanel() {
639
    public ListPanelEcritures getEcriturePanel() {
576
        return ecriturePanel;
640
        return ecriturePanel;
577
    }
641
    }
578
 
642
 
579
    // Pointe la ligne passée en parametre
643
    // Pointe la ligne passée en parametre
580
    private void actionDepointage(int rowIndex) {
644
    private void actionDepointage(int rowIndex) {
581
 
645
 
582
        int id = this.ecriturePanel.getListe().idFromIndex(rowIndex);
646
        int id = this.ecriturePanel.getListe().idFromIndex(rowIndex);
583
 
647
 
584
        SQLRow row = this.tableEcr.getRow(id);
648
        SQLRow row = this.tableEcr.getRow(id);
585
        SQLRowValues rowVals = new SQLRowValues(this.tableEcr);
649
        SQLRowValues rowVals = new SQLRowValues(this.tableEcr);
586
 
650
 
587
        // Dépointage
651
        // Dépointage
588
        if (row.getString("POINTEE").trim().length() != 0) {
652
        if (row.getString("POINTEE").trim().length() != 0) {
589
 
653
 
590
            rowVals.put("POINTEE", "");
654
            rowVals.put("POINTEE", "");
591
            rowVals.put("DATE_POINTEE", null);
655
            rowVals.put("DATE_POINTEE", null);
592
 
656
 
593
            try {
657
            try {
594
                rowVals.update(id);
658
                rowVals.update(id);
595
            } catch (SQLException e1) {
659
            } catch (SQLException e1) {
596
                e1.printStackTrace();
660
                e1.printStackTrace();
597
            }
661
            }
598
        }
662
        }
599
        this.model.updateTotauxCompte();
663
        this.model.updateTotauxCompte(PointagePanel.this.fieldSoldeD, PointagePanel.this.fieldSoldeA, PointagePanel.this.fieldEcart);
600
    }
664
    }
601
 
665
 
602
    /*
666
    /*
603
     * MaJ de la requete pour remplir la IListe en fonction du compte sélectionner et du mode de
667
     * MaJ de la requete pour remplir la IListe en fonction du compte sélectionner et du mode de
604
     * sélection
668
     * sélection
605
     */
669
     */
606
    private void changeListRequest() {
670
    private void changeListRequest() {
607
        Object idCpt = this.selCompte.getSelectedId();
671
        Object idCpt = this.selCompte.getSelectedId();
608
 
672
 
609
        // filtre de selection
673
        // filtre de selection
610
 
674
 
611
        Where w = new Where(this.tableEcr.getField("ID_COMPTE_PCE"), "=", idCpt);
675
        Where w = new Where(this.tableEcr.getField("ID_COMPTE_PCE"), "=", idCpt);
612
 
676
 
613
        if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
677
        if (!UserRightsManager.getCurrentUserRights().haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) {
614
            // TODO Show Restricted acces in UI
678
            // TODO Show Restricted acces in UI
615
            w = w.and(new Where(this.tableEcr.getField("COMPTE_NUMERO"), "LIKE", "411%"));
679
            w = w.and(new Where(this.tableEcr.getField("COMPTE_NUMERO"), "LIKE", "411%"));
616
        }
680
        }
617
 
681
 
618
        Date d1 = this.dateDeb.getValue();
682
        Date d1 = this.dateDeb.getValue();
619
        Date d2 = this.dateFin.getValue();
683
        Date d2 = this.dateFin.getValue();
620
 
684
 
621
        if (d1 == null && d2 != null) {
685
        if (d1 == null && d2 != null) {
622
            w = w.and(new Where(this.tableEcr.getField("DATE"), "<=", d2));
686
            w = w.and(new Where(this.tableEcr.getField("DATE"), "<=", d2));
623
        } else {
687
        } else {
624
            if (d1 != null && d2 == null) {
688
            if (d1 != null && d2 == null) {
625
                w = w.and(new Where(this.tableEcr.getField("DATE"), ">=", d1));
689
                w = w.and(new Where(this.tableEcr.getField("DATE"), ">=", d1));
626
            } else {
690
            } else {
627
                if (d1 != null && d2 != null) {
691
                if (d1 != null && d2 != null) {
628
                    w = w.and(new Where(this.tableEcr.getField("DATE"), d1, d2));
692
                    w = w.and(new Where(this.tableEcr.getField("DATE"), d1, d2));
629
                }
693
                }
630
            }
694
            }
631
        }
695
        }
632
 
696
 
633
        if (this.modeSelect == ecriturePointee) {
697
        if (this.modeSelect == ecriturePointee) {
634
            w = w.and(new Where(this.tableEcr.getField("POINTEE"), "!=", ""));
698
            w = w.and(new Where(this.tableEcr.getField("POINTEE"), "!=", ""));
635
        } else {
699
        } else {
636
            if (this.modeSelect == ecritureNotPointee) {
700
            if (this.modeSelect == ecritureNotPointee) {
637
                w = w.and(new Where(this.tableEcr.getField("POINTEE"), "=", ""));
701
                w = w.and(new Where(this.tableEcr.getField("POINTEE"), "=", ""));
638
            }
702
            }
639
        }
703
        }
640
 
704
 
641
        this.ecriturePanel.getListe().getRequest().setWhere(w);
705
        this.ecriturePanel.getListe().getRequest().setWhere(w);
642
        this.ecriturePanel.getListe().setModificationAllowed(false);
706
        this.ecriturePanel.getListe().setModificationAllowed(false);
643
 
707
 
644
        this.model.setIdCompte(Integer.parseInt(idCpt.toString()));
708
        this.model.setIdCompte(Integer.parseInt(idCpt.toString()));
645
    }
709
    }
646
 
710
 
647
    /*
711
    /*
648
     * Panel de sélection du mode d'affichage des ecritures
712
     * Panel de sélection du mode d'affichage des ecritures
649
     */
713
     */
650
    private JPanel createPanelSelectionEcritures() {
714
    private JPanel createPanelSelectionEcritures() {
651
 
715
 
652
        JPanel panelSelectEcritures = new JPanel();
716
        JPanel panelSelectEcritures = new JPanel();
653
 
717
 
654
        GridBagConstraints cPanel = new GridBagConstraints();
718
        GridBagConstraints cPanel = new GridBagConstraints();
655
        cPanel.anchor = GridBagConstraints.NORTHWEST;
719
        cPanel.anchor = GridBagConstraints.NORTHWEST;
656
        cPanel.fill = GridBagConstraints.HORIZONTAL;
720
        cPanel.fill = GridBagConstraints.HORIZONTAL;
657
        cPanel.gridheight = 1;
721
        cPanel.gridheight = 1;
658
        cPanel.gridwidth = 1;
722
        cPanel.gridwidth = 1;
659
        cPanel.gridx = 0;
723
        cPanel.gridx = 0;
660
        cPanel.gridy = 0;
724
        cPanel.gridy = 0;
661
        cPanel.weightx = 0;
725
        cPanel.weightx = 0;
662
        cPanel.weighty = 0;
726
        cPanel.weighty = 0;
663
 
727
 
664
        panelSelectEcritures.setLayout(new GridBagLayout());
728
        panelSelectEcritures.setLayout(new GridBagLayout());
665
 
729
 
666
        final JRadioButton buttonBoth = new JRadioButton("Toutes");
730
        final JRadioButton buttonBoth = new JRadioButton("Toutes");
667
        panelSelectEcritures.add(buttonBoth, cPanel);
731
        panelSelectEcritures.add(buttonBoth, cPanel);
668
        cPanel.gridx++;
732
        cPanel.gridx++;
669
        final JRadioButton buttonNotPointe = new JRadioButton("Non pointées");
733
        final JRadioButton buttonNotPointe = new JRadioButton("Non pointées");
670
        panelSelectEcritures.add(buttonNotPointe, cPanel);
734
        panelSelectEcritures.add(buttonNotPointe, cPanel);
671
        cPanel.gridx++;
735
        cPanel.gridx++;
672
        final JRadioButton buttonPointe = new JRadioButton("Pointées");
736
        final JRadioButton buttonPointe = new JRadioButton("Pointées");
673
        panelSelectEcritures.add(buttonPointe, cPanel);
737
        panelSelectEcritures.add(buttonPointe, cPanel);
674
 
738
 
675
        ButtonGroup group = new ButtonGroup();
739
        ButtonGroup group = new ButtonGroup();
676
        group.add(buttonBoth);
740
        group.add(buttonBoth);
677
        group.add(buttonNotPointe);
741
        group.add(buttonNotPointe);
678
        group.add(buttonPointe);
742
        group.add(buttonPointe);
679
        buttonBoth.setSelected(true);
743
        buttonBoth.setSelected(true);
680
 
744
 
681
        buttonPointe.addActionListener(new ActionListener() {
745
        buttonPointe.addActionListener(new ActionListener() {
682
            public void actionPerformed(ActionEvent e) {
746
            public void actionPerformed(ActionEvent e) {
683
                if (buttonPointe.isSelected()) {
747
                if (buttonPointe.isSelected()) {
684
                    PointagePanel.this.modeSelect = ecriturePointee;
748
                    PointagePanel.this.modeSelect = ecriturePointee;
685
                    changeListRequest();
749
                    changeListRequest();
686
                }
750
                }
687
            }
751
            }
688
        });
752
        });
689
 
753
 
690
        buttonNotPointe.addActionListener(new ActionListener() {
754
        buttonNotPointe.addActionListener(new ActionListener() {
691
            public void actionPerformed(ActionEvent e) {
755
            public void actionPerformed(ActionEvent e) {
692
                if (buttonNotPointe.isSelected()) {
756
                if (buttonNotPointe.isSelected()) {
693
                    PointagePanel.this.modeSelect = ecritureNotPointee;
757
                    PointagePanel.this.modeSelect = ecritureNotPointee;
694
                    changeListRequest();
758
                    changeListRequest();
695
                }
759
                }
696
            }
760
            }
697
        });
761
        });
698
 
762
 
699
        buttonBoth.addActionListener(new ActionListener() {
763
        buttonBoth.addActionListener(new ActionListener() {
700
            public void actionPerformed(ActionEvent e) {
764
            public void actionPerformed(ActionEvent e) {
701
                if (buttonBoth.isSelected()) {
765
                if (buttonBoth.isSelected()) {
702
                    PointagePanel.this.modeSelect = allEcriture;
766
                    PointagePanel.this.modeSelect = allEcriture;
703
                    changeListRequest();
767
                    changeListRequest();
704
                }
768
                }
705
            }
769
            }
706
        });
770
        });
707
 
771
 
708
        return panelSelectEcritures;
772
        return panelSelectEcritures;
709
    }
773
    }
710
 
774
 
711
    /*
775
    /*
712
     * Creation du panel de la legende
776
     * Creation du panel de la legende
713
     */
777
     */
714
    private JPanel createPanelLegende() {
778
    private JPanel createPanelLegende() {
715
        JPanel panelLegende = new JPanel();
779
        JPanel panelLegende = new JPanel();
716
 
780
 
717
        GridBagConstraints c = new GridBagConstraints();
781
        GridBagConstraints c = new GridBagConstraints();
718
        c.anchor = GridBagConstraints.NORTHWEST;
782
        c.anchor = GridBagConstraints.NORTHWEST;
719
        c.fill = GridBagConstraints.HORIZONTAL;
783
        c.fill = GridBagConstraints.HORIZONTAL;
720
        c.gridheight = 1;
784
        c.gridheight = 1;
721
        c.gridwidth = 1;
785
        c.gridwidth = 1;
722
        c.gridx = 0;
786
        c.gridx = 0;
723
        c.gridy = GridBagConstraints.RELATIVE;
787
        c.gridy = GridBagConstraints.RELATIVE;
724
        c.weightx = 0;
788
        c.weightx = 0;
725
        c.weighty = 0;
789
        c.weighty = 0;
726
        c.insets = new Insets(2, 0, 0, 0);
790
        c.insets = new Insets(2, 0, 0, 0);
727
 
791
 
728
        GridBagConstraints cPanel = new GridBagConstraints();
792
        GridBagConstraints cPanel = new GridBagConstraints();
729
        cPanel.anchor = GridBagConstraints.NORTHWEST;
793
        cPanel.anchor = GridBagConstraints.NORTHWEST;
730
        cPanel.fill = GridBagConstraints.HORIZONTAL;
794
        cPanel.fill = GridBagConstraints.HORIZONTAL;
731
        cPanel.gridheight = 1;
795
        cPanel.gridheight = 1;
732
        cPanel.gridwidth = 1;
796
        cPanel.gridwidth = 1;
733
        cPanel.gridx = 0;
797
        cPanel.gridx = 0;
734
        cPanel.gridy = GridBagConstraints.RELATIVE;
798
        cPanel.gridy = GridBagConstraints.RELATIVE;
735
        cPanel.weightx = 0;
799
        cPanel.weightx = 0;
736
        cPanel.weighty = 0;
800
        cPanel.weighty = 0;
737
        cPanel.insets = new Insets(0, 0, 0, 0);
801
        cPanel.insets = new Insets(0, 0, 0, 0);
738
 
802
 
739
        panelLegende.setLayout(new GridBagLayout());
803
        panelLegende.setLayout(new GridBagLayout());
740
        panelLegende.setBorder(BorderFactory.createTitledBorder("Légendes"));
804
        panelLegende.setBorder(BorderFactory.createTitledBorder("Légendes"));
741
 
805
 
742
        JPanel ecritureValidPanel = new JPanel();
806
        JPanel ecritureValidPanel = new JPanel();
743
        ecritureValidPanel.setLayout(new GridBagLayout());
807
        ecritureValidPanel.setLayout(new GridBagLayout());
744
        ecritureValidPanel.setBackground(Color.WHITE);
808
        ecritureValidPanel.setBackground(Color.WHITE);
745
        ecritureValidPanel.add(new JLabel("Ecritures validées"), cPanel);
809
        ecritureValidPanel.add(new JLabel("Ecritures validées"), cPanel);
746
        panelLegende.add(ecritureValidPanel, c);
810
        panelLegende.add(ecritureValidPanel, c);
747
 
811
 
748
        JPanel ecritureNonValidPanel = new JPanel();
812
        JPanel ecritureNonValidPanel = new JPanel();
749
        ecritureNonValidPanel.setLayout(new GridBagLayout());
813
        ecritureNonValidPanel.setLayout(new GridBagLayout());
750
        ecritureNonValidPanel.setBackground(PointageRenderer.getCouleurEcritureNonValide());
814
        ecritureNonValidPanel.setBackground(PointageRenderer.getCouleurEcritureNonValide());
751
        ecritureNonValidPanel.add(new JLabel("Ecritures non validées"), cPanel);
815
        ecritureNonValidPanel.add(new JLabel("Ecritures non validées"), cPanel);
752
        panelLegende.add(ecritureNonValidPanel, c);
816
        panelLegende.add(ecritureNonValidPanel, c);
753
 
817
 
754
        JPanel ecritureNonValidTodayPanel = new JPanel();
818
        JPanel ecritureNonValidTodayPanel = new JPanel();
755
        ecritureNonValidTodayPanel.setLayout(new GridBagLayout());
819
        ecritureNonValidTodayPanel.setLayout(new GridBagLayout());
756
        ecritureNonValidTodayPanel.setBackground(PointageRenderer.getCouleurEcritureToDay());
820
        ecritureNonValidTodayPanel.setBackground(PointageRenderer.getCouleurEcritureToDay());
757
        ecritureNonValidTodayPanel.add(new JLabel("Ecritures non validées du jour"), cPanel);
821
        ecritureNonValidTodayPanel.add(new JLabel("Ecritures non validées du jour"), cPanel);
758
        panelLegende.add(ecritureNonValidTodayPanel, c);
822
        panelLegende.add(ecritureNonValidTodayPanel, c);
759
 
823
 
760
        JPanel ecriturePointePanel = new JPanel();
824
        JPanel ecriturePointePanel = new JPanel();
761
        ecriturePointePanel.setLayout(new GridBagLayout());
825
        ecriturePointePanel.setLayout(new GridBagLayout());
762
        ecriturePointePanel.setBackground(PointageRenderer.getCouleurEcriturePointee());
826
        ecriturePointePanel.setBackground(PointageRenderer.getCouleurEcriturePointee());
763
        ecriturePointePanel.add(new JLabel("Ecritures pointées"), cPanel);
827
        ecriturePointePanel.add(new JLabel("Ecritures pointées"), cPanel);
764
        panelLegende.add(ecriturePointePanel, c);
828
        panelLegende.add(ecriturePointePanel, c);
765
 
829
 
766
        return panelLegende;
830
        return panelLegende;
767
    }
831
    }
768
}
832
}