OpenConcerto

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

svn://code.openconcerto.org/openconcerto

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
180 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.ui.table.TableCellRendererUtils;
17
import org.openconcerto.utils.GestionDevise;
18
 
19
import java.awt.Component;
20
import java.text.DateFormat;
21
import java.text.SimpleDateFormat;
22
import java.util.Date;
23
 
24
import javax.swing.JTable;
25
import javax.swing.SwingConstants;
26
import javax.swing.table.DefaultTableCellRenderer;
27
 
28
public class PropoLettrageRenderer extends DefaultTableCellRenderer {
29
 
30
    private final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
31
 
32
    public PropoLettrageRenderer() {
33
 
34
    }
35
 
36
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
37
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
38
        TableCellRendererUtils.setBackgroundColor(this, table, isSelected);
39
 
40
        if (value != null) {
41
            if (value instanceof Date) {
42
                this.setHorizontalAlignment(SwingConstants.RIGHT);
43
                this.setText(dateFormat.format((Date) value));
44
            } else if (value.getClass() == Long.class) {
45
                this.setHorizontalAlignment(SwingConstants.RIGHT);
46
                this.setText(GestionDevise.currencyToString(((Long) value).longValue()));
47
            }
48
        }
49
        return this;
50
    }
51
}