Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
EditPersonAction.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.persons;
20
21import java.awt.Frame;
22import java.awt.event.ActionEvent;
23import java.util.logging.Level;
24import javax.swing.AbstractAction;
25import javax.swing.JOptionPane;
26import org.openide.util.NbBundle.Messages;
27import org.openide.windows.WindowManager;
28import org.sleuthkit.autopsy.casemodule.Case;
29import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
30import org.sleuthkit.datamodel.TskCoreException;
31import org.sleuthkit.autopsy.coreutils.Logger;
32import org.sleuthkit.datamodel.Person;
33
37@Messages({
38 "EditPersonAction_menuTitle=Edit Person...",
39 "EditPersonAction_onError_title=Error Editing Person",
40 "# {0} - personName",
41 "EditPersonAction_onError_description=There was an error editing person: {0}.",})
42public class EditPersonAction extends AbstractAction {
43
44 private static final Logger logger = Logger.getLogger(EditPersonAction.class.getName());
45
46 private final Person person;
47
53 public EditPersonAction(Person person) {
54 super(Bundle.EditPersonAction_menuTitle());
55 this.person = person;
56 }
57
58
59 @Override
60 public void actionPerformed(ActionEvent e) {
61 try {
62 String newPersonName = getEditedPersonName(person);
63 if (newPersonName != null) {
64 person.setName(newPersonName);
65 }
66 Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().updatePerson(person);
67 } catch (NoCurrentCaseException | TskCoreException ex) {
68 String personName = this.person == null || this.person.getName() == null ? "" : this.person.getName();
69 logger.log(Level.WARNING, String.format("Unable to update person: %s", personName), ex);
70
71 JOptionPane.showMessageDialog(
72 WindowManager.getDefault().getMainWindow(),
73 Bundle.EditPersonAction_onError_description(personName),
74 Bundle.EditPersonAction_onError_title(),
75 JOptionPane.WARNING_MESSAGE);
76 }
77 }
78
86 private String getEditedPersonName(Person person) throws NoCurrentCaseException, TskCoreException {
87 Frame parent = WindowManager.getDefault().getMainWindow();
88
89 AddEditPersonDialog addEditDialog
91 parent,
92 Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().getPersons(),
93 person);
94
95 addEditDialog.setResizable(false);
96 addEditDialog.setLocationRelativeTo(parent);
97 addEditDialog.setVisible(true);
98 addEditDialog.toFront();
99
100 if (addEditDialog.isChanged()) {
101 String newHostName = addEditDialog.getValue();
102 return newHostName;
103 }
104
105 return null;
106 }
107
108}
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.