Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
UpdateRecentCases.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.casemodule;
20 
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;
27 
31 class UpdateRecentCases extends JMenuItem implements DynamicMenuContent {
32 
33  int length;
34  static boolean hasRecentCase = false;
35 
39  UpdateRecentCases() {
40  // display last 5 cases.
41  length = RecentCases.LENGTH - 1;
42  }
43 
52  @Override
53  public JComponent[] getMenuPresenters() {
54  String[] caseName = RecentCases.getInstance().getRecentCaseNames();
55  String[] casePath = RecentCases.getInstance().getRecentCasePaths();
56  JComponent[] comps = new JComponent[length + 2]; // + 2 for separator and clear menu
57 
58  // if it has the recent menus, add them to the component list
59  for (int i = 0; i < length; i++) {
60  if ((!caseName[i].equals(""))) {
61  JMenuItem menuItem = new JMenuItem(caseName[i]);
62  menuItem.setActionCommand(caseName[i].toUpperCase());
63  menuItem.addActionListener(new RecentItems(caseName[i], casePath[i]));
64  comps[i] = menuItem;
65  hasRecentCase = true;
66  }
67  }
68 
69  // if it has recent case, create clear menu
70  if (hasRecentCase) {
71  comps[length] = new JSeparator();
72  JMenuItem clearMenu = new JMenuItem(
73  NbBundle.getMessage(UpdateRecentCases.class, "UpdateRecentCases.menuItem.clearRecentCases.text"));
74  clearMenu.addActionListener(SystemAction.get(RecentCases.class));
75  comps[length + 1] = clearMenu;
76  } // otherwise, just create a disabled empty menu
77  else {
78  comps = new JComponent[1];
79  JMenuItem emptyMenu = new JMenuItem(NbBundle.getMessage(UpdateRecentCases.class, "UpdateRecentCases.menuItem.empty"));
80  emptyMenu.addActionListener(new RecentItems("", ""));
81  comps[0] = emptyMenu;
82  comps[0].setEnabled(false);
83  }
84  return comps;
85  }
86 
97  @Override
98  public JComponent[] synchMenuPresenters(JComponent[] jcs) {
99  return getMenuPresenters();
100  }
101 }

Copyright © 2012-2015 Basis Technology. Generated on: Wed Apr 6 2016
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.