summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java80
1 files changed, 62 insertions, 18 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java
index 6f6a3cfe..3b542a10 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ContainerBindMountWindowLayout.java
@@ -1,13 +1,18 @@
package org.openslx.dozmod.gui.window.layout;
+import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.control.ComboBox;
import org.openslx.dozmod.gui.control.QLabel;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.helper.StatusHeader;
+import org.openslx.dozmod.util.ContainerUtils;
+import org.openslx.virtualization.configuration.container.ContainerBindMount;
import javax.swing.*;
import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
public class ContainerBindMountWindowLayout extends JDialog {
@@ -19,8 +24,7 @@ public class ContainerBindMountWindowLayout extends JDialog {
private static final String title = "Add Bind Mount";
protected final StatusHeader header;
- protected final QLabel lblBmSource;
- protected final JTextField txtBmSource;
+ // protected final QLabel lblBmSource;
protected final QLabel lblBmTarget;
protected final JTextField txtBmTarget;
protected final QLabel lblBmOptions;
@@ -33,14 +37,14 @@ public class ContainerBindMountWindowLayout extends JDialog {
protected static String[] SOURCE_MOUNT_POINTS = { EMPTY_MARKER, TAGS[0], TAGS[1], "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
- protected final ComboBox<String> cboSourceMountPoint = new ComboBox<String>(
- new ComboBox.ComboBoxRenderer<String>() {
- @Override public String renderItem(String letter) {
- if (letter == null)
- return null;
- return letter;
+ protected final ComboBox<ContainerMountChoice> cboSourceMount = new ComboBox<>(
+ new ComboBox.ComboBoxRenderer<ContainerMountChoice>() {
+ @Override public String renderItem(ContainerMountChoice choice) {
+ if (choice == null)
+ return "";
+ return choice.name;
}
- }, String.class);
+ }, ContainerMountChoice.class);
public ContainerBindMountWindowLayout(Window modalParent) {
super(modalParent, title, ModalityType.APPLICATION_MODAL);
@@ -53,16 +57,17 @@ public class ContainerBindMountWindowLayout extends JDialog {
add(contentPanel, BorderLayout.CENTER);
GridManager grid = new GridManager(contentPanel, 2, true, new Insets(2, 2, 2, 2));
- lblBmSource = new QLabel("Source");
-
- txtBmSource = new JTextField();
- cboSourceMountPoint.setModel(new DefaultComboBoxModel<>(SOURCE_MOUNT_POINTS));
- cboSourceMountPoint.setSelectedItem(SOURCE_MOUNT_POINTS[0]);
-
- grid.add(lblBmSource);
- grid.add(cboSourceMountPoint).fill(true, false).expand(true, false);
+ cboSourceMount.setModel(
+ new DefaultComboBoxModel<>(generateMountChoices().toArray(new ContainerMountChoice[0])));
+ cboSourceMount.setSelectedIndex(0);
+ grid.add(new QLabel("Source"));
+ grid.add(cboSourceMount).fill(true, false).expand(true, false);
grid.nextRow();
+ // grid.add(lblBmSource);
+ // grid.add(cboSourceMountPoint).fill(true, false).expand(true, false);
+ // grid.nextRow();
+
lblBmTarget = new QLabel("Target");
txtBmTarget = new JTextField();
grid.add(lblBmTarget);
@@ -87,10 +92,49 @@ public class ContainerBindMountWindowLayout extends JDialog {
grid.add(buttonPane, 2).fill(true, false).expand(true, false);
grid.finish(false);
- setSize(350, 200);
+ setSize(350, 300);
setResizable(false);
if (modalParent != null) {
Gui.centerShellOverShell(modalParent, this);
}
}
+
+ private ArrayList<ContainerMountChoice> generateMountChoices() {
+ List<ImageSummaryRead> dataContainerImages = ContainerUtils.getDataContainerImages();
+ ArrayList<ContainerMountChoice> mountChoices = new ArrayList<>();
+ mountChoices.add(ContainerMountChoice.getEmptyChoice());
+
+ for (int i = 1; i < SOURCE_MOUNT_POINTS.length; i++) {
+ mountChoices.add(new ContainerMountChoice(ContainerBindMount.ContainerMountType.DEFAULT,
+ SOURCE_MOUNT_POINTS[i], SOURCE_MOUNT_POINTS[i]));
+ }
+
+ for (ImageSummaryRead image : dataContainerImages) {
+ mountChoices.add(new ContainerMountChoice(ContainerBindMount.ContainerMountType.CONTAINER_IMAGE,
+ image.imageName, image.imageBaseId));
+ }
+ return mountChoices;
+ }
+
+ protected static class ContainerMountChoice {
+
+ public final ContainerBindMount.ContainerMountType type;
+ public final String name;
+ public final String value;
+
+ private static ContainerMountChoice emptyMountChoice = null;
+
+ public ContainerMountChoice(ContainerBindMount.ContainerMountType type, String name, String value) {
+ this.type = type;
+ this.name = name;
+ this.value = value;
+ }
+
+ public static ContainerMountChoice getEmptyChoice() {
+ if (emptyMountChoice == null)
+ emptyMountChoice = new ContainerMountChoice(ContainerBindMount.ContainerMountType.DEFAULT,
+ "-", "-");
+ return emptyMountChoice;
+ }
+ }
}