blob: f69d3c471618f869670d7b40eb38deb226850ccd (
plain) (
tree)
|
|
package org.openslx.dozmod.gui.control.table;
import org.openslx.bwlp.thrift.iface.ImageVersionDetails;
import org.openslx.dozmod.thrift.cache.UserCache;
import org.openslx.dozmod.util.FormatHelper;
@SuppressWarnings("serial")
public class ImageVersionTable extends ListTable<ImageVersionDetails> {
public static final ListTableColumn COL_CREATED = new ListTableColumn("Erstellungszeitpunkt", Long.class);
public static final ListTableColumn COL_EXPIRING = new ListTableColumn("Ablaufszeitpunkt", Long.class);
public static final ListTableColumn COL_UPLOADER = new ListTableColumn("Ersteller");
public static final ListTableColumn COL_VALID = new ListTableColumn("Verwendbar", Boolean.class);
public static final ListTableColumn COL_SIZE = new ListTableColumn("Größe", Long.class);
public static final ListTableColumn COL_ID = new ListTableColumn("Interne ID");
public ImageVersionTable() {
super(COL_CREATED, COL_EXPIRING, COL_UPLOADER, COL_VALID, COL_SIZE, COL_ID);
}
@Override
protected Object getValueAtInternal(ImageVersionDetails row, ListTableColumn column) {
if (column == COL_CREATED)
return row.getCreateTime();
if (column == COL_EXPIRING)
return row.getExpireTime();
if (column == COL_UPLOADER)
return row.getUploaderId();
if (column == COL_VALID)
return row.isValid;
if (column == COL_SIZE)
return row.getFileSize();
if (column == COL_ID)
return row.getVersionId();
throw new IndexOutOfBoundsException();
}
@Override
public Object modelValueToDisplayFormat(Object value, ListTableColumn column) {
if (column == COL_VALID || column == COL_ID)
return value;
if (column == COL_CREATED)
return FormatHelper.longDate((long) value);
if (column == COL_EXPIRING)
return FormatHelper.daysTil((long) value);
if (column == COL_UPLOADER)
return FormatHelper.userName(UserCache.find((String) value));
if (column == COL_SIZE)
return FormatHelper.bytes((long) value, false);
throw new IndexOutOfBoundsException();
}
}
|