Invoke the addImage action after all of the case open proprty change listeners complete so that Cores are open

This commit is contained in:
Brian Carrier 2011-12-31 00:12:42 -05:00
parent 5f8a2581f2
commit 47b52ce1da

18
Case/src/org/sleuthkit/autopsy/casemodule/Case.java Normal file → Executable file
View File

@ -38,6 +38,7 @@ import java.util.Set;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.SwingUtilities;
import org.openide.DialogDisplayer; import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor; import org.openide.NotifyDescriptor;
import org.openide.util.Lookup; import org.openide.util.Lookup;
@ -715,7 +716,7 @@ public class Case {
* Call if there are no images in the case. Displays * Call if there are no images in the case. Displays
* a dialog offering to add one. * a dialog offering to add one.
*/ */
private void noRootObjectsNotification() throws TskException { private static void noRootObjectsNotification() {
NotifyDescriptor nd = new NotifyDescriptor( NotifyDescriptor nd = new NotifyDescriptor(
"This case contains no images. Would you like to add one?", "This case contains no images. Would you like to add one?",
"No images in case", NotifyDescriptor.YES_NO_OPTION, "No images in case", NotifyDescriptor.YES_NO_OPTION,
@ -776,9 +777,7 @@ public class Case {
Object oldValue = evt.getOldValue(); Object oldValue = evt.getOldValue();
Object newValue = evt.getNewValue(); Object newValue = evt.getNewValue();
if (changed.equals(Case.CASE_CURRENT_CASE)) { if (changed.equals(Case.CASE_CURRENT_CASE)) {
try {
if (newValue != null) { // new case is open if (newValue != null) { // new case is open
Case newCase = (Case) newValue; Case newCase = (Case) newValue;
@ -797,8 +796,12 @@ public class Case {
} else { } else {
// close all top components // close all top components
CoreComponentControl.closeCoreWindows(); CoreComponentControl.closeCoreWindows();
// notify user // prompt user to add an image
newCase.noRootObjectsNotification(); SwingUtilities.invokeLater(new Runnable() {
public void run() {
Case.noRootObjectsNotification();
}
});
} }
} else { // case is closed } else { // case is closed
// disable these menus // disable these menus
@ -813,11 +816,8 @@ public class Case {
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
} }
} catch (TskException ex) {
Log.get(CaseListener.class).log(Level.WARNING, "Error handling change in current case.", ex);
}
}
}
// changed in the case name // changed in the case name
if (changed.equals(Case.CASE_NAME)) { if (changed.equals(Case.CASE_NAME)) {