Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
AssociatePersonsMenuAction.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2021 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 */
19package org.sleuthkit.autopsy.datamodel.hosts;
20
21import java.awt.event.ActionEvent;
22import java.util.Collections;
23import java.util.List;
24import java.util.logging.Level;
25import javax.swing.AbstractAction;
26import javax.swing.JMenu;
27import javax.swing.JMenuItem;
28import javax.swing.JSeparator;
29import org.openide.util.NbBundle.Messages;
30import org.openide.util.actions.Presenter;
31import org.sleuthkit.autopsy.casemodule.Case;
32import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.datamodel.Host;
35import org.sleuthkit.datamodel.Person;
36import org.sleuthkit.datamodel.TskCoreException;
37
43@Messages({
44 "AssociatePersonsMenuAction_menuTitle=Associate with Person",})
45public class AssociatePersonsMenuAction extends AbstractAction implements Presenter.Popup {
46
47 private static final Logger logger = Logger.getLogger(AssociatePersonsMenuAction.class.getName());
48
49 private final Host host;
50
57 super("");
58 this.host = host;
59 }
60
61 @Override
62 @SuppressWarnings("NoopMethodInAbstractClass")
63 public void actionPerformed(ActionEvent event) {
64 }
65
66 @Override
67 public JMenuItem getPopupPresenter() {
68 JMenu menu = new JMenu(Bundle.AssociatePersonsMenuAction_menuTitle());
69
70 List<Person> existingPersons = Collections.emptyList();
71 try {
72 existingPersons = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().getPersons();
73 } catch (NoCurrentCaseException | TskCoreException ex) {
74 logger.log(Level.WARNING, "Error getting persons for case.", ex);
75 }
76
77 existingPersons.stream()
78 .filter(p -> p != null && p.getName() != null)
79 .sorted((a, b) -> a.getName().compareToIgnoreCase(b.getName()))
80 .map(p -> new JMenuItem(new AssociatePersonAction(this.host, p)))
81 .forEach(menu::add);
82
83 if (menu.getItemCount() > 0) {
84 menu.add(new JSeparator());
85 }
86
87 menu.add(new JMenuItem(new AssociateNewPersonAction(this.host)));
88 return menu;
89 }
90
91}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.