01: package org.airtodo.headers;
02:
03: import java.awt.Component;
04:
05: import javax.swing.Icon;
06: import javax.swing.JLabel;
07: import javax.swing.table.DefaultTableCellRenderer;
08:
09: import org.air.framework.core.ColumnDecorations;
10: import org.air.framework.core.Header;
11: import org.air.framework.core.Registry;
12: import org.air.framework.core.Utils;
13: import org.air.framework.gui.lookup.LookupObject;
14: import org.air.framework.gui.table_view.table.Table;
15: import org.air.framework.properties.Icons;
16: import org.airtodo.gui_common.components.lookup_data.LookupDataPriority;
17: import org.airtodo.gui_common.components.lookup_data.LookupDataPriorityCustomer;
18: import org.airtodo.records.Customers;
19:
20: public class Customer extends Header {
21: public Customer() {
22: put(Customers.NAME, new ColumnDecorations(true, 150));
23: put(Customers.PRIORITY, new ColumnDecorations(true, 60));
24: put(Customers.ADDRESS, new ColumnDecorations(false, 150));
25: put(Customers.PHONE, new ColumnDecorations(false, 100));
26: put(Customers.EMAIL, new ColumnDecorations(false, 100));
27: put(Customers.COMMENT, new ColumnDecorations(true, 300));
28: }
29:
30: @Override
31: public Class getRecordClass() {
32: return Customers.class;
33: }
34:
35: public Component getCellRendererComponent(
36: DefaultTableCellRenderer defaultTableCellRenderer,
37: Object columnIdentifier, Object recordId, Table table,
38: Object value, boolean isSelected, int row, int column) {
39: if (value == null)
40: return null;
41: if (columnIdentifier.equals(Utils
42: .getColumnIdentifier(Customers.NAME))) {
43: defaultTableCellRenderer
44: .setHorizontalAlignment(JLabel.LEFT);
45: Object defaultId = Registry.getDefaultId().get(
46: getRecordClass());
47: Icon icon;
48: if (defaultId != null && recordId.equals(defaultId))
49: icon = Icons.CIRCLE_BLUE;
50: else
51: icon = Icons.CIRCLE_WHITE;
52: defaultTableCellRenderer.setIcon(icon);
53: } else if (columnIdentifier.equals(Utils
54: .getColumnIdentifier(Customers.PRIORITY))) {
55: int intValue = ((LookupObject) value).getValue();
56: LookupDataPriority lookupData = new LookupDataPriorityCustomer();
57: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
58: defaultTableCellRenderer.setIcon(icon);
59: defaultTableCellRenderer
60: .setHorizontalAlignment(JLabel.CENTER);
61: return defaultTableCellRenderer;
62: }
63: return null;
64: }
65:
66: }
|