Minor fixes for EDT changes.

This commit is contained in:
Ann Priestman 2015-07-20 11:14:00 -04:00
parent 42ef9c5a8b
commit a2ef14a82f
6 changed files with 94 additions and 175 deletions

View File

@ -329,7 +329,9 @@ public class Case {
currentCase = newCase; currentCase = newCase;
Logger.setLogDirectory(currentCase.getLogDirectoryPath()); Logger.setLogDirectory(currentCase.getLogDirectoryPath());
doCaseChange(currentCase); doCaseChange(currentCase);
RecentCases.getInstance().addRecentCase(currentCase.name, currentCase.configFilePath); // update the recent cases SwingUtilities.invokeLater(() -> {
RecentCases.getInstance().addRecentCase(currentCase.name, currentCase.configFilePath); // update the recent cases
});
if (CaseType.MULTI_USER_CASE == newCase.getCaseType()) { if (CaseType.MULTI_USER_CASE == newCase.getCaseType()) {
try { try {
/** /**
@ -794,6 +796,8 @@ public class Case {
/** /**
* Updates the case name. * Updates the case name.
* *
* This should not be called from the EDT.
*
* @param oldCaseName the old case name that wants to be updated * @param oldCaseName the old case name that wants to be updated
* @param oldPath the old path that wants to be updated * @param oldPath the old path that wants to be updated
* @param newCaseName the new case name * @param newCaseName the new case name
@ -803,10 +807,14 @@ public class Case {
try { try {
xmlcm.setCaseName(newCaseName); // set the case xmlcm.setCaseName(newCaseName); // set the case
name = newCaseName; // change the local value name = newCaseName; // change the local value
RecentCases.getInstance().updateRecentCase(oldCaseName, oldPath, newCaseName, newPath); // update the recent case
eventPublisher.publish(new AutopsyEvent(Events.NAME.toString(), oldCaseName, newCaseName)); eventPublisher.publish(new AutopsyEvent(Events.NAME.toString(), oldCaseName, newCaseName));
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
updateMainWindowTitle(newCaseName); try{
RecentCases.getInstance().updateRecentCase(oldCaseName, oldPath, newCaseName, newPath); // update the recent case
updateMainWindowTitle(newCaseName);
} catch (Exception e) {
Logger.getLogger(CasePropertiesForm.class.getName()).log(Level.WARNING, "Error: problem updating case name.", e); //NON-NLS
}
}); });
} catch (Exception e) { } catch (Exception e) {
throw new CaseActionException(NbBundle.getMessage(this.getClass(), "Case.updateCaseName.exception.msg"), e); throw new CaseActionException(NbBundle.getMessage(this.getClass(), "Case.updateCaseName.exception.msg"), e);
@ -816,6 +824,8 @@ public class Case {
/** /**
* Updates the case examiner * Updates the case examiner
* *
* This should not be called from the EDT.
*
* @param oldExaminer the old examiner * @param oldExaminer the old examiner
* @param newExaminer the new examiner * @param newExaminer the new examiner
*/ */
@ -832,6 +842,8 @@ public class Case {
/** /**
* Updates the case number * Updates the case number
* *
* This should not be called from the EDT.
*
* @param oldCaseNumber the old case number * @param oldCaseNumber the old case number
* @param newCaseNumber the new case number * @param newCaseNumber the new case number
*/ */
@ -1488,10 +1500,12 @@ public class Case {
if (IngestManager.getInstance().isRunningInteractively()) { if (IngestManager.getInstance().isRunningInteractively()) {
// enable these menus // enable these menus
CallableSystemAction.get(AddImageAction.class).setEnabled(true); SwingUtilities.invokeLater(() -> {
CallableSystemAction.get(CaseCloseAction.class).setEnabled(true); CallableSystemAction.get(AddImageAction.class).setEnabled(true);
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true); CallableSystemAction.get(CaseCloseAction.class).setEnabled(true);
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); // Delete Case menu CallableSystemAction.get(CasePropertiesAction.class).setEnabled(true);
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(true); // Delete Case menu
});
if (toChangeTo.hasData()) { if (toChangeTo.hasData()) {
// open all top components // open all top components
@ -1519,20 +1533,23 @@ public class Case {
} else { // case is closed } else { // case is closed
if (IngestManager.getInstance().isRunningInteractively()) { if (IngestManager.getInstance().isRunningInteractively()) {
// close all top components first
SwingUtilities.invokeLater(() -> {
CoreComponentControl.closeCoreWindows();
});
// disable these menus SwingUtilities.invokeLater(() -> {
CallableSystemAction.get(AddImageAction.class).setEnabled(false); // Add Image menu // close all top components first
CallableSystemAction.get(CaseCloseAction.class).setEnabled(false); // Case Close menu CoreComponentControl.closeCoreWindows();
CallableSystemAction.get(CasePropertiesAction.class).setEnabled(false); // Case Properties menu
CallableSystemAction.get(CaseDeleteAction.class).setEnabled(false); // Delete Case menu // 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
});
} }
//clear pending notifications //clear pending notifications
MessageNotifyUtil.Notify.clear(); SwingUtilities.invokeLater(() -> {
MessageNotifyUtil.Notify.clear();
});
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
Frame f = WindowManager.getDefault().getMainWindow(); Frame f = WindowManager.getDefault().getMainWindow();

View File

@ -100,52 +100,26 @@ public final class CaseOpenAction implements ActionListener {
logger.log(Level.WARNING, "Error closing startup window.", ex); //NON-NLS logger.log(Level.WARNING, "Error closing startup window.", ex); //NON-NLS
} }
new SwingWorker<Void, Void>() { new Thread(() -> {
// Create case.
@Override try{
protected Void doInBackground() throws Exception { Case.open(path);
// Create case. } catch (CaseActionException ex) {
try{ SwingUtilities.invokeLater(() -> {
Case.open(path); JOptionPane.showMessageDialog(null,
} catch (CaseActionException ex) { NbBundle.getMessage(this.getClass(),
SwingUtilities.invokeLater(() -> { "CaseOpenAction.msgDlg.cantOpenCase.msg", path,
JOptionPane.showMessageDialog(null, ex.getMessage()),
NbBundle.getMessage(this.getClass(), NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.msg", path, "CaseOpenAction.msgDlg.cantOpenCase.title"),
ex.getMessage()), JOptionPane.ERROR_MESSAGE);
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.ERROR_MESSAGE);
StartupWindowProvider.getInstance().open(); StartupWindowProvider.getInstance().open();
}); });
logger.log(Level.WARNING, "Error opening case in folder " + path, ex); //NON-NLS logger.log(Level.WARNING, "Error opening case in folder " + path, ex); //NON-NLS
}
return null;
} }
}).start();
@Override
protected void done() {
try {
get();
} catch (ExecutionException | InterruptedException ex) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null,
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.msg", path,
ex.getMessage()),
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.ERROR_MESSAGE);
StartupWindowProvider.getInstance().open();
});
logger.log(Level.WARNING, "Error opening case in folder " + path, ex); //NON-NLS
}
}
}.execute();
} }
} }
} }

View File

@ -105,17 +105,7 @@ import org.sleuthkit.datamodel.TskData.DbType;
String createdDirectory = (String) wizardDescriptor.getProperty("createdDirectory"); //NON-NLS String createdDirectory = (String) wizardDescriptor.getProperty("createdDirectory"); //NON-NLS
CaseType caseType = CaseType.values()[(int)wizardDescriptor.getProperty("caseType")]; //NON-NLS CaseType caseType = CaseType.values()[(int)wizardDescriptor.getProperty("caseType")]; //NON-NLS
try { Case.create(createdDirectory, caseName, caseNumber, examiner, caseType);
Case.create(createdDirectory, caseName, caseNumber, examiner, caseType);
} catch (Exception ex) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(),
"CaseCreateAction.msgDlg.cantCreateCase.msg")+" "+caseName,
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.ERROR_MESSAGE);
});
}
return null; return null;
} }
@ -137,7 +127,7 @@ import org.sleuthkit.datamodel.TskData.DbType;
} }
} catch (ExecutionException | InterruptedException ex) { } catch (Exception ex) {
final String caseName = (String) wizardDescriptor.getProperty("caseName"); //NON-NLS final String caseName = (String) wizardDescriptor.getProperty("caseName"); //NON-NLS
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(), JOptionPane.showMessageDialog(null, NbBundle.getMessage(this.getClass(),
@ -161,14 +151,9 @@ import org.sleuthkit.datamodel.TskData.DbType;
private void doFailedCaseCleanup(WizardDescriptor wizardDescriptor){ private void doFailedCaseCleanup(WizardDescriptor wizardDescriptor){
String createdDirectory = (String) wizardDescriptor.getProperty("createdDirectory"); //NON-NLS String createdDirectory = (String) wizardDescriptor.getProperty("createdDirectory"); //NON-NLS
// if there's case opened, close the case
if (Case.existsCurrentCase()) {
// close the previous case if there's any
CaseCloseAction closeCase = SystemAction.get(CaseCloseAction.class);
closeCase.actionPerformed(null);
}
if (createdDirectory != null) { if (createdDirectory != null) {
logger.log(Level.INFO, "Deleting a created case directory due to isCancelled set, dir: " + createdDirectory); //NON-NLS logger.log(Level.INFO, "Deleting a created case directory due to an error, dir: " + createdDirectory); //NON-NLS
Case.deleteCaseDirectory(new File(createdDirectory)); Case.deleteCaseDirectory(new File(createdDirectory));
} }
} }

View File

@ -217,46 +217,23 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
} }
} else { } else {
new SwingWorker<Void, Void>() { new Thread(() -> {
// Create case.
@Override try{
protected Void doInBackground() throws Exception { Case.open(casePath);
// Create case. } catch (CaseActionException ex) {
try{ SwingUtilities.invokeLater(() -> {
Case.open(casePath); JOptionPane.showMessageDialog(null,
} catch (CaseActionException ex) { NbBundle.getMessage(this.getClass(),
SwingUtilities.invokeLater(() -> { "CaseOpenAction.msgDlg.cantOpenCase.msg", caseName,
JOptionPane.showMessageDialog(null, ex.getMessage()),
NbBundle.getMessage(this.getClass(), NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.msg", caseName, "CaseOpenAction.msgDlg.cantOpenCase.title"),
ex.getMessage()), JOptionPane.ERROR_MESSAGE);
NbBundle.getMessage(this.getClass(), });
"CaseOpenAction.msgDlg.cantOpenCase.title"), logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex); //NON-NLS
JOptionPane.ERROR_MESSAGE);
});
logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex); //NON-NLS
}
return null;
} }
}).start();
@Override
protected void done() {
try {
get();
} catch (ExecutionException | InterruptedException ex) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null,
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.msg", caseName,
ex.getMessage()),
NbBundle.getMessage(this.getClass(),
"CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.ERROR_MESSAGE);
});
logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex); //NON-NLS
}
}
}.execute();
} }
} }
} }

View File

@ -79,40 +79,20 @@ class RecentItems implements ActionListener {
} }
} }
else { else {
new SwingWorker<Void, Void>() { new Thread(() -> {
// Create case.
@Override try{
protected Void doInBackground() throws Exception { Case.open(casePath);
// Create case. } catch (CaseActionException ex) {
try{ SwingUtilities.invokeLater(() -> {
Case.open(casePath); JOptionPane.showMessageDialog(null,
} catch (CaseActionException ex) { NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.msg", casePath,
SwingUtilities.invokeLater(() -> { ex.getMessage()), NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.showMessageDialog(null, JOptionPane.ERROR_MESSAGE);
NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.msg", casePath, });
ex.getMessage()), NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.title"), Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case at " + casePath, ex); //NON-NLS
JOptionPane.ERROR_MESSAGE);
});
Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case at " + casePath, ex); //NON-NLS
}
return null;
} }
}).start();
@Override
protected void done() {
try {
get();
} catch (ExecutionException | InterruptedException ex) {
SwingUtilities.invokeLater(() -> {
JOptionPane.showMessageDialog(null,
NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.msg", casePath,
ex.getMessage()), NbBundle.getMessage(this.getClass(), "CaseOpenAction.msgDlg.cantOpenCase.title"),
JOptionPane.ERROR_MESSAGE);
});
Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error opening recent case. ", ex); //NON-NLS
}
}
}.execute();
} }
} }
} }

View File

@ -79,28 +79,14 @@ public class Installer extends ModuleInstall {
final String caseFile = argsProcessor.getDefaultArg(); final String caseFile = argsProcessor.getDefaultArg();
if (caseFile != null && !caseFile.equals("") && caseFile.endsWith(".aut") && new File(caseFile).exists()) { //NON-NLS if (caseFile != null && !caseFile.equals("") && caseFile.endsWith(".aut") && new File(caseFile).exists()) { //NON-NLS
new SwingWorker<Void, Void>() { new Thread(() -> {
// Create case.
@Override try{
protected Void doInBackground() throws Exception { Case.open(caseFile);
// Create case. } catch(Exception ex){
try{ logger.log(Level.WARNING, "Error opening case. ", ex); //NON-NLS
Case.open(caseFile);
} catch(Exception ex){
logger.log(Level.WARNING, "Error opening case. ", ex); //NON-NLS
}
return null;
} }
}).start();
@Override
protected void done() {
try {
get();
} catch (ExecutionException | InterruptedException ex) {
logger.log(Level.WARNING, "Error opening case. ", ex); //NON-NLS
}
}
}.execute();
return; return;
} }
} }