20 package org.sleuthkit.autopsy.menuactions;
22 import java.util.ArrayList;
23 import java.util.List;
24 import javax.swing.JComponent;
25 import javax.swing.JMenu;
26 import javax.swing.JMenuItem;
27 import org.openide.awt.DynamicMenuContent;
28 import org.openide.util.NbBundle;
35 class SearchResultMenu
extends JMenuItem implements DynamicMenuContent {
42 public JComponent[] getMenuPresenters() {
43 List<String> dataResultsIds = DataResultTopComponent.getActiveComponentIds();
44 DirectoryTreeTopComponent directoryTree = DirectoryTreeTopComponent.
findInstance();
49 List<JComponent> menuItems =
new ArrayList<JComponent>();
52 JMenuItem dlItem =
new JMenuItem(directoryListing.getName());
53 dlItem.addActionListener(
new OpenTopComponentAction(directoryListing));
54 dlItem.setEnabled(directoryTree.isOpened());
56 menuItems.add(dlItem);
60 if(dataResultsIds.size() > 0){
61 JMenu submenu =
new JMenu(NbBundle.getMessage(
this.getClass(),
"SearchResultMenu.menu.dataRes.text"));
62 for(String resultTabId : dataResultsIds){
63 JMenuItem item =
new JMenuItem(resultTabId);
64 item.addActionListener(
new OpenTopComponentAction(resultTabId));
68 menuItems.add(submenu);
71 return menuItems.toArray(
new JComponent[menuItems.size()]);
75 public JComponent[] synchMenuPresenters(JComponent[] jcs) {
76 return getMenuPresenters();
DataResultTopComponent getDirectoryListing()
static synchronized DirectoryTreeTopComponent findInstance()