mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Merge pull request #7219 from kellykelly3/7881-fix-cvt-media-viewer
7881 - Fixed CVT Media Viewer thumbnail selection
This commit is contained in:
commit
e0d27a7b5c
@ -24,6 +24,7 @@ import java.awt.KeyboardFocusManager;
|
|||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyChangeListener;
|
import java.beans.PropertyChangeListener;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -38,6 +39,7 @@ import org.openide.nodes.AbstractNode;
|
|||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
import org.openide.util.NbBundle.Messages;
|
import org.openide.util.NbBundle.Messages;
|
||||||
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.communications.ModifiableProxyLookup;
|
import org.sleuthkit.autopsy.communications.ModifiableProxyLookup;
|
||||||
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
import org.sleuthkit.autopsy.corecomponents.TableFilterNode;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -46,8 +48,10 @@ import org.sleuthkit.autopsy.directorytree.DataResultFilterNode;
|
|||||||
import org.sleuthkit.datamodel.AbstractContent;
|
import org.sleuthkit.datamodel.AbstractContent;
|
||||||
import org.sleuthkit.datamodel.Account;
|
import org.sleuthkit.datamodel.Account;
|
||||||
import org.sleuthkit.datamodel.BlackboardArtifact;
|
import org.sleuthkit.datamodel.BlackboardArtifact;
|
||||||
|
import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
|
||||||
|
import org.sleuthkit.datamodel.BlackboardAttribute;
|
||||||
import org.sleuthkit.datamodel.Content;
|
import org.sleuthkit.datamodel.Content;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Panel that shows the media (thumbnails) for the selected account.
|
* A Panel that shows the media (thumbnails) for the selected account.
|
||||||
@ -65,6 +69,7 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
|
|||||||
private final MessageDataContent contentViewer;
|
private final MessageDataContent contentViewer;
|
||||||
|
|
||||||
private MediaViewerWorker worker;
|
private MediaViewerWorker worker;
|
||||||
|
private SelectionWorker selectionWorker;
|
||||||
|
|
||||||
@Messages({
|
@Messages({
|
||||||
"MediaViewer_Name=Media Attachments"
|
"MediaViewer_Name=Media Attachments"
|
||||||
@ -106,11 +111,15 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
|
|||||||
@Override
|
@Override
|
||||||
public void setSelectionInfo(SelectionInfo info) {
|
public void setSelectionInfo(SelectionInfo info) {
|
||||||
contentViewer.setNode(null);
|
contentViewer.setNode(null);
|
||||||
thumbnailViewer.resetComponent();
|
thumbnailViewer.setNode(null);
|
||||||
|
|
||||||
if (worker != null) {
|
if (worker != null) {
|
||||||
worker.cancel(true);
|
worker.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(selectionWorker != null) {
|
||||||
|
selectionWorker.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
worker = new MediaViewerWorker(info);
|
worker = new MediaViewerWorker(info);
|
||||||
|
|
||||||
@ -181,21 +190,66 @@ final class MediaViewer extends JPanel implements RelationshipsViewer, ExplorerM
|
|||||||
*/
|
*/
|
||||||
private void handleNodeSelectionChange() {
|
private void handleNodeSelectionChange() {
|
||||||
final Node[] nodes = tableEM.getSelectedNodes();
|
final Node[] nodes = tableEM.getSelectedNodes();
|
||||||
|
contentViewer.setNode(null);
|
||||||
|
|
||||||
|
if(selectionWorker != null) {
|
||||||
|
selectionWorker.cancel(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (nodes != null && nodes.length == 1) {
|
if (nodes != null && nodes.length == 1) {
|
||||||
AbstractContent thumbnail = nodes[0].getLookup().lookup(AbstractContent.class);
|
AbstractContent thumbnail = nodes[0].getLookup().lookup(AbstractContent.class);
|
||||||
if (thumbnail != null) {
|
if (thumbnail != null) {
|
||||||
try {
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
Content parentContent = thumbnail.getParent();
|
selectionWorker = new SelectionWorker(thumbnail);
|
||||||
if (parentContent != null && parentContent instanceof BlackboardArtifact) {
|
selectionWorker.execute();
|
||||||
contentViewer.setNode(new BlackboardArtifactNode((BlackboardArtifact) parentContent));
|
}
|
||||||
}
|
}
|
||||||
} catch (TskCoreException ex) {
|
}
|
||||||
logger.log(Level.WARNING, "Unable to get parent Content from AbstraceContent instance.", ex); //NON-NLS
|
|
||||||
|
/**
|
||||||
|
* A SwingWorker to get the artifact associated with the selected thumbnail.
|
||||||
|
*/
|
||||||
|
private class SelectionWorker extends SwingWorker<BlackboardArtifact, Void> {
|
||||||
|
|
||||||
|
private final AbstractContent thumbnail;
|
||||||
|
|
||||||
|
// Construct a SelectionWorker.
|
||||||
|
SelectionWorker(AbstractContent thumbnail) {
|
||||||
|
this.thumbnail = thumbnail;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected BlackboardArtifact doInBackground() throws Exception {
|
||||||
|
SleuthkitCase skCase = Case.getCurrentCase().getSleuthkitCase();
|
||||||
|
List<BlackboardArtifact> artifactsList = skCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, thumbnail.getId());
|
||||||
|
for (BlackboardArtifact contextArtifact : artifactsList) {
|
||||||
|
BlackboardAttribute associatedArtifactAttribute = contextArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
|
||||||
|
if (associatedArtifactAttribute != null) {
|
||||||
|
long artifactId = associatedArtifactAttribute.getValueLong();
|
||||||
|
return contextArtifact.getSleuthkitCase().getBlackboardArtifact(artifactId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return null;
|
||||||
contentViewer.setNode(null);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
if (isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
BlackboardArtifact artifact = get();
|
||||||
|
if (artifact != null) {
|
||||||
|
contentViewer.setNode(new BlackboardArtifactNode(artifact));
|
||||||
|
} else {
|
||||||
|
contentViewer.setNode(null);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException | ExecutionException ex) {
|
||||||
|
logger.log(Level.SEVERE, "Failed message viewer based on thumbnail selection. thumbnailID = " + thumbnail.getId(), ex);
|
||||||
|
} finally {
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user