All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bidib.wizard.dcca.client.view.DecoderUniqueIdCellRenderer Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy