mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-19 11:07:43 +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
|
* 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 {
|
||||||
|
|
||||||
@ -41,11 +41,11 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
|||||||
private static Logger logger = Logger.getLogger(OpenRecentCasePanel.class.getName());
|
private static Logger logger = Logger.getLogger(OpenRecentCasePanel.class.getName());
|
||||||
private static OpenRecentCasePanel instance;
|
private static OpenRecentCasePanel instance;
|
||||||
private RecentCasesTableModel model;
|
private RecentCasesTableModel model;
|
||||||
|
|
||||||
private OpenRecentCasePanel() {
|
private OpenRecentCasePanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves all the recent cases and adds them to the table.
|
* 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(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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static OpenRecentCasePanel getInstance() {
|
static OpenRecentCasePanel getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new OpenRecentCasePanel();
|
instance = new OpenRecentCasePanel();
|
||||||
@ -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,12 +215,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table model to keep track of recent cases.
|
* Table model to keep track of recent cases.
|
||||||
*/
|
*/
|
||||||
@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +241,7 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
|||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
String colName = null;
|
String colName = null;
|
||||||
@ -284,14 +285,13 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
|||||||
@Override
|
@Override
|
||||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user