summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src
diff options
context:
space:
mode:
Diffstat (limited to 'dozentenmodul/src')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java60
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerMeta.java47
2 files changed, 64 insertions, 43 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java
index 8b79d064..a3b5ee3b 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java
@@ -25,21 +25,24 @@ public class ContainerPanel extends JPanel {
* Version for serialization.
*/
private static final long serialVersionUID = -3335320345960410582L;
-
- // TODO Set the height of txtContainerRecipe dependent of the Context. Full height for IMAGE_CONTEXT.
+
+ // TODO Set the height of txtContainerRecipe to a proper Value
public static final String IMAGE_CONTEXT = "IMAGE";
public static final String CONTAINER_CONTEXT = "CONTAINER";
private final Logger LOGGER = Logger.getLogger(ContainerBindMountConfigurator.class);
- private final QLabel lblContainerRunOpt;
-
+ // TODO ContainerImageType should be set in MetaData
private final QLabel lblContainerImageType;
private final ComboBox<ContainerMeta.ContainerImageType> cboContainerImageType;
+ private final JPanel pnlContainerMeta;
+
private final JTextArea txtContainerRecipe;
private final JTextField txtContainerRun;
private final JTextField txtContainerImageName;
+
+ private final JTextField txtContainerRunCommand;
private final ContainerBindMountConfigurator bindMountConfigurator;
private ContainerDefinition containerDefinition = null;
@@ -48,18 +51,24 @@ public class ContainerPanel extends JPanel {
public ContainerPanel() {
- JPanel pnlContainerMeta = new JPanel();
+ pnlContainerMeta = new JPanel();
GridManager grdContainerMeta = new GridManager(pnlContainerMeta, 3);
- lblContainerRunOpt = new QLabel(
+ QLabel lblContainerRunOpt = new QLabel(
I18n.PANEL.getString("ContainerPanel.ContainerStartOptions.label"));
lblContainerRunOpt.setToolTipText(
I18n.PANEL.getString("ContainerPanel.ContainerStartOptions.tooltip"));
- grdContainerMeta.add(lblContainerRunOpt);
txtContainerRun = new JTextField();
+ grdContainerMeta.add(lblContainerRunOpt);
grdContainerMeta.add(txtContainerRun, 2).fill(true, false).expand(true, false);
grdContainerMeta.nextRow();
+ QLabel lblContainerRunCommand = new QLabel("Container Run Command");
+ txtContainerRunCommand = new JTextField();
+ grdContainerMeta.add(lblContainerRunCommand);
+ grdContainerMeta.add(txtContainerRunCommand, 2).fill(true, false).expand(true, false);
+ grdContainerMeta.nextRow();
+
bindMountConfigurator = new ContainerBindMountConfigurator();
grdContainerMeta.add(bindMountConfigurator, 3).fill(true, true).expand(true, true);
grdContainerMeta.finish(true);
@@ -79,21 +88,21 @@ public class ContainerPanel extends JPanel {
scrollableTextArea.setPreferredSize(Gui.getScaledDimension(0, 200));
grdContainer.add(scrollableTextArea, 2).fill(true, true).expand(true, true);
-
lblContainerImageType = new QLabel("Container Image Type");
- cboContainerImageType = new ComboBox<>(new ComboBox.ComboBoxRenderer<ContainerMeta.ContainerImageType>() {
- @Override public String renderItem(ContainerMeta.ContainerImageType item) {
- if (item == null)
- return "null";
- return item.name();
- }
- }, ContainerMeta.ContainerImageType.class);
- for (ContainerMeta.ContainerImageType type:ContainerMeta.ContainerImageType.values()) {
+ cboContainerImageType = new ComboBox<>(
+ new ComboBox.ComboBoxRenderer<ContainerMeta.ContainerImageType>() {
+ @Override public String renderItem(ContainerMeta.ContainerImageType item) {
+ if (item == null)
+ return "null";
+ return item.name();
+ }
+ }, ContainerMeta.ContainerImageType.class);
+ for (ContainerMeta.ContainerImageType type : ContainerMeta.ContainerImageType.values()) {
cboContainerImageType.addItem(type);
}
cboContainerImageType.setSelectedItem(ContainerMeta.ContainerImageType.LECTURE);
grdContainer.add(lblContainerImageType);
- grdContainer.add(cboContainerImageType).fill(true,false).expand(true,false);
+ grdContainer.add(cboContainerImageType).fill(true, false).expand(true, false);
grdContainer.add(pnlContainerMeta, 2).fill(true, true).expand(true, true);
grdContainer.finish(true);
@@ -124,8 +133,7 @@ public class ContainerPanel extends JPanel {
txtContainerImageName.setText(image.imageName);
txtContainerImageName.setEnabled(false);
// TODO simplify this mess. ContainerBuildContextMethod is to complex or useless
- switch (containerDefinition.getBuildContextMethod())
- {
+ switch (containerDefinition.getBuildContextMethod()) {
case FILE:
txtContainerRecipe.setText(containerDefinition.getContainerRecipe());
break;
@@ -157,9 +165,8 @@ public class ContainerPanel extends JPanel {
txtContainerRecipe.setEnabled(false);
// do not show container specific input options
- lblContainerRunOpt.setVisible(false);
- txtContainerRun.setVisible(false);
- bindMountConfigurator.setVisible(false);
+ pnlContainerMeta.setVisible(false);
+ pnlContainerMeta.setEnabled(false);
}
private void initContainerDetails() {
@@ -169,6 +176,7 @@ public class ContainerPanel extends JPanel {
cboContainerImageType.setEditable(false);
cboContainerImageType.setVisible(false);
txtContainerRun.setText(containerDefinition.getContainerMeta().getRunOptions());
+ txtContainerRunCommand.setText(containerDefinition.getContainerMeta().getRunCommand());
bindMountConfigurator.setData(containerDefinition.getContainerMeta().getBindMountConfig());
}
@@ -178,8 +186,9 @@ public class ContainerPanel extends JPanel {
.addConstraint(new DialogChangeMonitor.TextNotEmptyConstraint(
I18n.PANEL.getString("ContainerPanel.Constraint.NoEmptyDockerfile.text")));
changeMonitor.add(txtContainerRun);
+ changeMonitor.add(txtContainerRunCommand);
changeMonitor.add(bindMountConfigurator);
- changeMonitor.addFixedCombo(cboContainerImageType,null);
+ changeMonitor.addFixedCombo(cboContainerImageType, null);
isFirstTime = false;
}
}
@@ -195,8 +204,9 @@ public class ContainerPanel extends JPanel {
ContainerDefinition newConDev = new ContainerDefinition(containerDefinition);
- newConDev.getContainerMeta().setImageType(
- (ContainerMeta.ContainerImageType) cboContainerImageType.getSelectedItem());
+ newConDev.getContainerMeta()
+ .setImageType((ContainerMeta.ContainerImageType) cboContainerImageType.getSelectedItem());
+ newConDev.getContainerMeta().setRunCommand(txtContainerRunCommand.getText());
newConDev.getContainerMeta().setRunOptions(txtContainerRun.getText());
newConDev.getContainerMeta().setBindMountConfig(bindMountConfigurator.getData());
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerMeta.java b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerMeta.java
index 0306d0ee..2f13c156 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerMeta.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerMeta.java
@@ -7,29 +7,28 @@ import java.util.Objects;
/**
* ContainerMeta is used to store container specific information.
* An object of this class will be serialized with gson to a json file.
- *
+ * <p>
* TODO remove build_context_method
- * no need to distinguish beettween methods
+ * no need to distinguish between methods
* TODO rename build_context_url to build_context
*/
public class ContainerMeta {
public enum ContainerImageType implements org.apache.thrift.TEnum {
- LECTURE("lecture"),
- BATCH("batch"),
- DATA("data");
+ LECTURE("lecture"), BATCH("batch"), DATA("data");
private final String name;
- ContainerImageType(String name){
+ ContainerImageType(String name) {
this.name = name;
}
- public boolean equalNames(String other){
+ public boolean equalNames(String other) {
return name.equals(other);
}
- public static ContainerImageType getByName(String name){
- for (ContainerImageType item : ContainerImageType.values()){
+
+ public static ContainerImageType getByName(String name) {
+ for (ContainerImageType item : ContainerImageType.values()) {
if (item.name.equals(name))
return item;
}
@@ -37,8 +36,6 @@ public class ContainerMeta {
return LECTURE;
}
-
-
@Override public String toString() {
return this.name;
}
@@ -48,12 +45,12 @@ public class ContainerMeta {
}
}
-
private int build_context_method;
private String image_repo;
private String build_context_url;
private String image_name;
private String run_options;
+ private String run_command;
private String image_type;
private List<ContainerBindMount> bind_mount_config = new ArrayList<>();
@@ -64,6 +61,7 @@ public class ContainerMeta {
build_context_url = "";
image_name = "";
run_options = "";
+ run_command = "";
image_type = ContainerImageType.LECTURE.toString();
bind_mount_config = new ArrayList<>();
}
@@ -73,6 +71,7 @@ public class ContainerMeta {
build_context_url = containerMeta.build_context_url;
image_name = containerMeta.image_name;
run_options = containerMeta.run_options;
+ run_command = containerMeta.run_command;
image_repo = containerMeta.image_repo;
for (ContainerBindMount bm : containerMeta.bind_mount_config)
@@ -104,6 +103,14 @@ public class ContainerMeta {
this.run_options = run_options;
}
+ public void setRunCommand(String run_command) {
+ this.run_command = run_command;
+ }
+
+ public String getRunCommand() {
+ return this.run_command;
+ }
+
public String getImageName() {
return image_name;
}
@@ -120,9 +127,13 @@ public class ContainerMeta {
this.bind_mount_config = bindMountConfig;
}
- public String getImageRepo() { return image_repo; }
+ public String getImageRepo() {
+ return image_repo;
+ }
- public void setImageRepo(String from_image) { this.image_repo = from_image; }
+ public void setImageRepo(String from_image) {
+ this.image_repo = from_image;
+ }
public ContainerImageType getImageType() {
if (image_type == null || image_type.length() == 0)
@@ -143,12 +154,12 @@ public class ContainerMeta {
ContainerMeta that = (ContainerMeta) o;
return Objects.equals(build_context_url, that.build_context_url) && Objects.equals(image_name,
that.image_name) && Objects.equals(run_options, that.run_options) && Objects.equals(
- bind_mount_config, that.bind_mount_config) && Objects.equals(image_repo,that.image_repo)
- && Objects.equals(image_type,that.image_type);
+ run_command, that.run_command) && Objects.equals(bind_mount_config, that.bind_mount_config)
+ && Objects.equals(image_repo, that.image_repo) && Objects.equals(image_type, that.image_type);
}
@Override public int hashCode() {
- return Objects.hash(build_context_url, image_name, run_options,
- bind_mount_config, image_repo, image_type);
+ return Objects.hash(build_context_url, image_name, run_options, run_command, bind_mount_config,
+ image_repo, image_type);
}
}