mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 16:36:15 +00:00
Merge pull request #1510 from sidheshenator/open_recent_cases_fix
Open recent cases fix
This commit is contained in:
commit
c517eb4e5a
@ -18,9 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.sleuthkit.autopsy.casemodule;
|
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.ActionListener;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -201,10 +198,10 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
|||||||
try {
|
try {
|
||||||
if (caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())) {
|
if (caseName.equals("") || casePath.equals("") || (!new File(casePath).exists())) {
|
||||||
JOptionPane.showMessageDialog(null,
|
JOptionPane.showMessageDialog(null,
|
||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(OpenRecentCasePanel.class,
|
||||||
"OpenRecentCasePanel.openCase.msgDlg.caseDoesntExist.msg",
|
"OpenRecentCasePanel.openCase.msgDlg.caseDoesntExist.msg",
|
||||||
caseName),
|
caseName),
|
||||||
NbBundle.getMessage(this.getClass(),
|
NbBundle.getMessage(OpenRecentCasePanel.class,
|
||||||
"OpenRecentCasePanel.openCase.msgDlg.err"),
|
"OpenRecentCasePanel.openCase.msgDlg.err"),
|
||||||
JOptionPane.ERROR_MESSAGE);
|
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
|
||||||
@ -266,10 +263,10 @@ class OpenRecentCasePanel extends javax.swing.JPanel {
|
|||||||
|
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case 0:
|
case 0:
|
||||||
colName = NbBundle.getMessage(this.getClass(), "OpenRecentCasePanel.colName.caseName");
|
colName = NbBundle.getMessage(OpenRecentCasePanel.class, "OpenRecentCasePanel.colName.caseName");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
colName = NbBundle.getMessage(this.getClass(), "OpenRecentCasePanel.colName.path");
|
colName = NbBundle.getMessage(OpenRecentCasePanel.class, "OpenRecentCasePanel.colName.path");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
|
@ -29,6 +29,7 @@ import java.util.LinkedList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import javax.swing.JMenuItem;
|
import javax.swing.JMenuItem;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.openide.util.HelpCtx;
|
import org.openide.util.HelpCtx;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.actions.CallableSystemAction;
|
import org.openide.util.actions.CallableSystemAction;
|
||||||
@ -44,7 +45,7 @@ import org.sleuthkit.autopsy.coreutils.Logger;
|
|||||||
*/
|
*/
|
||||||
final class RecentCases extends CallableSystemAction implements Presenter.Menu {
|
final class RecentCases extends CallableSystemAction implements Presenter.Menu {
|
||||||
|
|
||||||
static final int LENGTH = 5;
|
static final int LENGTH = 6;
|
||||||
static final String NAME_PROP_KEY = "LBL_RecentCase_Name"; //NON-NLS
|
static final String NAME_PROP_KEY = "LBL_RecentCase_Name"; //NON-NLS
|
||||||
static final String PATH_PROP_KEY = "LBL_RecentCase_Path"; //NON-NLS
|
static final String PATH_PROP_KEY = "LBL_RecentCase_Path"; //NON-NLS
|
||||||
static final RecentCase BLANK_RECENTCASE = new RecentCase("", "");
|
static final RecentCase BLANK_RECENTCASE = new RecentCase("", "");
|
||||||
@ -364,7 +365,7 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu {
|
|||||||
/**
|
/**
|
||||||
* Gets the recent case names.
|
* Gets the recent case names.
|
||||||
*
|
*
|
||||||
* @return caseNames An array String[LENGTH], newest case first, with any
|
* @return caseNames An array String[LENGTH - 1], newest case first, with any
|
||||||
* extra spots filled with ""
|
* extra spots filled with ""
|
||||||
*/
|
*/
|
||||||
public String[] getRecentCaseNames() {
|
public String[] getRecentCaseNames() {
|
||||||
@ -372,41 +373,64 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu {
|
|||||||
|
|
||||||
Iterator<RecentCase> mostRecentFirst = recentCases.descendingIterator();
|
Iterator<RecentCase> mostRecentFirst = recentCases.descendingIterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
String currentCaseName = null;
|
||||||
|
try {
|
||||||
|
currentCaseName = Case.getCurrentCase().getName();
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
// in case there is no current case.
|
||||||
|
}
|
||||||
|
|
||||||
while (mostRecentFirst.hasNext()) {
|
while (mostRecentFirst.hasNext()) {
|
||||||
caseNames[i] = mostRecentFirst.next().name;
|
String name = mostRecentFirst.next().name;
|
||||||
|
if ((currentCaseName != null && !name.equals(currentCaseName)) || currentCaseName == null) {
|
||||||
|
// exclude currentCaseName from the caseNames[]
|
||||||
|
caseNames[i] = name;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (i < caseNames.length) {
|
while (i < caseNames.length) {
|
||||||
caseNames[i] = "";
|
caseNames[i] = "";
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return caseNames;
|
// return last 5 case names
|
||||||
|
return (String[]) ArrayUtils.subarray(caseNames, 0, LENGTH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the recent case paths.
|
* Gets the recent case paths.
|
||||||
*
|
*
|
||||||
* @return casePaths An array String[LENGTH], newest case first, with any
|
* @return casePaths An array String[LENGTH - 1], newest case first, with any
|
||||||
* extra spots filled with ""
|
* extra spots filled with ""
|
||||||
*/
|
*/
|
||||||
public String[] getRecentCasePaths() {
|
public String[] getRecentCasePaths() {
|
||||||
String[] casePaths = new String[LENGTH];
|
String[] casePaths = new String[LENGTH];
|
||||||
|
String currentCasePath = null;
|
||||||
|
try {
|
||||||
|
currentCasePath = Case.getCurrentCase().getConfigFilePath();
|
||||||
|
} catch (IllegalStateException ex) {
|
||||||
|
// in case there is no current case.
|
||||||
|
}
|
||||||
|
|
||||||
Iterator<RecentCase> mostRecentFirst = recentCases.descendingIterator();
|
Iterator<RecentCase> mostRecentFirst = recentCases.descendingIterator();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (mostRecentFirst.hasNext()) {
|
while (mostRecentFirst.hasNext()) {
|
||||||
casePaths[i] = mostRecentFirst.next().path;
|
String path = mostRecentFirst.next().path;
|
||||||
|
if ((currentCasePath != null && !path.equals(currentCasePath)) || currentCasePath == null) {
|
||||||
|
// exclude currentCasePath from the casePaths[]
|
||||||
|
casePaths[i] = path;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (i < casePaths.length) {
|
while (i < casePaths.length) {
|
||||||
casePaths[i] = "";
|
casePaths[i] = "";
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return casePaths;
|
// return last 5 case paths
|
||||||
|
return (String[]) ArrayUtils.subarray(casePaths, 0, LENGTH - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,7 +448,7 @@ final class RecentCases extends CallableSystemAction implements Presenter.Menu {
|
|||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
//return NbBundle.getMessage(RecentCases.class, "CTL_RecentCases");
|
//return NbBundle.getMessage(RecentCases.class, "CTL_RecentCases");
|
||||||
return NbBundle.getMessage(this.getClass(), "RecentCases.getName.text");
|
return NbBundle.getMessage(RecentCases.class, "RecentCases.getName.text");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,11 +33,10 @@ class UpdateRecentCases extends JMenuItem implements DynamicMenuContent {
|
|||||||
int length;
|
int length;
|
||||||
static boolean hasRecentCase = false;
|
static boolean hasRecentCase = false;
|
||||||
|
|
||||||
/**
|
/** the constructor */
|
||||||
* the constructor
|
|
||||||
*/
|
|
||||||
UpdateRecentCases(){
|
UpdateRecentCases(){
|
||||||
length = RecentCases.LENGTH;
|
// display last 5 cases.
|
||||||
|
length = RecentCases.LENGTH - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,13 +68,13 @@ class UpdateRecentCases extends JMenuItem implements DynamicMenuContent {
|
|||||||
if (hasRecentCase) {
|
if (hasRecentCase) {
|
||||||
comps[length] = new JSeparator();
|
comps[length] = new JSeparator();
|
||||||
JMenuItem clearMenu = new JMenuItem(
|
JMenuItem clearMenu = new JMenuItem(
|
||||||
NbBundle.getMessage(this.getClass(), "UpdateRecentCases.menuItem.clearRecentCases.text"));
|
NbBundle.getMessage(UpdateRecentCases.class, "UpdateRecentCases.menuItem.clearRecentCases.text"));
|
||||||
clearMenu.addActionListener(SystemAction.get(RecentCases.class));
|
clearMenu.addActionListener(SystemAction.get(RecentCases.class));
|
||||||
comps[length + 1] = clearMenu;
|
comps[length + 1] = clearMenu;
|
||||||
} // otherwise, just create a disabled empty menu
|
} // otherwise, just create a disabled empty menu
|
||||||
else {
|
else {
|
||||||
comps = new JComponent[1];
|
comps = new JComponent[1];
|
||||||
JMenuItem emptyMenu = new JMenuItem(NbBundle.getMessage(this.getClass(), "UpdateRecentCases.menuItem.empty"));
|
JMenuItem emptyMenu = new JMenuItem(NbBundle.getMessage(UpdateRecentCases.class, "UpdateRecentCases.menuItem.empty"));
|
||||||
emptyMenu.addActionListener(new RecentItems("", ""));
|
emptyMenu.addActionListener(new RecentItems("", ""));
|
||||||
comps[0] = emptyMenu;
|
comps[0] = emptyMenu;
|
||||||
comps[0].setEnabled(false);
|
comps[0].setEnabled(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user