OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 18 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 19
Line 11... Line 11...
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.sql.model.SQLRowValues;
-
 
17
import org.openconcerto.sql.view.list.ITableModel;
-
 
18
import org.openconcerto.utils.GestionDevise;
16
import javax.swing.table.TableCellRenderer;
19
 
17
 
20
import java.awt.Color;
-
 
21
import java.awt.Component;
-
 
22
import java.math.BigInteger;
18
public class PointageRenderer extends EcritureCheckedRenderer {
23
import java.text.DateFormat;
-
 
24
import java.util.Date;
-
 
25
import java.util.Locale;
-
 
26
 
19
 
27
import javax.swing.JTable;
-
 
28
import javax.swing.table.DefaultTableCellRenderer;
20
    static public final EcritureUtils<PointageRenderer> UTILS = new EcritureUtils<PointageRenderer>(PointageRenderer.class);
29
 
21
 
30
public class PointageRenderer extends DefaultTableCellRenderer {
22
    public PointageRenderer(final TableCellRenderer r) {
31
 
-
 
32
    private static final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.FRENCH);
-
 
33
    private final static Color couleurEcritureNonValide = new Color(253, 243, 204);
-
 
34
    // private final static Color couleurEcritureToDay = new Color(255, 252, 236);
-
 
35
    private final static Color couleurEcritureToDay = new Color(225, 254, 207);
-
 
36
 
-
 
37
    private final static Color couleurEcriturePointee = new Color(255, 232, 245);
-
 
38
 
-
 
39
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
 
40
 
-
 
41
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
 
42
 
-
 
43
        // System.out.println("Cell renderer ON :: " + row);
-
 
44
 
-
 
45
        if (!isSelected) {
-
 
46
            final SQLRowValues ecritureRow = ITableModel.getLine(table.getModel(), row).getRow();
-
 
47
            if (!ecritureRow.getBoolean("VALIDE")) {
-
 
48
                // this.setForeground(couleurEcritureNonValide);
-
 
49
                Date dateEcr = ((Date) ecritureRow.getObject("DATE"));
-
 
50
                Date dateToDay = new Date();
-
 
51
 
-
 
52
                if ((dateEcr.getDate() == dateToDay.getDate()) && (dateEcr.getMonth() == dateToDay.getMonth()) && (dateEcr.getYear() == dateToDay.getYear())) {
-
 
53
                    // System.out.println("ToDay :: " + dateToDay + " Ecr ::: " + dateEcr);
-
 
54
 
-
 
55
                    this.setBackground(couleurEcritureToDay);
-
 
56
                } else {
-
 
57
                    this.setBackground(couleurEcritureNonValide);
-
 
58
                }
-
 
59
            } else {
-
 
60
                // this.setForeground(Color.BLACK);
-
 
61
                this.setBackground(Color.WHITE);
-
 
62
            }
-
 
63
 
-
 
64
            if (ecritureRow.getString("POINTEE").trim().length() > 0) {
-
 
65
                this.setBackground(couleurEcriturePointee);
-
 
66
            }
-
 
67
        }
-
 
68
 
-
 
69
        if (value instanceof Date) {
-
 
70
            this.setText(dateFormat.format((Date) value));
-
 
71
        }
-
 
72
 
-
 
73
        if (value != null && (table.getColumnClass(column) == BigInteger.class || value.getClass() == Long.class)) {
-
 
74
            this.setText(GestionDevise.currencyToString(((Long) value).longValue()));
-
 
75
        }
-
 
76
 
-
 
77
        return this;
23
        super(r, "POINTEE");
78
    }
-
 
79
 
-
 
80
    public static Color GetCouleurEcritureNonValide() {
-
 
81
        return couleurEcritureNonValide;
-
 
82
    }
-
 
83
 
-
 
84
    public static Color getCouleurEcritureToDay() {
-
 
85
        return couleurEcritureToDay;
-
 
86
    }
-
 
87
 
-
 
88
    public static Color getCouleurEcriturePointee() {
-
 
89
        return couleurEcriturePointee;
-
 
90
    }
24
    }
91
}
25
}