Autopsy  4.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
RunIngestSubMenu.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2015 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.ingest;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.swing.JComponent;
24 import javax.swing.JMenuItem;
25 import org.openide.awt.DynamicMenuContent;
26 import org.openide.util.NbBundle;
28 import org.sleuthkit.datamodel.Content;
29 import org.sleuthkit.datamodel.Image;
30 import org.sleuthkit.datamodel.SleuthkitCase;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
36 final class RunIngestSubMenu extends JMenuItem implements DynamicMenuContent {
37 
45  @Override
46  public JComponent[] getMenuPresenters() {
47  List<Content> dataSources = new ArrayList<>();
48 
49  try {
50  dataSources = Case.getCurrentCase().getDataSources();
51  } catch (IllegalStateException ex) {
52  // No open Cases, create a disabled empty menu
53  return getEmpty();
54  } catch (TskCoreException e) {
55  System.out.println("Exception getting images: " + e.getMessage()); //NON-NLS
56  }
57  JComponent[] comps = new JComponent[dataSources.size()];
58 
59  // Add Images to the component list
60  for (int i = 0; i < dataSources.size(); i++) {
61  String action = dataSources.get(i).getName();
62  JMenuItem menuItem = new JMenuItem(action);
63  menuItem.setActionCommand(action.toUpperCase());
64  menuItem.addActionListener(new RunIngestModulesAction(dataSources.get(i)));
65  comps[i] = menuItem;
66  }
67  // If no dataSources are open, create a disabled empty menu
68  if (dataSources.isEmpty()) {
69  return getEmpty();
70  }
71  return comps;
72  }
73 
74  // returns a disabled empty menu
75  private JComponent[] getEmpty() {
76  JComponent[] comps = new JComponent[1];
77  JMenuItem emptyMenu = new JMenuItem(NbBundle.getMessage(RunIngestSubMenu.class, "RunIngestSubMenu.menuItem.empty"));
78  comps[0] = emptyMenu;
79  comps[0].setEnabled(false);
80  return comps;
81  }
82 
93  @Override
94  public JComponent[] synchMenuPresenters(JComponent[] jcs) {
95  return getMenuPresenters();
96  }
97 
98 
99 }

Copyright © 2012-2016 Basis Technology. Generated on: Tue Oct 25 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.