Autopsy  4.14.0
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.filequery;
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;
32 import org.sleuthkit.datamodel.AbstractFile;
33 
38 class DiscoveryThumbnailChildren extends Children.Keys<AbstractFile> {
39 
40  private final List<AbstractFile> files;
41 
42  /*
43  * Creates the list of thumbnails from the given list of AbstractFiles.
44  */
45  DiscoveryThumbnailChildren(List<AbstractFile> files) {
46  super(false);
47 
48  this.files = files;
49 
50  }
51 
52  @Override
53  protected Node[] createNodes(AbstractFile t) {
54  return new Node[]{new ThumbnailNode(t)};
55  }
56 
57  @Override
58  protected void addNotify() {
59  super.addNotify();
60 
61  Set<AbstractFile> thumbnails = new TreeSet<>((AbstractFile file1, AbstractFile file2) -> {
62  int result = Long.compare(file1.getSize(), file2.getSize());
63  if (result == 0) {
64  result = file1.getName().compareTo(file2.getName());
65  }
66 
67  return result;
68  });
69  thumbnails.addAll(files);
70  setKeys(thumbnails);
71  }
72 
76  static class ThumbnailNode extends FileNode {
77 
78  ThumbnailNode(AbstractFile file) {
79  super(file, false);
80  }
81 
82  @Override
83  protected Sheet createSheet() {
84  Sheet sheet = super.createSheet();
85  Set<String> keepProps = new HashSet<>(Arrays.asList(
86  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"),
87  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"),
88  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"),
89  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"),
90  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.sizeColLbl"),
91  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"),
92  NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.knownColLbl")));
93 
94  //Remove all other props except for the ones above
95  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
96  for (Node.Property<?> p : sheetSet.getProperties()) {
97  if (!keepProps.contains(p.getName())) {
98  sheetSet.remove(p.getName());
99  }
100  }
101 
102  return sheet;
103  }
104  }
105 }

Copyright © 2012-2020 Basis Technology. Generated on: Wed Apr 8 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.