Autopsy  4.17.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 })
45 public class PastCasesPanel extends BaseDataSourceSummaryPanel {
46 
47  private static final long serialVersionUID = 1L;
48 
49  private static final ColumnModel<Pair<String, Long>> CASE_COL = new ColumnModel<>(
50  Bundle.PastCasesPanel_caseColumn_title(),
51  (pair) -> new DefaultCellModel(pair.getKey()),
52  300
53  );
54 
55  private static final ColumnModel<Pair<String, Long>> COUNT_COL = new ColumnModel<>(
56  Bundle.PastCasesPanel_countColumn_title(),
57  (pair) -> new DefaultCellModel(String.valueOf(pair.getValue())),
58  100
59  );
60 
61  private static final List<ColumnModel<Pair<String, Long>>> DEFAULT_COLUMNS = Arrays.asList(CASE_COL, COUNT_COL);
62 
63  private final JTablePanel<Pair<String, Long>> notableFileTable = JTablePanel.getJTablePanel(DEFAULT_COLUMNS);
64 
65  private final JTablePanel<Pair<String, Long>> sameIdTable = JTablePanel.getJTablePanel(DEFAULT_COLUMNS);
66 
67  private final List<JTablePanel<?>> tables = Arrays.asList(
68  notableFileTable,
69  sameIdTable
70  );
71 
72  private final List<DataFetchComponents<DataSource, ?>> dataFetchComponents;
73 
74  private final IngestRunningLabel ingestRunningLabel = new IngestRunningLabel();
75 
76  public PastCasesPanel() {
77  this(new PastCasesSummary());
78  }
79 
83  public PastCasesPanel(PastCasesSummary pastCaseData) {
84  super(pastCaseData);
85 
86  // set up data acquisition methods
87  dataFetchComponents = Arrays.asList(
89  (dataSource) -> pastCaseData.getPastCasesData(dataSource),
90  (result) -> handleResult(result))
91  );
92 
93  initComponents();
94  }
95 
103  notableFileTable.showDataFetchResult(DataFetchResult.getSubResult(result, (res) -> res.getTaggedNotable()));
104  sameIdTable.showDataFetchResult(DataFetchResult.getSubResult(result, (res) -> res.getSameIdsResults()));
105  }
106 
107  @Override
108  protected void fetchInformation(DataSource dataSource) {
109  fetchInformation(dataFetchComponents, dataSource);
110  }
111 
112  @Override
113  protected void onNewDataSource(DataSource dataSource) {
114  onNewDataSource(dataFetchComponents, tables, dataSource);
115  }
116 
117  @Override
118  public void close() {
119  ingestRunningLabel.unregister();
120  super.close();
121  }
122 
128  @SuppressWarnings("unchecked")
129  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
130  private void initComponents() {
131 
132  javax.swing.JScrollPane mainScrollPane = new javax.swing.JScrollPane();
133  javax.swing.JPanel mainContentPanel = new javax.swing.JPanel();
134  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
135  javax.swing.JLabel notableFileLabel = new javax.swing.JLabel();
136  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));
137  javax.swing.JPanel notableFilePanel = notableFileTable;
138  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));
139  javax.swing.JLabel sameIdLabel = new javax.swing.JLabel();
140  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));
141  javax.swing.JPanel sameIdPanel = sameIdTable;
142  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));
143 
144  mainContentPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
145  mainContentPanel.setLayout(new javax.swing.BoxLayout(mainContentPanel, javax.swing.BoxLayout.PAGE_AXIS));
146 
147  ingestRunningPanel.setAlignmentX(0.0F);
148  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
149  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
150  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
151  mainContentPanel.add(ingestRunningPanel);
152 
153  org.openide.awt.Mnemonics.setLocalizedText(notableFileLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
154  mainContentPanel.add(notableFileLabel);
155  notableFileLabel.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.notableFileLabel.text")); // NOI18N
156 
157  filler1.setAlignmentX(0.0F);
158  mainContentPanel.add(filler1);
159 
160  notableFilePanel.setAlignmentX(0.0F);
161  notableFilePanel.setMaximumSize(new java.awt.Dimension(32767, 106));
162  notableFilePanel.setMinimumSize(new java.awt.Dimension(100, 106));
163  notableFilePanel.setPreferredSize(new java.awt.Dimension(100, 106));
164  mainContentPanel.add(notableFilePanel);
165 
166  filler2.setAlignmentX(0.0F);
167  mainContentPanel.add(filler2);
168 
169  org.openide.awt.Mnemonics.setLocalizedText(sameIdLabel, org.openide.util.NbBundle.getMessage(PastCasesPanel.class, "PastCasesPanel.sameIdLabel.text")); // NOI18N
170  mainContentPanel.add(sameIdLabel);
171 
172  filler3.setAlignmentX(0.0F);
173  mainContentPanel.add(filler3);
174 
175  sameIdPanel.setAlignmentX(0.0F);
176  sameIdPanel.setMaximumSize(new java.awt.Dimension(32767, 106));
177  sameIdPanel.setMinimumSize(new java.awt.Dimension(100, 106));
178  sameIdPanel.setPreferredSize(new java.awt.Dimension(100, 106));
179  mainContentPanel.add(sameIdPanel);
180 
181  filler5.setAlignmentX(0.0F);
182  mainContentPanel.add(filler5);
183 
184  mainScrollPane.setViewportView(mainContentPanel);
185 
186  javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
187  this.setLayout(layout);
188  layout.setHorizontalGroup(
189  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
190  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
191  );
192  layout.setVerticalGroup(
193  layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
194  .addComponent(mainScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
195  );
196  }// </editor-fold>//GEN-END:initComponents
197 
198 
199  // Variables declaration - do not modify//GEN-BEGIN:variables
200  // End of variables declaration//GEN-END:variables
201 }
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 > JTablePanel< T > getJTablePanel(List< ColumnModel< T >> columns)
final List< DataFetchComponents< DataSource,?> > dataFetchComponents

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