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.gui.lookup.LookupObject;
12: import org.air.framework.gui.table_view.table.Table;
13: import org.air.framework.records.Attachments;
14: import org.airtodo.db.types.AttachmentType;
15: import org.airtodo.gui_common.components.lookup_data.LookupDataAttachment;
16:
17: public class Attachment extends Header {
18: public Attachment() {
19: put(Attachments.TYPE, new ColumnDecorations(true, 5));
20: put(Attachments.NAME, new ColumnDecorations(true, 60));
21: put(Attachments.DESCRIPTION, new ColumnDecorations(true, 35));
22: put(Attachments.COMMENT, new ColumnDecorations(false, 20));
23: }
24:
25: @Override
26: public Class getRecordClass() {
27: return Attachments.class;
28: }
29:
30: public Component getCellRendererComponent(
31: DefaultTableCellRenderer defaultTableCellRenderer,
32: Object columnIdentifier, Object recordId, Table table,
33: Object value, boolean isSelected, int row, int column) {
34: if (value instanceof AttachmentType) {
35: int intValue = ((LookupObject) value).getValue();
36: LookupDataAttachment lookupData = new LookupDataAttachment();
37: Icon icon = (Icon) lookupData.getTextsAndIcons()[intValue][1];
38: defaultTableCellRenderer.setIcon(icon);
39: defaultTableCellRenderer
40: .setHorizontalAlignment(JLabel.CENTER);
41: defaultTableCellRenderer.setText("");
42: return defaultTableCellRenderer;
43: }
44: return null;
45: }
46: }
|