org.bidib.wizard.dcca.client.view.DecoderUniqueIdCellRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bidibwizard-dcca-client Show documentation
Show all versions of bidibwizard-dcca-client Show documentation
jBiDiB BiDiB Wizard DCC-A client POM
The newest version!
package org.bidib.wizard.dcca.client.view;
import java.awt.Component;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import org.bidib.jbidibc.messages.DecoderIdAddressData;
public class DecoderUniqueIdCellRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
public DecoderUniqueIdCellRenderer() {
}
@Override
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof DecoderIdAddressData) {
DecoderIdAddressData val = (DecoderIdAddressData) value;
setText(getFormattedDecoderUniqueId(val));
}
else {
setText(null);
}
return this;
}
public String getFormattedDecoderUniqueId(DecoderIdAddressData decoderUniqueId) {
if (decoderUniqueId != null) {
return String.format("%04X %08X", decoderUniqueId.getManufacturedId(), decoderUniqueId.getDid());
}
return null;
}
}