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.Utils;
12: import org.air.framework.gui.lookup.LookupObject;
13: import org.air.framework.gui.table_view.table.Table;
14: import org.airtodo.gui_common.components.lookup_data.LookupDataPriority;
15: import org.airtodo.gui_common.components.lookup_data.LookupDataPriorityCustomer;
16: import org.airtodo.gui_common.components.lookup_data.LookupDataPriorityNote;
17: import org.airtodo.records.Customers;
18: import org.airtodo.records.Initiators;
19: import org.airtodo.records.Notes;
20:
21: public class Note extends Header {
22: public Note() {
23: put(Notes.TIMESTAMP, new ColumnDecorations(true, 5));
24: put(Initiators.NAME, new ColumnDecorations(true, 5));
25: put(Initiators.COMMENT, new ColumnDecorations(false, 5));
26: put(Notes.PRIORITY, new ColumnDecorations(true, 5));
27: put(Notes.SUBJECT, new ColumnDecorations(true, 5));
28: put(Notes.NOTE, new ColumnDecorations(true, 5));
29: }
30:
31: @Override
32: public Class getRecordClass() {
33: return Notes.class;
34: }
35:
36: public Component getCellRendererComponent(
37: DefaultTableCellRenderer defaultTableCellRenderer,
38: Object columnIdentifier, Object recordId, Table table,
39: Object value, boolean isSelected, int row, int column) {
40: if (value == null)
41: return null;
42: if (columnIdentifier.equals(Utils
43: .getColumnIdentifier(Notes.PRIORITY))) {
44: int intValue = ((LookupObject) value).getValue();
45: LookupDataPriority lookupData = new LookupDataPriorityNote();
46: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
47: defaultTableCellRenderer.setIcon(icon);
48: defaultTableCellRenderer
49: .setHorizontalAlignment(JLabel.CENTER);
50: return defaultTableCellRenderer;
51: }
52: return null;
53: }
54:
55: }
|