142 |
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.sales.product.ui;
|
|
|
15 |
|
|
|
16 |
import org.openconcerto.erp.core.common.ui.DeviseNiceTableCellRenderer;
|
|
|
17 |
import org.openconcerto.sql.model.SQLRowValues;
|
|
|
18 |
import org.openconcerto.sql.view.list.RowValuesTable;
|
|
|
19 |
import org.openconcerto.sql.view.list.RowValuesTableModel;
|
|
|
20 |
import org.openconcerto.ui.table.AlternateTableCellRenderer;
|
177 |
ilm |
21 |
import org.openconcerto.ui.table.XTableColumnModel;
|
142 |
ilm |
22 |
import org.openconcerto.utils.CollectionUtils;
|
|
|
23 |
|
|
|
24 |
import java.awt.Color;
|
|
|
25 |
import java.awt.Component;
|
|
|
26 |
|
|
|
27 |
import javax.swing.JLabel;
|
|
|
28 |
import javax.swing.JTable;
|
|
|
29 |
import javax.swing.SwingConstants;
|
|
|
30 |
|
|
|
31 |
public class DeliveredQtyRowValuesRenderer extends DeviseNiceTableCellRenderer {
|
|
|
32 |
|
|
|
33 |
// Red
|
|
|
34 |
public static final Color red = new Color(255, 31, 52);
|
|
|
35 |
public static final Color redLightGrey = new Color(240, 65, 85);
|
|
|
36 |
|
|
|
37 |
// Orange
|
|
|
38 |
public final static Color orange = new Color(243, 125, 75);
|
|
|
39 |
public final static Color orangeGrey = new Color(222, 107, 47);
|
|
|
40 |
|
|
|
41 |
// Blue
|
|
|
42 |
public final static Color light = new Color(232, 238, 250);
|
|
|
43 |
public final static Color lightGrey = new Color(211, 220, 222);
|
|
|
44 |
|
|
|
45 |
// Black
|
|
|
46 |
public final static Color lightBlack = new Color(192, 192, 192);
|
|
|
47 |
public final static Color lightBlackGrey = new Color(155, 155, 155);
|
|
|
48 |
|
174 |
ilm |
49 |
private final boolean customer;
|
|
|
50 |
|
142 |
ilm |
51 |
public DeliveredQtyRowValuesRenderer() {
|
174 |
ilm |
52 |
this(true);
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
public DeliveredQtyRowValuesRenderer(boolean customer) {
|
142 |
ilm |
56 |
AlternateTableCellRenderer.setBGColorMap(this, CollectionUtils.createMap(lightBlack, lightBlackGrey, red, redLightGrey, orange, orangeGrey));
|
174 |
ilm |
57 |
this.customer = customer;
|
142 |
ilm |
58 |
}
|
|
|
59 |
|
|
|
60 |
@Override
|
|
|
61 |
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
|
62 |
|
|
|
63 |
Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
|
|
64 |
|
|
|
65 |
if (table instanceof RowValuesTable) {
|
|
|
66 |
|
|
|
67 |
((JLabel) comp).setHorizontalAlignment(SwingConstants.RIGHT);
|
177 |
ilm |
68 |
RowValuesTable rowValuesTable = (RowValuesTable) table;
|
|
|
69 |
XTableColumnModel columnModel = rowValuesTable.getColumnModel();
|
|
|
70 |
RowValuesTableModel model = rowValuesTable.getRowValuesTableModel();
|
|
|
71 |
boolean qteALivrerVisible = columnModel.isColumnVisible(columnModel.getColumnByModelIndex(model.getColumnForField("QTE_A_LIVRER")));
|
|
|
72 |
if (qteALivrerVisible) {
|
|
|
73 |
SQLRowValues rowVals = model.getRowValuesAt(row);
|
142 |
ilm |
74 |
|
177 |
ilm |
75 |
Number qte;
|
|
|
76 |
Number qteL;
|
|
|
77 |
if (this.customer) {
|
|
|
78 |
qte = (Number) rowVals.getObject("QTE");
|
|
|
79 |
qteL = (Number) rowVals.getObject("QTE_LIVREE");
|
|
|
80 |
} else {
|
|
|
81 |
qte = (Number) rowVals.getObject("QTE_ORIGINE");
|
|
|
82 |
qteL = (Number) rowVals.getObject("QTE");
|
142 |
ilm |
83 |
}
|
177 |
ilm |
84 |
if (qte != null && qteL != null) {
|
|
|
85 |
if (qte.intValue() < qteL.intValue()) {
|
|
|
86 |
comp.setBackground(red);
|
|
|
87 |
} else if (qteL.intValue() <= 0) {
|
|
|
88 |
comp.setBackground(lightBlack);
|
|
|
89 |
} else if (qteL.intValue() != qte.intValue()) {
|
|
|
90 |
comp.setBackground(orange);
|
|
|
91 |
}
|
|
|
92 |
}
|
142 |
ilm |
93 |
}
|
|
|
94 |
}
|
|
|
95 |
return comp;
|
|
|
96 |
}
|
|
|
97 |
}
|