summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ImageTable.java
blob: 8221cef597074680f5cd5d3261cc7709ea9f6b63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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<ImageSummaryRead> {

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

}