Autopsy  4.21.0
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 public class PastCasesPanel extends BaseDataSourceSummaryPanel {
45 
46  private static final long serialVersionUID = 1L;
47 
48  // model for column indicating the case
49  private static final ColumnModel<Pair<String, Long>, DefaultCellModel<?>> CASE_COL = new ColumnModel<>(
50  Bundle.PastCasesPanel_caseColumn_title(),
51  (pair) -> new DefaultCellModel<>(pair.getKey()),
52  300
53  );
54 
55  // model for column indicating the count
56  private static final ColumnModel<Pair<String, Long>, DefaultCellModel<?>> COUNT_COL = new ColumnModel<>(
57  Bundle.PastCasesPanel_countColumn_title(),
58  (pair) -> new DefaultCellModel<>(pair.getValue()),
59  100
60  );
61 
62  // the template for columns in both tables in this tab
63  private static List<ColumnModel<Pair<String, Long>, DefaultCellModel<?>>> DEFAULT_TEMPLATE
64  = Arrays.asList(CASE_COL, COUNT_COL);
65 
66  private final JTablePanel<Pair<String, Long>> notableFileTable = JTablePanel.getJTablePanel(DEFAULT_TEMPLATE);
67  private final JTablePanel<Pair<String, Long>> seenDeviceTable = JTablePanel.getJTablePanel(DEFAULT_TEMPLATE);
68  private final JTablePanel<Pair<String, Long>> seenResultTable = JTablePanel.getJTablePanel(DEFAULT_TEMPLATE);
69 
70  private final List<JTablePanel<?>> tables = Arrays.asList(
71  notableFileTable,
72  seenResultTable,
73  seenDeviceTable
74  );
75 
76  private final List<DataFetchComponents<DataSource, ?>> dataFetchComponents;
77 
78  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
79 
81 
82  public PastCasesPanel() {
83  this(new PastCasesSummaryGetter());
84  }
85 
89  public PastCasesPanel(PastCasesSummaryGetter pastCaseData) {
90  super(pastCaseData);
91 
92  this.pastCasesFetcher = (dataSource) -> pastCaseData.getPastCasesData(dataSource);
93 
94  // set up data acquisition methods
95  dataFetchComponents = Arrays.asList(
97  pastCasesFetcher,
98  (result) -> handleResult(result))
99  );
100 
101  initComponents();
102  }
103 
111  notableFileTable.showDataFetchResult(DataFetchResult.getSubResult(result, res -> res.getPreviouslyNotable()));
112  seenResultTable.showDataFetchResult(DataFetchResult.getSubResult(result, res -> res.getPreviouslySeenResults()));
113  seenDeviceTable.showDataFetchResult(DataFetchResult.getSubResult(result, res -> res.getPreviouslySeenDevices()));
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 seenResultLabel = 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 seenResultPanel = seenResultTable;
151  javax.swing.Box.Filler filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
152  javax.swing.JLabel seenDeviceLabel = new javax.swing.JLabel();
153  javax.swing.Box.Filler filler5 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2), new java.awt.Dimension(0, 2));
154  javax.swing.JPanel seenDevicePanel = seenDeviceTable;
155  javax.swing.Box.Filler filler6 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20), new java.awt.Dimension(0, 20));
156  javax.swing.JLabel warningLabel = new javax.swing.JLabel();
157 
158  mainContentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
159  mainContentPanel.setLayout(new javax.swing.BoxLayout(mainContentPanel, javax.swing.BoxLayout.PAGE_AXIS));
160 
161  ingestRunningPanel.setAlignmentX(0.0F);
162  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
163  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
164  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
165  mainContentPanel.add(ingestRunningPanel);
166 
167  org.openide.awt.Mnemonics.setLocalizedText(notableFileLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
168  mainContentPanel.add(notableFileLabel);
169  notableFileLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
170 
171  filler1.setAlignmentX(0.0F);
172  mainContentPanel.add(filler1);
173 
174  notableFilePanel.setAlignmentX(0.0F);
175  notableFilePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
176  notableFilePanel.setMinimumSize(new java.awt.Dimension(100, 106));
177  notableFilePanel.setPreferredSize(new java.awt.Dimension(100, 106));
178  mainContentPanel.add(notableFilePanel);
179 
180  filler2.setAlignmentX(0.0F);
181  mainContentPanel.add(filler2);
182 
183  org.openide.awt.Mnemonics.setLocalizedText(seenResultLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.seenResultLabel.text")); // NOI18N
184  mainContentPanel.add(seenResultLabel);
185 
186  filler3.setAlignmentX(0.0F);
187  mainContentPanel.add(filler3);
188 
189  seenResultPanel.setAlignmentX(0.0F);
190  seenResultPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
191  seenResultPanel.setMinimumSize(new java.awt.Dimension(100, 106));
192  seenResultPanel.setPreferredSize(new java.awt.Dimension(100, 106));
193  mainContentPanel.add(seenResultPanel);
194 
195  filler4.setAlignmentX(0.0F);
196  mainContentPanel.add(filler4);
197 
198  org.openide.awt.Mnemonics.setLocalizedText(seenDeviceLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.seenDeviceLabel.text")); // NOI18N
199  mainContentPanel.add(seenDeviceLabel);
200 
201  filler5.setAlignmentX(0.0F);
202  mainContentPanel.add(filler5);
203 
204  seenDevicePanel.setAlignmentX(0.0F);
205  seenDevicePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
206  seenDevicePanel.setMinimumSize(new java.awt.Dimension(100, 106));
207  seenDevicePanel.setPreferredSize(new java.awt.Dimension(100, 106));
208  mainContentPanel.add(seenDevicePanel);
209 
210  filler6.setAlignmentX(0.0F);
211  mainContentPanel.add(filler6);
212 
213  org.openide.awt.Mnemonics.setLocalizedText(warningLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.warningLabel.text")); // NOI18N
214  mainContentPanel.add(warningLabel);
215 
216  mainScrollPane.setViewportView(mainContentPanel);
217 
218  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
219  this.setLayout(layout);
220  layout.setHorizontalGroup(
221  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
222  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
223  );
224  layout.setVerticalGroup(
225  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
226  .addComponent(mainScrollPane)
227  );
228  }// </editor-fold>//GEN-END:initComponents
229 
230 
231  // Variables declaration - do not modify//GEN-BEGIN:variables
232  // End of variables declaration//GEN-END:variables
233 }
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-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.