20 package org.sleuthkit.autopsy.casemodule;
22 import javax.swing.JComponent;
23 import javax.swing.JMenuItem;
24 import javax.swing.JSeparator;
25 import org.openide.awt.DynamicMenuContent;
26 import org.openide.util.NbBundle;
27 import org.openide.util.actions.SystemAction;
32 class UpdateRecentCases
extends JMenuItem implements DynamicMenuContent {
35 static boolean hasRecentCase =
false;
39 length = RecentCases.LENGTH;
51 public JComponent[] getMenuPresenters() {
52 String[] caseName = RecentCases.getInstance().getRecentCaseNames();
53 String[] casePath = RecentCases.getInstance().getRecentCasePaths();
54 JComponent[] comps =
new JComponent[length + 2];
57 for (
int i = 0; i < length; i++) {
58 if((!caseName[i].equals(
""))){
59 JMenuItem menuItem =
new JMenuItem(caseName[i]);
60 menuItem.setActionCommand(caseName[i].toUpperCase());
61 menuItem.addActionListener(
new RecentItems(caseName[i], casePath[i]));
63 hasRecentCase = hasRecentCase ||
true;
69 comps[length] =
new JSeparator();
70 JMenuItem clearMenu =
new JMenuItem(
71 NbBundle.getMessage(
this.getClass(),
"UpdateRecentCases.menuItem.clearRecentCases.text"));
72 clearMenu.addActionListener(SystemAction.get(RecentCases.class));
73 comps[length+1] = clearMenu;
77 comps =
new JComponent[1];
78 JMenuItem emptyMenu =
new JMenuItem(NbBundle.getMessage(
this.getClass(),
"UpdateRecentCases.menuItem.empty"));
79 emptyMenu.addActionListener(
new RecentItems(
"",
""));
81 comps[0].setEnabled(
false);
93 public JComponent[] synchMenuPresenters(JComponent[] jcs) {
94 return getMenuPresenters();