OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Details | Compare with Previous | Last modification | View Log | RSS feed

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