summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-03-17 13:11:39 +0100
committerSimon Rettberg2022-03-17 13:11:39 +0100
commitbff3e6f556534c04ad192a171de81bcc6c3a7334 (patch)
tree1499674f2ce9d8a69ed84e6ce9036b6014fdec97
parent[client] Add timestamps to file logger (diff)
downloadtutor-module-bff3e6f556534c04ad192a171de81bcc6c3a7334.tar.gz
tutor-module-bff3e6f556534c04ad192a171de81bcc6c3a7334.tar.xz
tutor-module-bff3e6f556534c04ad192a171de81bcc6c3a7334.zip
[client] Try to do a better job cleaning up when closing wizards
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageCreationWizard.java42
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java8
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java7
-rw-r--r--dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/Wizard.java26
4 files changed, 66 insertions, 17 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 6d310bf1..0bfe2b22 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
@@ -1,5 +1,13 @@
package org.openslx.dozmod.gui.wizard;
+import java.awt.Window;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.thrift.TException;
@@ -10,24 +18,27 @@ import org.openslx.dozmod.gui.helper.I18n;
import org.openslx.dozmod.gui.helper.MessageType;
import org.openslx.dozmod.gui.helper.QuitNotification;
import org.openslx.dozmod.gui.helper.UiFeedback;
-import org.openslx.dozmod.gui.wizard.page.*;
+import org.openslx.dozmod.gui.wizard.page.ContainerUploadPage;
+import org.openslx.dozmod.gui.wizard.page.ImageCustomPermissionPage;
+import org.openslx.dozmod.gui.wizard.page.ImageMetaDataPage;
+import org.openslx.dozmod.gui.wizard.page.ImageOvfConversionPage;
+import org.openslx.dozmod.gui.wizard.page.ImageTypePage;
+import org.openslx.dozmod.gui.wizard.page.ImageUploadPage;
+import org.openslx.dozmod.gui.wizard.page.ImageUploadSummaryPage;
import org.openslx.dozmod.model.ContainerDefinition;
import org.openslx.dozmod.state.UploadWizardState;
-import org.openslx.dozmod.thrift.*;
+import org.openslx.dozmod.thrift.Session;
+import org.openslx.dozmod.thrift.ThriftActions;
+import org.openslx.dozmod.thrift.ThriftError;
+import org.openslx.dozmod.thrift.UploadInitiator;
import org.openslx.dozmod.thrift.UploadInitiator.GotUploadTokenCallback;
+import org.openslx.dozmod.thrift.WrappedException;
import org.openslx.sat.thrift.version.Feature;
import org.openslx.thrifthelper.ThriftManager;
import org.openslx.util.QuickTimer;
import org.openslx.util.QuickTimer.Task;
import org.openslx.virtualization.configuration.VirtualizationConfigurationDocker;
-import javax.swing.*;
-import java.awt.*;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.List;
-
public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotification {
/**
@@ -37,9 +48,9 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif
private final static Logger LOGGER = LogManager.getLogger(ImageCreationWizard.class);
- private final UploadWizardState state = new UploadWizardState();
+ private UploadWizardState state = new UploadWizardState();
- private final ContainerDefinition containerDefinition = new ContainerDefinition();
+ private ContainerDefinition containerDefinition = new ContainerDefinition();
private List<WizardPage> currentPages = new ArrayList<>();
@@ -313,7 +324,14 @@ public class ImageCreationWizard extends Wizard implements UiFeedback, QuitNotif
@Override public void onApplicationQuit() {
if (state != null && state.upload != null) {
- state.upload.cancelError("Application quit (redirected via wizard)");
+ state.upload.cancelError("Application quit (via ImageCreationWizard)");
}
}
+
+ @Override
+ protected void doCleanup() {
+ state = null;
+ containerDefinition = null;
+ currentPages.clear();
+ }
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java
index ccdf8d53..ac8f80c1 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/ImageUpdateWizard.java
@@ -31,7 +31,7 @@ public class ImageUpdateWizard extends Wizard implements UiFeedback, QuitNotific
private static final long serialVersionUID = -584900619809829672L;
private final static Logger LOGGER = LogManager.getLogger(ImageCreationWizard.class);
- private final UploadWizardState state = new UploadWizardState();
+ private UploadWizardState state = new UploadWizardState();
protected ImageUploadPage imageUploadPage;
@@ -145,4 +145,10 @@ public class ImageUpdateWizard extends Wizard implements UiFeedback, QuitNotific
}
}
+ @Override
+ protected void doCleanup() {
+ imageUploadPage = null;
+ state = null;
+ }
+
}
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
index bd7c0aeb..6df5c494 100644
--- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
+++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/LectureWizard.java
@@ -29,7 +29,7 @@ public class LectureWizard extends Wizard implements UiFeedback {
private final static Logger LOGGER = LogManager.getLogger(LectureWizard.class);
- public final LectureWizardState state = new LectureWizardState();
+ public LectureWizardState state = new LectureWizardState();
/**
* Wizard for creating or editing a lecture.
@@ -144,4 +144,9 @@ public class LectureWizard extends Wizard implements UiFeedback {
lw.networkExceptions = state.netRules;
return lw;
}
+
+ @Override
+ protected void doCleanup() {
+ state = null;
+ }
}
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 3c5e27ba..6490180b 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
@@ -275,14 +275,14 @@ public abstract class Wizard extends JDialog {
if (outOfOrderPage != null) {
outOfOrderPage.onPageLeave();
}
- dispose();
+ cleanup();
}
}
protected final void doFinish() {
if (isPostFinish) {
postFinishPage.onPageLeave();
- dispose();
+ cleanup();
return;
}
if (!btnFinish.isEnabled())
@@ -297,7 +297,7 @@ public abstract class Wizard extends JDialog {
}
postFinishPage = performFinish();
if (postFinishPage == null) {
- dispose();
+ cleanup();
} else {
isPostFinish = true;
btnPrev.setVisible(false);
@@ -355,5 +355,25 @@ public abstract class Wizard extends JDialog {
protected WizardPage performFinish() {
return null;
}
+
+ /**
+ * Called when this wizard is closed, either by aborting or
+ * by finishing it.
+ */
+ private final void cleanup()
+ {
+ doCleanup();
+ dispose();
+ pages.clear();
+ postFinishPage = null;
+ outOfOrderPage = null;
+ }
+
+ /**
+ * Force all derived wizards to think about what
+ * references they might want to free when they're
+ * being closed.
+ */
+ protected abstract void doCleanup();
}