Autopsy  4.19.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
PastCasesPanel.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 org.apache.commons.lang3.tuple.Pair;
24 import org.openide.util.NbBundle.Messages;
34 import org.sleuthkit.datamodel.DataSource;
35 
40 @Messages({
41  "PastCasesPanel_caseColumn_title=Case",
42  "PastCasesPanel_countColumn_title=Count",
43  "PastCasesPanel_onNoCrIngest_message=No results will be shown because the Central Repository module was not run.",
44  "PastCasesPanel_notableFileTable_tabName=Cases with Common Notable Items at Time Of Ingest",
45  "PastCasesPanel_sameIdsTable_tabName=Past Cases with the Same Devices",})
46 public class PastCasesPanel extends BaseDataSourceSummaryPanel {
47 
48  private static final long serialVersionUID = 1L;
49 
50  // model for column indicating the case
51  private static final ColumnModel<Pair<String, Long>, DefaultCellModel<?>> CASE_COL = new ColumnModel<>(
52  Bundle.PastCasesPanel_caseColumn_title(),
53  (pair) -> new DefaultCellModel<>(pair.getKey()),
54  300
55  );
56 
57  // model for column indicating the count
58  private static final ColumnModel<Pair<String, Long>, DefaultCellModel<?>> COUNT_COL = new ColumnModel<>(
59  Bundle.PastCasesPanel_countColumn_title(),
60  (pair) -> new DefaultCellModel<>(pair.getValue()),
61  100
62  );
63 
64  // the template for columns in both tables in this tab
65  private static List<ColumnModel<Pair<String, Long>, DefaultCellModel<?>>> DEFAULT_TEMPLATE
66  = Arrays.asList(CASE_COL, COUNT_COL);
67 
68  private final JTablePanel<Pair<String, Long>> notableFileTable = JTablePanel.getJTablePanel(DEFAULT_TEMPLATE);
69 
70  private final JTablePanel<Pair<String, Long>> sameIdTable = JTablePanel.getJTablePanel(DEFAULT_TEMPLATE);
71 
72  private final List<JTablePanel<?>> tables = Arrays.asList(
73  notableFileTable,
74  sameIdTable
75  );
76 
77  private final List<DataFetchComponents<DataSource, ?>> dataFetchComponents;
78 
79  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
80 
82 
83  public PastCasesPanel() {
84  this(new PastCasesSummaryGetter());
85  }
86 
90  public PastCasesPanel(PastCasesSummaryGetter pastCaseData) {
91  super(pastCaseData);
92 
93  this.pastCasesFetcher = (dataSource) -> pastCaseData.getPastCasesData(dataSource);
94 
95  // set up data acquisition methods
96  dataFetchComponents = Arrays.asList(
98  pastCasesFetcher,
99  (result) -> handleResult(result))
100  );
101 
102  initComponents();
103  }
104 
112  notableFileTable.showDataFetchResult(DataFetchResult.getSubResult(result, (res) -> res.getTaggedNotable()));
113  sameIdTable.showDataFetchResult(DataFetchResult.getSubResult(result, (res) -> res.getSameIdsResults()));
114  }
115 
116  @Override
117  protected void fetchInformation(DataSource dataSource) {
118  fetchInformation(dataFetchComponents, dataSource);
119  }
120 
121  @Override
122  protected void onNewDataSource(DataSource dataSource) {
123  onNewDataSource(dataFetchComponents, tables, dataSource);
124  }
125 
126  @Override
127  public void close() {
128  ingestRunningLabel.unregister();
129  super.close();
130  }
131 
137  @SuppressWarnings("unchecked")
138  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
139  private void initComponents() {
140 
141  javax.swing.JScrollPane mainScrollPane = new javax.swing.JScrollPane();
142  javax.swing.JPanel mainContentPanel = new javax.swing.JPanel();
143  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
144  javax.swing.JLabel notableFileLabel = new javax.swing.JLabel();
145  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(0, 2));
146  javax.swing.JPanel notableFilePanel = notableFileTable;
147  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(0, 20));
148  javax.swing.JLabel sameIdLabel = new javax.swing.JLabel();
149  javax.swing.Box.Filler filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
150  javax.swing.JPanel sameIdPanel = sameIdTable;
151  javax.swing.Box.Filler filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
152 
153  mainContentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
154  mainContentPanel.setLayout(new javax.swing.BoxLayout(mainContentPanel, javax.swing.BoxLayout.PAGE_AXIS));
155 
156  ingestRunningPanel.setAlignmentX(0.0F);
157  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
158  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
159  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
160  mainContentPanel.add(ingestRunningPanel);
161 
162  org.openide.awt.Mnemonics.setLocalizedText(notableFileLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
163  mainContentPanel.add(notableFileLabel);
164  notableFileLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
165 
166  filler1.setAlignmentX(0.0F);
167  mainContentPanel.add(filler1);
168 
169  notableFilePanel.setAlignmentX(0.0F);
170  notableFilePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
171  notableFilePanel.setMinimumSize(new java.awt.Dimension(100, 106));
172  notableFilePanel.setPreferredSize(new java.awt.Dimension(100, 106));
173  mainContentPanel.add(notableFilePanel);
174 
175  filler2.setAlignmentX(0.0F);
176  mainContentPanel.add(filler2);
177 
178  org.openide.awt.Mnemonics.setLocalizedText(sameIdLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.sameIdLabel.text")); // NOI18N
179  mainContentPanel.add(sameIdLabel);
180 
181  filler3.setAlignmentX(0.0F);
182  mainContentPanel.add(filler3);
183 
184  sameIdPanel.setAlignmentX(0.0F);
185  sameIdPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
186  sameIdPanel.setMinimumSize(new java.awt.Dimension(100, 106));
187  sameIdPanel.setPreferredSize(new java.awt.Dimension(100, 106));
188  mainContentPanel.add(sameIdPanel);
189 
190  filler5.setAlignmentX(0.0F);
191  mainContentPanel.add(filler5);
192 
193  mainScrollPane.setViewportView(mainContentPanel);
194 
195  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
196  this.setLayout(layout);
197  layout.setHorizontalGroup(
198  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
199  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
200  );
201  layout.setVerticalGroup(
202  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
203  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
204  );
205  }// </editor-fold>//GEN-END:initComponents
206 
207 
208  // Variables declaration - do not modify//GEN-BEGIN:variables
209  // End of variables declaration//GEN-END:variables
210 }
void handleResult(DataFetchResult< PastCasesResult > result)
static< I, O > DataFetchResult< O > getSubResult(DataFetchResult< I > inputResult, Function< I, O > getSubResult)
void showDataFetchResult(DataFetchResult< T > result, String errorMessage, String noResultsMessage)
static< T, CextendsGuiCellModel > JTablePanel< T > getJTablePanel(List< ColumnModel< T, C >> columns)
PastCasesPanel(PastCasesSummaryGetter pastCaseData)
final List< DataFetchComponents< DataSource,?> > dataFetchComponents
final DataFetcher< DataSource, PastCasesResult > pastCasesFetcher

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