org.yamcs.ui.packetviewer.PacketsTableModel Maven / Gradle / Ivy
The newest version!
package org.yamcs.ui.packetviewer;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import org.yamcs.parameter.ParameterValue;
import org.yamcs.parameter.Value;
import org.yamcs.utils.TimeEncoding;
import org.yamcs.utils.ValueUtility;
import org.yamcs.xtce.Parameter;
public class PacketsTableModel extends DefaultTableModel {
private static final long serialVersionUID = 1L;
private static final String[] FIXED_COLUMNS = { "#", "Generation Time", "Packet Name" };
private int continuousRowCount = 0; // Always increases, even when rows were removed
private List shownColumnParameters = new ArrayList<>();
public PacketsTableModel() {
super(FIXED_COLUMNS, 0);
}
@Override
public Class> getColumnClass(int column) {
if (column == 0) {
return Integer.class;
} else if (column == 1) {
return Long.class;
} else if (column == 2) {
return ListPacket.class;
} else {
return Object.class;
}
}
@Override
public String getColumnName(int column) {
if (column < FIXED_COLUMNS.length) {
return FIXED_COLUMNS[column];
} else {
return shownColumnParameters.get(column - FIXED_COLUMNS.length).getName();
}
}
public int getFixedColumnsSize() {
return FIXED_COLUMNS.length;
}
public void addParameterColumn(Parameter p) {
shownColumnParameters.add(p);
addColumn(p.getName());
}
public Parameter getParameter(int column) {
if (column < FIXED_COLUMNS.length) {
return null;
} else {
return shownColumnParameters.get(column - FIXED_COLUMNS.length);
}
}
public void resetParameterColumns() {
shownColumnParameters = new ArrayList<>();
setColumnCount(FIXED_COLUMNS.length);
fireTableStructureChanged();
}
public void addPacket(ListPacket packet) {
packet.setIdentifier(++continuousRowCount);
List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy