01: package org.osbl.client.wings.form;
02:
03: import org.wings.*;
04: import org.wingx.table.EditableTableCellRenderer;
05: import org.conform.AbstractDomainProvider;
06:
07: import javax.swing.*;
08: import java.awt.event.ActionListener;
09: import java.awt.event.ActionEvent;
10: import java.util.List;
11: import java.util.ArrayList;
12:
13: public class DomainEditableCellRenderer extends SComboBox implements
14: EditableTableCellRenderer, ActionListener {
15: public DomainEditableCellRenderer(
16: final AbstractDomainProvider domainProvider) {
17: List domain = new ArrayList(domainProvider.getDomain());
18: if (domain.get(0) != null)
19: domain.add(0, null);
20:
21: setModel(new DefaultComboBoxModel(domain.toArray()));
22: setRenderer(new SDefaultListCellRenderer() {
23: public SComponent getListCellRendererComponent(
24: SComponent list, Object value, boolean selected,
25: int row) {
26: value = value != null ? domainProvider.format(value)
27: : null;
28: return super .getListCellRendererComponent(list, value,
29: selected, row);
30: }
31: });
32: addActionListener(this );
33: }
34:
35: public SComponent getTableCellRendererComponent(STable table,
36: Object value, boolean isSelected, int row, int column) {
37: setSelectedItem(value);
38: return this ;
39: }
40:
41: public Object getValue() {
42: return getSelectedItem();
43: }
44:
45: public LowLevelEventListener getLowLevelEventListener(STable table,
46: int row, int col) {
47: return this ;
48: }
49:
50: public void actionPerformed(ActionEvent e) {
51: }
52: }
|