diff options
author | Simon Rettberg | 2015-08-27 11:00:38 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-08-27 11:00:38 +0200 |
commit | ba9fe6f36af0fbf576ba136cbf22bf2e005a1733 (patch) | |
tree | 8354e9915c39dc008b13e02d8c416735772e43a8 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java | |
parent | [client] reworked ThriftActions.deleteImageBase and deleteImageVersion (diff) | |
download | tutor-module-ba9fe6f36af0fbf576ba136cbf22bf2e005a1733.tar.gz tutor-module-ba9fe6f36af0fbf576ba136cbf22bf2e005a1733.tar.xz tutor-module-ba9fe6f36af0fbf576ba136cbf22bf2e005a1733.zip |
[client] Changes to column handling in ListTable
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java index 2cc507c0..fdd2caeb 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageVersionTable.java @@ -1,6 +1,5 @@ package org.openslx.dozmod.gui.control.table; -import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.ImageVersionDetails; import org.openslx.dozmod.thrift.cache.UserCache; import org.openslx.dozmod.util.FormatHelper; @@ -8,30 +7,42 @@ import org.openslx.dozmod.util.FormatHelper; @SuppressWarnings("serial") public class ImageVersionTable extends ListTable<ImageVersionDetails> { - private final static Logger LOGGER = Logger.getLogger(ImageVersionTable.class); - - private static String[] columnNames = { "Datum", "Uploader", "Valid", "Größe", "Id" }; - - private static Class<?>[] columnClasses = { String.class, String.class, Boolean.class, String.class, - String.class }; + private static final ListTableColumn COL_CREATED = new ListTableColumn(Long.class, "Erstellungszeitpunkt"); + private static final ListTableColumn COL_UPLOADER = new ListTableColumn("Ersteller"); + private static final ListTableColumn COL_VALID = new ListTableColumn(Boolean.class, "Verwendbar"); + private static final ListTableColumn COL_SIZE = new ListTableColumn(Long.class, "Größe"); + private static final ListTableColumn COL_ID = new ListTableColumn("Interne ID"); public ImageVersionTable() { - super(columnNames, columnClasses); + super(COL_CREATED, COL_UPLOADER, COL_VALID, COL_SIZE, COL_ID); } @Override - protected Object getValueAtInternal(ImageVersionDetails row, int columnIndex) { - if (columnIndex == 0) - return FormatHelper.longDate(row.getCreateTime()); - if (columnIndex == 1) - return FormatHelper.userName(UserCache.find(row.getUploaderId())); - ; - if (columnIndex == 2) + protected Object getValueAtInternal(ImageVersionDetails row, ListTableColumn column) { + if (column == COL_CREATED) + return row.getCreateTime(); + if (column == COL_UPLOADER) + return row.getUploaderId(); + if (column == COL_VALID) return row.isValid; - if (columnIndex == 3) - return FormatHelper.bytes(row.getFileSize(), false); - if (columnIndex == 4) + 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_UPLOADER) + return FormatHelper.userName(UserCache.find((String) value)); + if (column == COL_SIZE) + return FormatHelper.bytes((long) value, false); + throw new IndexOutOfBoundsException(); + } + } |