diff options
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 45 |
1 files changed, 33 insertions, 12 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 a23a62ac..ad1cd40d 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 @@ -127,17 +127,40 @@ public class ImageUploadPage extends ImageUploadPageLayout { int action = fc.showOpenDialog(getDialog()); File file = fc.getSelectedFile(); - // 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()) { - File[] vmxfiles = file.listFiles(new FilenameFilter() { - public boolean accept(File dir, String filename) { - return filename.endsWith(".vmx"); + 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; } - }); - // There should be only one vmx file in the directory - if (vmxfiles[0] != null && vmxfiles[0].isFile()) - file = vmxfiles[0]; + } } if (action != JFileChooser.APPROVE_OPTION || file == null) @@ -151,8 +174,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."); |