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 {
@ -60,7 +60,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
imagesTable.getColumnModel().getColumn(0).setPreferredWidth((int) (.30 * width)); imagesTable.getColumnModel().getColumn(0).setPreferredWidth((int) (.30 * width));
imagesTable.getColumnModel().getColumn(1).setPreferredWidth((int) (.70 * width)); imagesTable.getColumnModel().getColumn(1).setPreferredWidth((int) (.70 * width));
// If there are any images, let's select the first one // If there are any images, let's select the first one
if(imagesTable.getRowCount() > 0) { if (imagesTable.getRowCount() > 0) {
imagesTable.setRowSelectionInterval(0, 0); imagesTable.setRowSelectionInterval(0, 0);
} }
} }
@ -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
@ -166,12 +166,12 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
private void imagesTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagesTableMouseClicked private void imagesTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_imagesTableMouseClicked
// If it's a doubleclick // If it's a doubleclick
if (evt.getClickCount() == 2) { if (evt.getClickCount() == 2) {
openCase(); openCase();
} }
}//GEN-LAST:event_imagesTableMouseClicked }//GEN-LAST:event_imagesTableMouseClicked
private void imagesTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_imagesTableKeyPressed private void imagesTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_imagesTableKeyPressed
if(evt.getKeyCode() == KeyEvent.VK_ENTER) { if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
openCase(); openCase();
} }
}//GEN-LAST:event_imagesTableKeyPressed }//GEN-LAST:event_imagesTableKeyPressed
@ -180,20 +180,22 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
private void openCase() { private void openCase() {
String casePath = casePaths[imagesTable.getSelectedRow()]; String casePath = casePaths[imagesTable.getSelectedRow()];
String caseName = caseNames[imagesTable.getSelectedRow()]; String caseName = caseNames[imagesTable.getSelectedRow()];
if(!casePath.equals("")) { if (!casePath.equals("")) {
// Close the startup menu // Close the startup menu
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
try { try {
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;
@ -214,9 +215,9 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
/** /**
* Sets the Close button action listener. * Sets the Close button action listener.
* *
* @param e the action listener * @param e the action listener
*/ */
public void setCloseButtonActionListener(ActionListener e){ public void setCloseButtonActionListener(ActionListener e) {
this.cancelButton.addActionListener(e); this.cancelButton.addActionListener(e);
} }
@ -228,8 +229,8 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
@Override @Override
public int getRowCount() { public int getRowCount() {
int count = 0; int count = 0;
for(String s: caseNames) { for (String s : caseNames) {
if(!s.equals("")) { if (!s.equals("")) {
count++; count++;
} }
} }
@ -286,12 +287,11 @@ 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);
} }
} }
} }