diff options
author | ralph isenmann | 2021-02-15 09:51:19 +0100 |
---|---|---|
committer | ralph isenmann | 2021-02-15 10:38:35 +0100 |
commit | c32d9153d9135eb8528ee795a8811e53bdb445ae (patch) | |
tree | ae3f3eb50f471988fe08dd0723d7d842afb4f835 | |
parent | [client] Add try catche clause (diff) | |
download | tutor-module-c32d9153d9135eb8528ee795a8811e53bdb445ae.tar.gz tutor-module-c32d9153d9135eb8528ee795a8811e53bdb445ae.tar.xz tutor-module-c32d9153d9135eb8528ee795a8811e53bdb445ae.zip |
[client] Add ContainerPanel in ImageDetails and LectureDetails
Depending on the context (image or lecture), the panel displays the required information in the Details window. This panel is only displayed if the selected image or lecture is a ContainerImage or is based on it.
7 files changed, 237 insertions, 296 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/ContainerBindMountConfigurator.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/ContainerBindMountConfigurator.java index d7e73e3d..961bbc29 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/ContainerBindMountConfigurator.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/configurator/ContainerBindMountConfigurator.java @@ -81,6 +81,10 @@ public class ContainerBindMountConfigurator extends JPanel fireUserChangeEvent(); } + public void setData(List<ContainerBindMount> bindMountConfig) { + setData(bindMountConfig, true); + } + public void setData(List<ContainerBindMount> bindMountConfig, boolean sort) { bindMountTable.setData(bindMountConfig, sort); } 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 new file mode 100644 index 00000000..53b3e199 --- /dev/null +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/panel/ContainerPanel.java @@ -0,0 +1,165 @@ +package org.openslx.dozmod.gui.panel; + +import org.apache.log4j.Logger; +import org.apache.thrift.TException; +import org.openslx.bwlp.thrift.iface.ImageDetailsRead; +import org.openslx.dozmod.gui.Gui; +import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor; +import org.openslx.dozmod.gui.configurator.ContainerBindMountConfigurator; +import org.openslx.dozmod.gui.control.QLabel; +import org.openslx.dozmod.gui.helper.GridManager; +import org.openslx.dozmod.gui.helper.I18n; +import org.openslx.dozmod.model.ContainerBuildContextMethod; +import org.openslx.dozmod.model.ContainerDefinition; +import org.openslx.thrifthelper.ThriftManager; +import org.openslx.util.ThriftUtil; + +import javax.swing.*; +import java.awt.*; +import java.nio.ByteBuffer; + +public class ContainerPanel extends JPanel { + + // TODO Set the height of txtContainerRecipe dependent of the Context. Full height for IMAGE_CONTEXT. + + 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; + private final QLabel lblContainerImageName; + + private final JTextArea txtContainerRecipe; + private final JTextField txtContainerRun; + private final JTextField txtContainerImageName; + private final ContainerBindMountConfigurator bindMountConfigurator; + + private ContainerDefinition containerDefinition = null; + + public ContainerPanel() { + + JPanel pnlContainerMeta = new JPanel(); + GridManager grdContainerMeta = new GridManager(pnlContainerMeta, 3); + + lblContainerRunOpt = new QLabel( + I18n.WINDOW_LAYOUT.getString("ImageDetails.Label.ContainerRunOptions.text")); + grdContainerMeta.add(lblContainerRunOpt); + txtContainerRun = new JTextField(); + grdContainerMeta.add(txtContainerRun, 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); + + GridManager grdContainer = new GridManager(this, 2, false, new Insets(8, 2, 8, 2)); + + lblContainerImageName = new QLabel(I18n.WINDOW_LAYOUT.getString("ImageDetails.Label.ImageName.text")); + grdContainer.add(lblContainerImageName); + txtContainerImageName = new JTextField(); + grdContainer.add(txtContainerImageName, 1).fill(true, false).expand(true, false); + grdContainer.nextRow(); + + txtContainerRecipe = new JTextArea(); + JScrollPane scrollableTextArea = new JScrollPane(txtContainerRecipe); + scrollableTextArea.setMinimumSize(Gui.getScaledDimension(0, 200)); + scrollableTextArea.setPreferredSize(Gui.getScaledDimension(0, 200)); + grdContainer.add(scrollableTextArea, 2).fill(true, true).expand(true, true); + grdContainer.add(pnlContainerMeta, 2).fill(true, true).expand(true, true); + grdContainer.finish(true); + + } + + /** + * Retrieves Container specific details for the currently displayed lecture and disables gui elements for + * the specific context. + * + * @param satelliteToken The satelliteToken from which the information are retrieved. + * @param image The ImageDetailsRead which has general information about Image (name, type, version, etc.) + * @param context In which context this Panel ist used (Image or Lecture) + */ + public void init(String satelliteToken, ImageDetailsRead image, String context) { + + try { + byte[] rawVirtConfig; + ByteBuffer byteBuffer = ThriftManager.getSatClient() + .getImageVersionVirtConfig(satelliteToken, image.getLatestVersionId()); + rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer); + containerDefinition = ContainerDefinition.fromByteArray(rawVirtConfig); + } catch (TException e) { + LOGGER.error("Failed to retrieve virtualizer config for image version " + "'" + + image.getLatestVersionId() + ", see trace: ", e); + } + + txtContainerImageName.setText(image.imageName); + txtContainerImageName.setEnabled(false); + // TODO simplify this mess. ContainerBuildContextMethod is to complex + if (containerDefinition.getBuildContextMethod() == ContainerBuildContextMethod.FILE) { + txtContainerRecipe.setText(containerDefinition.getContainerRecipe()); + } else if (containerDefinition.getBuildContextMethod() + == ContainerBuildContextMethod.GIT_REPOSITORY) { + txtContainerRecipe.setText(containerDefinition.getContainerMeta().getBuildContextUrl()); + } + + if (context.equals(IMAGE_CONTEXT)) { + initImageDetails(); + } else if (context.equals(CONTAINER_CONTEXT)) { + initContainerDetails(); + } else { + LOGGER.error("Container Panel init failed: Please use proper context"); + } + + } + + private void initImageDetails() { + + // currently do not allow user to change the Dockerfile in the suite. + txtContainerRecipe.setEnabled(false); + lblContainerRunOpt.setVisible(false); + txtContainerRun.setVisible(false); + bindMountConfigurator.setVisible(false); + } + + private void initContainerDetails() { + + txtContainerRecipe.setEnabled(false); + txtContainerRun.setText(containerDefinition.getContainerMeta().getRunOptions()); + bindMountConfigurator.setData(containerDefinition.getContainerMeta().getBindMountConfig()); + } + + public void addToChangeMonitor(DialogChangeMonitor changeMonitor) { + changeMonitor.add(txtContainerRecipe); + changeMonitor.add(txtContainerRun); + changeMonitor.add(bindMountConfigurator); + } + + /** + * Stores changes in ContainerDefinition and Uploads changes to Sat. + * + * @param satelliteToken for current session to communicate with Sat. + * @param image of the image version, which will be updated. + * @return Returns true uf upload successfully finished, false if error occurred. + */ + public boolean saveChanges(String satelliteToken, ImageDetailsRead image) { + + ContainerDefinition newConDev = new ContainerDefinition(containerDefinition); + + newConDev.getContainerMeta().setRunOptions(txtContainerRun.getText()); + newConDev.getContainerMeta().setBindMountConfig(bindMountConfigurator.getData()); + + // TODO do I really need this check? Maybe just get every setting and upload it. + if (!newConDev.equals(containerDefinition)) { + try { + ThriftManager.getSatClient() + .setImageVersionVirtConfig(satelliteToken, image.getLatestVersionId(), + newConDev.toByteBuffer()); + } catch (TException e) { + LOGGER.error("Upload new ContainerDefinition failed", e); + return false; + } + } + return true; + } +} + 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 efc75236..e8ac7091 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 @@ -37,6 +37,7 @@ import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor; import org.openslx.dozmod.gui.changemonitor.DialogChangeMonitor.TextNotEmptyConstraint; import org.openslx.dozmod.gui.helper.PopupMenu; import org.openslx.dozmod.gui.helper.*; +import org.openslx.dozmod.gui.panel.ContainerPanel; import org.openslx.dozmod.gui.window.UserListWindow.UserAddedCallback; import org.openslx.dozmod.gui.window.layout.ImageDetailsWindowLayout; import org.openslx.dozmod.gui.wizard.ImageUpdateWizard; @@ -131,8 +132,6 @@ import java.util.*; private AbstractControlWrapper<?> changeListenerPermissions; - private ContainerDefinition containerDefinition = new ContainerDefinition(); - /** * Constructor * @@ -355,6 +354,8 @@ import java.util.*; changeMonitor.add(chkDefaultPermAdmin); changeListenerPermissions = changeMonitor.add(ctlImagePermissionConfigurator); + this.pnlTabContainer.addToChangeMonitor(changeMonitor); + // update default permissions hook for the permission configurator to apply to newly added users final ItemListener updateDefaultPermissionsListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { @@ -423,45 +424,6 @@ import java.util.*; }); } - /** - * Uploads ByteBuffer data to satellite server and stores it in ImageVersion.VirtConfig - * for the given imageVersionId. - * - * @param imageVersionId Id of the image version, which will be updated. - * @param data New virtConfig to store in database. - */ - private void uploadContainerDef(final String imageVersionId, ByteBuffer data) { - - try { - ThriftManager.getSatClient() - .setImageVersionVirtConfig(Session.getSatelliteToken(), imageVersionId, data); - } catch (TException e) { - e.printStackTrace(); - } - } - - /** - * Loads binary file ImageVersion.VirtConfig from the Satellites Database. - * - * @param selected the selected Image Version. TODO: For now only just the latest Version. - */ - private byte[] loadContainerDef(final ImageVersionDetails selected) { - - byte[] rawVirtConfig = null; - - try { - ByteBuffer byteBuffer = ThriftManager.getSatClient() - .getImageVersionVirtConfig(Session.getSatelliteToken(), selected.versionId); - rawVirtConfig = ThriftUtil.unwrapByteBuffer(byteBuffer); - - } catch (TException e) { - LOGGER.error( - "Failed to retrieve virtualizer config for image version " + "'" + image.latestVersionId - + ", see trace: ", e); - } - return rawVirtConfig; - } - /******************************************************************************** * * Helper triggering the actual thrift calls @@ -624,43 +586,11 @@ import java.util.*; } } - // if image is container - // prepare to upload container definition to local satellite server. - // TODO - if (image.getVirtId().equals(TConst.VIRT_DOCKER)) - saveContainerDefinition(); - changeMonitor.reset(); 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 newConDev = new ContainerDefinition(containerDefinition); - - if (newConDev.getBuildContextMethod() == ContainerBuildContextMethod.FILE) { - newConDev.setContainerRecipe(txtContainerRecipe.getText()); - } - // currently no update of the git url allowed - - newConDev.getContainerMeta().setImageName(txtContainerImageName.getText()); - newConDev.getContainerMeta().setRunOptions(txtContainerRun.getText()); - newConDev.getContainerMeta().setBindMountConfig(bindMountConfigurator.getData()); - - if (!newConDev.equals(containerDefinition)) { - uploadContainerDef(image.versions.get(0).versionId, newConDev.toByteBuffer()); - LOGGER.info("Upload new DockerDefinition"); - } - } - - /** * Helper to save the custom user permissions (those not included in * ImageBaseWrite). * @@ -822,45 +752,6 @@ import java.util.*; if (virt != null) lblVirtualizer.setText(virt.getVirtName()); - if (TConst.VIRT_DOCKER.equals(image.getVirtId())) { - lblVirtualizer.setText(TConst.VIRT_DOCKER); - showContainerTab(); - - if (image.versions.isEmpty()) { - LOGGER.info("Close Window because no ImageVersions available!"); - dispose(); - return; - } - // TODO if only a single version is created an the user deletes it, next line will out of bounce! - containerDefinition = ContainerDefinition.fromByteArray(loadContainerDef(image.versions.get(0))); - - ContainerMeta containerMeta = containerDefinition.getContainerMeta(); - ContainerBuildContextMethod method = ContainerBuildContextMethod.fromInt( - containerMeta.getBuildContextMethod()); - - switch (method) { - case FILE: - txtContainerRecipe.setText(containerDefinition.getContainerRecipe()); - break; - case GIT_REPOSITORY: - txtContainerRecipe.setText(containerMeta.getBuildContextUrl()); - txtContainerRecipe.setEnabled(false); - break; - } - - txtContainerImageName.setText(containerMeta.getImageName()); - txtContainerRun.setText(containerMeta.getRunOptions()); - bindMountConfigurator.setData(containerMeta.getBindMountConfig(), true); - - changeMonitor.add(txtContainerRecipe). - addConstraint(new TextNotEmptyConstraint(I18n.WINDOW.getString("ImageDetails.Constraint.NoEmptyDockerfile.text"))); - changeMonitor.add(txtContainerImageName) - .addConstraint(new TextNotEmptyConstraint(I18n.WINDOW.getString("ImageDetails.Constraint.NoEmptyName.text"))); - changeMonitor.add(txtContainerRun) - .addConstraint(new TextNotEmptyConstraint(I18n.WINDOW.getString("ImageDetails.Constraint.NoEmptyRunOptions.text"))); - changeMonitor.add(bindMountConfigurator); - } - // fill share mode combo, if not already done if (cboShareMode.getItemCount() == 0) { for (ShareMode mode : ShareMode.values()) { @@ -929,12 +820,17 @@ import java.util.*; if (actionHandler.isImagePublishSupported()) btnUploadToMaster.setEnabled(editable); - if (image != null && TConst.VIRT_DOCKER.equals(image.getVirtId())) { + + // If this Image is from type Docker (Container) show the new Container Tab + if (image != null && image.getVirtId().equals(TConst.VIRT_DOCKER)) { + lblVirtualizer.setText(TConst.VIRT_DOCKER); + pnlTabContainer.init(Session.getSatelliteToken(), image, ContainerPanel.IMAGE_CONTEXT); + showContainerTab(); + // 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/LectureDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java index b98023b0..00f138f4 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java @@ -1,6 +1,5 @@ package org.openslx.dozmod.gui.window; -import java.awt.Color; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -45,6 +44,7 @@ import org.openslx.dozmod.gui.helper.DateTimeHelper; import org.openslx.dozmod.gui.helper.I18n; import org.openslx.dozmod.gui.helper.MessageType; import org.openslx.dozmod.gui.helper.UiFeedback; +import org.openslx.dozmod.gui.panel.ContainerPanel; import org.openslx.dozmod.gui.window.UserListWindow.UserAddedCallback; import org.openslx.dozmod.gui.window.layout.LectureDetailsWindowLayout; import org.openslx.dozmod.permissions.ImagePerms; @@ -59,6 +59,7 @@ import org.openslx.dozmod.thrift.ThriftError; import org.openslx.dozmod.thrift.cache.UserCache; import org.openslx.dozmod.util.FormatHelper; import org.openslx.thrifthelper.Comparators; +import org.openslx.thrifthelper.TConst; import org.openslx.thrifthelper.ThriftManager; /** @@ -117,7 +118,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /** * Constructor - * + * * @param modalParent parent of this popup window * @param callback function to be called when a lecture update occured */ @@ -193,6 +194,8 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements ctlRunscriptConfigurator.addToChangeMonitor(changeMonitor); ctlNetshareConfigurator.addToChangeMonitor(changeMonitor); ctlLdapFilterConfigurator.addToChangeMonitor(changeMonitor); + + pnlTabContainer.addToChangeMonitor(changeMonitor); // TODO: LDAP/NetShare: Having uncommitted changes in the input fields should be // handled too // End change monitor @@ -299,7 +302,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /** * Sets the lecture to show the details of by setting the 'lecture' and 'image' * members to its metadata. This method will fetch the information from the sat - * + * * @param lectureId the id of the lecture to be displayed */ public void setLecture(final String lectureId) { @@ -340,6 +343,14 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements txtImageName.setText(image.getImageName()); lblImageNameInfo.setText(image.getImageName()); } + + // init container info panel + if (image != null && image.getVirtId().equals(TConst.VIRT_DOCKER) ) + { + showContainerTab(); + pnlTabContainer.init(Session.getSatelliteToken(), image, ContainerPanel.CONTAINER_CONTEXT); + } + // init permission info adminRightsFromDefaultPermissions = lecture.defaultPermissions.admin; ctlPermissionManager.initPanel(customPermissions, lecture.defaultPermissions, lecture.ownerId); @@ -431,7 +442,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /** * Sets the lecture's owner to the given user - * + * * @param user UserInfo representation of the new owner */ private void setLectureOwner(final UserInfo user) { @@ -549,6 +560,14 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements metadata.setLdapFilters(ctlLdapFilterConfigurator.getState()); metadata.setPresetScriptIds(startupSettings.selectedScripts); + // TODO maybe there could be a nicer way to distinguish between Lectures withs Containers + if (image != null && image.getVirtId().equals(TConst.VIRT_DOCKER) ) { + if(!pnlTabContainer.saveChanges(Session.getSatelliteToken(),image)) + return false; + } else { + LOGGER.error("No Image: Could not save Container Settings!"); + } + // now trigger the actual action try { ThriftManager.getSatClient().updateLecture(Session.getSatelliteToken(), lecture.getLectureId(), metadata); @@ -589,7 +608,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /** * Checks if the given start and end date represent a valid time period. This is * the case, if start < end and if current time < end - * + * * @param start date of the period to check * @param end date of the period to check * @param feedback true if the user should be shown feedback, false otherwise @@ -644,7 +663,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /** * Opens a new LectureDetailsWindow showing the details of the lecture with ID = * lectureId - * + * * @param modalParent parent of this window * @param lectureId id of the lecture to set the details of */ @@ -667,7 +686,7 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements /* * ***************************************************************************** * ** - * + * * UIFeedback implementation * ********************************************************************************/ 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 4d141c18..64e2ddf5 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 @@ -30,6 +30,7 @@ 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.dozmod.gui.panel.ContainerPanel; import org.openslx.thrifthelper.Comparators; import javax.swing.*; @@ -46,12 +47,6 @@ import java.awt.*; protected final JTextField txtTitle; protected final JEditorPane txtDescription; - private final JPanel pnlTabContainer; - protected final JTextArea txtContainerRecipe; - protected final JTextField txtContainerRun; - protected final JTextField txtContainerImageName; - protected ContainerBindMountConfigurator bindMountConfigurator; - protected QLabel lblError; protected final PersonLabel lblOwner; protected final JButton btnChangeOwner; @@ -88,6 +83,8 @@ import java.awt.*; protected ImagePermissionConfigurator ctlImagePermissionConfigurator; + protected final ContainerPanel pnlTabContainer; + public ImageDetailsWindowLayout(Frame modalParent) { super(modalParent, "<init>", ModalityType.APPLICATION_MODAL); setResizable(true); @@ -293,36 +290,7 @@ import java.awt.*; * Container panel * ********************************************************************************/ - pnlTabContainer = new JPanel(); - 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); - - grdContainerMeta.add(new QLabel(I18n.WINDOW_LAYOUT.getString("ImageDetails.Label.ImageName.text"))); - txtContainerImageName = new JTextField(); - txtContainerImageName.setDocument(txtTitle.getDocument()); - grdContainerMeta.add(txtContainerImageName, 2).fill(true, false).expand(true, false); - grdContainerMeta.nextRow(); - - grdContainerMeta.add(new QLabel(I18n.WINDOW_LAYOUT.getString("ImageDetails.Label.ContainerRunOptions.text"))); - txtContainerRun = new JTextField(); - grdContainerMeta.add(txtContainerRun, 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); - - 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, true).expand(true, true); - //grdContainer.add(Box.createVerticalGlue()).fill(true, true).expand(true,true); - grdContainer.finish(true); - + pnlTabContainer = new ContainerPanel(); /* ******************************************************************************* @@ -362,6 +330,6 @@ import java.awt.*; 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)); + //pnlTabs.remove(pnlTabs.indexOfTab(TAB_VERSIONS_TITEL)); } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java index 6abdfc47..ff8b4d54 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java @@ -36,11 +36,7 @@ import org.jdatepicker.JDatePicker; import org.openslx.bwlp.thrift.iface.ImageVersionDetails; import org.openslx.dozmod.Branding; import org.openslx.dozmod.gui.Gui; -import org.openslx.dozmod.gui.configurator.LdapFilterConfigurator; -import org.openslx.dozmod.gui.configurator.LecturePermissionConfigurator; -import org.openslx.dozmod.gui.configurator.NetrulesConfigurator; -import org.openslx.dozmod.gui.configurator.NetshareConfigurator; -import org.openslx.dozmod.gui.configurator.StartupConfigurator; +import org.openslx.dozmod.gui.configurator.*; import org.openslx.dozmod.gui.control.ComboBox; import org.openslx.dozmod.gui.control.ComboBox.ComboBoxRenderer; import org.openslx.dozmod.gui.control.LocationSelector; @@ -50,6 +46,7 @@ import org.openslx.dozmod.gui.control.QLabel; import org.openslx.dozmod.gui.control.WordWrapLabel; import org.openslx.dozmod.gui.helper.GridManager; import org.openslx.dozmod.gui.helper.I18n; +import org.openslx.dozmod.gui.panel.ContainerPanel; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.cache.MetaDataCache; import org.openslx.dozmod.util.FormatHelper; @@ -115,6 +112,8 @@ public abstract class LectureDetailsWindowLayout extends JDialog { protected final JPanel pnlTabNetshare; protected final JPanel pnlTabLdapFilter; + protected final ContainerPanel pnlTabContainer; + public LectureDetailsWindowLayout(Frame modalParent) { super(modalParent, I18n.WINDOW_LAYOUT.getString("LectureDetails.Dialog.title"), ModalityType.APPLICATION_MODAL); @@ -183,7 +182,7 @@ public abstract class LectureDetailsWindowLayout extends JDialog { grdGeneral.add(new QLabel(I18n.WINDOW_LAYOUT.getString("LectureDetails.Label.title.text"))); grdGeneral.add(txtTitle, 4).expand(true, false).fill(true, false); grdGeneral.nextRow(); - + // description txtDescription = new JEditorPane(); grdGeneral.add(new QLabel(I18n.WINDOW_LAYOUT.getString("LectureDetails.Label.description.text"))).anchor(GridBagConstraints.FIRST_LINE_START); @@ -283,10 +282,10 @@ public abstract class LectureDetailsWindowLayout extends JDialog { grdGeneral.add(chkIsActive, 4); grdGeneral.nextRow(); grdGeneral.finish(true); - + Insets descriptionInset = new Insets(2, 4, 2, 4); Insets firstInset = new Insets(12, 4, 2, 4); - + // Network rules pnlTabNetrules = new JPanel(); GridManager grdNetrules = new GridManager(pnlTabNetrules, 1, true, new Insets(9, 4, 2, 4)); @@ -306,11 +305,11 @@ public abstract class LectureDetailsWindowLayout extends JDialog { grdNetrules.add(ctlNetrulesConfigurator).fill(true, true).expand(true, true); grdNetrules.nextRow(); grdNetrules.finish(false); - + // Tab restrictions pnlTabRestrictions = new JPanel(); GridManager grdRestrictions = new GridManager(pnlTabRestrictions, 2, true, new Insets(9, 4, 2, 4)); - + chkHasUsbAccess = new JCheckBox(I18n.WINDOW_LAYOUT.getString("LectureDetails.CheckBox.hasUSBAccess.text")); grdRestrictions.add(chkHasUsbAccess, 2); grdRestrictions.nextRow(); @@ -335,8 +334,8 @@ public abstract class LectureDetailsWindowLayout extends JDialog { .insets(descriptionInset); grdRestrictions.finish(true); - /* ******************************************************************************* - * + /* ******************************************************************************* + * * Tab "Permissions" * ********************************************************************************/ @@ -355,6 +354,13 @@ public abstract class LectureDetailsWindowLayout extends JDialog { grdPermissions.add(defaultPermissionPane).fill(true, false).expand(true, false); grdPermissions.finish(false); + /* ******************************************************************************* + * + * Tab "Container" + * + ********************************************************************************/ + pnlTabContainer = new ContainerPanel(); + /* ******************************************************************************* * * Tab "Locations" @@ -387,7 +393,7 @@ public abstract class LectureDetailsWindowLayout extends JDialog { GridManager grdNetshare = new GridManager(pnlTabNetshare, 1, false, new Insets(8, 2, 8, 2)); grdNetshare.add(ctlNetshareConfigurator).fill(true, true).expand(true, true); grdNetshare.finish(false); - + /* ******************************************************************************* * * Tab "LDAP-Filters" @@ -398,10 +404,10 @@ public abstract class LectureDetailsWindowLayout extends JDialog { GridManager grdLdap = new GridManager(pnlTabLdapFilter, 1, false, new Insets(8, 2, 8, 2)); grdLdap.add(ctlLdapFilterConfigurator).fill(true, true).expand(true, true); grdLdap.finish(false); - - /* ******************************************************************************* - * - * Main panel containing the tabs + + /* ******************************************************************************* + * + * Main panel containing the tabs * ********************************************************************************/ // finally build the tabbedPane and add it to the main view @@ -442,6 +448,10 @@ public abstract class LectureDetailsWindowLayout extends JDialog { add(buttonPanel, BorderLayout.SOUTH); } + protected void showContainerTab() { + pnlTabs.addTab("Container", pnlTabContainer); + } + private JSpinner makeTimeSpinner(int h, int m) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, h); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmMetaDataDummy.java b/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmMetaDataDummy.java deleted file mode 100644 index bd5d4323..00000000 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/util/VmMetaDataDummy.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.openslx.dozmod.util; - -import org.openslx.bwlp.thrift.iface.Virtualizer; -import org.openslx.thrifthelper.TConst; -import org.openslx.util.vm.VmMetaData; - -import java.io.File; -import java.util.List; - -public class VmMetaDataDummy extends VmMetaData { - // TODO Define DOCKER CONSTANT - private final Virtualizer virtualizer = new Virtualizer( TConst.VIRT_VMWARE, "DOCKER" ); - - public VmMetaDataDummy(List osList) { - super(osList); - } - - @Override public byte[] getFilteredDefinitionArray() { - return new byte[0]; - } - - @Override public void applySettingsForLocalEdit() { - - } - - @Override public boolean addHddTemplate(File diskImage, String hddMode, String redoDir) { - return false; - } - - @Override public boolean addHddTemplate(String diskImagePath, String hddMode, String redoDir) { - return false; - } - - @Override public boolean addDefaultNat() { - return false; - } - - @Override public void setOs(String vendorOsId) { - - } - - @Override public boolean addDisplayName(String name) { - return false; - } - - @Override public boolean addRam(int mem) { - return false; - } - - @Override public void addFloppy(int index, String image, boolean readOnly) { - - } - - @Override public boolean addCdrom(String image) { - return false; - } - - @Override public boolean addCpuCoreCount(int nrOfCores) { - return false; - } - - @Override public void setSoundCard(SoundCardType type) { - - } - - @Override public SoundCardType getSoundCard() { - return SoundCardType.NONE; - } - - @Override public void setDDAcceleration(DDAcceleration type) { - - } - - @Override public DDAcceleration getDDAcceleration() { - return DDAcceleration.OFF; - } - - @Override public void setHWVersion(HWVersion type) { - - } - - @Override public HWVersion getHWVersion() { - return HWVersion.DEFAULT; - } - - @Override public void setEthernetDevType(int cardIndex, EthernetDevType type) { - - } - - @Override public EthernetDevType getEthernetDevType(int cardIndex) { - return EthernetDevType.NONE; - } - - @Override public void setMaxUsbSpeed(UsbSpeed speed) { - - } - - @Override public UsbSpeed getMaxUsbSpeed() { - return UsbSpeed.NONE; - } - - @Override public byte[] getDefinitionArray() { - return new byte[0]; - } - - @Override public boolean addEthernet(EtherType type) { - return false; - } - - @Override public Virtualizer getVirtualizer() { - return virtualizer; - } - - @Override public boolean tweakForNonPersistent() { - return false; - } - - @Override public void registerVirtualHW() { - - } -} |