Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
DiscoveryThumbnailChildren.java
Go to the documentation of this file.
1/*
2 * Autopsy
3 *
4 * Copyright 2019 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 obt ain 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.discovery.ui;
20
21import java.util.Arrays;
22import java.util.HashSet;
23import java.util.List;
24import java.util.Set;
25import java.util.TreeSet;
26import org.openide.nodes.Children;
27import org.openide.nodes.Node;
28import org.openide.nodes.Sheet;
29import org.openide.util.NbBundle;
30import org.sleuthkit.autopsy.coreutils.ThreadConfined;
31import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode;
32import org.sleuthkit.autopsy.datamodel.FileNode;
33import org.sleuthkit.datamodel.AbstractFile;
34
39class DiscoveryThumbnailChildren extends Children.Keys<AbstractFile> {
40
41 private final List<AbstractFile> files;
42
43 /*
44 * Creates the list of thumbnails from the given list of AbstractFiles.
45 */
46 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
47 DiscoveryThumbnailChildren(List<AbstractFile> files) {
48 super(false);
49 this.files = files;
50 }
51
52 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
53 @Override
54 protected Node[] createNodes(AbstractFile t) {
55 return new Node[]{new ThumbnailNode(t)};
56 }
57
58 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
59 @Override
60 protected void addNotify() {
61 super.addNotify();
62 Set<AbstractFile> thumbnails = new TreeSet<>((AbstractFile file1, AbstractFile file2) -> {
63 int result = Long.compare(file1.getSize(), file2.getSize());
64 if (result == 0) {
65 result = file1.getName().compareTo(file2.getName());
66 }
67 return result;
68 });
69 thumbnails.addAll(files);
70 setKeys(thumbnails);
71 }
72
76 static class ThumbnailNode extends FileNode {
77
78 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
79 ThumbnailNode(AbstractFile file) {
80 super(file, false);
81 }
82
83 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
84 @Override
85 protected Sheet createSheet() {
86 Sheet sheet = super.createSheet();
87 Set<String> keepProps = new HashSet<>(Arrays.asList(
88 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"),
89 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"),
90 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"),
91 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"),
92 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.sizeColLbl"),
93 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"),
94 NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.knownColLbl")));
95
96 //Remove all other props except for the ones above
97 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
98 for (Node.Property<?> p : sheetSet.getProperties()) {
99 if (!keepProps.contains(p.getName())) {
100 sheetSet.remove(p.getName());
101 }
102 }
103
104 return sheet;
105 }
106 }
107}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.