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

70
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,48 +777,47 @@ 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;
// clear the temp folder when the case is created / opened // clear the temp folder when the case is created / opened
Case.clearTempFolder(); Case.clearTempFolder();
// 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);
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true); CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true);
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); // Delete Case menu CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); // Delete Case menu
if (newCase.getRootObjectsCount() > 0) {
// open all top components
CoreComponentControl.openCoreWindows();
} else {
// close all top components
CoreComponentControl.closeCoreWindows();
// notify user
newCase.noRootObjectsNotification();
}
} else { // case is closed
// disable these menus
CallableSystemAction.get(AddImageAction.class).setEnabled(false); // Add Image menu
CallableSystemAction.get(CaseCloseAction.class).setEnabled(false); // Case Close menu
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(false); // Case Properties menu
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); // Delete Case menu
if (newCase.getRootObjectsCount() > 0) {
// open all top components
CoreComponentControl.openCoreWindows();
} else {
// close all top components // close all top components
CoreComponentControl.closeCoreWindows(); CoreComponentControl.closeCoreWindows();
// prompt user to add an image
Frame f = WindowManager.getDefault().getMainWindow(); SwingUtilities.invokeLater(new Runnable() {
f.setTitle(Case.getAppName()); // set the window name to just application name public void run() {
Case.noRootObjectsNotification();
}
});
} }
} catch (TskException ex) { } else { // case is closed
Log.get(CaseListener.class).log(Level.WARNING, "Error handling change in current case.", ex); // disable these menus
} CallableSystemAction.get(AddImageAction.class).setEnabled(false); // Add Image menu
} CallableSystemAction.get(CaseCloseAction.class).setEnabled(false); // Case Close menu
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(false); // Case Properties menu
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); // Delete Case menu
// close all top components
CoreComponentControl.closeCoreWindows();
Frame f = WindowManager.getDefault().getMainWindow();
f.setTitle(Case.getAppName()); // set the window name to just application name
}
}
// changed in the case name // changed in the case name
if (changed.equals(Case.CASE_NAME)) { if (changed.equals(Case.CASE_NAME)) {