Code that results in UI interaction needs to be invoked on the EDT.

This commit is contained in:
Eamonn Saunders 2014-12-01 10:21:57 -05:00
parent f9e998dcd6
commit 4e1da6b73e

View File

@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.casemodule; package org.sleuthkit.autopsy.casemodule;
import java.awt.EventQueue;
import java.awt.Frame; import java.awt.Frame;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeSupport;
@ -1077,7 +1078,7 @@ public class Case implements SleuthkitCase.ErrorObserver {
} }
//case change helper //case change helper
private static void doCaseChange(Case toChangeTo) { private static void doCaseChange(final Case toChangeTo) {
logger.log(Level.INFO, "Changing Case to: " + toChangeTo); //NON-NLS logger.log(Level.INFO, "Changing Case to: " + toChangeTo); //NON-NLS
if (toChangeTo != null) { // new case is open if (toChangeTo != null) { // new case is open
@ -1085,6 +1086,9 @@ public class Case implements SleuthkitCase.ErrorObserver {
Case.clearTempFolder(); Case.clearTempFolder();
checkSubFolders(toChangeTo); checkSubFolders(toChangeTo);
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
// enable these menus // enable these menus
CallableSystemAction.get(AddImageAction.class).setEnabled(true); CallableSystemAction.get(AddImageAction.class).setEnabled(true);
CallableSystemAction.get(CaseCloseAction.class).setEnabled(true); CallableSystemAction.get(CaseCloseAction.class).setEnabled(true);
@ -1098,7 +1102,13 @@ public class Case implements SleuthkitCase.ErrorObserver {
// close all top components // close all top components
CoreComponentControl.closeCoreWindows(); CoreComponentControl.closeCoreWindows();
} }
}
});
} else { // case is closed } else { // case is closed
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
// close all top components first // close all top components first
CoreComponentControl.closeCoreWindows(); CoreComponentControl.closeCoreWindows();
@ -1111,7 +1121,6 @@ public class Case implements SleuthkitCase.ErrorObserver {
//clear pending notifications //clear pending notifications
MessageNotifyUtil.Notify.clear(); MessageNotifyUtil.Notify.clear();
Frame f = WindowManager.getDefault().getMainWindow(); Frame f = WindowManager.getDefault().getMainWindow();
f.setTitle(Case.getAppName()); // set the window name to just application name f.setTitle(Case.getAppName()); // set the window name to just application name
@ -1119,6 +1128,8 @@ public class Case implements SleuthkitCase.ErrorObserver {
System.gc(); System.gc();
System.gc(); System.gc();
} }
});
}
//log memory usage after case changed //log memory usage after case changed
logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo()); logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo());
@ -1130,9 +1141,14 @@ public class Case implements SleuthkitCase.ErrorObserver {
private static void doCaseNameChange(String newCaseName) { private static void doCaseNameChange(String newCaseName) {
// update case name // update case name
if (!newCaseName.equals("")) { if (!newCaseName.equals("")) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
Frame f = WindowManager.getDefault().getMainWindow(); Frame f = WindowManager.getDefault().getMainWindow();
f.setTitle(newCaseName + " - " + Case.getAppName()); // set the window name to the new value f.setTitle(newCaseName + " - " + Case.getAppName()); // set the window name to the new value
} }
});
}
} }
//delete image helper //delete image helper