19 package org.sleuthkit.autopsy.menuactions;
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.JComponent;
24 import javax.swing.JMenu;
25 import javax.swing.JMenuItem;
26 import org.openide.awt.DynamicMenuContent;
27 import org.openide.util.NbBundle;
34 class SearchResultMenu
extends JMenuItem implements DynamicMenuContent {
41 public JComponent[] getMenuPresenters() {
42 List<String> dataResultsIds = DataResultTopComponent.getActiveComponentIds();
43 DirectoryTreeTopComponent directoryTree = DirectoryTreeTopComponent.
findInstance();
46 List<JComponent> menuItems =
new ArrayList<JComponent>();
49 JMenuItem dlItem =
new JMenuItem(directoryListing.getName());
50 dlItem.addActionListener(
new OpenTopComponentAction(directoryListing));
51 dlItem.setEnabled(directoryTree.isOpened());
53 menuItems.add(dlItem);
56 if (dataResultsIds.size() > 0) {
57 JMenu submenu =
new JMenu(NbBundle.getMessage(
this.getClass(),
"SearchResultMenu.menu.dataRes.text"));
58 for (String resultTabId : dataResultsIds) {
59 JMenuItem item =
new JMenuItem(resultTabId);
60 item.addActionListener(
new OpenTopComponentAction(resultTabId));
64 menuItems.add(submenu);
67 return menuItems.toArray(
new JComponent[menuItems.size()]);
71 public JComponent[] synchMenuPresenters(JComponent[] jcs) {
72 return getMenuPresenters();
DataResultTopComponent getDirectoryListing()
static synchronized DirectoryTreeTopComponent findInstance()