18 |
ilm |
1 |
/*
|
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
|
|
3 |
*
|
|
|
4 |
* Copyright 2011 OpenConcerto, by ILM Informatique. All rights reserved.
|
|
|
5 |
*
|
|
|
6 |
* The contents of this file are subject to the terms of the GNU General Public License Version 3
|
|
|
7 |
* only ("GPL"). You may not use this file except in compliance with the License. You can obtain a
|
|
|
8 |
* copy of the License at http://www.gnu.org/licenses/gpl-3.0.html See the License for the specific
|
|
|
9 |
* language governing permissions and limitations under the License.
|
|
|
10 |
*
|
|
|
11 |
* When distributing the software, include this License Header Notice in each file.
|
|
|
12 |
*/
|
|
|
13 |
|
|
|
14 |
package org.openconcerto.erp.core.finance.accounting.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.finance.accounting.model.ConsultCompteModel;
|
|
|
17 |
import org.openconcerto.erp.element.objet.Ecriture;
|
|
|
18 |
import org.openconcerto.ui.table.TableCellRendererUtils;
|
|
|
19 |
import org.openconcerto.utils.GestionDevise;
|
|
|
20 |
import org.openconcerto.utils.TableSorter;
|
|
|
21 |
|
|
|
22 |
import java.awt.Color;
|
|
|
23 |
import java.awt.Component;
|
|
|
24 |
import java.text.DateFormat;
|
|
|
25 |
import java.util.Date;
|
|
|
26 |
import java.util.Locale;
|
|
|
27 |
|
|
|
28 |
import javax.swing.JTable;
|
|
|
29 |
import javax.swing.table.DefaultTableCellRenderer;
|
|
|
30 |
|
|
|
31 |
public class EcritureGrandLivreRenderer extends DefaultTableCellRenderer {
|
|
|
32 |
|
|
|
33 |
private TableSorter model;
|
142 |
ilm |
34 |
private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
|
18 |
ilm |
35 |
private final static Color couleurEcritureValide = new Color(253, 243, 204);
|
|
|
36 |
private final static Color couleurEcritureToDay = new Color(225, 254, 207);
|
|
|
37 |
|
|
|
38 |
public EcritureGrandLivreRenderer(TableSorter model) {
|
|
|
39 |
this.model = model;
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
|
43 |
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
|
44 |
TableCellRendererUtils.setBackgroundColor(this, table, isSelected);
|
|
|
45 |
|
|
|
46 |
if (!isSelected) {
|
|
|
47 |
Ecriture ecrTmp = ((ConsultCompteModel) this.model.getTableModel()).getEcritures().get(this.model.viewIndex(row));
|
|
|
48 |
|
|
|
49 |
if (!ecrTmp.getValide()) {
|
|
|
50 |
Date dateEcr = ecrTmp.getDate();
|
|
|
51 |
Date dateToDay = new Date();
|
|
|
52 |
if ((dateEcr.getDate() == dateToDay.getDate()) && (dateEcr.getMonth() == dateToDay.getMonth()) && (dateEcr.getYear() == dateToDay.getYear())) {
|
|
|
53 |
this.setBackground(couleurEcritureToDay);
|
|
|
54 |
} else {
|
|
|
55 |
this.setBackground(couleurEcritureValide);
|
|
|
56 |
}
|
|
|
57 |
}
|
|
|
58 |
}
|
174 |
ilm |
59 |
if (value != null) {
|
|
|
60 |
if (value instanceof Date) {
|
|
|
61 |
this.setText(dateFormat.format((Date) value));
|
|
|
62 |
} else if (value.getClass() == Long.class) {
|
|
|
63 |
this.setText(GestionDevise.currencyToString(((Long) value).longValue()));
|
|
|
64 |
}
|
18 |
ilm |
65 |
}
|
|
|
66 |
return this;
|
|
|
67 |
}
|
|
|
68 |
}
|