mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 10:17:41 +00:00
add startup window after error when recent case could not open
This commit is contained in:
parent
2e4e453ae6
commit
3f408e9e34
@ -16,11 +16,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.sleuthkit.autopsy.casemodule;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Event;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
@ -31,8 +31,8 @@ import javax.swing.table.AbstractTableModel;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
|
||||
/**
|
||||
* Panel show from the splash dialog that shows recent cases and allows them
|
||||
* to be opened.
|
||||
* Panel show from the splash dialog that shows recent cases and allows them to
|
||||
* be opened.
|
||||
*/
|
||||
class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
|
||||
@ -41,11 +41,11 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
private static Logger logger = Logger.getLogger(OpenRecentCasePanel.class.getName());
|
||||
private static OpenRecentCasePanel instance;
|
||||
private RecentCasesTableModel model;
|
||||
|
||||
|
||||
private OpenRecentCasePanel() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves all the recent cases and adds them to the table.
|
||||
*/
|
||||
@ -60,11 +60,11 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
imagesTable.getColumnModel().getColumn(0).setPreferredWidth((int) (.30 * width));
|
||||
imagesTable.getColumnModel().getColumn(1).setPreferredWidth((int) (.70 * width));
|
||||
// If there are any images, let's select the first one
|
||||
if(imagesTable.getRowCount() > 0) {
|
||||
if (imagesTable.getRowCount() > 0) {
|
||||
imagesTable.setRowSelectionInterval(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static OpenRecentCasePanel getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new OpenRecentCasePanel();
|
||||
@ -73,10 +73,10 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <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
|
||||
// If it's a doubleclick
|
||||
if (evt.getClickCount() == 2) {
|
||||
openCase();
|
||||
openCase();
|
||||
}
|
||||
}//GEN-LAST:event_imagesTableMouseClicked
|
||||
|
||||
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();
|
||||
}
|
||||
}//GEN-LAST:event_imagesTableKeyPressed
|
||||
@ -180,20 +180,22 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
private void openCase() {
|
||||
String casePath = casePaths[imagesTable.getSelectedRow()];
|
||||
String caseName = caseNames[imagesTable.getSelectedRow()];
|
||||
if(!casePath.equals("")) {
|
||||
if (!casePath.equals("")) {
|
||||
// Close the startup menu
|
||||
try{
|
||||
try {
|
||||
StartupWindow.getInstance().close();
|
||||
CueBannerPanel.closeOpenRecentCasesWindow();
|
||||
}
|
||||
catch(Exception ex){
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.WARNING, "Error: couldn't open case: " + caseName, ex);
|
||||
}
|
||||
// Open the recent cases
|
||||
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);
|
||||
RecentCases.getInstance().removeRecentCase(caseName, casePath); // remove the recent case if it doesn't exist anymore
|
||||
|
||||
StartupWindow.getInstance().open();
|
||||
|
||||
} else {
|
||||
Case.open(casePath); // open the case
|
||||
}
|
||||
@ -202,7 +204,6 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton cancelButton;
|
||||
private javax.swing.JTable imagesTable;
|
||||
@ -214,12 +215,12 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Table model to keep track of recent cases.
|
||||
*/
|
||||
@ -228,8 +229,8 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
int count = 0;
|
||||
for(String s: caseNames) {
|
||||
if(!s.equals("")) {
|
||||
for (String s : caseNames) {
|
||||
if (!s.equals("")) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -240,7 +241,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
public int getColumnCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
String colName = null;
|
||||
@ -284,14 +285,13 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
||||
@Override
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
}
|
||||
|
||||
|
||||
private String shortenPath(String path) {
|
||||
if(path.length() > 50){
|
||||
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));
|
||||
if (path.length() > 50) {
|
||||
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));
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -55,14 +55,16 @@ class RecentItems implements ActionListener {
|
||||
// check if the file exists
|
||||
if(caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())){
|
||||
// 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
|
||||
|
||||
StartupWindow.getInstance().open();
|
||||
}
|
||||
else {
|
||||
try {
|
||||
Case.open(casePath); // open the case
|
||||
} catch (Exception ex) {
|
||||
Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case.", ex);
|
||||
} catch (CaseActionException ex) {
|
||||
Logger.getLogger(RecentItems.class.getName()).log(Level.WARNING, "Error: Couldn't open recent case at " + casePath, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user