diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/OpenRecentCasePanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/OpenRecentCasePanel.java index 36277a8a5a..5469480c4b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/OpenRecentCasePanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/OpenRecentCasePanel.java @@ -18,9 +18,6 @@ */ 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; diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java b/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java index 641d7d75eb..8649e487e5 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/RecentCases.java @@ -30,6 +30,7 @@ import java.util.LinkedList; import java.util.List; import java.util.logging.Level; import javax.swing.JMenuItem; +import org.apache.commons.lang.ArrayUtils; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CallableSystemAction; @@ -45,7 +46,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; */ 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 PATH_PROP_KEY = "LBL_RecentCase_Path"; //NON-NLS static final RecentCase BLANK_RECENTCASE = new RecentCase("", ""); @@ -358,7 +359,7 @@ import org.sleuthkit.autopsy.coreutils.Logger; /** * 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 "" */ public String[] getRecentCaseNames() { @@ -366,9 +367,20 @@ import org.sleuthkit.autopsy.coreutils.Logger; Iterator mostRecentFirst = recentCases.descendingIterator(); int i = 0; + String currentCaseName = null; + try { + currentCaseName = Case.getCurrentCase().getName(); + } catch (IllegalStateException ex) { + // in case there is no current case. + } + while (mostRecentFirst.hasNext()) { - caseNames[i] = mostRecentFirst.next().name; - i++; + String name = mostRecentFirst.next().name; + if ((currentCaseName != null && !name.equals(currentCaseName)) || currentCaseName == null) { + // exclude currentCaseName from the caseNames[] + caseNames[i] = name; + i++; + } } while (i < caseNames.length) { @@ -376,23 +388,34 @@ import org.sleuthkit.autopsy.coreutils.Logger; i++; } - return caseNames; + // return last 5 case names + return (String[]) ArrayUtils.subarray(caseNames, 0, LENGTH - 1); } /** * 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 "" */ public String[] getRecentCasePaths() { String[] casePaths = new String[LENGTH]; + String currentCasePath = null; + try { + currentCasePath = Case.getCurrentCase().getName(); + } catch (IllegalStateException ex) { + // in case there is no current case. + } Iterator mostRecentFirst = recentCases.descendingIterator(); int i = 0; while (mostRecentFirst.hasNext()) { - casePaths[i] = mostRecentFirst.next().path; - i++; + String path = mostRecentFirst.next().path; + if ((currentCasePath != null && !path.equals(currentCasePath)) || currentCasePath == null) { + // exclude currentCasePath from the casePaths[] + casePaths[i] = path; + i++; + } } while (i < casePaths.length) { @@ -400,7 +423,8 @@ import org.sleuthkit.autopsy.coreutils.Logger; i++; } - return casePaths; + // return last 5 case paths + return (String[]) ArrayUtils.subarray(casePaths, 0, LENGTH - 1); } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/UpdateRecentCases.java b/Core/src/org/sleuthkit/autopsy/casemodule/UpdateRecentCases.java index 0355fc20fe..8476d17aa8 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/UpdateRecentCases.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/UpdateRecentCases.java @@ -36,7 +36,8 @@ import org.openide.util.actions.SystemAction; /** the constructor */ UpdateRecentCases(){ - length = RecentCases.LENGTH; + // display last 5 cases. + length = RecentCases.LENGTH - 1; } /**