Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AnalysisPanel.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2020 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 obtain 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.datasourcesummary.ui;
20 
21 import java.util.Arrays;
22 import java.util.List;
23 import java.util.function.Function;
24 import java.util.stream.Collectors;
25 import java.util.stream.Stream;
26 import org.apache.commons.lang3.tuple.Pair;
27 import org.openide.util.NbBundle.Messages;
36 import org.sleuthkit.datamodel.DataSource;
37 
42 @Messages({
43  "AnalysisPanel_keyColumn_title=Name",
44  "AnalysisPanel_countColumn_title=Count",
45  "AnalysisPanel_keywordSearchModuleName=Keyword Search",
46  "AnalysisPanel_hashsetHits_tabName=Hashset Hits",
47  "AnalysisPanel_keywordHits_tabName=Keyword Hits",
48  "AnalysisPanel_interestingItemHits_tabName=Interesting Item Hits",})
49 public class AnalysisPanel extends BaseDataSourceSummaryPanel {
50 
51  private static final long serialVersionUID = 1L;
52 
53  // Default Column definitions for each table
54  private static final List<ColumnModel<Pair<String, Long>, DefaultCellModel<?>>> DEFAULT_COLUMNS = Arrays.asList(
55  new ColumnModel<>(
56  Bundle.AnalysisPanel_keyColumn_title(),
57  (pair) -> new DefaultCellModel<>(pair.getKey()),
58  300
59  ),
60  new ColumnModel<>(
61  Bundle.AnalysisPanel_countColumn_title(),
62  (pair) -> new DefaultCellModel<>(pair.getValue()),
63  100
64  )
65  );
66 
67  // Identifies the key in the records for the tables.
68  private static final Function<Pair<String, Long>, String> DEFAULT_KEY_PROVIDER = (pair) -> pair.getKey();
69 
73 
74  private final JTablePanel<Pair<String, Long>> hashsetHitsTable
75  = JTablePanel.getJTablePanel(DEFAULT_COLUMNS)
76  .setKeyFunction(DEFAULT_KEY_PROVIDER);
77 
78  private final JTablePanel<Pair<String, Long>> keywordHitsTable
79  = JTablePanel.getJTablePanel(DEFAULT_COLUMNS)
80  .setKeyFunction(DEFAULT_KEY_PROVIDER);
81 
82  private final JTablePanel<Pair<String, Long>> interestingItemsTable
83  = JTablePanel.getJTablePanel(DEFAULT_COLUMNS)
84  .setKeyFunction(DEFAULT_KEY_PROVIDER);
85 
86  private final List<JTablePanel<?>> tables = Arrays.asList(
87  hashsetHitsTable,
88  keywordHitsTable,
89  interestingItemsTable
90  );
91 
92  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
93 
98  private final List<DataFetchWorker.DataFetchComponents<DataSource, ?>> dataFetchComponents;
99 
103  public AnalysisPanel() {
104  this(new AnalysisSummary());
105  }
106 
107  public AnalysisPanel(AnalysisSummary analysisData) {
108  super(analysisData);
109 
110  hashsetsFetcher = (dataSource) -> analysisData.getHashsetCounts(dataSource);
111  keywordsFetcher = (dataSource) -> analysisData.getKeywordCounts(dataSource);
112  interestingItemsFetcher = (dataSource) -> analysisData.getInterestingItemCounts(dataSource);
113 
114  // set up data acquisition methods
115  dataFetchComponents = Arrays.asList(
116  // hashset hits loading components
118  hashsetsFetcher,
119  (result) -> hashsetHitsTable.showDataFetchResult(result)),
120  // keyword hits loading components
122  keywordsFetcher,
123  (result) -> keywordHitsTable.showDataFetchResult(result)),
124  // interesting item hits loading components
126  interestingItemsFetcher,
127  (result) -> interestingItemsTable.showDataFetchResult(result))
128  );
129 
130  initComponents();
131  }
132 
133  @Override
134  public void close() {
135  ingestRunningLabel.unregister();
136  super.close();
137  }
138 
139  @Override
140  protected void fetchInformation(DataSource dataSource) {
141  fetchInformation(dataFetchComponents, dataSource);
142  }
143 
144  @Override
145  protected void onNewDataSource(DataSource dataSource) {
146  onNewDataSource(dataFetchComponents, tables, dataSource);
147  }
148 
154  @SuppressWarnings("unchecked")
155  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
156  private void initComponents() {
157 
158  javax.swing.JScrollPane mainScrollPane = new javax.swing.JScrollPane();
159  javax.swing.JPanel mainContentPanel = new javax.swing.JPanel();
160  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
161  javax.swing.JLabel hashsetHitsLabel = new javax.swing.JLabel();
162  javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(32767, 2));
163  javax.swing.JPanel hashSetHitsPanel = hashsetHitsTable;
164  javax.swing.Box.Filler filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(32767, 20));
165  javax.swing.JLabel keywordHitsLabel = new javax.swing.JLabel();
166  javax.swing.Box.Filler filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(32767, 2));
167  javax.swing.JPanel keywordHitsPanel = keywordHitsTable;
168  javax.swing.Box.Filler filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(32767, 20));
169  javax.swing.JLabel interestingItemLabel = new javax.swing.JLabel();
170  javax.swing.Box.Filler filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(32767, 2));
171  javax.swing.JPanel interestingItemPanel = interestingItemsTable;
172  javax.swing.Box.Filler filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
173 
174  mainContentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
175  mainContentPanel.setMaximumSize(new java.awt.Dimension(32767, 452));
176  mainContentPanel.setMinimumSize(new java.awt.Dimension(200, 452));
177  mainContentPanel.setLayout(new javax.swing.BoxLayout(mainContentPanel, javax.swing.BoxLayout.PAGE_AXIS));
178 
179  ingestRunningPanel.setAlignmentX(0.0F);
180  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
181  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
182  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
183  mainContentPanel.add(ingestRunningPanel);
184 
185  org.openide.awt.Mnemonics.setLocalizedText(hashsetHitsLabel, org.openide.util.NbBundle.getMessage(AnalysisPanel.class, "AnalysisPanel.hashsetHitsLabel.text")); // NOI18N
186  mainContentPanel.add(hashsetHitsLabel);
187  mainContentPanel.add(filler1);
188 
189  hashSetHitsPanel.setAlignmentX(0.0F);
190  hashSetHitsPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
191  hashSetHitsPanel.setMinimumSize(new java.awt.Dimension(10, 106));
192  hashSetHitsPanel.setPreferredSize(new java.awt.Dimension(10, 106));
193  mainContentPanel.add(hashSetHitsPanel);
194  mainContentPanel.add(filler2);
195 
196  org.openide.awt.Mnemonics.setLocalizedText(keywordHitsLabel, org.openide.util.NbBundle.getMessage(AnalysisPanel.class, "AnalysisPanel.keywordHitsLabel.text")); // NOI18N
197  mainContentPanel.add(keywordHitsLabel);
198  mainContentPanel.add(filler4);
199 
200  keywordHitsPanel.setAlignmentX(0.0F);
201  keywordHitsPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
202  keywordHitsPanel.setMinimumSize(new java.awt.Dimension(10, 106));
203  keywordHitsPanel.setPreferredSize(new java.awt.Dimension(10, 106));
204  mainContentPanel.add(keywordHitsPanel);
205  mainContentPanel.add(filler5);
206 
207  org.openide.awt.Mnemonics.setLocalizedText(interestingItemLabel, org.openide.util.NbBundle.getMessage(AnalysisPanel.class, "AnalysisPanel.interestingItemLabel.text")); // NOI18N
208  mainContentPanel.add(interestingItemLabel);
209  mainContentPanel.add(filler6);
210 
211  interestingItemPanel.setAlignmentX(0.0F);
212  interestingItemPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
213  interestingItemPanel.setMinimumSize(new java.awt.Dimension(10, 106));
214  interestingItemPanel.setPreferredSize(new java.awt.Dimension(10, 106));
215  mainContentPanel.add(interestingItemPanel);
216  mainContentPanel.add(filler3);
217 
218  mainScrollPane.setViewportView(mainContentPanel);
219 
220  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
221  this.setLayout(layout);
222  layout.setHorizontalGroup(
223  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 756, Short.MAX_VALUE)
225  );
226  layout.setVerticalGroup(
227  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
228  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
229  );
230  }// </editor-fold>//GEN-END:initComponents
231 
232  @Override
233  List<ExcelSheetExport> getExports(DataSource dataSource) {
234  return Stream.of(
235  getTableExport(hashsetsFetcher, DEFAULT_COLUMNS, Bundle.AnalysisPanel_hashsetHits_tabName(), dataSource),
236  getTableExport(keywordsFetcher, DEFAULT_COLUMNS, Bundle.AnalysisPanel_keywordHits_tabName(), dataSource),
237  getTableExport(interestingItemsFetcher, DEFAULT_COLUMNS, Bundle.AnalysisPanel_interestingItemHits_tabName(), dataSource))
238  .filter(sheet -> sheet != null)
239  .collect(Collectors.toList());
240  }
241 
242 
243  // Variables declaration - do not modify//GEN-BEGIN:variables
244  // End of variables declaration//GEN-END:variables
245 }
final DataFetcher< DataSource, List< Pair< String, Long > > > interestingItemsFetcher
List< Pair< String, Long > > getInterestingItemCounts(DataSource dataSource)
final DataFetcher< DataSource, List< Pair< String, Long > > > keywordsFetcher
final DataFetcher< DataSource, List< Pair< String, Long > > > hashsetsFetcher
static< T, CextendsGuiCellModel > JTablePanel< T > getJTablePanel(List< ColumnModel< T, C >> columns)
List< Pair< String, Long > > getHashsetCounts(DataSource dataSource)
List< Pair< String, Long > > getKeywordCounts(DataSource dataSource)
final List< DataFetchWorker.DataFetchComponents< DataSource,?> > dataFetchComponents

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.