Autopsy  4.19.3
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  */
19 package org.sleuthkit.autopsy.discovery.ui;
20 
21 import java.util.Arrays;
22 import java.util.HashSet;
23 import java.util.List;
24 import java.util.Set;
25 import java.util.TreeSet;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Node;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.NbBundle;
33 import org.sleuthkit.datamodel.AbstractFile;
34 
39 class 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-2022 Basis Technology. Generated on: Wed Oct 5 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.