01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings.table;
14:
15: import org.wings.SComponent;
16: import org.wings.SIcon;
17: import org.wings.SLabel;
18: import org.wings.STable;
19:
20: /**
21: * @author <a href="mailto:holger.engels@mercatis.de">Holger Engels</a>
22: */
23: public class SDefaultTableCellRenderer extends SLabel implements
24: STableCellRenderer {
25: SIcon editIcon;
26:
27: /**
28: * The icon to display if the cell value is <code>null</code> .
29: */
30: public SIcon getEditIcon() {
31: return editIcon;
32: }
33:
34: /**
35: * The icon to display if the cell value is <code>null</code> .
36: * Can be any abritriary icon. <p/>Example:<br/>
37: * <code>setEditIcon(getSession().getCGManager().getIcon("TableCG.editIcon"));</code>
38: */
39: public void setEditIcon(SIcon editIcon) {
40: this .editIcon = editIcon;
41: }
42:
43: public SComponent getTableCellRendererComponent(STable table,
44: Object value, boolean selected, int row, int col) {
45: setText(null);
46: setIcon(null);
47:
48: if (value == null) {
49: if (editIcon != null && table.isEditable()
50: && table.isCellEditable(row, col))
51: setIcon(editIcon);
52: } else if (value instanceof SIcon)
53: setIcon((SIcon) value);
54: else if (value instanceof SComponent)
55: return (SComponent) value;
56: else
57: setText(value.toString());
58:
59: return this;
60: }
61: }
|