use of org.knime.core.data.property.ShapeSelectionComboBoxRenderer in project knime-core by knime.
the class ShapeManagerNodeDialogPane method columnChanged.
private void columnChanged(final String column) {
final LinkedHashMap<DataCell, Shape> domMap = m_map.get(column);
TableModel tableModel = new DefaultTableModel() {
private final DataCell[] m_valueNames = new DataCell[domMap.size()];
{
int row = 0;
for (DataCell cell : domMap.keySet()) {
m_valueNames[row] = cell;
row++;
}
}
@Override
public String getColumnName(final int columnIdx) {
if (columnIdx == 1) {
return "Shapes";
} else {
return "Values of " + column;
}
}
@Override
public boolean isCellEditable(final int row, final int columnIdx) {
return (columnIdx == 1);
}
@Override
public int getRowCount() {
return domMap.size();
}
@Override
public int getColumnCount() {
return 2;
}
@Override
public Class<?> getColumnClass(final int columnIndex) {
if (columnIndex == 1) {
return Shape.class;
} else {
return DataCell.class;
}
}
@Override
public Object getValueAt(final int row, final int columnIndex) {
if (columnIndex == 1) {
return domMap.get(m_valueNames[row]);
} else {
return m_valueNames[row];
}
}
@Override
public void setValueAt(final Object aValue, final int row, final int columnIdx) {
assert aValue instanceof Shape;
assert columnIdx == 1;
domMap.put(m_valueNames[row], (Shape) aValue);
}
};
m_valueTable.setModel(tableModel);
m_valueTable.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(new ShapeSelectionComboBox()));
m_valueTable.getColumnModel().getColumn(1).setCellRenderer(new ShapeSelectionComboBoxRenderer());
}
Aggregations