summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/control/table/ContainerBindMountTable.java
blob: 28a5225f06e9113724ce372b771fe4e667e93c71 (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
package org.openslx.dozmod.gui.control.table;

import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.util.ContainerUtils;
import org.openslx.virtualization.configuration.container.ContainerBindMount;

import java.util.ArrayList;

public class ContainerBindMountTable extends ListTable<ContainerBindMount> {

	/**
	 * Version for serialization.
	 */
	private static final long serialVersionUID = -2908607335582645909L;

	public static final ListTableColumn COL_SOURCE = new ListTableColumn(
			I18n.CONFIGURATOR.getString("ContainerBindMount.BindMountTable.col.src"));
	public static final ListTableColumn COL_TARGET = new ListTableColumn(
			I18n.CONFIGURATOR.getString("ContainerBindMount.BindMountTable.col.dest"));
	public static final ListTableColumn COL_OPTIONS = new ListTableColumn(
			I18n.CONFIGURATOR.getString("ContainerBindMount.BindMountTable.col.opt"));

	public ContainerBindMountTable() {
		super(COL_SOURCE, COL_TARGET, COL_OPTIONS);
		// init with empty data list
		this.setData(new ArrayList<ContainerBindMount>(), false);
	}

	@Override protected Object getValueAtInternal(ContainerBindMount item, ListTableColumn column) {
		if (COL_SOURCE == column)
			switch (item.getMountType()){
			case DEFAULT:
				return item.getSource();
			case CONTAINER_IMAGE:
				return ContainerUtils.getImageNameByBaseId(item.getSource());
			}

		if (COL_TARGET == column)
			return item.getTarget();
		if (COL_OPTIONS == column)
			return item.getOptions();
		throw new IndexOutOfBoundsException();
	}
}