19 package org.sleuthkit.autopsy.casemodule;
21 import javax.swing.JComponent;
22 import javax.swing.JMenuItem;
23 import javax.swing.JSeparator;
24 import org.openide.awt.DynamicMenuContent;
25 import org.openide.util.NbBundle;
26 import org.openide.util.actions.SystemAction;
31 class UpdateRecentCases
extends JMenuItem implements DynamicMenuContent {
33 private static final long serialVersionUID = 1L;
34 private static int NUM_CASES_TO_DISPLAY;
35 private static boolean hasRecentCase =
false;
42 NUM_CASES_TO_DISPLAY = 5;
45 static void setHasRecentCase(
boolean value) {
46 hasRecentCase = value;
58 public JComponent[] getMenuPresenters() {
59 String[] caseName = RecentCases.getInstance().getRecentCaseNames();
60 String[] casePath = RecentCases.getInstance().getRecentCasePaths();
61 JComponent[] comps =
new JComponent[NUM_CASES_TO_DISPLAY + 2];
64 for (
int i = 0; i < NUM_CASES_TO_DISPLAY; i++) {
65 if ((!caseName[i].equals(
""))) {
66 JMenuItem menuItem =
new JMenuItem(caseName[i]);
67 menuItem.setActionCommand(caseName[i].toUpperCase());
68 menuItem.addActionListener(
new RecentItems(caseName[i], casePath[i]));
76 comps[NUM_CASES_TO_DISPLAY] =
new JSeparator();
77 JMenuItem clearMenu =
new JMenuItem(
78 NbBundle.getMessage(UpdateRecentCases.class,
"UpdateRecentCases.menuItem.clearRecentCases.text"));
79 clearMenu.addActionListener(SystemAction.get(RecentCases.class));
80 comps[NUM_CASES_TO_DISPLAY + 1] = clearMenu;
83 comps =
new JComponent[1];
84 JMenuItem emptyMenu =
new JMenuItem(NbBundle.getMessage(UpdateRecentCases.class,
"UpdateRecentCases.menuItem.empty"));
85 emptyMenu.addActionListener(
new RecentItems(
"",
""));
87 comps[0].setEnabled(
false);
101 public JComponent[] synchMenuPresenters(JComponent[] menuItems) {
102 return getMenuPresenters();