mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
updates
This commit is contained in:
parent
1c3059d76c
commit
f718f3ae07
@ -82,11 +82,14 @@ import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceDeletedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.DataSourceNameChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostRemovedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostsAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostsChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostsRemovedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.OsAccountAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.OsAccountChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.PersonsAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.PersonsChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.PersonsRemovedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.ReportAddedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.multiusercases.CaseNodeData.CaseNodeDataException;
|
||||
import org.sleuthkit.autopsy.casemodule.multiusercases.CoordinationServiceUtils;
|
||||
@ -135,11 +138,18 @@ import org.sleuthkit.datamodel.ContentTag;
|
||||
import org.sleuthkit.datamodel.DataSource;
|
||||
import org.sleuthkit.datamodel.FileSystem;
|
||||
import org.sleuthkit.datamodel.Host;
|
||||
import org.sleuthkit.datamodel.HostManager.HostsCreationEvent;
|
||||
import org.sleuthkit.datamodel.HostManager.HostsUpdateEvent;
|
||||
import org.sleuthkit.datamodel.HostManager.HostsDeletionEvent;
|
||||
import org.sleuthkit.datamodel.Image;
|
||||
import org.sleuthkit.datamodel.OsAccount;
|
||||
import org.sleuthkit.datamodel.OsAccountManager;
|
||||
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsCreationEvent;
|
||||
import org.sleuthkit.datamodel.OsAccountManager.OsAccountsUpdateEvent;
|
||||
import org.sleuthkit.datamodel.Person;
|
||||
import org.sleuthkit.datamodel.PersonManager.PersonsCreationEvent;
|
||||
import org.sleuthkit.datamodel.PersonManager.PersonsUpdateEvent;
|
||||
import org.sleuthkit.datamodel.PersonManager.PersonsDeletionEvent;
|
||||
import org.sleuthkit.datamodel.Report;
|
||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||
import org.sleuthkit.datamodel.TimelineManager;
|
||||
@ -517,7 +527,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the creation of hosts.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishHostsAddedEvent(HostCreationEvent event) {
|
||||
public void publishHostsAddedEvent(HostsCreationEvent event) {
|
||||
eventPublisher.publish(new HostsAddedEvent(
|
||||
event == null ? Collections.emptyList() : event.getHosts()));
|
||||
}
|
||||
@ -529,7 +539,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the updating of hosts.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishHostsChangedEvent(HostUpdateEvent event) {
|
||||
public void publishHostsChangedEvent(HostsUpdateEvent event) {
|
||||
eventPublisher.publish(new HostsChangedEvent(
|
||||
event == null ? Collections.emptyList() : event.getHosts()));
|
||||
}
|
||||
@ -541,7 +551,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the deleting of hosts.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishHostsDeletedEvent(HostDeletedEvent event) {
|
||||
public void publishHostsDeletedEvent(HostsDeletionEvent event) {
|
||||
eventPublisher.publish(new HostsRemovedEvent(
|
||||
event == null ? Collections.emptyList() : event.getHosts()));
|
||||
}
|
||||
@ -553,7 +563,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the creation of persons.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishPersonsAddedEvent(PersonCreationEvent event) {
|
||||
public void publishPersonsAddedEvent(PersonsCreationEvent event) {
|
||||
eventPublisher.publish(new PersonsAddedEvent(
|
||||
event == null ? Collections.emptyList() : event.getPersons()));
|
||||
}
|
||||
@ -565,7 +575,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the updating of persons.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishPersonsChangedEvent(PersonUpdateEvent event) {
|
||||
public void publishPersonsChangedEvent(PersonsUpdateEvent event) {
|
||||
eventPublisher.publish(new PersonsChangedEvent(
|
||||
event == null ? Collections.emptyList() : event.getPersons()));
|
||||
}
|
||||
@ -577,7 +587,7 @@ public class Case {
|
||||
* @param event The sleuthkit event for the deleting of persons.
|
||||
*/
|
||||
@Subscribe
|
||||
public void publishPersonsDeletedEvent(PersonDeletedEvent event) {
|
||||
public void publishPersonsDeletedEvent(PersonsDeletionEvent event) {
|
||||
eventPublisher.publish(new PersonsRemovedEvent(
|
||||
event == null ? Collections.emptyList() : event.getPersons()));
|
||||
}
|
||||
@ -1793,7 +1803,7 @@ public class Case {
|
||||
* @param host The host that has been added.
|
||||
*/
|
||||
public void notifyHostAdded(Host host) {
|
||||
eventPublisher.publish(new HostAddedEvent(Collections.singletonList(host)));
|
||||
eventPublisher.publish(new HostsAddedEvent(Collections.singletonList(host)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1801,7 +1811,7 @@ public class Case {
|
||||
* @param newValue The host that has been updated.
|
||||
*/
|
||||
public void notifyHostChanged(Host newValue) {
|
||||
eventPublisher.publish(new HostChangedEvent(Collections.singletonList(newValue)));
|
||||
eventPublisher.publish(new HostsChangedEvent(Collections.singletonList(newValue)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1809,7 +1819,7 @@ public class Case {
|
||||
* @param host The host that has been deleted.
|
||||
*/
|
||||
public void notifyHostDeleted(Host host) {
|
||||
eventPublisher.publish(new HostRemovedEvent(Collections.singletonList(host)));
|
||||
eventPublisher.publish(new HostsRemovedEvent(Collections.singletonList(host)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1817,7 +1827,7 @@ public class Case {
|
||||
* @param person The person that has been added.
|
||||
*/
|
||||
public void notifyPersonAdded(Person person) {
|
||||
eventPublisher.publish(new PersonAddedEvent(Collections.singletonList(person)));
|
||||
eventPublisher.publish(new PersonsAddedEvent(Collections.singletonList(person)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1825,7 +1835,7 @@ public class Case {
|
||||
* @param newValue The person that has been updated.
|
||||
*/
|
||||
public void notifyPersonChanged(Person newValue) {
|
||||
eventPublisher.publish(new PersonChangedEvent(Collections.singletonList(newValue)));
|
||||
eventPublisher.publish(new PersonsChangedEvent(Collections.singletonList(newValue)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1833,7 +1843,7 @@ public class Case {
|
||||
* @param person The person that has been deleted.
|
||||
*/
|
||||
public void notifyPersonDeleted(Person person) {
|
||||
eventPublisher.publish(new PersonRemovedEvent(Collections.singletonList(person)));
|
||||
eventPublisher.publish(new PersonsRemovedEvent(Collections.singletonList(person)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Host;
|
||||
/**
|
||||
* Event fired when new hosts are added.
|
||||
*/
|
||||
public class HostAddedEvent extends HostEvent {
|
||||
public class HostsAddedEvent extends HostsEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -33,7 +33,7 @@ public class HostAddedEvent extends HostEvent {
|
||||
* Main constructor.
|
||||
* @param dataModelObjects The hosts that have been added.
|
||||
*/
|
||||
public HostAddedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOST_ADDED.name(), dataModelObjects);
|
||||
public HostsAddedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOSTS_ADDED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Host;
|
||||
/**
|
||||
* Event fired when hosts are changed.
|
||||
*/
|
||||
public class HostChangedEvent extends HostEvent {
|
||||
public class HostsChangedEvent extends HostsEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -35,7 +35,7 @@ public class HostChangedEvent extends HostEvent {
|
||||
* @param dataModelObjects The new values for the hosts that have been
|
||||
* changed.
|
||||
*/
|
||||
public HostChangedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOST_CHANGED.name(), dataModelObjects);
|
||||
public HostsChangedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOSTS_CHANGED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
/**
|
||||
* Base event class for when something pertaining to hosts changes.
|
||||
*/
|
||||
public class HostEvent extends TskDataModelChangeEvent<Host> {
|
||||
public class HostsEvent extends TskDataModelChangeEvent<Host> {
|
||||
|
||||
/**
|
||||
* Retrieves a list of ids from a list of hosts.
|
||||
@ -62,7 +62,7 @@ public class HostEvent extends TskDataModelChangeEvent<Host> {
|
||||
* type.
|
||||
* @param dataModelObjects The list of hosts for the event.
|
||||
*/
|
||||
protected HostEvent(String eventName, List<Host> dataModelObjects) {
|
||||
protected HostsEvent(String eventName, List<Host> dataModelObjects) {
|
||||
super(eventName, getIds(dataModelObjects), new ArrayList<>(getSafeList(dataModelObjects)));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Host;
|
||||
/**
|
||||
* Event fired when hosts are removed.
|
||||
*/
|
||||
public class HostRemovedEvent extends HostEvent {
|
||||
public class HostsRemovedEvent extends HostsEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -33,7 +33,7 @@ public class HostRemovedEvent extends HostEvent {
|
||||
* Main constructor.
|
||||
* @param dataModelObjects The list of hosts that have been deleted.
|
||||
*/
|
||||
public HostRemovedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOST_DELETED.name(), dataModelObjects);
|
||||
public HostsRemovedEvent(List<Host> dataModelObjects) {
|
||||
super(Case.Events.HOSTS_DELETED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Person;
|
||||
/**
|
||||
* Event fired when new persons are added.
|
||||
*/
|
||||
public class PersonAddedEvent extends PersonEvent {
|
||||
public class PersonsAddedEvent extends PersonxEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -33,7 +33,7 @@ public class PersonAddedEvent extends PersonEvent {
|
||||
* Main constructor.
|
||||
* @param dataModelObjects The persons that have been added.
|
||||
*/
|
||||
public PersonAddedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSON_ADDED.name(), dataModelObjects);
|
||||
public PersonsAddedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSONS_ADDED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Person;
|
||||
/**
|
||||
* Event fired when persons are changed.
|
||||
*/
|
||||
public class PersonChangedEvent extends PersonEvent {
|
||||
public class PersonsChangedEvent extends PersonxEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -35,7 +35,7 @@ public class PersonChangedEvent extends PersonEvent {
|
||||
* @param dataModelObjects The new values for the persons that have been
|
||||
* changed.
|
||||
*/
|
||||
public PersonChangedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSON_CHANGED.name(), dataModelObjects);
|
||||
public PersonsChangedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSONS_CHANGED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -25,7 +25,7 @@ import org.sleuthkit.datamodel.Person;
|
||||
/**
|
||||
* Event fired when persons are removed.
|
||||
*/
|
||||
public class PersonRemovedEvent extends PersonEvent {
|
||||
public class PersonsRemovedEvent extends PersonxEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -33,7 +33,7 @@ public class PersonRemovedEvent extends PersonEvent {
|
||||
* Main constructor.
|
||||
* @param dataModelObjects The list of persons that have been deleted.
|
||||
*/
|
||||
public PersonRemovedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSON_DELETED.name(), dataModelObjects);
|
||||
public PersonsRemovedEvent(List<Person> dataModelObjects) {
|
||||
super(Case.Events.PERSONS_DELETED.name(), dataModelObjects);
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
/**
|
||||
* Base event class for when something pertaining to persons changes.
|
||||
*/
|
||||
public class PersonEvent extends TskDataModelChangeEvent<Person> {
|
||||
public class PersonxEvent extends TskDataModelChangeEvent<Person> {
|
||||
|
||||
/**
|
||||
* Retrieves a list of ids from a list of persons.
|
||||
@ -62,7 +62,7 @@ public class PersonEvent extends TskDataModelChangeEvent<Person> {
|
||||
* type.
|
||||
* @param dataModelObjects The list of persons for the event.
|
||||
*/
|
||||
protected PersonEvent(String eventName, List<Person> dataModelObjects) {
|
||||
protected PersonxEvent(String eventName, List<Person> dataModelObjects) {
|
||||
super(eventName, getIds(dataModelObjects), new ArrayList<>(getSafeList(dataModelObjects)));
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.openide.nodes.ChildFactory;
|
||||
import org.openide.nodes.Node;
|
||||
@ -47,6 +48,18 @@ import org.sleuthkit.datamodel.TskCoreException;
|
||||
*/
|
||||
public final class AutopsyTreeChildFactory extends ChildFactory.Detachable<Object> {
|
||||
|
||||
private static final Set<Case.Events> LISTENING_EVENTS = EnumSet.of(
|
||||
Case.Events.DATA_SOURCE_ADDED,
|
||||
Case.Events.HOSTS_ADDED,
|
||||
Case.Events.HOSTS_DELETED,
|
||||
Case.Events.PERSONS_ADDED,
|
||||
Case.Events.PERSONS_DELETED
|
||||
);
|
||||
|
||||
private static final Set<String> LISTENING_EVENT_NAMES = LISTENING_EVENTS.stream()
|
||||
.map(evt -> evt.name())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AutopsyTreeChildFactory.class.getName());
|
||||
|
||||
/**
|
||||
@ -56,7 +69,7 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable<Objec
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String eventType = evt.getPropertyName();
|
||||
if (eventType.equals(Case.Events.DATA_SOURCE_ADDED.toString())
|
||||
if (LISTENING_EVENT_NAMES.contains(eventType)
|
||||
&& Objects.equals(CasePreferences.getGroupItemsInTreeByDataSource(), true)) {
|
||||
refreshChildren();
|
||||
}
|
||||
@ -66,13 +79,13 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable<Objec
|
||||
@Override
|
||||
protected void addNotify() {
|
||||
super.addNotify();
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.addEventTypeSubscriber(LISTENING_EVENTS, pcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeNotify() {
|
||||
super.removeNotify();
|
||||
Case.removeEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.removeEventTypeSubscriber(LISTENING_EVENTS, pcl);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,11 +107,11 @@ public final class AutopsyTreeChildFactory extends ChildFactory.Detachable<Objec
|
||||
.map(PersonGrouping::new)
|
||||
.sorted()
|
||||
.forEach(list::add);
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(personManager.getHostsForPerson(null))) {
|
||||
list.add(new PersonGrouping(null));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
} else {
|
||||
// otherwise, just show host level
|
||||
|
@ -36,6 +36,7 @@ import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.util.lookup.Lookups;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostsChangedEvent;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.hosts.AssociatePersonsMenuAction;
|
||||
import org.sleuthkit.autopsy.datamodel.hosts.RemoveParentPersonAction;
|
||||
@ -76,7 +77,7 @@ public class HostNode extends DisplayableItemNode {
|
||||
/**
|
||||
* Listener for handling DATA_SOURCE_ADDED events.
|
||||
*/
|
||||
private final PropertyChangeListener pcl = new PropertyChangeListener() {
|
||||
private final PropertyChangeListener dataSourceAddedPcl = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String eventType = evt.getPropertyName();
|
||||
@ -88,12 +89,12 @@ public class HostNode extends DisplayableItemNode {
|
||||
|
||||
@Override
|
||||
protected void addNotify() {
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), dataSourceAddedPcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeNotify() {
|
||||
Case.removeEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.removeEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), dataSourceAddedPcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,7 +164,24 @@ public class HostNode extends DisplayableItemNode {
|
||||
return new DataSourceGroupingNode(key.getDataSource());
|
||||
};
|
||||
|
||||
/**
|
||||
* Listener for handling host change events.
|
||||
*/
|
||||
private final PropertyChangeListener hostChangePcl = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String eventType = evt.getPropertyName();
|
||||
if (hostId != null && eventType.equals(Case.Events.HOSTS_CHANGED.toString()) && evt instanceof HostsChangedEvent) {
|
||||
((HostsChangedEvent) evt).getNewValue().stream()
|
||||
.filter(h -> h != null && h.getId() == hostId)
|
||||
.findFirst()
|
||||
.ifPresent((newHost) -> setDisplayName(newHost.getName()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private final Host host;
|
||||
private final Long hostId;
|
||||
|
||||
/**
|
||||
* Main constructor for HostDataSources key where data source children
|
||||
@ -197,7 +215,9 @@ public class HostNode extends DisplayableItemNode {
|
||||
String safeName = (host == null || host.getName() == null)
|
||||
? Bundle.HostGroupingNode_unknownHostNode_title()
|
||||
: host.getName();
|
||||
|
||||
|
||||
hostId = host == null ? null : host.getId();
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.HOSTS_CHANGED), hostChangePcl);
|
||||
super.setName(safeName);
|
||||
super.setDisplayName(safeName);
|
||||
this.setIconBaseWithExtension(ICON_PATH);
|
||||
|
@ -23,7 +23,10 @@ import java.beans.PropertyChangeListener;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.swing.Action;
|
||||
import org.openide.nodes.ChildFactory;
|
||||
import org.openide.nodes.Children;
|
||||
@ -33,6 +36,8 @@ import org.openide.util.NbBundle.Messages;
|
||||
import org.openide.util.lookup.Lookups;
|
||||
import org.sleuthkit.autopsy.casemodule.Case;
|
||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||
import org.sleuthkit.autopsy.casemodule.events.HostsChangedEvent;
|
||||
import org.sleuthkit.autopsy.casemodule.events.PersonsChangedEvent;
|
||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||
import org.sleuthkit.autopsy.datamodel.persons.DeletePersonAction;
|
||||
import org.sleuthkit.autopsy.datamodel.persons.EditPersonAction;
|
||||
@ -56,6 +61,11 @@ public class PersonGroupingNode extends DisplayableItemNode {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(PersonChildren.class.getName());
|
||||
|
||||
private static final Set<Case.Events> CHILD_EVENTS = EnumSet.of(Case.Events.HOSTS_ADDED, Case.Events.HOSTS_CHANGED);
|
||||
private static final Set<String> CHILD_EVENTS_STR = CHILD_EVENTS.stream()
|
||||
.map(ev -> ev.name())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
private final Person person;
|
||||
|
||||
/**
|
||||
@ -68,15 +78,13 @@ public class PersonGroupingNode extends DisplayableItemNode {
|
||||
}
|
||||
|
||||
/**
|
||||
* Listener for handling DATA_SOURCE_ADDED and DATA_SOURCE_DELETED
|
||||
* events.
|
||||
* Listener for handling adding and removing host events.
|
||||
*/
|
||||
private final PropertyChangeListener pcl = new PropertyChangeListener() {
|
||||
private final PropertyChangeListener hostAddedDeletedPcl = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String eventType = evt.getPropertyName();
|
||||
if (eventType.equals(Case.Events.DATA_SOURCE_ADDED.toString())
|
||||
|| eventType.equals(Case.Events.DATA_SOURCE_DELETED.toString())) {
|
||||
if (eventType != null && CHILD_EVENTS_STR.contains(eventType)) {
|
||||
refresh(true);
|
||||
}
|
||||
}
|
||||
@ -84,12 +92,12 @@ public class PersonGroupingNode extends DisplayableItemNode {
|
||||
|
||||
@Override
|
||||
protected void addNotify() {
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.addEventTypeSubscriber(CHILD_EVENTS, hostAddedDeletedPcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeNotify() {
|
||||
Case.removeEventTypeSubscriber(EnumSet.of(Case.Events.DATA_SOURCE_ADDED), pcl);
|
||||
Case.removeEventTypeSubscriber(CHILD_EVENTS, hostAddedDeletedPcl);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,7 +125,24 @@ public class PersonGroupingNode extends DisplayableItemNode {
|
||||
}
|
||||
|
||||
private final Person person;
|
||||
private final Long personId;
|
||||
|
||||
/**
|
||||
* Listener for handling person change events.
|
||||
*/
|
||||
private final PropertyChangeListener personChangePcl = new PropertyChangeListener() {
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String eventType = evt.getPropertyName();
|
||||
if (personId != null && eventType.equals(Case.Events.PERSONS_CHANGED.toString()) && evt instanceof PersonsChangedEvent) {
|
||||
((PersonsChangedEvent) evt).getNewValue().stream()
|
||||
.filter(p -> p != null && p.getId() == personId)
|
||||
.findFirst()
|
||||
.ifPresent((newPerson) -> setDisplayName(newPerson.getName()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Main constructor.
|
||||
*
|
||||
@ -134,7 +159,11 @@ public class PersonGroupingNode extends DisplayableItemNode {
|
||||
super.setDisplayName(safeName);
|
||||
this.setIconBaseWithExtension(ICON_PATH);
|
||||
this.person = person;
|
||||
this.personId = person == null ? null : person.getId();
|
||||
Case.addEventTypeSubscriber(EnumSet.of(Case.Events.PERSONS_CHANGED), personChangePcl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isLeafTypeNode() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user