blob: bfab9edec9c89c85268c19156f0214d7dbd6e658 (
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
39
40
41
42
43
44
45
46
47
48
|
package org.openslx.dozmod.gui.control.table;
import org.openslx.bwlp.thrift.iface.ImagePermissions;
import org.openslx.dozmod.gui.control.table.ImagePermissionTable.UserImagePermissions;
import org.openslx.dozmod.thrift.UserCache;
import org.openslx.dozmod.util.FormatHelper;
@SuppressWarnings("serial")
public class ImagePermissionTable extends ListTable<UserImagePermissions> {
private static String[] columnNames = { "Benutzer", "Link", "Download", "Bearbeiten", "Admin" };
public ImagePermissionTable() {
super(columnNames);
}
@Override
protected Object getValueAtInternal(int rowIndex, int columnIndex) {
UserImagePermissions row = get(rowIndex);
if (columnIndex == 0)
return FormatHelper.userName(UserCache.find(row.userId));
if (columnIndex == 1)
return row.permissions.link;
if (columnIndex == 2)
return row.permissions.download;
if (columnIndex == 3)
return row.permissions.edit;
if (columnIndex == 4)
return row.permissions.admin;
throw new IndexOutOfBoundsException();
}
/**
* Helper class for linking UserIds to permissions of an image.
*/
public static class UserImagePermissions {
public final String userId;
public final ImagePermissions permissions;
public UserImagePermissions(String userId, ImagePermissions permission) {
this.userId = userId;
this.permissions = permission;
}
}
}
|