mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 08:26:15 +00:00
fixes
This commit is contained in:
parent
7d49ee323e
commit
e4442cce82
@ -246,20 +246,23 @@ public class HostNode extends DisplayableItemNode {
|
|||||||
|
|
||||||
Optional<Person> parent = Optional.empty();
|
Optional<Person> parent = Optional.empty();
|
||||||
|
|
||||||
|
// if there is a host, then provide actions
|
||||||
if (this.host != null) {
|
if (this.host != null) {
|
||||||
try {
|
try {
|
||||||
parent = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().getPerson(this.host);
|
parent = Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().getPerson(this.host);
|
||||||
} catch (NoCurrentCaseException | TskCoreException ex) {
|
} catch (NoCurrentCaseException | TskCoreException ex) {
|
||||||
logger.log(Level.WARNING, String.format("Error fetching parent person of host: %s", this.host.getName() == null ? "<null>" : this.host.getName()), ex);
|
logger.log(Level.WARNING, String.format("Error fetching parent person of host: %s", this.host.getName() == null ? "<null>" : this.host.getName()), ex);
|
||||||
return new Action[0];
|
return new Action[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if there is a parent, only give option to remove parent person.
|
||||||
if (parent.isPresent()) {
|
if (parent.isPresent()) {
|
||||||
return new Action[]{
|
return new Action[]{
|
||||||
new RemoveParentPersonAction(this.host, parent.get()),
|
new RemoveParentPersonAction(this.host, parent.get()),
|
||||||
null
|
null
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
// otherwise provide options to associate with new person or existing persons
|
||||||
List<Person> existingPersons = Collections.emptyList();
|
List<Person> existingPersons = Collections.emptyList();
|
||||||
try {
|
try {
|
||||||
existingPersons = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().getPersons();
|
existingPersons = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().getPersons();
|
||||||
|
@ -28,7 +28,6 @@ import org.openide.util.NbBundle.Messages;
|
|||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.autopsy.datamodel.persons.AddEditPersonDialog;
|
import org.sleuthkit.autopsy.datamodel.persons.AddEditPersonDialog;
|
||||||
import org.sleuthkit.datamodel.Host;
|
import org.sleuthkit.datamodel.Host;
|
||||||
@ -64,7 +63,7 @@ public class AssociateNewPersonAction extends AbstractAction {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
String newPersonName = "";
|
String newPersonName = "";
|
||||||
try {
|
try {
|
||||||
newPersonName = getAddDialogName();
|
newPersonName = getAddDialogName();
|
||||||
if (StringUtils.isNotBlank(newPersonName)) {
|
if (StringUtils.isNotBlank(newPersonName)) {
|
||||||
Person person = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().createPerson(newPersonName);
|
Person person = Case.getCurrentCaseThrows().getSleuthkitCase().getPersonManager().createPerson(newPersonName);
|
||||||
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().setPerson(host, person);
|
Case.getCurrentCaseThrows().getSleuthkitCase().getHostManager().setPerson(host, person);
|
||||||
@ -82,6 +81,13 @@ public class AssociateNewPersonAction extends AbstractAction {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get dialog to add new person name.
|
||||||
|
*
|
||||||
|
* @return The name for the new person or null to cancel.
|
||||||
|
* @throws NoCurrentCaseException
|
||||||
|
* @throws TskCoreException
|
||||||
|
*/
|
||||||
private String getAddDialogName() throws NoCurrentCaseException, TskCoreException {
|
private String getAddDialogName() throws NoCurrentCaseException, TskCoreException {
|
||||||
Frame parent = WindowManager.getDefault().getMainWindow();
|
Frame parent = WindowManager.getDefault().getMainWindow();
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import org.openide.util.NbBundle.Messages;
|
|||||||
import org.openide.windows.WindowManager;
|
import org.openide.windows.WindowManager;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.datamodel.Host;
|
import org.sleuthkit.datamodel.Host;
|
||||||
import org.sleuthkit.datamodel.Person;
|
import org.sleuthkit.datamodel.Person;
|
||||||
@ -51,14 +50,14 @@ public class AssociatePersonAction extends AbstractAction {
|
|||||||
/**
|
/**
|
||||||
* Main constructor.
|
* Main constructor.
|
||||||
*
|
*
|
||||||
* @param host The host that will become parentless.
|
* @param host The host that will get associated with the person.
|
||||||
* @param person The person to be removed as a parent from the host.
|
* @param person The person to be the parent of the host.
|
||||||
*/
|
*/
|
||||||
public AssociatePersonAction(Host host, Person person) {
|
public AssociatePersonAction(Host host, Person person) {
|
||||||
super(person == null || person.getName() == null ?
|
super(person == null || person.getName() == null
|
||||||
Bundle.RemoveParentPersonAction_unknownPerson() :
|
? Bundle.RemoveParentPersonAction_unknownPerson()
|
||||||
person.getName());
|
: person.getName());
|
||||||
|
|
||||||
this.host = host;
|
this.host = host;
|
||||||
this.person = person;
|
this.person = person;
|
||||||
}
|
}
|
||||||
|
@ -30,16 +30,22 @@ import org.sleuthkit.datamodel.Person;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* JMenu item to show menu to associate given host with an existing person.
|
* JMenu item to show a menu giving options to associate the given host with an
|
||||||
|
* existing person.
|
||||||
*/
|
*/
|
||||||
@Messages({
|
@Messages({
|
||||||
"AssociatePersonsMenuAction_menuTitle=Associate with Existing Person",
|
"AssociatePersonsMenuAction_menuTitle=Associate with Existing Person",})
|
||||||
})
|
|
||||||
public class AssociatePersonsMenuAction extends AbstractAction implements Presenter.Popup {
|
public class AssociatePersonsMenuAction extends AbstractAction implements Presenter.Popup {
|
||||||
|
|
||||||
private final List<Person> persons;
|
private final List<Person> persons;
|
||||||
private final Host host;
|
private final Host host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main constructor.
|
||||||
|
*
|
||||||
|
* @param persons The persons that this host can be associated with.
|
||||||
|
* @param host The host.
|
||||||
|
*/
|
||||||
public AssociatePersonsMenuAction(List<Person> persons, Host host) {
|
public AssociatePersonsMenuAction(List<Person> persons, Host host) {
|
||||||
super("");
|
super("");
|
||||||
this.persons = persons;
|
this.persons = persons;
|
||||||
@ -63,6 +69,5 @@ public class AssociatePersonsMenuAction extends AbstractAction implements Presen
|
|||||||
|
|
||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,9 @@ public class DeletePersonAction extends AbstractAction {
|
|||||||
setEnabled();
|
setEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the action enabled only if no child hosts.
|
||||||
|
*/
|
||||||
private void setEnabled() {
|
private void setEnabled() {
|
||||||
if (person == null) {
|
if (person == null) {
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
|
@ -76,6 +76,13 @@ public class EditPersonAction extends AbstractAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Presents a dialog that will allow the user to edit the person's name.
|
||||||
|
* @param person The person.
|
||||||
|
* @return The edited person's name or null if cancelled..
|
||||||
|
* @throws NoCurrentCaseException
|
||||||
|
* @throws TskCoreException
|
||||||
|
*/
|
||||||
private String getEditedPersonName(Person person) throws NoCurrentCaseException, TskCoreException {
|
private String getEditedPersonName(Person person) throws NoCurrentCaseException, TskCoreException {
|
||||||
Frame parent = WindowManager.getDefault().getMainWindow();
|
Frame parent = WindowManager.getDefault().getMainWindow();
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import java.util.logging.Level;
|
|||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import org.openide.nodes.FilterNode;
|
import org.openide.nodes.FilterNode;
|
||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
|
import org.openide.util.Lookup;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.lookup.Lookups;
|
import org.openide.util.lookup.Lookups;
|
||||||
import org.openide.util.lookup.ProxyLookup;
|
import org.openide.util.lookup.ProxyLookup;
|
||||||
@ -36,6 +37,8 @@ import org.sleuthkit.datamodel.AbstractFile;
|
|||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
|
import org.sleuthkit.datamodel.Host;
|
||||||
|
import org.sleuthkit.datamodel.Person;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
import org.sleuthkit.datamodel.TskData;
|
import org.sleuthkit.datamodel.TskData;
|
||||||
|
|
||||||
@ -54,9 +57,9 @@ class DirectoryTreeFilterNode extends FilterNode {
|
|||||||
* the tree view and wraps the Children object of the wrapped node with a
|
* the tree view and wraps the Children object of the wrapped node with a
|
||||||
* DirectoryTreeFilterChildren.
|
* DirectoryTreeFilterChildren.
|
||||||
*
|
*
|
||||||
* @param nodeToWrap The node to wrap.
|
* @param nodeToWrap The node to wrap.
|
||||||
* @param createChildren Whether to create the children of the wrapped node
|
* @param createChildren Whether to create the children of the wrapped node
|
||||||
* or treat it a a leaf node.
|
* or treat it a a leaf node.
|
||||||
*/
|
*/
|
||||||
DirectoryTreeFilterNode(Node nodeToWrap, boolean createChildren) {
|
DirectoryTreeFilterNode(Node nodeToWrap, boolean createChildren) {
|
||||||
super(nodeToWrap,
|
super(nodeToWrap,
|
||||||
@ -131,7 +134,7 @@ class DirectoryTreeFilterNode extends FilterNode {
|
|||||||
numVisibleChildren--;
|
numVisibleChildren--;
|
||||||
}
|
}
|
||||||
} else if (child instanceof BlackboardArtifact) {
|
} else if (child instanceof BlackboardArtifact) {
|
||||||
|
|
||||||
if (FilterNodeUtils.showMessagesInDatasourceTree()) {
|
if (FilterNodeUtils.showMessagesInDatasourceTree()) {
|
||||||
// In older versions of Autopsy, attachments were children of email/message artifacts
|
// In older versions of Autopsy, attachments were children of email/message artifacts
|
||||||
// and hence email/messages with attachments are shown in the directory tree.
|
// and hence email/messages with attachments are shown in the directory tree.
|
||||||
@ -141,8 +144,7 @@ class DirectoryTreeFilterNode extends FilterNode {
|
|||||||
&& (bba.getArtifactTypeID() != ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
|
&& (bba.getArtifactTypeID() != ARTIFACT_TYPE.TSK_MESSAGE.getTypeID())) {
|
||||||
numVisibleChildren--;
|
numVisibleChildren--;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
numVisibleChildren--;
|
numVisibleChildren--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,22 +158,33 @@ class DirectoryTreeFilterNode extends FilterNode {
|
|||||||
* Gets the context mneu (right click menu) actions for the wrapped node.
|
* Gets the context mneu (right click menu) actions for the wrapped node.
|
||||||
*
|
*
|
||||||
* @param context Whether to find actions for context meaning or for the
|
* @param context Whether to find actions for context meaning or for the
|
||||||
* node itself.
|
* node itself.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Action[] getActions(boolean context) {
|
public Action[] getActions(boolean context) {
|
||||||
List<Action> actions = new ArrayList<>();
|
List<Action> actions = new ArrayList<>();
|
||||||
|
actions.addAll(Arrays.asList(getNodeActions()));
|
||||||
//final Content content = this.getLookup().lookup(Content.class);
|
|
||||||
//if (content != null) {
|
|
||||||
actions.addAll(Arrays.asList(super.getActions(true)));
|
|
||||||
//}
|
|
||||||
actions.add(collapseAllAction);
|
actions.add(collapseAllAction);
|
||||||
return actions.toArray(new Action[actions.size()]);
|
return actions.toArray(new Action[actions.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If lookup node is content, host, or person, returns super
|
||||||
|
* actions. Otherwise, returns empty array.
|
||||||
|
*/
|
||||||
|
private Action[] getNodeActions() {
|
||||||
|
Lookup lookup = this.getLookup();
|
||||||
|
if (lookup.lookup(Content.class) != null
|
||||||
|
|| lookup.lookup(Host.class) != null
|
||||||
|
|| lookup.lookup(Person.class) != null) {
|
||||||
|
return super.getActions(true);
|
||||||
|
} else {
|
||||||
|
return new Action[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the wrapped node.
|
* Get the wrapped node.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user