OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 156
Line 21... Line 21...
21
import javax.swing.JTable;
21
import javax.swing.JTable;
22
import javax.swing.table.DefaultTableCellRenderer;
22
import javax.swing.table.DefaultTableCellRenderer;
23
 
23
 
24
public class GestionChequesRenderer extends DefaultTableCellRenderer {
24
public class GestionChequesRenderer extends DefaultTableCellRenderer {
25
 
25
 
26
    private final static Color couleurChequeValide = new Color(255, 128, 64);
26
    private static final Color CHEQUE_VALIDE_COLOR = new Color(255, 128, 64);
27
    private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
27
    private final DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
28
 
28
 
29
    @Override
29
    @Override
30
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
30
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
31
        final Component res = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
31
        final Component res = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
32
        final Color fgColor;
32
        final Color fgColor;
33
        if (!isSelected && System.currentTimeMillis() > ((Date) value).getTime()) {
33
        if (value != null && !isSelected && System.currentTimeMillis() > ((Date) value).getTime()) {
34
            fgColor = couleurChequeValide;
34
            fgColor = CHEQUE_VALIDE_COLOR;
35
        } else {
35
        } else {
36
            fgColor = table.getForeground();
36
            fgColor = table.getForeground();
37
        }
37
        }
38
        res.setForeground(fgColor);
38
        res.setForeground(fgColor);
39
        return res;
39
        return res;
40
    }
40
    }
41
 
41
 
42
    @Override
42
    @Override
43
    protected void setValue(Object value) {
43
    protected void setValue(Object value) {
-
 
44
        if (value == null) {
-
 
45
            super.setValue(null);
-
 
46
        } else {
44
        super.setValue(dateFormat.format((Date) value));
47
            super.setValue(dateFormat.format((Date) value));
-
 
48
        }
45
    }
49
    }
46
}
50
}