add startup window after error when recent case could not open

This commit is contained in:
adam-m 2012-11-12 13:37:44 -05:00
parent 2e4e453ae6
commit 3f408e9e34
2 changed files with 35 additions and 33 deletions

View File

@ -16,11 +16,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.sleuthkit.autopsy.casemodule; package org.sleuthkit.autopsy.casemodule;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Event; import java.awt.Event;
import java.awt.EventQueue;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.File; import java.io.File;
@ -31,8 +31,8 @@ import javax.swing.table.AbstractTableModel;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
/** /**
* Panel show from the splash dialog that shows recent cases and allows them * Panel show from the splash dialog that shows recent cases and allows them to
* to be opened. * be opened.
*/ */
class OpenRecentCasePanel extends javax.swing.JPanel { class OpenRecentCasePanel extends javax.swing.JPanel {
@ -73,10 +73,10 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
return instance; return instance;
} }
/** This method is called from within the constructor to /**
* initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is always
* always regenerated by the Form Editor. * regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
@ -185,8 +185,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
try { try {
StartupWindow.getInstance().close(); StartupWindow.getInstance().close();
CueBannerPanel.closeOpenRecentCasesWindow(); CueBannerPanel.closeOpenRecentCasesWindow();
} } catch (Exception ex) {
catch(Exception ex){
logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex); logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex);
} }
// Open the recent cases // Open the recent cases
@ -194,6 +193,9 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
if (caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())) { if (caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())) {
JOptionPane.showMessageDialog(null, "Error: Case " + caseName + " doesn't exist.", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Error: Case " + caseName + " doesn't exist.", "Error", JOptionPane.ERROR_MESSAGE);
RecentCases.getInstance().removeRecentCase(caseName, casePath); // remove the recent case if it doesn't exist anymore RecentCases.getInstance().removeRecentCase(caseName, casePath); // remove the recent case if it doesn't exist anymore
StartupWindow.getInstance().open();
} else { } else {
Case.open(casePath); // open the case Case.open(casePath); // open the case
} }
@ -202,7 +204,6 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
} }
} }
} }
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton; private javax.swing.JButton cancelButton;
private javax.swing.JTable imagesTable; private javax.swing.JTable imagesTable;
@ -287,11 +288,10 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
private String shortenPath(String path) { private String shortenPath(String path) {
if (path.length() > 50) { if (path.length() > 50) {
path = path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) + "..." + path = path.substring(0, 10 + path.substring(10).indexOf(File.separator) + 1) + "..."
path.substring((path.length() - 20) + path.substring(path.length() - 20).indexOf(File.separator)); + path.substring((path.length() - 20) + path.substring(path.length() - 20).indexOf(File.separator));
} }
return path; return path;
} }
} }
} }

View File

@ -55,14 +55,16 @@ class RecentItems implements ActionListener {
// check if the file exists // check if the file exists
if(caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())){ if(caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())){
// throw an error here // throw an error here
JOptionPane.showMessageDialog(caller, "Error: Case doesn't exist.", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(caller, "Error: Case " + caseName + " doesn't exist.", "Error", JOptionPane.ERROR_MESSAGE);
RecentCases.getInstance().removeRecentCase(caseName, casePath); // remove the recent case if it doesn't exist anymore RecentCases.getInstance().removeRecentCase(caseName, casePath); // remove the recent case if it doesn't exist anymore
StartupWindow.getInstance().open();
} }
else { else {
try { try {
Case.open(casePath); // open the case Case.open(casePath); // open the case
} catch (Exception ex) { } catch (CaseActionException ex) {
Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case.", ex); Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case at " + casePath, ex);
} }
} }
} }