diff options
author | Stephan Schwär | 2021-02-19 04:08:04 +0100 |
---|---|---|
committer | Stephan Schwär | 2021-02-19 04:08:04 +0100 |
commit | 7631383a56fc7dd5e5621ef0efa81e0c777f3218 (patch) | |
tree | 4b0e8ba2b510c86184d3342fadd9229b542d540e /dozentenmodul/src/main/java | |
parent | Merge remote-tracking branch 'origin/feature/qemu-integration' into feature-m... (diff) | |
parent | [client] Improve error handling for vmwarevm (diff) | |
download | tutor-module-7631383a56fc7dd5e5621ef0efa81e0c777f3218.tar.gz tutor-module-7631383a56fc7dd5e5621ef0efa81e0c777f3218.tar.xz tutor-module-7631383a56fc7dd5e5621ef0efa81e0c777f3218.zip |
Merge branch 'feature/vmwarevm-support' into feature-merge
Diffstat (limited to 'dozentenmodul/src/main/java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index eb5e3d4e..c764bee3 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -6,6 +6,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.io.File; import java.io.FileNotFoundException; +import java.io.FilenameFilter; import java.io.IOException; import java.util.List; @@ -132,6 +133,42 @@ public class ImageUploadPage extends ImageUploadPageLayout { int action = fc.showOpenDialog(getDialog()); File file = fc.getSelectedFile(); + if (action == JFileChooser.APPROVE_OPTION) { + // If the vm was exported via vmware fusion on macos it might be + // a vmwarevm which is a directory containing the vm files within. + if (file != null && file.isDirectory()) { + try { + File[] vmxfiles = file.listFiles(new FilenameFilter() { + public boolean accept(File dir, String filename) { + return filename.endsWith(".vmx"); + } + }); + + // There should be only one vmx file in the directory + if (vmxfiles.length < 1) { + // TODO translate + Gui.showMessageBox(this, + I18n.PAGE.getString("ImageUpload.WizardPage.errorMessage.noVmxInDir"), + MessageType.ERROR, LOGGER, null); + return; + } else if (vmxfiles.length >= 2) { + Gui.showMessageBox(this, + I18n.PAGE.getString( + "ImageUpload.WizardPage.errorMessage.multipleVmxInDirFound"), + MessageType.ERROR, LOGGER, null); + } + if (vmxfiles[0] != null && vmxfiles[0].isFile()) + file = vmxfiles[0]; + } catch (Exception e) { + Gui.showMessageBox(this, + I18n.PAGE.getString( + "ImageUpload.WizardPage.errorMessage.errorWhileSearchingForVmx"), + MessageType.ERROR, LOGGER, e); + return; + } + } + } + if (action != JFileChooser.APPROVE_OPTION || file == null) return; vmSelected(file.getAbsoluteFile()); @@ -143,8 +180,6 @@ public class ImageUploadPage extends ImageUploadPageLayout { I18n.PAGE.getString("ImageUpload.WizardPage.dialog.OvfOvaDetected"), I18n.PAGE.getString("ImageUpload.WizardPage.dialog.title"), dialogButton); if (dialogResult == 0) { - // txtImageFile.setText(file.getAbsolutePath()); - // txtImageName.setText(state.meta.getDisplayName()); state.descriptionFile = file; setErrorMessage(null); setDescription("Bitte starten Sie die Konvertierung."); |