diff options
author | Stephan Schwär | 2020-10-22 11:17:14 +0200 |
---|---|---|
committer | Stephan Schwär | 2020-10-22 11:17:14 +0200 |
commit | 67bf5d0331e5dd25ca3db596466c278714101a39 (patch) | |
tree | 91a83e81970b7e5979601314734810c20e6a5353 /dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page | |
parent | [client] Set standard path of ovftool in windows (diff) | |
download | tutor-module-67bf5d0331e5dd25ca3db596466c278714101a39.tar.gz tutor-module-67bf5d0331e5dd25ca3db596466c278714101a39.tar.xz tutor-module-67bf5d0331e5dd25ca3db596466c278714101a39.zip |
[client] Add OVF Tool path for vmware workstation under windows
+ Code cleanup
+ Fix some user feedback strings
Feature: #3771
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java | 50 | ||||
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 59 |
2 files changed, 47 insertions, 62 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java index 97319a54..61c869c3 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageOvfConversionPage.java @@ -46,8 +46,14 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { this.state = uploadWizardState; page = this; String os = System.getProperty("os.name"); + // Linux install should have put the ovftool into the path variable. + // Try to set it for windows and macos. if (os.toLowerCase().contains("windows")) { - ovfToolPath = "C:\\Program Files (x86)\\VMware\\VMware Player\\OVFTool\\ovftool.exe"; + ovfToolPath = "C:\\Program Files (x86)\\VMware\\VMware Workstation\\OVFTool\\ovftool.exe"; + if (!(new File(ovfToolPath).exists())) { + ovfToolPath = "C:\\Program Files (x86)\\VMware\\VMware Player\\OVFTool\\ovftool.exe"; + } + } else if (os.toLowerCase().contains("mac")) { ovfToolPath = "/Applications/VMware Fusion.app/Contents/Library/VMware OVF Tool"; } @@ -77,39 +83,23 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { btnBrowseForOvftool.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - QFileChooser fc = new QFileChooser(Config.getUploadPath(), false); - int action = fc.showOpenDialog(getDialog()); - File file = fc.getSelectedFile(); - - if (action != JFileChooser.APPROVE_OPTION || file == null) { - return; - } - page.ovfToolPath = file.getAbsolutePath(); - btnStartConversion.setEnabled(true); - ovfToolFile.setText(page.ovfToolPath); + browseForOvftoolPath(); } }); } - private void browseForOvfTool() { - // fc.setAcceptAllFileFilterUsed(false); - // fc.addChoosableFileFilter(vmxFilter); - // fc.addChoosableFileFilter(ovfFilter); - // if (Session.hasFeature(Feature.MULTIPLE_HYPERVISORS)) { - // fc.addChoosableFileFilter(vboxFilter); - // } - // fc.addChoosableFileFilter(allSupportedFilter); - // fc.setFileFilter(allSupportedFilter); - // // differentiate between existing and new VMs - // if (existingImage != null) { - // if (existingImage.virtId.equals(TConst.VIRT_VMWARE)) { - // fc.setFileFilter(vmxFilter); - // } else if (existingImage.virtId.equals(TConst.VIRT_VIRTUALBOX)) { - // fc.setFileFilter(vboxFilter); - // } - // } + public void browseForOvftoolPath() { + QFileChooser fc = new QFileChooser(Config.getUploadPath(), false); + int action = fc.showOpenDialog(getDialog()); + File file = fc.getSelectedFile(); + if (action != JFileChooser.APPROVE_OPTION || file == null) { + return; + } + page.ovfToolPath = file.getAbsolutePath(); + btnStartConversion.setEnabled(true); + ovfToolFile.setText(page.ovfToolPath); } public void cancelConversionWorker() { @@ -147,12 +137,12 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { .showConfirmDialog(this, "Für die abgebrochene Konvertierung wurde ein Verzeichnis erstellt.\n" + "Soll dieses und dessen Inhalt wieder entfernt werden?", - "Teststring", dialogButton); + "Verzeichnis Überschreiben?", dialogButton); } else { dialogResult = JOptionPane.showConfirmDialog(this, "Das Verzeichnis, in welcher das konvertierte Image gespeichert werden soll existiert bereits. \n" + "Soll dieses ersetzt und die darin enthaltenen Dateien gelöscht werden?", - "Teststring", dialogButton); + "Verzeichnis Überschreiben?", dialogButton); } if (dialogResult == 0) { FileUtils.deleteDirectory(directoryFile); 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 df485907..d3b067ef 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 @@ -52,16 +52,13 @@ public class ImageUploadPage extends ImageUploadPageLayout { private ImageDetailsRead existingImage = null; private final FileNameExtensionFilter allSupportedFilter; - private final FileNameExtensionFilter vmxFilter = new FileNameExtensionFilter("VMware Virtual Machine", - "vmx"); - private final FileNameExtensionFilter vboxFilter = new FileNameExtensionFilter( - "VirtualBox Virtual Machine", "vbox"); + private final FileNameExtensionFilter vmxFilter = new FileNameExtensionFilter("VMware Virtual Machine", "vmx"); + private final FileNameExtensionFilter vboxFilter = new FileNameExtensionFilter("VirtualBox Virtual Machine", + "vbox"); - private final FileNameExtensionFilter ovfFilter = new FileNameExtensionFilter( - "ovf Virtual Machine Format", "ovf"); + private final FileNameExtensionFilter ovfFilter = new FileNameExtensionFilter("ovf Virtual Machine Format", "ovf"); - public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState, - final ImageDetailsRead existingImage) { + public ImageUploadPage(Wizard wizard, UploadWizardState uploadWizardState, final ImageDetailsRead existingImage) { super(wizard); setPageComplete(false); this.canComeBack = false; @@ -135,20 +132,20 @@ public class ImageUploadPage extends ImageUploadPageLayout { // gets the metadata object of the selected VM depending on its type state.meta = VmMetaData.getInstance(MetaDataCache.getOperatingSystems(), file); } catch (IOException e) { - Gui.showMessageBox(this, "Konnte " + file.getPath() + " nicht lesen", MessageType.ERROR, LOGGER, - e); + Gui.showMessageBox(this, "Konnte " + file.getPath() + " nicht lesen", MessageType.ERROR, LOGGER, e); setPageComplete(false); return; } - // if the description file is an ovf file, we can end here and jump to the conversion page + // if the description file is an ovf file, we can end here and jump to the + // conversion page if (state.meta instanceof OvfMetaData) { int dialogButton = JOptionPane.YES_NO_OPTION; int dialogResult = JOptionPane.showConfirmDialog(this, "Sie haben ein Image im ovf Format ausgewählt. \n" - + "Wenn dieses mit dem Programm vmWare exportiert wurde sollte es mithilfe\n" - + "des ovfTool von vmWare in ein kompatibles vmx Image umgewandelt werden können. \n" - + "Möchten sie die Konvertierung starten?", + + "Wenn dieses mit dem Programm VMware exportiert wurde sollte es mithilfe\n" + + "des ovfTool von VMware in ein kompatibles vmx Image umgewandelt werden können. \n" + + "Möchten sie das Image konvertieren? (Das original Image bleibt unverändert.)", "Image konvertieren?", dialogButton); if (dialogResult == 0) { txtImageFile.setText(file.getAbsolutePath()); @@ -197,8 +194,7 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } if (hdds.size() > 1) { - setErrorMessage( - "Die gewählte " + fileformat + "-Datei enthält mehr als eine virtuelle Festplatte!"); + setErrorMessage("Die gewählte " + fileformat + "-Datei enthält mehr als eine virtuelle Festplatte!"); setPageComplete(false); return; // Allow to continue!? @@ -240,10 +236,10 @@ public class ImageUploadPage extends ImageUploadPageLayout { return; } if (!diskImage.isStandalone) { - Gui.showMessageBox("Die zu dieser VM gehörige Virtuelle Festplatte ist im Format '" - + diskImage.subFormat + "'.\n" + "Dieses Format wird von " + Branding.getApplicationName() - + " nicht unterstützt. Bitte konvertieren Sie die VM\n" - + "in das Format 'monolithicSparse'.", MessageType.WARNING, null, null); + Gui.showMessageBox("Die zu dieser VM gehörige Virtuelle Festplatte ist im Format '" + diskImage.subFormat + + "'.\n" + "Dieses Format wird von " + Branding.getApplicationName() + + " nicht unterstützt. Bitte konvertieren Sie die VM\n" + "in das Format 'monolithicSparse'.", + MessageType.WARNING, null, null); setErrorMessage("Die VMDK Datei der VM hat ein inkompatibles Format"); setPageComplete(false); return; @@ -289,20 +285,20 @@ public class ImageUploadPage extends ImageUploadPageLayout { * This function starts the image creation process. It is triggered by the * "Next" button. * - * Depending on the state, it will first try to get a UUID for the new image - * by calling createImage() of the thrift API. If a UUID is received, it - * will request an upload with requestImageVersionUpload(). If granted, it - * will finally start a thread for the UploadTask. + * Depending on the state, it will first try to get a UUID for the new image by + * calling createImage() of the thrift API. If a UUID is received, it will + * request an upload with requestImageVersionUpload(). If granted, it will + * finally start a thread for the UploadTask. * - * Then a callback to the Gui is executed where we can process the upload - * state and give the user feedback about it. + * Then a callback to the Gui is executed where we can process the upload state + * and give the user feedback about it. * */ @Override protected boolean wantNextOrFinish() { // if (state.isOvf) { - // return true; + // return true; // } // Check for vmware player lock files - warn user if found, might corrupt upload @@ -334,14 +330,12 @@ public class ImageUploadPage extends ImageUploadPageLayout { // file, connecting for upload... if (state.upload == null) { try { - state.upload = new UploadInitiator(state.uuid, state.diskFile, - state.meta.getFilteredDefinition()); + state.upload = new UploadInitiator(state.uuid, state.diskFile, state.meta.getFilteredDefinition()); } catch (WrappedException e) { ThriftError.showMessage(this, LOGGER, e.exception, e.displayMessage); return false; } catch (IOException e) { - Gui.showMessageBox(this, "Upload-Initialisierung fehlgeschlagen", MessageType.ERROR, LOGGER, - e); + Gui.showMessageBox(this, "Upload-Initialisierung fehlgeschlagen", MessageType.ERROR, LOGGER, e); return false; } } @@ -354,7 +348,8 @@ public class ImageUploadPage extends ImageUploadPageLayout { @Override protected void onPageEnter() { super.onPageEnter(); - // When entering from the conversion page the user probably wants to upload the new vmx file + // When entering from the conversion page the user probably wants to upload the + // new vmx file if (state.convertedDescriptionFile != null) vmSelected(state.convertedDescriptionFile); } |