19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.util.Collections;
24 import java.util.EnumSet;
25 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.stream.Collectors;
29 import javax.swing.Action;
30 import org.openide.nodes.ChildFactory;
31 import org.openide.nodes.Children;
32 import org.openide.nodes.Sheet;
33 import org.openide.util.NbBundle;
34 import org.openide.util.NbBundle.Messages;
35 import org.openide.util.WeakListeners;
36 import org.openide.util.lookup.Lookups;
54 @NbBundle.Messages(value = {
"PersonNode_unknownPersonNode_title=Unknown Persons"})
57 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/person.png";
66 return Bundle.PersonNode_unknownPersonNode_title();
72 private static class PersonChildren extends ChildFactory.Detachable<HostGrouping> {
82 private static final Set<String> HOST_EVENTS_OF_INTEREST_NAMES = HOST_EVENTS_OF_INTEREST.stream()
84 .collect(Collectors.toSet());
106 private final PropertyChangeListener hostAddedDeletedPcl =
new PropertyChangeListener() {
108 public void propertyChange(PropertyChangeEvent evt) {
109 String eventType = evt.getPropertyName();
110 if (eventType != null && HOST_EVENTS_OF_INTEREST_NAMES.contains(eventType)) {
116 private final PropertyChangeListener weakPcl = WeakListeners.propertyChange(hostAddedDeletedPcl, null);
131 return key == null ? null :
new HostNode(key);
135 protected boolean createKeys(List<HostGrouping> toPopulate) {
136 List<Host> hosts = Collections.emptyList();
138 if (person != null) {
145 String personName = person == null || person.getName() == null ?
"<unknown>" : person.getName();
146 logger.log(Level.WARNING, String.format(
"Unable to get data sources for host: %s", personName), ex);
149 toPopulate.addAll(hosts.stream()
150 .map(HostGrouping::new)
152 .collect(Collectors.toList()));
165 private final PropertyChangeListener personChangePcl =
new PropertyChangeListener() {
167 public void propertyChange(PropertyChangeEvent evt) {
168 String eventType = evt.getPropertyName();
170 ((PersonsUpdatedEvent) evt).getNewValue().stream()
171 .filter(p -> p != null && p.getPersonId() == personId)
173 .ifPresent((newPerson) -> {
174 setName(newPerson.getName());
175 setDisplayName(newPerson.getName());
181 private final PropertyChangeListener weakPcl = WeakListeners.propertyChange(personChangePcl, null);
191 return (person == null || person.getName() == null)
192 ? getUnknownPersonId()
202 this(person, getDisplayName(person));
213 person == null ? Lookups.fixed(displayName) : Lookups.fixed(person, displayName));
214 super.setName(displayName);
215 super.setDisplayName(displayName);
216 this.setIconBaseWithExtension(ICON_PATH);
217 this.person = person;
218 this.personId = person == null ? null : person.getPersonId();
229 return getClass().getName();
234 return visitor.
visit(
this);
238 "PersonGroupingNode_createSheet_nameProperty=Name",})
241 Sheet sheet = Sheet.createDefault();
242 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
243 if (sheetSet == null) {
244 sheetSet = Sheet.createPropertiesSet();
248 sheetSet.put(
new NodeProperty<>(
"Name", Bundle.PersonGroupingNode_createSheet_nameProperty(),
"", getDisplayName()));
254 @Messages({
"PersonGroupingNode_actions_rename=Rename Person...",
255 "PersonGroupingNode_actions_delete=Delete Person"})
257 if (this.person == null) {
258 return new Action[0];
static String getDisplayName(Person person)
boolean createKeys(List< HostGrouping > toPopulate)
Action[] getActions(boolean context)
static String getUnknownPersonId()
HostNode createNodeForKey(HostGrouping key)
SleuthkitCase getSleuthkitCase()
T visit(DataSourceFilesNode in)
synchronized static Logger getLogger(String name)
static Case getCurrentCaseThrows()
static void addEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
PersonNode(Person person, String displayName)
static void removeEventTypeSubscriber(Set< Events > eventTypes, PropertyChangeListener subscriber)
HOSTS_REMOVED_FROM_PERSON