summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window
diff options
context:
space:
mode:
authorStephan Schwär2020-12-15 07:13:33 +0100
committerStephan Schwär2020-12-15 07:13:33 +0100
commitfa10bc6f53eb554603b86798d7a6a4bf467d438c (patch)
tree106c8a0f4ef0c5755e436dc820b758eb60b86135 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/window
parentMerge remote-tracking branch 'origin/feature/htmlEditorInDescrioptionText' in... (diff)
parent[client] Refactoring (diff)
downloadtutor-module-fa10bc6f53eb554603b86798d7a6a4bf467d438c.tar.gz
tutor-module-fa10bc6f53eb554603b86798d7a6a4bf467d438c.tar.xz
tutor-module-fa10bc6f53eb554603b86798d7a6a4bf467d438c.zip
Merge remote-tracking branch 'origin/feature/docker-integration-new' into feature-merge
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/window')
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java65
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java48
2 files changed, 65 insertions, 48 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
index b718c1e3..d6019fea 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java
@@ -38,24 +38,15 @@ import javax.swing.text.html.HTMLEditorKit;
import org.apache.log4j.Logger;
import org.apache.thrift.TException;
-import org.openslx.bwlp.thrift.iface.ImageBaseWrite;
-import org.openslx.bwlp.thrift.iface.ImageDetailsRead;
-import org.openslx.bwlp.thrift.iface.ImagePermissions;
-import org.openslx.bwlp.thrift.iface.ImageSummaryRead;
-import org.openslx.bwlp.thrift.iface.ImageVersionDetails;
-import org.openslx.bwlp.thrift.iface.LectureSummary;
-import org.openslx.bwlp.thrift.iface.OperatingSystem;
-import org.openslx.bwlp.thrift.iface.ShareMode;
-import org.openslx.bwlp.thrift.iface.UserInfo;
-import org.openslx.bwlp.thrift.iface.Virtualizer;
+import org.openslx.bwlp.thrift.iface.*;
import org.openslx.dozmod.Branding;
import org.openslx.dozmod.gui.Gui;
import org.openslx.dozmod.gui.MainWindow;
import org.openslx.dozmod.gui.changemonitor.AbstractControlWrapper;
import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor;
import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor.TextNotEmptyConstraint;
-import org.openslx.dozmod.gui.helper.*;
import org.openslx.dozmod.gui.helper.PopupMenu;
+import org.openslx.dozmod.gui.helper.*;
import org.openslx.dozmod.gui.window.UserListWindow.UserAddedCallback;
import org.openslx.dozmod.gui.window.layout.ImageDetailsWindowLayout;
import org.openslx.dozmod.gui.wizard.ImageUpdateWizard;
@@ -84,6 +75,13 @@ import org.openslx.util.QuickTimer.Task;
import org.openslx.util.ThriftUtil;
import org.openslx.util.Util;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.*;
+
/**
* Window for displaying and editing the details of an image.
*/
@@ -738,17 +736,28 @@ import org.openslx.util.Util;
return true;
}
+ /**
+ * If the user make changes and saves it this method will be executed.
+ * It makes a deep copy of the current containerDefinition to get all settings.
+ * After that, every user setting is set in that copy-object.
+ * If the copy-object and containerDefinition differ, the new settings will be uploaded.
+ */
private void saveContainerDefinition() {
+ // TODO do I really need this check? Maybe just get every setting and upload it.
- ContainerDefinition conDev = new ContainerDefinition();
+ ContainerDefinition newConDev = new ContainerDefinition(containerDefinition);
- conDev.setDescription(txtContainerDescription.getText());
+ if (newConDev.getBuildContextMethod() == ContainerBuildContextMethod.FILE) {
+ newConDev.setContainerRecipe(txtContainerRecipe.getText());
+ }
+ // currently no update of the git url allowed
- conDev.getContainerMeta().setImageName(txtContainerImageName.getText());
- conDev.getContainerMeta().setRunOptions(txtContainerRun.getText());
+ newConDev.getContainerMeta().setImageName(txtContainerImageName.getText());
+ newConDev.getContainerMeta().setRunOptions(txtContainerRun.getText());
+ newConDev.getContainerMeta().setBindMountConfig(bindMountConfigurator.getData());
- if (!conDev.equals(containerDefinition)) {
- uploadContainerDef(image.versions.get(0).versionId, conDev.toByteBuffer());
+ if (!newConDev.equals(containerDefinition)) {
+ uploadContainerDef(image.versions.get(0).versionId, newConDev.toByteBuffer());
LOGGER.info("Upload new DockerDefinition");
}
}
@@ -933,24 +942,25 @@ import org.openslx.util.Util;
switch (method) {
case FILE:
- txtContainerDescription.setText(containerDefinition.getDescription());
+ txtContainerRecipe.setText(containerDefinition.getContainerRecipe());
break;
case GIT_REPOSITORY:
- txtContainerDescription.setText(containerMeta.getBuildContextUrl());
- txtContainerDescription.setEnabled(false);
+ txtContainerRecipe.setText(containerMeta.getBuildContextUrl());
+ txtContainerRecipe.setEnabled(false);
break;
}
txtContainerImageName.setText(containerMeta.getImageName());
txtContainerRun.setText(containerMeta.getRunOptions());
- bindMountTable.setData(containerMeta.getBindMountConfig(), true);
+ bindMountConfigurator.setData(containerMeta.getBindMountConfig(), true);
- changeMonitor.add(txtContainerDescription).
+ changeMonitor.add(txtContainerRecipe).
addConstraint(new TextNotEmptyConstraint("Empty Dockerfile not allowed!"));
changeMonitor.add(txtContainerImageName)
.addConstraint(new TextNotEmptyConstraint("Empty Name not allowed!"));
changeMonitor.add(txtContainerRun)
.addConstraint(new TextNotEmptyConstraint("No Container Run Options provided!"));
+ changeMonitor.add(bindMountConfigurator);
}
// fill share mode combo, if not already done
@@ -1006,9 +1016,9 @@ import org.openslx.util.Util;
*/
private void makeEditable(boolean editable) {
// always disable all buttons unless image's share mode is LOCAL or PUBLISH
- if (image != null)
+ if (image != null) {
editable &= image.shareMode == ShareMode.LOCAL || image.shareMode == ShareMode.PUBLISH;
-
+ }
// now do the regular permission check
editable = editable && (ImagePerms.canEdit(image) || ImagePerms.canAdmin(image));
txtTitle.setEditable(editable);
@@ -1026,6 +1036,13 @@ import org.openslx.util.Util;
btnUpdateImage.setEnabled(editable);
if (actionHandler.isImagePublishSupported())
btnUploadToMaster.setEnabled(editable);
+
+ if (image != null && TConst.VIRT_DOCKER.equals(image.getVirtId())) {
+ // TODO Currently, do not allow user to upload a new version or share an Container Image.
+ btnUpdateImage.setEnabled(false);
+ btnUploadToMaster.setEnabled(false);
+ }
+
}
/**
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
index c83d511c..73425880 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java
@@ -23,32 +23,37 @@ import javax.swing.text.html.HTMLEditorKit;
import org.openslx.bwlp.thrift.iface.OperatingSystem;
import org.openslx.bwlp.thrift.iface.ShareMode;
import org.openslx.dozmod.gui.Gui;
+import org.openslx.dozmod.gui.configurator.ContainerBindMountConfigurator;
import org.openslx.dozmod.gui.configurator.ImagePermissionConfigurator;
import org.openslx.dozmod.gui.control.ComboBox;
import org.openslx.dozmod.gui.control.ComboBox.ComboBoxRenderer;
import org.openslx.dozmod.gui.control.PersonLabel;
import org.openslx.dozmod.gui.control.QLabel;
-import org.openslx.dozmod.gui.control.table.ContainerBindMountTable;
import org.openslx.dozmod.gui.control.table.ImageVersionTable;
import org.openslx.dozmod.gui.control.table.QScrollPane;
import org.openslx.dozmod.gui.helper.GridManager;
import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.thrifthelper.Comparators;
+import javax.swing.*;
+import java.awt.*;
+
@SuppressWarnings("serial") public abstract class ImageDetailsWindowLayout extends JDialog {
private static final int ICON_SIZE_Y = 24;
+ private final String TAB_OVERVIEW_TITEL = "Übersicht";
+ private final String TAB_VERSIONS_TITEL = "VM-Versionen";
+ private final String TAB_PERMISSIONS_TITEL = "Berechtigungen";
+
protected final JTextField txtTitle;
protected final JEditorPane txtDescription;
private final JPanel pnlTabContainer;
- protected final JTextArea txtContainerDescription;
+ protected final JTextArea txtContainerRecipe;
protected final JTextField txtContainerRun;
protected final JTextField txtContainerImageName;
- protected final ContainerBindMountTable bindMountTable;
- protected final JButton btnAddBindMount;
- protected final JButton btnDelBindMount;
+ protected ContainerBindMountConfigurator bindMountConfigurator;
protected QLabel lblError;
protected final PersonLabel lblOwner;
@@ -342,41 +347,34 @@ import org.openslx.thrifthelper.Comparators;
*
********************************************************************************/
pnlTabContainer = new JPanel();
- txtContainerDescription = new JTextArea();
- JScrollPane scrollableTextArea = new JScrollPane(txtContainerDescription);
+ txtContainerRecipe = new JTextArea();
+ JScrollPane scrollableTextArea = new JScrollPane(txtContainerRecipe);
+ scrollableTextArea.setMinimumSize(Gui.getScaledDimension(0, 200));
+ scrollableTextArea.setPreferredSize(Gui.getScaledDimension(0, 200));
JPanel pnlContainerMeta = new JPanel();
- GridManager grdContainerMeta = new GridManager(pnlContainerMeta, 3, false, new Insets(8, 2, 8, 2));
+ GridManager grdContainerMeta = new GridManager(pnlContainerMeta, 3);
grdContainerMeta.add(new QLabel("Image Name"));
txtContainerImageName = new JTextField();
txtContainerImageName.setDocument(txtTitle.getDocument());
- grdContainerMeta.add(txtContainerImageName, 2).fill(true, false);
+ grdContainerMeta.add(txtContainerImageName, 2).fill(true, false).expand(true, false);
grdContainerMeta.nextRow();
grdContainerMeta.add(new QLabel("Container Run Options"));
txtContainerRun = new JTextField();
- grdContainerMeta.add(txtContainerRun, 2).fill(true, false);
+ grdContainerMeta.add(txtContainerRun, 2).fill(true, false).expand(true, false);
grdContainerMeta.nextRow();
- bindMountTable = new ContainerBindMountTable();
- QScrollPane scrollPaneTable = new QScrollPane(bindMountTable);
- grdContainerMeta.add(scrollPaneTable, 3).fill(true, true).expand(true, true);
- grdContainerMeta.nextRow();
-
- btnAddBindMount = new JButton("Add Bind Mount");
- btnDelBindMount = new JButton("Remove Bind Mount");
- grdContainerMeta.add(Box.createHorizontalBox(), 1).fill(true, false).expand(true, false);
- grdContainerMeta.add(btnAddBindMount);
- grdContainerMeta.add(btnDelBindMount);
- grdContainerMeta.nextRow();
+ bindMountConfigurator = new ContainerBindMountConfigurator();
+ grdContainerMeta.add(bindMountConfigurator, 3).fill(true, true).expand(true, true);
grdContainerMeta.finish(true);
GridManager grdContainer = new GridManager(pnlTabContainer, 1, false, new Insets(8, 2, 8, 2));
grdContainer.add(scrollableTextArea, 1).fill(true, true).expand(true, true);
- grdContainer.add(pnlContainerMeta, 1).fill(true, false).anchor(GridBagConstraints.FIRST_LINE_START);
- grdContainer.add(Box.createVerticalGlue()).fill(true, true);
- grdContainer.finish(false);
+ grdContainer.add(pnlContainerMeta, 1).fill(true, true).expand(true, true);
+ //grdContainer.add(Box.createVerticalGlue()).fill(true, true).expand(true,true);
+ grdContainer.finish(true);
@@ -416,5 +414,7 @@ import org.openslx.thrifthelper.Comparators;
protected void showContainerTab() {
pnlTabs.addTab("Container", pnlTabContainer);
+ // TODO currently, do not allow to alter the version of a container image.
+ pnlTabs.remove(pnlTabs.indexOfTab(TAB_VERSIONS_TITEL));
}
}