use of de.embl.rieslab.emu.configuration.ui.utils.IconTableCellRenderer in project micro-manager by micro-manager.
the class ParametersTable method createTable.
private void createTable(DefaultTableModel model) {
table = new JTable(model) {
private static final long serialVersionUID = 1L;
@Override
public TableCellRenderer getCellRenderer(int row, int column) {
switch(column) {
case 0:
return new BoldTableCellRenderer();
case 1:
String s = (String) table.getValueAt(row, 0);
if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.COLOR)) {
// if Color parameter
return new IconTableCellRenderer();
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.BOOL)) {
// if checkbox
return super.getDefaultRenderer(Boolean.class);
} else {
return new DefaultTableCellRenderer();
}
default:
return super.getCellRenderer(row, column);
}
}
@Override
public TableCellEditor getCellEditor(int row, int column) {
switch(column) {
case 0:
return super.getCellEditor(row, column);
case 1:
String s = (String) table.getValueAt(row, 0);
if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.COLOR)) {
return new DefaultCellEditor(color);
} else if (uiparameterSet_.get(s) instanceof ComboUIParameter) {
return new DefaultCellEditor(new JComboBox<String>(((ComboUIParameter) uiparameterSet_.get(s)).getComboValues()));
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.BOOL)) {
return super.getDefaultEditor(Boolean.class);
} else if (uiparameterSet_.get(s).getType().equals(UIParameter.UIParameterType.UIPROPERTY)) {
return new DefaultCellEditor(new JComboBox<String>(getAvailableProperties((UIPropertyParameter) uiparameterSet_.get(s))));
} else {
return new DefaultCellEditor(new JTextField());
}
default:
return super.getCellEditor(row, column);
}
}
@Override
public boolean isCellEditable(int row, int col) {
// only second column is editable
if (col < 1) {
return false;
} else {
return true;
}
}
};
table.setAutoCreateRowSorter(false);
table.setRowHeight(23);
table.addMouseListener(new java.awt.event.MouseAdapter() {
@Override
public void mouseClicked(java.awt.event.MouseEvent evt) {
int row = table.rowAtPoint(evt.getPoint());
updateHelper(row);
}
});
}
Aggregations