package org.openslx.dozmod.gui.control.table; import org.openslx.bwlp.thrift.iface.ImageSummaryRead; import org.openslx.dozmod.thrift.MetaDataCache; import org.openslx.dozmod.thrift.UserCache; import org.openslx.dozmod.util.FormatHelper; @SuppressWarnings("serial") public class ImageTable extends ListTable { private static String[] columnNames = { "Name", "OS", "Verantwortlicher", "Letztes Update", "Größe", "Version", "Vorlage" }; public ImageTable() { super(columnNames); } @Override protected Object getValueAtInternal(int rowIndex, int columnIndex) { ImageSummaryRead row = get(rowIndex); if (columnIndex == 0) return row.getImageName(); if (columnIndex == 1) return FormatHelper.osName(MetaDataCache.getOsById(row.getOsId())); if (columnIndex == 2) return FormatHelper.userName(UserCache.find(row.getOwnerId())); if (columnIndex == 3) return FormatHelper.longDate(row.getUpdateTime()); if (columnIndex == 4) return row.getCurrentVersionId() == null ? "-" : FormatHelper.bytes(row.getFileSize(), false); if (columnIndex == 5) return row.getCurrentVersionId() == null ? "-" : row.getCurrentVersionId(); if (columnIndex == 6) return row.isTemplate ? "Ja" : "Nein"; throw new IndexOutOfBoundsException(); } }