Autopsy  4.16.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
RecentFilesPanel.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.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import org.openide.util.NbBundle.Messages;
36 import org.sleuthkit.datamodel.DataSource;
37 
41 public final class RecentFilesPanel extends BaseDataSourceSummaryPanel {
42 
43  private static final long serialVersionUID = 1L;
44  private static final String EMAIL_PARSER_FACTORY = "org.sleuthkit.autopsy.thunderbirdparser.EmailParserModuleFactory";
45  private static final String EMAIL_PARSER_MODULE_NAME = Bundle.RecentFilePanel_emailParserModuleName();
46 
47  private final List<JTablePanel<?>> tablePanelList = new ArrayList<>();
48  private final List<DataFetchWorker.DataFetchComponents<DataSource, ?>> dataFetchComponents = new ArrayList<>();
49 
51 
53 
54  @Messages({
55  "RecentFilesPanel_col_head_date=Date",
56  "RecentFilePanel_col_header_domain=Domain",
57  "RecentFilePanel_col_header_path=Path",
58  "RecentFilePanel_col_header_sender=Sender",
59  "RecentFilePanel_emailParserModuleName=Email Parser"
60  })
61 
65  public RecentFilesPanel() {
66  this(new RecentFilesSummary());
67  }
68 
72  public RecentFilesPanel(RecentFilesSummary dataHandler) {
73  super(dataHandler);
74  this.dataHandler = dataHandler;
75 
78  }
79 
80  @Override
81  protected void fetchInformation(DataSource dataSource) {
82  fetchInformation(dataFetchComponents, dataSource);
83  }
84 
85  @Override
86  protected void onNewDataSource(DataSource dataSource) {
87  onNewDataSource(dataFetchComponents, tablePanelList, dataSource);
88  }
89 
90  @Override
91  public void close() {
92  ingestRunningLabel.unregister();
93  super.close();
94  }
95 
99  private void initalizeTables() {
103  }
104 
105  @Messages({
106  "RecentFilePanel_no_open_documents=No recently open documents found."
107  })
111  @SuppressWarnings("unchecked")
112  private void initalizeOpenDocsTable() {
113  List<ColumnModel<RecentFileDetails>> list = Arrays.asList(
114  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
115  (prog) -> {
116  return new DefaultCellModel(prog.getPath());
117  }, 250),
118  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
119  (prog) -> {
120  return new DefaultCellModel(prog.getDateAsString());
121  }, 80));
122 
124 
126  pane.setModel(tableModel);
128  pane.setKeyFunction((recentFile) -> recentFile.getPath());
129  tablePanelList.add(pane);
130 
131  DataFetchWorker.DataFetchComponents<DataSource, List<RecentFileDetails>> worker
133  (dataSource) -> dataHandler.getRecentlyOpenedDocuments(dataSource, 10),
134  (result) -> {
135  showResultWithModuleCheck(pane, result,
138  });
139 
140  dataFetchComponents.add(worker);
141  }
142 
146  @SuppressWarnings("unchecked")
147  private void initalizeDownloadTable() {
148  List<ColumnModel<RecentDownloadDetails>> list = Arrays.asList(
149  new ColumnModel<>(Bundle.RecentFilePanel_col_header_domain(),
150  (prog) -> {
151  return new DefaultCellModel(prog.getWebDomain());
152  }, 100),
153  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
154  (prog) -> {
155  return new DefaultCellModel(prog.getPath());
156  }, 250),
157  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
158  (prog) -> {
159  return new DefaultCellModel(prog.getDateAsString());
160  }, 80));
161 
163 
165  pane.setModel(tableModel);
166  pane.setKeyFunction((download) -> download.getPath());
168  tablePanelList.add(pane);
169 
170  DataFetchWorker.DataFetchComponents<DataSource, List<RecentDownloadDetails>> worker
172  (dataSource) -> dataHandler.getRecentDownloads(dataSource, 10),
173  (result) -> {
174  showResultWithModuleCheck(pane, result,
177  });
178 
179  dataFetchComponents.add(worker);
180  }
181 
185  @SuppressWarnings("unchecked")
186  private void initalizeAttchementsTable() {
187  List<ColumnModel<RecentAttachmentDetails>> list = Arrays.asList(
188  new ColumnModel<>(Bundle.RecentFilePanel_col_header_path(),
189  (prog) -> {
190  return new DefaultCellModel(prog.getPath());
191  }, 250),
192  new ColumnModel<>(Bundle.RecentFilesPanel_col_head_date(),
193  (prog) -> {
194  return new DefaultCellModel(prog.getDateAsString());
195  }, 80),
196  new ColumnModel<>(Bundle.RecentFilePanel_col_header_sender(),
197  (prog) -> {
198  return new DefaultCellModel(prog.getSender());
199  }, 150));
200 
202 
204  pane.setModel(tableModel);
205  pane.setKeyFunction((attachment) -> attachment.getPath());
207  tablePanelList.add(pane);
208 
209  DataFetchWorker.DataFetchComponents<DataSource, List<RecentAttachmentDetails>> worker
211  (dataSource) -> dataHandler.getRecentAttachments(dataSource, 10),
212  (result) -> showResultWithModuleCheck(pane, result, EMAIL_PARSER_FACTORY, EMAIL_PARSER_MODULE_NAME)
213  );
214 
215  dataFetchComponents.add(worker);
216  }
217 
223  @SuppressWarnings("unchecked")
224  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
225  private void initComponents() {
226  java.awt.GridBagConstraints gridBagConstraints;
227 
228  javax.swing.JScrollPane scrollPane = new javax.swing.JScrollPane();
229  javax.swing.JPanel tablePanel = new javax.swing.JPanel();
230  javax.swing.JPanel ingestRunningPanel = ingestRunningLabel;
234  javax.swing.JLabel openDocsLabel = new javax.swing.JLabel();
235  javax.swing.JLabel downloadLabel = new javax.swing.JLabel();
236  javax.swing.JLabel attachmentLabel = new javax.swing.JLabel();
237 
238  setLayout(new java.awt.BorderLayout());
239 
240  tablePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
241  tablePanel.setMinimumSize(new java.awt.Dimension(400, 400));
242  tablePanel.setPreferredSize(new java.awt.Dimension(600, 400));
243  tablePanel.setLayout(new java.awt.GridBagLayout());
244 
245  ingestRunningPanel.setAlignmentX(0.0F);
246  ingestRunningPanel.setMaximumSize(new java.awt.Dimension(32767, 25));
247  ingestRunningPanel.setMinimumSize(new java.awt.Dimension(10, 25));
248  ingestRunningPanel.setPreferredSize(new java.awt.Dimension(10, 25));
249  gridBagConstraints = new java.awt.GridBagConstraints();
250  gridBagConstraints.gridx = 0;
251  gridBagConstraints.gridy = 0;
252  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
253  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
254  tablePanel.add(ingestRunningPanel, gridBagConstraints);
255  gridBagConstraints = new java.awt.GridBagConstraints();
256  gridBagConstraints.gridx = 0;
257  gridBagConstraints.gridy = 2;
258  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
259  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
260  gridBagConstraints.weightx = 1.0;
261  gridBagConstraints.weighty = 1.0;
262  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
263  tablePanel.add(openedDocPane, gridBagConstraints);
264  gridBagConstraints = new java.awt.GridBagConstraints();
265  gridBagConstraints.gridx = 0;
266  gridBagConstraints.gridy = 4;
267  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
268  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
269  gridBagConstraints.weightx = 1.0;
270  gridBagConstraints.weighty = 1.0;
271  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
272  tablePanel.add(downloadsPane, gridBagConstraints);
273  gridBagConstraints = new java.awt.GridBagConstraints();
274  gridBagConstraints.gridx = 0;
275  gridBagConstraints.gridy = 6;
276  gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
277  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
278  gridBagConstraints.weightx = 1.0;
279  gridBagConstraints.weighty = 1.0;
280  gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
281  tablePanel.add(attachmentsPane, gridBagConstraints);
282 
283  org.openide.awt.Mnemonics.setLocalizedText(openDocsLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.openDocsLabel.text")); // NOI18N
284  gridBagConstraints = new java.awt.GridBagConstraints();
285  gridBagConstraints.gridx = 0;
286  gridBagConstraints.gridy = 1;
287  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
288  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
289  tablePanel.add(openDocsLabel, gridBagConstraints);
290 
291  org.openide.awt.Mnemonics.setLocalizedText(downloadLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.downloadLabel.text")); // NOI18N
292  gridBagConstraints = new java.awt.GridBagConstraints();
293  gridBagConstraints.gridx = 0;
294  gridBagConstraints.gridy = 3;
295  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
296  gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
297  tablePanel.add(downloadLabel, gridBagConstraints);
298 
299  org.openide.awt.Mnemonics.setLocalizedText(attachmentLabel, org.openide.util.NbBundle.getMessage(RecentFilesPanel.class, "RecentFilesPanel.attachmentLabel.text")); // NOI18N
300  gridBagConstraints = new java.awt.GridBagConstraints();
301  gridBagConstraints.gridx = 0;
302  gridBagConstraints.gridy = 5;
303  gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
304  gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
305  gridBagConstraints.insets = new java.awt.Insets(20, 0, 0, 0);
306  tablePanel.add(attachmentLabel, gridBagConstraints);
307 
308  scrollPane.setViewportView(tablePanel);
309 
310  add(scrollPane, java.awt.BorderLayout.CENTER);
311  }// </editor-fold>//GEN-END:initComponents
312 
313 
314  // Variables declaration - do not modify//GEN-BEGIN:variables
315  private javax.swing.JPanel attachmentsPane;
316  private javax.swing.JPanel downloadsPane;
317  private javax.swing.JPanel openedDocPane;
318  // End of variables declaration//GEN-END:variables
319 }
JTablePanel< T > setColumnModel(TableColumnModel columnModel)
List< RecentFileDetails > getRecentlyOpenedDocuments(DataSource dataSource, int maxCount)
List< RecentDownloadDetails > getRecentDownloads(DataSource dataSource, int maxCount)
List< RecentAttachmentDetails > getRecentAttachments(DataSource dataSource, int maxCount)
static< T > TableColumnModel getTableColumnModel(List< ColumnModel< T >> columns)
final List< DataFetchWorker.DataFetchComponents< DataSource,?> > dataFetchComponents
static< T > ListTableModel< T > getTableModel(List< ColumnModel< T >> columns)
final JTablePanel< T > setModel(ListTableModel< T > tableModel)
JTablePanel< T > setKeyFunction(Function< T,?extends Object > keyFunction)

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