| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.app.bss; |
| 27 |
|
| 28 |
import java.awt.Component; |
| 29 |
|
| 30 |
import javax.swing.DefaultCellEditor; |
| 31 |
import javax.swing.JComboBox; |
| 32 |
import javax.swing.JTable; |
| 33 |
|
| 34 |
|
| 35 |
@SuppressWarnings("serial") |
| 36 |
public class JTableComboBoxCellEditor extends DefaultCellEditor { |
| 37 |
|
| 38 |
private PartitionDataList dataList = null; |
| 39 |
|
| 40 |
public JTableComboBoxCellEditor(PartitionDataList dataList) { |
| 41 |
super(new JComboBox()); |
| 42 |
this.dataList = dataList; |
| 43 |
} |
| 44 |
|
| 45 |
@SuppressWarnings("unchecked") |
| 46 |
public Component getTableCellEditorComponent(JTable table, |
| 47 |
Object value, boolean isSelected, int row, int column) { |
| 48 |
|
| 49 |
((JComboBox)editorComponent).removeAllItems(); |
| 50 |
|
| 51 |
if (column == PartitionTableModel.DATA_INDEX) { |
| 52 |
|
| 53 |
for (TreesTableRecord record : dataList.recordsList) { |
| 54 |
((JComboBox)editorComponent).addItem(record); |
| 55 |
} |
| 56 |
|
| 57 |
} else if (column == PartitionTableModel.DATA_TYPE_INDEX) { |
| 58 |
|
| 59 |
for (String dataType : PartitionData.dataTypes) { |
| 60 |
((JComboBox)editorComponent).addItem(dataType); |
| 61 |
} |
| 62 |
|
| 63 |
} else { |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
((JComboBox)editorComponent).setSelectedItem(value); |
| 70 |
delegate.setValue(value); |
| 71 |
|
| 72 |
return editorComponent; |
| 73 |
} |
| 74 |
|
| 75 |
public void setDataList(PartitionDataList dataList) { |
| 76 |
this.dataList = dataList; |
| 77 |
} |
| 78 |
|
| 79 |
} |