Autopsy  3.1
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 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 
20 package org.sleuthkit.autopsy.casemodule;
21 
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;
28 
32  class UpdateRecentCases extends JMenuItem implements DynamicMenuContent {
33 
34  int length;
35  static boolean hasRecentCase = false;
36 
38  UpdateRecentCases(){
39  length = RecentCases.LENGTH;
40  }
41 
50  @Override
51  public JComponent[] getMenuPresenters() {
52  String[] caseName = RecentCases.getInstance().getRecentCaseNames();
53  String[] casePath = RecentCases.getInstance().getRecentCasePaths();
54  JComponent[] comps = new JComponent[length + 2]; // + 2 for separator and clear menu
55 
56  // if it has the recent menus, add them to the component list
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]));
62  comps[i] = menuItem;
63  hasRecentCase = hasRecentCase || true;
64  }
65  }
66 
67  // if it has recent case, create clear menu
68  if(hasRecentCase){
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;
74  }
75  // otherwise, just create a disabled empty menu
76  else{
77  comps = new JComponent[1];
78  JMenuItem emptyMenu = new JMenuItem(NbBundle.getMessage(this.getClass(), "UpdateRecentCases.menuItem.empty"));
79  emptyMenu.addActionListener(new RecentItems("", ""));
80  comps[0] = emptyMenu;
81  comps[0].setEnabled(false);
82  }
83  return comps;
84  }
85 
92  @Override
93  public JComponent[] synchMenuPresenters(JComponent[] jcs) {
94  return getMenuPresenters();
95  }
96 }

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