diff options
Diffstat (limited to 'dozentenmodul/src/main/java')
6 files changed, 115 insertions, 33 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java index 1c2b2201..745a5b47 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java @@ -52,12 +52,16 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif * Adding Pages to the Wizard to create a virtual machine */ public void doVmCreation() { + cleanCurrent(); - currentPages.add(new ImageUploadPage(this, state, null)); - // currentPages.add(new ImageOvfConversionPage(this,state)); + state.imageUploadPage = new ImageUploadPage(this, state, null); + currentPages.add(state.imageUploadPage); currentPages.add(new ImageMetaDataPage(this, state)); currentPages.add(new ImageCustomPermissionPage(this, state)); addPages(); + + state.conversionPage = new ImageOvfConversionPage(this, state); + addOutOfOrderPage(state.conversionPage); } /** @@ -66,20 +70,20 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif public void doDockerCreation() { cleanCurrent(); - currentPages.add(new DockerfileUploadPage(this,state)); - currentPages.add(new ImageMetaDataPage(this,state)); + currentPages.add(new DockerfileUploadPage(this, state)); + currentPages.add(new ImageMetaDataPage(this, state)); currentPages.add(new ImageCustomPermissionPage(this, state)); addPages(); } private void addPages() { - for (WizardPage i:currentPages) { + for (WizardPage i : currentPages) { addPage(i); } } private void cleanCurrent() { - if( !currentPages.isEmpty()) { + if (!currentPages.isEmpty()) { removePages(currentPages); currentPages = new ArrayList<WizardPage>(); } @@ -133,8 +137,8 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif public void fire() { // push version data try { - ThriftActions.updateImageVersion(state.upload.getToken(), new ImageVersionWrite( - state.isRestricted)); + ThriftActions.updateImageVersion(state.upload.getToken(), + new ImageVersionWrite(state.isRestricted)); } catch (TException e) { if (state.isRestricted) { Gui.showMessageBox(null, "Unerwarteter Fehler beim Setzen der Option" @@ -221,6 +225,16 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif } @Override + protected final void doPrevious() { + if (state.outOfOrderFlow) { + state.outOfOrderFlow = false; + returnAfterOutOfOrderPage(state.imageUploadPage, state.conversionPage); + } else { + super.doPrevious(); + } + } + + @Override protected boolean onCancelRequest() { if (state.uuid == null) return true; diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java index 5ce2c815..cd455e6a 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java @@ -146,7 +146,7 @@ public abstract class Wizard extends JDialog { super.show(); } - private void showPage(int index) { + protected void showPage(int index) { if (currentPage != -1) { WizardPage old = getPage(currentPage); old.onPageLeave(); @@ -161,6 +161,36 @@ public abstract class Wizard extends JDialog { validate(); } + // Show an out of order page e.g. for converting an image + public void showOutOfOrderPage(WizardPage page) { + WizardPage old = getPage(currentPage); + old.onPageLeave(); + old.setVisible(false); + + page.onPageEnter(); + page.setVisible(true); + updateHeader(page); + updateButtons(page); + validate(); + } + + // Show an out of order page e.g. for converting an image + /** + * + * @param NewPage to return to. + * @param OldPage that should be hidden. + */ + public void returnAfterOutOfOrderPage(WizardPage newPage, WizardPage oldPage) { + oldPage.onPageLeave(); + oldPage.setVisible(false); + + newPage.onPageEnter(); + newPage.setVisible(true); + updateHeader(newPage); + updateButtons(newPage); + validate(); + } + void updateHeader(WizardPage page) { if (!isPostFinish && (currentPage == -1 || getPage(currentPage) != page)) return; @@ -172,7 +202,8 @@ public abstract class Wizard extends JDialog { pageDesc = ""; titleLabel.setText(pageTitle); messageLabel.setText(pageDesc); - messageLabel.setIcon(ResourceLoader.getScaledIcon(page.getMessageIcon(), messageLabel.getHeight(), messageLabel)); + messageLabel.setIcon( + ResourceLoader.getScaledIcon(page.getMessageIcon(), messageLabel.getHeight(), messageLabel)); messageLabel.setForeground(page.getMessageColor()); messageLabel.validate(); setTitle(getWindowTitle() + " - " + pageTitle); @@ -188,9 +219,14 @@ public abstract class Wizard extends JDialog { pages.add(page); } + // For adding pages which are not in the normal linear flow + protected final void addOutOfOrderPage(WizardPage page) { + contentPanel.add(page); + page.setVisible(false); + } + protected final void removePages(List<WizardPage> currentPages) { - for (WizardPage i: currentPages) - { + for (WizardPage i : currentPages) { pages.remove(i); } } @@ -249,7 +285,11 @@ public abstract class Wizard extends JDialog { } } - protected final void doPrevious() { + // protected void returnAfterOutOfOrderPage(int previousPage){ + // showPage(previousPage); + // } + + protected void doPrevious() { if (isPostFinish || !btnPrev.isEnabled()) return; if (currentPage > 0) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageOvfConversionPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageOvfConversionPageLayout.java index 0e6224f8..d86d063e 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageOvfConversionPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageOvfConversionPageLayout.java @@ -5,6 +5,7 @@ import java.awt.event.KeyEvent; import javax.swing.BorderFactory; import javax.swing.Box; import javax.swing.JButton; +import javax.swing.JTextArea; import javax.swing.JTextField; import org.openslx.dozmod.gui.control.QLabel; @@ -23,13 +24,14 @@ public abstract class ImageOvfConversionPageLayout extends WizardPage { */ public ImageOvfConversionPageLayout(Wizard wizard) { super(wizard, "ovf konvertieren"); - setDescription("Bitte wählen Sie eine Virtuelle Maschine zum Hochladen aus."); + setDescription("Ovf zu vmx konvertieren."); GridManager grid = new GridManager(this, 3, false); // -- Browse for VM -- - QLabel imageFileCaption = new QLabel("Virtuelle Maschine"); + QLabel imageFileCaption = new QLabel( + "Mit dem Betätigen des konvertieren Buttons wird versucht das ovfTool zu starten."); - btnStartConversion = new JButton("Durchsuchen"); + btnStartConversion = new JButton("Konvertieren"); btnStartConversion.setMnemonic(KeyEvent.VK_B); grid.add(imageFileCaption); grid.add(btnStartConversion); @@ -45,7 +47,7 @@ public abstract class ImageOvfConversionPageLayout extends WizardPage { txtInfoText.setFocusable(false); txtInfoText.setOpaque(false); txtInfoText.setText("Je nach Geschwindigkeit Ihres Computers " - + "und der Größe der Virtuellen Maschine kann die Konvertierung" + + "und der Größe der Virtuellen Maschine kann die Konvertierung " + "einige Zeit in Anspruch nehmen."); grid.add(txtInfoText, 3).fill(true, false).expand(true, false); grid.nextRow(); 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 dd673324..3b9cd69d 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 @@ -34,10 +34,17 @@ public class ImageOvfConversionPage extends ImageOvfConversionPageLayout { convertOvfToVmx(); } }); - } private void convertOvfToVmx() { LOGGER.debug("Conversion button clicked"); } + + /** + * + */ + @Override + protected boolean wantNextOrFinish() { + return false; + } } 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 43db9b95..fcf4ab99 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 @@ -143,15 +143,28 @@ public class ImageUploadPage extends ImageUploadPageLayout { // If the description file is an ovf file, we can end here to be able to skip to conversion. if (state.meta instanceof OvfMetaData) { - JOptionPane.showMessageDialog(wizard, - "Sie haben ein Image im ovf Format ausgewählt. Dieses muss vor dem Upload im nächsten Schritt konvertiert werden."); - txtImageFile.setText(file.getAbsolutePath()); - txtImageName.setText(state.meta.getDisplayName()); - state.descriptionFile = file; - setErrorMessage(null); - setDescription("Im nächsten Schritt wird die Konvertierung gestartet."); - setPageComplete(true); - return; + 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?", + "Image konvertieren?", dialogButton); + if (dialogResult == 0) { + txtImageFile.setText(file.getAbsolutePath()); + txtImageName.setText(state.meta.getDisplayName()); + state.descriptionFile = file; + setErrorMessage(null); + setDescription("Im nächsten Schritt wird die Konvertierung gestartet."); + // setPageComplete(true); + state.outOfOrderFlow = true; + wizard.showOutOfOrderPage(state.conversionPage); + return; + } else { + setPageComplete(false); + return; + } + } if (state.meta == null || state.meta.getDisplayName() == null) { @@ -290,9 +303,9 @@ public class ImageUploadPage extends ImageUploadPageLayout { @Override protected boolean wantNextOrFinish() { - if (state.isOvf) { - return true; - } + // if (state.isOvf) { + // return true; + // } // Check for vmware player lock files - warn user if found, might corrupt upload if (askCancelLockFile(state.descriptionFile.getAbsolutePath() + ".lck", diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java b/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java index f70cf156..ec7aa5c0 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/state/UploadWizardState.java @@ -7,6 +7,7 @@ import java.util.Map; import org.openslx.bwlp.thrift.iface.ImagePermissions; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.ShareMode; +import org.openslx.dozmod.gui.wizard.WizardPage; import org.openslx.dozmod.thrift.Session; import org.openslx.dozmod.thrift.UploadInitiator; import org.openslx.util.vm.VmMetaData; @@ -35,8 +36,8 @@ public class UploadWizardState { public boolean isRestricted = true; // flags an image as a template public boolean isTemplate = false; - // flag if we the description file is in the ovf format - public boolean isOvf = false; + // flag if we the description file is in the ovf format that needs conversion + public boolean outOfOrderFlow = false; /** * list of strings for tags */ @@ -44,7 +45,7 @@ public class UploadWizardState { // -- Objects returned by thrift calls -- // UUID given returned by the satellite after creating the image public String uuid = null; - + public UploadInitiator upload = null; /** @@ -52,4 +53,9 @@ public class UploadWizardState { */ public VmMetaData meta = null; + // To be able to call the conversion Page from within the ImageUploadPage + // TODO find cleaner approach, this probably shouldn't be in here.. + public WizardPage conversionPage; + public WizardPage imageUploadPage; + } |
