diff options
author | ralph isenmann | 2021-05-11 09:17:52 +0200 |
---|---|---|
committer | ralph isenmann | 2021-05-11 09:17:52 +0200 |
commit | 568506424ab62dbc42198940451fb73d46407ff1 (patch) | |
tree | 6da72faf7b39e85d6284a696a86fcf4abd34a9c6 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard | |
parent | [server] Fix NPE (diff) | |
download | tutor-module-568506424ab62dbc42198940451fb73d46407ff1.tar.gz tutor-module-568506424ab62dbc42198940451fb73d46407ff1.tar.xz tutor-module-568506424ab62dbc42198940451fb73d46407ff1.zip |
[client] Allow user to define container with Repository Image (directly from hub.docker)
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard')
2 files changed, 31 insertions, 5 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java index 5fcc6dcd..0496261f 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ContainerUploadPageLayout.java @@ -24,6 +24,8 @@ public class ContainerUploadPageLayout extends WizardPage { protected final QLabel lblImageName; protected final JTextArea txtInfoText; + protected final JTextField txtImageRepo; + protected final JTabbedPane tpInput; protected final JTextField txtGitRepo; @@ -38,8 +40,24 @@ public class ContainerUploadPageLayout extends WizardPage { setDescription(I18n.PAGE_LAYOUT.getString("ContainerUploadPage.description")); GridManager grid = new GridManager(this, 3, false); + JPanel imageRepoPanel = new JPanel(); + imageRepoPanel.setVisible(true); + GridManager tmpGrid = new GridManager(imageRepoPanel, 2, true, new Insets(5, 0, 5, 0)); + QLabel lblImageRepo = new QLabel( + I18n.PAGE_LAYOUT.getString("ContainerUploadPage.DockerFile.label")); + lblImageRepo.setToolTipText( + I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ImageRepository.ToolTipText")); + txtImageRepo = new JTextField(); + txtImageRepo.setEditable(true); + txtImageRepo.setToolTipText( + I18n.PAGE_LAYOUT.getString("ContainerUploadPage.ImageRepository.ToolTipText")); + tmpGrid.add(lblImageRepo); + tmpGrid.add(txtImageRepo).fill(true, false).expand(true, false); + tmpGrid.finish(false); + + JPanel p1 = new JPanel(); - p1.setVisible(true); + p1.setVisible(false); GridManager g1 = new GridManager(p1, 3, true, new Insets(5, 0, 5, 0)); QLabel imageFileCaption = new QLabel( I18n.PAGE_LAYOUT.getString("ContainerUploadPage.DockerFile.label")); @@ -68,13 +86,12 @@ public class ContainerUploadPageLayout extends WizardPage { tpInput = new JTabbedPane(); tpInput.addTab("Dockerfile", p1); tpInput.addTab("Git Repository", p2); - tpInput.setSelectedIndex(ContainerBuildContextMethod.FILE.ordinal()); + tpInput.addTab("Image Repository", imageRepoPanel); + // set "Image Repository" as selected + tpInput.setSelectedIndex(2); grid.add(tpInput, 3).fill(true, false); - // Start as with Dockerfile as input! - tpInput.setSelectedIndex(0); - lblImageName = new QLabel(I18n.PANEL.getString("ContainerPanel.Label.ImageName.text")); txtImageName = new JTextField(); grid.add(lblImageName); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java index b16a9785..7ff19882 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ContainerUploadPage.java @@ -232,6 +232,12 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { ContainerBuildContextMethod method = getBuildContextMethod(); switch (method) { + case IMAGE_REPO: + if (txtImageRepo.getText() == null || txtImageRepo.getText().isEmpty()) { + setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoImageRepo")); + return false; + } + break; case FILE: if (txtImageFile.getText() == null || txtImageFile.getText().isEmpty()) { setWarningMessage(I18n.PAGE.getString("ContainerUploadPage.Warning.NoReceipt")); @@ -270,6 +276,9 @@ public class ContainerUploadPage extends ContainerUploadPageLayout { case FILE: containerDefinition.setContainerRecipe(state.descriptionFile); break; + case IMAGE_REPO: + containerMeta.setImageRepo(txtImageRepo.getText()); + state.descriptionFile = getDummyFile(); case GIT_REPOSITORY: containerMeta.setBuildContextUrl(txtGitRepo.getText()); state.descriptionFile = getDummyFile(); |